Closed spineki closed 4 months ago
Pyright is working as designed here, so I don't consider this a bug.
You're relying on an advanced inference technique in pyright called narrowing for implied else. This technique has some documented limitation for performance reasons. You're hitting these limitations in two of your three code snippets above.
Environment data
Code Snippet
Repro Steps
Expected behavior
The returned variable should not be highlighted as possibly unbound because all the cases are covered.
Actual behavior
The variable is shown as Unbound. It is still the case if the attribute is copied into a local variable, but is solved by adding an extra type indication to the copied variable.
Logs