Skip to content

Commit 891fc5d

Browse files
committed
add a test
1 parent 73804f3 commit 891fc5d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

mypy/stubtest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ def verify_typeinfo(
571571

572572
# If it came from the metaclass, consider the runtime_attr to be MISSING
573573
# for a more accurate message
574-
if runtime_attr is not MISSING and type(runtime) != runtime:
574+
if runtime_attr is not MISSING and type(runtime) is not runtime:
575575
if getattr(runtime_attr, "__objclass__", None) is type(runtime):
576576
runtime_attr = MISSING
577577

@@ -1526,6 +1526,7 @@ def is_probably_a_function(runtime: Any) -> bool:
15261526
isinstance(runtime, (types.FunctionType, types.BuiltinFunctionType))
15271527
or isinstance(runtime, (types.MethodType, types.BuiltinMethodType))
15281528
or (inspect.ismethoddescriptor(runtime) and callable(runtime))
1529+
or (inspect.ismethodwrapper(runtime) and callable(runtime))
15291530
)
15301531

15311532

mypy/test/teststubtest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,6 +1460,16 @@ def h(x: str): ...
14601460
runtime="__all__ += ['Z']\nclass Z:\n def __reduce__(self): return (Z,)",
14611461
error=None,
14621462
)
1463+
# __call__ exists on type, so it appears to exist on the class.
1464+
# This checks that we identify it as missing at runtime anyway.
1465+
yield Case(
1466+
stub="""
1467+
class ClassWithMetaclassOverride:
1468+
def __call__(*args, **kwds): ...
1469+
""",
1470+
runtime="class ClassWithMetaclassOverride: ...",
1471+
error="ClassWithMetaclassOverride.__call__",
1472+
)
14631473

14641474
@collect_cases
14651475
def test_missing_no_runtime_all(self) -> Iterator[Case]:

0 commit comments

Comments
 (0)