Skip to content

[BUG] FileChooser.set_files takes a list[str | Path] which is invariant #1953

@DetachHead

Description

@DetachHead

Context:

  • Playwright Version: 1.34.0

Code Snippet

with page.expect_file_chooser() as file_chooser:
    ...
file_chooser.value.set_files(["foo.txt", "bar.txt"])

Describe the bug
mypy error:

Argument 1 to "set_files" of "FileChooser" has incompatible type "list[str]"; expected "str | Path | FilePayload | list[str | Path] | list[FilePayload]"  [arg-type]
"List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
Consider using "Sequence" instead, which is covariant

it should be using a Sequence instead, as the error suggests

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions