8000 stubtest: error if a dunder method is missing from a stub by AlexWaygood · Pull Request #12203 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

stubtest: error if a dunder method is missing from a stub #12203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Feb 19, 2022
Merged
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
Move logic from verify_none into verify_typeinfo
  • Loading branch information
AlexWaygood committed Feb 19, 2022
commit a71b1b3c8acb6ea435d9c3b35a7e75ffe1b033bf
18 changes: 9 additions & 9 deletions mypy/stubtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,14 @@ class SubClass(runtime): # type: ignore
except Exception:
# Catch all exceptions in case the runtime raises an unexpected exception
# from __getattr__ or similar.
pass
else:
yield from verify(stub_to_verify, runtime_attr, object_path + [entry])
continue
# Do not error for an object missing from the stub
# If the runtime object is a types.WrapperDescriptorType object
# and has a non-special dunder name.
# The vast majority of these are false positives.
if isinstance(stub_to_verify, Missing) and is_dunder_slot_wrapper(runtime_attr):
continue
yield from verify(stub_to_verify, runtime_attr, object_path + [entry])


def _verify_static_class_methods(
Expand Down Expand Up @@ -808,12 +813,7 @@ def verify_funcitem(
def verify_none(
stub: Missing, runtime: MaybeMissing[Any], object_path: List[str]
) -> Iterator[Error]:
# Do not error for an object missing from the stub
# If the runtime object is a types.WrapperDescriptorType object
# and has a non-special dunder name.
# The vast majority of these are false positives.
if not is_dunder_slot_wrapper(runtime):
yield Error(object_path, "is not present in stub", stub, runtime)
yield Error(object_path, "is not present in stub", stub, runtime)


@verify.register(nodes.Var)
Expand Down
0