@@ -107,9 +107,9 @@ Your code will have to have a separate code path if the object
107107you're examining is a class (``isinstance(o, type) ``).
108108In that case, best practice relies on an implementation detail
109109of Python 3.9 and before: if a class has annotations defined,
110- they are stored in the class's `` __dict__ ` ` dictionary.  Since
110+ they are stored in the class's :attr: ` ~class. __dict__ ` dictionary.  Since
111111the class may or may not have annotations defined, best practice
112- is to call the `` get ` ` method on the class dict.
112+ is to call the :meth: ` ~dict. get ` method on the class dict.
113113
114114To put it all together, here is some sample code that safely
115115accesses the ``__annotations__ `` attribute on an arbitrary
@@ -126,8 +126,8 @@ the type of ``ann`` using :func:`isinstance` before further
126126examination.
127127
128128Note that some exotic or malformed type objects may not have
129- a `` __dict__ ` ` attribute, so for extra safety you may also wish
130- to use :func: `getattr ` to access `` __dict__ ` `.
129+ a :attr: ` ~class. __dict__ ` attribute, so for extra safety you may also wish
130+ to use :func: `getattr ` to access :attr: ` ! __dict__ `.
131131
132132
133133Manually Un-Stringizing Stringized Annotations
@@ -247,4 +247,5 @@ on the class, you may observe unexpected behavior; see
247247quirks by using :func: `annotationlib.get_annotations ` on Python 3.14+ or
248248:func: `inspect.get_annotations ` on Python 3.10+. On earlier versions of
249249Python, you can avoid these bugs by accessing the annotations from the
250- class's ``__dict__ `` (e.g., ``cls.__dict__.get('__annotations__', None) ``).
250+ class's :attr: `~class.__dict__ `
251+ (e.g., ``cls.__dict__.get('__annotations__', None) ``).
0 commit comments