You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Usecase: I found a bug and want to temporarily disable an execution branch in my code. I use assert not flag when I initialize my class. I expect this not to create new type errors.
Minimal repro (the class is necessary, doesn't rep with a local variable):
classBar:
def__init__(self) ->None:
ifFalse:
self.x="1"# E: Statement is unreachable [unreachable]else:
self.x="2"# E: Cannot determine type of "x" [has-type]
If an instance attribute is first set in an unreachable block, future attempts to set or read it fail with [has-type].
Bug Report
Usecase: I found a bug and want to temporarily disable an execution branch in my code. I use
assert not flag
when I initialize my class. I expect this not to create new type errors.To Reproduce
https://gist.github.com/mypy-play/c1ba8168e409b445cf187af04a4b42d8
or
Expected Behavior
There is no type error in this code.
Actual Behavior
Your Environment
mypy playground: mypy 1.15.0, python3.12
The text was updated successfully, but these errors were encountered: