Skip to content

Handling "default" methods in class hierarchies #5669

@rpgoldman

Description

@rpgoldman

feature request

See the directory test-data/default-methods/ in my branch: https://github.com/rpgoldman/mypy/tree/default-method-example

cd mypy/test-data/default-methods/code
mypy example.py

Complains that the SubClass method signature contradicts the one at SuperClass (which has a vacuous parameter list):

../stubs/example_classes.pyi:13: error: Signature of "example_method" incompatible with supertype "SuperClass"

Ideally, mypy should recognize that a method definition whose signature is:

(self, *args: Any, **kwargs: Any)

does not constrain any subclass's implementations of that method.

  • What are the versions of mypy and Python you are using?
mypy 0.640+dev-b923c587a3eaa6cb55d9908be5344b2d9a574b33

Python 3.6

  • What are the mypy flags you are using? (For example --strict-optional)

none

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions