@@ -317,11 +317,22 @@ Functions
317317 Compute the annotations dict for an object.
318318
319319 *obj * may be a callable, class, module, or other object with
320- :attr: `~object.__annotate__ ` and :attr: `~object.__annotations__ ` attributes.
321- Passing in an object of any other type raises :exc: `TypeError `.
320+ :attr: `~object.__annotate__ ` or :attr: `~object.__annotations__ ` attributes.
321+ Passing any other object raises :exc: `TypeError `.
322322
323323 The *format * parameter controls the format in which annotations are returned,
324324 and must be a member of the :class: `Format ` enum or its integer equivalent.
325+ The different formats work as follows:
326+
327+ * VALUE: :attr: `!object.__annotations__ ` is tried first; if that does not exist,
328+ the :attr: `!object.__annotate__ ` function is called if it exists.
329+ * FORWARDREF: If :attr: `!object.__annotations__ ` exists and can be evaluated successfully,
330+ it is used; otherwise, the :attr: `!object.__annotate__ ` function is called. If it
331+ does not exist either, :attr: `!object.__annotations__ ` is tried again and any error
332+ from accessing it is re-raised.
333+ * STRING: If :attr: `!object.__annotate__ ` exists, it is called first;
334+ otherwise, :attr: `!object.__annotations__ ` is used and stringified
335+ using :func: `annotations_to_string `.
325336
326337 Returns a dict. :func: `!get_annotations ` returns a new dict every time
327338 it's called; calling it twice on the same object will return two
0 commit comments