Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Apply None rule only to Callables, add unrelated previously forgotten…
… test
  • Loading branch information
ilevkivskyi committed Sep 24, 2017
commit 2876a95ed3a39b8690a5b4a19882cc028e4106b1
2 changes: 1 addition & 1 deletion mypy/subtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def f(self) -> A: ...
is_compat = is_proper_subtype(subtype, supertype)
if not is_compat:
return False
if isinstance(subtype, NoneTyp) and member.startswith('__') and member.endswith('__'):
if isinstance(subtype, NoneTyp) and isinstance(supertype, CallableType):
# We want __hash__ = None idiom to work even without --strict-optional
return False
subflags = get_member_flags(member, left.type)
Expand Down
6 changes: 6 additions & 0 deletions test-data/unit/check-protocols.test
Original file line number Diff line number Diff line change
Expand Up @@ -2118,6 +2118,12 @@ main:10: note: def other(self, *args: Any, hint: Optional[str] = ..., **
main:10: note: Got:
main:10: note: def other(self) -> int

[case testObjectAllowedInProtocolBases]
from typing import Protocol
class P(Protocol, object):
pass
[out]

[case testNoneSubtypeOfEmptyProtocol]
from typing import Protocol
class P(Protocol):
Expand Down