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
Next Next commit
Fix module and protocol subtyping
  • Loading branch information
hauntsaninja committed Sep 30, 2022
commit b37c47955588d46fe94f10c0bdc1801317656b30
1 change: 1 addition & 0 deletions mypy/subtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,7 @@ def find_member(
and name not in ["__getattr__", "__setattr__", "__getattribute__"]
and not is_operator
and not class_obj
and itype.extra_attrs is None # skip ModuleType.__getattr__
):
for method_name in ("__getattribute__", "__getattr__"):
# Normally, mypy assumes that instances that define __getattr__ have all
Expand Down
5 changes: 3 additions & 2 deletions test-data/unit/lib-stub/types.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from typing import TypeVar
from typing import Any, TypeVar
import sys

_T = TypeVar('_T')

def coroutine(func: _T) -> _T: pass

class ModuleType:
__file__ = ... # type: str
__file__: str
def __getattr__(self, name: str) -> Any: pass

if sys.version_info >= (3, 10):
class Union:
Expand Down