Tuple unpacking from a type alias results in wrong union type (original) (raw)
Summary
The following code snippet:
type Thing = tuple[str, int]
def thing() -> Thing: return ("1", 2)
def foo(): a, b = thing() a.lower()
Gives this error:
warning[possibly-unbound-attribute]: Attribute lower on type str | int is possibly unbound
|
8 | def foo():
9 | a, b = thing()
10 | a.lower()
| ^^^^^^^
|
info: rule possibly-unbound-attribute is enabled by default
Because it thinks a is str | int when it should be just str. If the type alias is removed and the return type is explicitly tuple[str, int] it type checks correctly.
This seems like a regression in 0.0.1a18, it works correctly in 0.0.1a17
Version
0.0.1a18