Running `get_dynamic_class_hook()` after `get_class_decorator_hook_2()`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Feature
It would be useful to run get_dynamic_class_hook() from plugins after get_class_decorator_hook_2() to support dynamic classes that inspect existing dataclasses / attrs classes.
Pitch
We have an internal mypy plugin that makes "partial" classes, where all required attributes are optional. It does this by examining the __init__ of an attrs class and creating a new __init__ for the new class where all args are now optional. This works in mypy 0.942, occasionally crashes in 0.950, and doesn't work at all in 0.960 (128661ccbf4396ed1538421c481f1773c7490169) because the attrs __init__ is not present during get_dynamic_class_hook().
Is there some way to work around this?
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 by tracing the plugin entry points get_dynamic_class_hook() and get_class_decorator_hook_2() and how hook ordering exposes attrs-generated init methods. The change is done when dynamic class hooks can inspect existing dataclasses or attrs classes after decorator processing, with regression coverage for the partial-class plugin scenario described here.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100