Skip to content

Commit 99b23c6

Browse files
gh-123242: Note that type.__annotations__ may not exist (#124557)
Closes #123242. The real criterion is that the attribute does not exist on heap types, but I don't think we should discuss heap vs. static types in the language reference.
1 parent bc54393 commit 99b23c6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Doc/reference/datamodel.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,8 @@ Special attributes
10451045

10461046
Accessing the :attr:`!__annotations__` attribute of a class
10471047
object directly may yield incorrect results in the presence of
1048-
metaclasses. Use :func:`annotationlib.get_annotations` to
1048+
metaclasses. In addition, the attribute may not exist for
1049+
some classes. Use :func:`annotationlib.get_annotations` to
10491050
retrieve class annotations safely.
10501051

10511052
.. versionchanged:: 3.14

0 commit comments

Comments
 (0)