Skip to content

Fix crash related to module-level __getattr__ in incremental mode #10430

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 1 commit into from
May 6, 2021
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion mypy/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ def deserialize(cls, data: JsonDict) -> 'Decorator':
'is_self', 'is_initialized_in_class', 'is_staticmethod',
'is_classmethod', 'is_property', 'is_settable_property', 'is_suppressed_import',
'is_classvar', 'is_abstract_var', 'is_final', 'final_unset_in_class', 'final_set_in_init',
'explicit_self_type', 'is_ready',
'explicit_self_type', 'is_ready', 'from_module_getattr',
] # type: Final


Expand Down
28 changes: 28 additions & 0 deletions test-data/unit/check-incremental.test
Original file line number Diff line number Diff line change
Expand Up @@ -4239,6 +4239,34 @@ tmp/c.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#mi
tmp/c.py:1: error: Cannot find implementation or library stub for module named "a.b.c"
tmp/c.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports

[case testModuleGetattrIncrementalSerializeVarFlag]
import main

[file main.py]
from b import A, f
f()

[file main.py.3]
from b import A, f # foo
f()

[file b.py]
from c import A
def f() -> A: ...

[file b.py.2]
from c import A # foo
def f() -> A: ...

[file c.py]
from d import A

[file d.pyi]
def __getattr__(n): ...
[out1]
[out2]
[out3]

[case testAddedMissingStubs]
# flags: --ignore-missing-imports
from missing import f
Expand Down