Avoid eagerly evaluating annotations
Open
Nobody has claimed this yet.
3.14
stdlib
type-bug
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
There are various places in the stdlib where we access the .__annotations__ attribute. Under PEP-649 / PEP-749, this now forces evaluation of lazy annotations. We should avoid evaluating annotations where it is not necessary.
For example, currently typing.Protocol evaluates its annotations at protocol creation time.
Linked PRs
- gh-132494
- gh-132534
- gh-132596
- gh-133411
- gh-133415
- gh-133796
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 the linked PRs and the stdlib sites that access .__annotations__, with typing.Protocol as the named example. Use PEP-649 and PEP-749 to understand the lazy-annotation behavior; done means unnecessary annotation evaluation is avoided, especially during protocol creation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100