KEMBAR78
Line number reported for invalid argument type can be confusing · Issue #4231 · python/mypy · GitHub
Skip to content

Line number reported for invalid argument type can be confusing #4231

@JukkaL

Description

@JukkaL

Here it looks like mypy is complaining about the first f call, but it's actually complaining about the second one:

class A:
    def f(self, x: int) -> 'A':
        return self

a: int
b: str

A().f(  # Argument 1 to "f" of "A" has incompatible type "str"; expected "int"
    a
).f(  # Why no error here?
    b
)

I actually lost a fair amount of time because of this issue. Maybe we should give the line number of the argument expression with an incompatible type.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions