Safe handling of `Self` typed attributes w.r.t. overrides.
Open
Nobody has claimed this yet.
feature
topic-self-types
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
This is a follow up for https://github.com/python/mypy/pull/14041
This example doesn't give an error, while it probably should:
from typing import Self
class C:
x: Self
class D(C):
x: D # Note this is already unsafe, but it essentially same as #2353 (for methods)
class E(D):
pass # This creates conflicting types for `x` from `C` and from `D`.
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
Review the follow-up context in PR #14041 and reproduce the provided C, D, and E example with mypy. Trace the existing override handling for Self-typed attributes and add coverage for the conflicting inherited types; done means mypy reports the expected error for E.
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