Skip to content

mypy error: Cannot infer type argument 1 of "sum" #3889

Closed
@levsa

Description

@levsa

When using sum() to concatenate lists, mypy fails to infer the type argument of "sum", even if types are declared explicitly.

sum([[1],[2],[3]], []

or

foo: List[List[int]] = [[1],[2],[3]]
sum(foo, [])

both give:

error: Cannot infer type argument 1 of "sum"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions