-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrongtopic-protocolstopic-self-typesTypes for selfTypes for self
Description
Bug Report
Sometimes there's a need to use a typing.Protocol
to specify self
typing for cases like mixin classes, where the methods aren't there at class definition, but will be there at runtime, once the mixin is inherited from. This generally works fine, except it breaks in one silly case, a short repro of which is available below.
In short, it looks like super
doesn't like protocols as it's second argument, which isn't even explicitly passed here.
To Reproduce
from typing import Protocol
class MixinProt(Protocol):
def func(self) -> None:
...
class Mixin:
def func(self: MixinProt) -> None:
return super().func()
Expected Behavior
No error, duh.
Actual Behavior
From the very last line of the code above:
Argument 2 for "super" not an instance of argument 1
Your Environment
- Mypy version used: 0.931
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini
(and other config files): none - Python version used: 3.8.10
- Operating system and version: Win7x64
Ivashkaization, d1618033, NoamNol, stinovlas, mtvx and 5 more
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-protocolstopic-self-typesTypes for selfTypes for self