-
Notifications
You must be signed in to change notification settings - Fork 82
Open
Labels
good first issueGood for newcomersGood for newcomersrejected upstreamalso a bug in pyright/pylance or feature that isn't in pyright/pylance - they refused to address italso a bug in pyright/pylance or feature that isn't in pyright/pylance - they refused to address it
Description
Description
foo: list[str] = ["a", "b"]
bar: list[str | float] = foo + ["c"] # incorrectly shows a type-widening error here
baz: list[str | float] = ["a", "b", "c"] # type-widening is correctly accepted here
bat: list[str | float] = foo # correctly shows a type-widening error here
The bar
line should be treated as the baz
, as list + list
creates a new list with no other references to it; mutating bar
does not/cannot affect foo
.
Link to BasedPyright Playground Example
Occurs in Pyright as well; filed upstream as Pyright bug #10943.
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomersrejected upstreamalso a bug in pyright/pylance or feature that isn't in pyright/pylance - they refused to address italso a bug in pyright/pylance or feature that isn't in pyright/pylance - they refused to address it