no error when method in metaclass is overridden by an incompatible method in its instance
Open
Nobody has claimed this yet.
bug
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
class Foo(type):
def foo(cls) -> None: ...
class Bar(Foo):
def asdf(cls) -> None:
cls.foo()
class Baz(metaclass=Bar):
# no error.
# at runtime it raises TypeError: Baz.foo() missing 2 required positional arguments: 'self' and 'asdf'
def foo(self, asdf: int) -> None: ...
Baz.asdf()
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked mypy-play reproduction and trace how mypy checks members across a metaclass and its instance. Add coverage for the example; done means the unsound call is diagnosed and the regression test passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100