Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mypy/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3595,6 +3595,7 @@ def accept(self, visitor: ExpressionVisitor[T]) -> T:
{
"__abstractmethods__",
"__annotations__",
"__class__",
"__dict__",
"__doc__",
"__init__",
Expand Down
39 changes: 39 additions & 0 deletions test-data/unit/check-overloading.test
Original file line number Diff line number Diff line change
Expand Up @@ -6856,3 +6856,42 @@ if isinstance(headers, dict):

reveal_type(headers) # N: Revealed type is "__main__.Headers | typing.Iterable[tuple[builtins.bytes, builtins.bytes]]"
[builtins fixtures/isinstancelist.pyi]

[case testOverloadProtocolClassPropertyDoesNotEraseListItemType]
from collections.abc import Iterator, Sequence
from typing import Any, Protocol, TypeVar, overload

T_co = TypeVar("T_co", covariant=True)

class ReducedCovariantList(Protocol[T_co]):
@property
def __class__(self) -> type[list[Any]]: ...
def __iter__(self) -> Iterator[T_co]: ...

@overload
def f(x: ReducedCovariantList[str]) -> str: ...
@overload
def f(x: Sequence[int]) -> int: ...
def f(x: object) -> object: ...

reveal_type(f([1])) # N: Revealed type is "builtins.int"
[file builtins.py]
from typing import Generic, Self, TypeVar
from collections.abc import Iterator, Sequence

class object:
@property
def __class__(self) -> type[Self]: pass
class type: pass
class function: pass
class property: pass
class int: pass
class str: pass
class bool: pass
class dict: pass
class ellipsis: pass
class tuple: pass

T = TypeVar("T")
class list(Sequence[T], Generic[T]):
def __iter__(self) -> Iterator[T]: pass
Loading