@@ -243,10 +243,22 @@ If you use a class with a custom metaclass and access ``__annotations__``
243243on the class, you may observe unexpected behavior; see
244244:pep: `749 <749#pep749-metaclasses >` for some examples. You can avoid these
245245quirks by using :func: `annotationlib.get_annotations ` on Python 3.14+ or
246- :func: `inspect.get_annotations ` on Python 3.10+. On earlier versions of
247- Python, you can avoid these bugs by accessing the annotations from the
248- class's :attr: `~type.__dict__ `
249- (for example, ``cls.__dict__.get('__annotations__', None) ``).
246+ :func: `inspect.get_annotations ` on Python 3.10+.
247+
248+ .. note ::
249+
250+ On Python 3.14 and later, annotations are evaluated lazily (see
251+ :pep: `649 ` and :pep: `749 `), and how the annotations dict is stored in
252+ the class's :attr: `~type.__dict__ ` is a private implementation detail.
253+ Reading ``cls.__dict__.get('__annotations__', None) `` may therefore
254+ return ``None `` even when the class has annotations. On these versions,
255+ always use :func: `annotationlib.get_annotations ` (or
256+ :func: `inspect.get_annotations `) rather than accessing
257+ :attr: `~type.__dict__ ` directly.
258+
259+ Only on Python 3.9 and earlier, where neither function is available, can you
260+ avoid these bugs by reading the annotations from the class's
261+ :attr: `~type.__dict__ ` (for example, ``cls.__dict__.get('__annotations__', None) ``).
250262
251263In some versions of Python, instances of classes may have an ``__annotations__ ``
252264attribute. However, this is not supported functionality. If you need the
0 commit comments