Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Stubtest: add some hacks so that sys.monitoring is checked in typeshed's CI #16269

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 4 additions & 2 deletions mypy/stubtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def verify_mypyfile(
def _belongs_to_runtime(r: types.ModuleType, attr: str) -> bool:
"""Heuristics to determine whether a name originates from another module."""
obj = getattr(r, attr)
if isinstance(obj, types.ModuleType):
if isinstance(obj, types.ModuleType) and not (r is sys and attr == "monitoring"):
return False
if callable(obj):
# It's highly likely to be a class or a function if it's callable,
Expand Down Expand Up @@ -390,7 +390,9 @@ def _belongs_to_runtime(r: types.ModuleType, attr: str) -> bool:

for entry in sorted(to_check):
stub_entry = stub.names[entry].node if entry in stub.names else MISSING
if isinstance(stub_entry, nodes.MypyFile):
if isinstance(stub_entry, nodes.MypyFile) and not (
runtime is sys and entry == "monitoring"
):
# Don't recursively check exported modules, since that leads to infinite recursion
continue
assert stub_entry is not None
Expand Down