Document that accessing `__annotations__` through `__dict__` no longer works
Open
Nobody has claimed this yet.
3.14
3.15
docs
stdlib
topic-typing
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Bug report
Bug description:
The following code crashes on 3.14.0a4 but runs without error on 3.13:
import dataclasses
def my_dataclass(cls):
try:
annotations = cls.__dict__["__annotations__"]
except KeyError:
cls = dataclasses.dataclass()(cls)
else:
new_annotations = dict(annotations)
for name in annotations.keys():
if name == "ignore_this_annotation":
new_annotations.pop(name)
cls.__annotations__ = new_annotations
cls = dataclasses.dataclass()(cls)
cls.__annotations__ = annotations
return cls
@my_dataclass
class X:
x: int = 3
ignore_this_annotation: int
with:
TypeError: non-default argument 'ignore_this_annotation' follows default argument 'x'
Python installed via uv venv --python=3.14.
x-ref https://github.com/patrick-kidger/optimistix/issues/168 https://github.com/patrick-kidger/equinox/issues/1096)
CPython versions tested on:
3.14
Operating systems tested on:
macOS
Linked PRs
- gh-151750
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 issue's reproducer and linked PR gh-151750 to understand the intended documentation change. Update the relevant Python documentation to explain that accessing annotations through dict no longer works, and confirm the behavior and version context are accurately covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100