Skip to content

Fix crash due to deserialization of TypedDict type objects #3275

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 2 commits into from
Apr 28, 2017
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: 2 additions & 0 deletions mypy/fixup.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def visit_type_info(self, info: TypeInfo) -> None:
info._promote.accept(self.type_fixer)
if info.tuple_type:
info.tuple_type.accept(self.type_fixer)
if info.typeddict_type:
info.typeddict_type.accept(self.type_fixer)
finally:
self.current_info = save_info

Expand Down
17 changes: 17 additions & 0 deletions test-data/unit/check-incremental.test
Original file line number Diff line number Diff line change
Expand Up @@ -1907,6 +1907,23 @@ a.A().x = 0
[out2]
tmp/b.py:2: error: Cannot assign to class variable "x" via instance

[case testSerializeTypedDict]
import b
reveal_type(b.x)
y: b.A
reveal_type(y)
[file b.py]
from mypy_extensions import TypedDict
A = TypedDict('A', {'x': int, 'y': str})
x: A
[builtins fixtures/dict.pyi]
[out1]
main:2: error: Revealed type is 'TypedDict(x=builtins.int, y=builtins.str, _fallback=b.A)'
main:4: error: Revealed type is 'TypedDict(x=builtins.int, y=builtins.str, _fallback=b.A)'
[out2]
main:2: error: Revealed type is 'TypedDict(x=builtins.int, y=builtins.str, _fallback=b.A)'
main:4: error: Revealed type is 'TypedDict(x=builtins.int, y=builtins.str, _fallback=b.A)'

[case testQuickAndDirty1]
# flags: --quick-and-dirty
import b, c
Expand Down