Skip to content
Merged
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
2 changes: 1 addition & 1 deletion mypy/subtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ def non_method_protocol_members(tp: TypeInfo) -> List[str]:

for member in tp.protocol_members:
typ = get_proper_type(find_member(member, instance, instance))
if not isinstance(typ, CallableType):
if not isinstance(typ, (Overloaded, CallableType)):
result.append(member)
return result

Expand Down
13 changes: 12 additions & 1 deletion test-data/unit/check-protocols.test
Original file line number Diff line number Diff line change
Expand Up @@ -2270,7 +2270,7 @@ y: PBad = None # E: Incompatible types in assignment (expression has type "None
[out]

[case testOnlyMethodProtocolUsableWithIsSubclass]
from typing import Protocol, runtime_checkable, Union, Type
from typing import Protocol, runtime_checkable, Union, Type, Sequence, overload
@runtime_checkable
class P(Protocol):
def meth(self) -> int:
Expand All @@ -2292,6 +2292,17 @@ if issubclass(cls, P):
reveal_type(cls) # N: Revealed type is "Type[__main__.C]"
else:
reveal_type(cls) # N: Revealed type is "Type[__main__.E]"

@runtime_checkable
class POverload(Protocol):
@overload
def meth(self, a: int) -> float: ...
@overload
def meth(self, a: str) -> Sequence[float]: ...
def meth(self, a):
pass

reveal_type(issubclass(int, POverload)) # N: Revealed type is "builtins.bool"
[builtins fixtures/isinstance.pyi]
[typing fixtures/typing-full.pyi]
[out]
Expand Down