Skip to content

List concatenation not resolving correctly to list[str] but to list[_T] #314

@ion-elgreco

Description

@ion-elgreco

Summary

def print_list(value: list[str]) -> None:
    print(value)


existing_list = ["foo"]
print_list(
    existing_list
    + [
        "bar",
    ],
)
  --> test.py:7:5
   |
 5 |   existing_list = ["foo"]
 6 |   print_list(
 7 | /     existing_list
 8 | |     + [
 9 | |         "bar",
10 | |     ],
   | |_____^ Expected `list[str]`, found `list[_T]`
11 |   )
   |
info: Function defined here
 --> test.py:1:5
  |
1 | def print_list(value: list[str]) -> None:
  |     ^^^^^^^^^^ ---------------- Parameter declared here
2 |     print(value)
  |
info: `invalid-argument-type` is enabled by default

Found 1 diagnostic

Version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggenericsBugs or features relating to ty's generics implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions