Skip to content

Better message if override violates Liskov substitution principle #7994

Open
@JukkaL

Description

@JukkaL

Some users don't understand why mypy complains about incompatible overrides. We could add an extra note in cases where the argument type is narrower in an override or the return type is wider (or all incompatible overrides). The note could mention Liskov substitution principle and add a link to mypy documentation (add a new section to https://mypy.readthedocs.io/en/latest/common_issues.html perhaps). We can also mention that # type: ignore[override] can be used to silence this error.

#7992 is an example where this came up, but several users have been confused about this.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions