Add support for marking classes `typing.final`
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- python
- Domain
- developer-experience
Research direction
Start by reviewing the public frozen, define, and mutable decorator APIs and the question of how they should interact with typing.final. The issue leaves defaults, backward compatibility, subclassing behavior, and deprecation options unresolved. Done would require an agreed design before implementation scope can be defined.
Written by the indexing model from the issue text.
Description
I am filing the below not really having through details, though I at least don't see this mentioned in any other issue, hence splatting it out :). Spicy takes I'm sure coming below as I'm sure part of this rests on how much each of us tolerates inheritance.
Should attrs have a way to apply typing.final to its classes so that they're easier to mark as "don't subclass"? E.g. a final= argument to frozen / define / mutable?
Obviously stacking the two decorators works, so the motivation I guess for me personally is just "I always want final for basically any class I expose", so if attrs had this it's one less thing to forget. What I do now is usually things at runtime, which don't use final() at all, but given I just realized I should probably add final() too so that users who do rely on their type checkers see a warning, that made me wonder whether that half is something general enough to be here.
If it were an argument to define, defaulting to True obviously breaks backwards compatibility. Perhaps doing it for frozen at least is justifiable? Or at least desirable with a deprecation warning for subclassing in the interim?
Any thoughts on how reasonable that sounds?
- Dominant language
- Python
- Stars
- 5.8k
- Forks
- 490
- Avg merge
- 1h 45m
- Merged PRs (30d)
- 1
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing 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.
More from python-attrs/attrs
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
python-attrs/attrs#1627 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
python-attrs/attrs#1620 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
python-attrs/attrs#1596 · 2 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
python-attrs/attrs#1549 · 3 comments ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
python-attrs/attrs#1543 · 2 comments ·
Maintainers usually reply within 1 day
All issues in python-attrs/attrs
Similar issues
-
tool-calling
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
vllm-project/vllm#59838 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
raullenchai/Rapid-MLX#4042 ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 1/5 Under an hour Newbie friendliness 92/100
transitmatters/mbta-slow-zone-bot#70 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
litestar-org/advanced-alchemy#811 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day