Add a plugin hook for handling function/method decorators
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Feature
mypy currently has the get_class_decorator_hook plugin hook. I want to propose adding a get_function_decorator_hook and get_method_decorator_hook.
Pitch
Adding these hooks would allow special handling of decorated functions, as would for example be required to solve #9911 using a plugin. mypy currently has special handling for a few decorated such as builtins.property, typing.final and more, but from what I can see it's currently not possible to add additional cases using a plugin.
I have already experimented with this a bit and could probably open a PR in the near future.
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 reviewing mypy's existing get_class_decorator_hook plugin hook and the handling of decorated functions, including builtins.property and typing.final. Define the corresponding function and method decorator hooks so plugins can handle additional decorated cases, then verify that the hooks support the intended use case described in issue #9911.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100