Skip to content

Better error location for incompatible override due to argument incompatibility #8298

@JukkaL

Description

@JukkaL

An incompatible override gets reported on the first line of a method header, even though it would be better to point it at the line with an argument that is incompatible, when possible. Example:

class A:
    def f(self, x: int, y: str, z: float) -> None: pass

class B(A):
    def f(  # Argument 3 incompatible with supertype "A" <-- reported here
            self,
            x: int,
            y: str,
            z: bool,  # <-- would be better to report it here
    ) -> None:
        pass

This would improve usability, especially for methods with many arguments on many lines. This would also make it cleaner to ignore these errors, as the location of the # type: ignore comment would document which argument is incompatible (if there is one argument per line, which is a common convention).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions