2 Sep
2020
2 Sep
'20
2:52 p.m.
For the `x: Union[..] = value` case, I don't believe that pyright's doing the wrong thing here. It's being narrowed as we can prove that it's an `int` at that point of the code, but that doesn't prevent that variable from being reassigned later. The type printing code makes use of narrowing to show what has happened, but the following code is still legal: x: Union[int, str] x = 42 print(x) x = "hey" print(x)