Skip to content

Inheriting overloaded signatures #5146

Description

@Geggles

Say we have a class Foo:

classFoo:
@overloaddeffun(self, s:str) ->str:
pass@overloaddeffun(self, i:int) ->int:
passdeffun(self, x):
pass

If we now add a subclass Bar like this:

classBar(Foo):
@overloaddeffun(self, s:str) ->str:
pass@overloaddeffun(self, i:int) ->int:
passdeffun(self, x):
passBar().fun([])

and run mypy on it without any flags, we get the expected
error: No overload variant of "fun" of "Bar" matches argument type "List[<nothing>]".
If however we don't copy the overloaded signatures,

classBar(Foo):
deffun(self, x):
passBar().fun([])

then mypy does not find any errors. Is this inteded behaviour? Is it not possible to find the overloaded signatures of the base classes statically? Am I not supposed to do this sort of thing in the first place?

> python -V
Python 3.6.2
> mypy -V
mypy 0.610+dev-eb1bb064d707ce05735ff6795df82126e75ea6ea

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions