mypy
mypy copied to clipboard
(🐞) Incorrect analysis of `while` loop subject
class A:
a: A | None
a: A | None
a = A()
while a := a.a: # error: Item "None" of "A | None" has no attribute "a" [union-attr]
...
When a becomes None, the while loop will not run, and a.a will not be evaluated