Fix faulty casts in checker by hauntsaninja · Pull Request #10560 · python/mypy · GitHub
Skip to content
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
7 changes: 5 additions & 2 deletions mypy/checker.py
9 changes: 9 additions & 0 deletions test-data/unit/check-redefine.test
Original file line number Diff line number Diff line change
Expand Up @@ -474,3 +474,12 @@ with A() as x:
reveal_type(x) # N: Revealed type is "builtins.int"
with B() as x:
x = 0 # E: Incompatible types in assignment (expression has type "int", variable has type "str")


[case testRedefineModuleAsException]

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that if you run this in real life you get:

crash.py:5: error: Incompatible types in assignment (expression has type "Exception", variable has type Module)
Found 1 error in 1 file (checked 1 source file)

I think the fixtures just aren't up to scratch here.

import typing
try:
pass
except Exception as typing:
pass
[builtins fixtures/exception.pyi]
16 changes: 16 additions & 0 deletions test-data/unit/check-unreachable-code.test