Skip to content

Type error due to repeated use of underscore as dummy assignment target #465

Closed
@spkersten

Description

@spkersten

Consider the following code:

from typing import Tuple

class A: pass
class B: pass
class C: pass

def f() -> Tuple[A, B, C]:
    pass

a = A()
a, _, _ = f()

mypy reports: line 11: Incompatible types in assignment (expression has type "C", variable has type "B")

Seems like mypy treats _ as just a variable. That prevents it from being used as a dummy in assignments like the one above.

A solution might be to always give _ the Any type.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions