PEP 749: use `annotationlib` as the proposed module name throughout (#3833)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
parent
93557b3808
commit
c5915b3ae0
|
@ -498,7 +498,7 @@ These attributes are read-only.
|
||||||
Usually, users would use these attributes in combinations with
|
Usually, users would use these attributes in combinations with
|
||||||
``annotationlib.call_evaluate_function``. For example, to get a ``TypeVar``'s bound
|
``annotationlib.call_evaluate_function``. For example, to get a ``TypeVar``'s bound
|
||||||
in SOURCE format, one could write
|
in SOURCE format, one could write
|
||||||
``annotationlib.call_evaluate_function(T.evaluate_bound, annotations.Format.SOURCE)``.
|
``annotationlib.call_evaluate_function(T.evaluate_bound, annotationlib.Format.SOURCE)``.
|
||||||
|
|
||||||
Miscellaneous implementation details
|
Miscellaneous implementation details
|
||||||
====================================
|
====================================
|
||||||
|
@ -670,7 +670,7 @@ Accessing ``.type`` might throw an error:
|
||||||
File "<python-input-4>", line 1, in <module>
|
File "<python-input-4>", line 1, in <module>
|
||||||
field.type
|
field.type
|
||||||
File ".../dataclasses.py", line 308, in type
|
File ".../dataclasses.py", line 308, in type
|
||||||
annos = self._annotate(annotations.Format.VALUE)
|
annos = self._annotate(annotationlib.Format.VALUE)
|
||||||
File "<python-input-2>", line 3, in __annotate__
|
File "<python-input-2>", line 3, in __annotate__
|
||||||
x: undefined
|
x: undefined
|
||||||
^^^^^^^^^
|
^^^^^^^^^
|
||||||
|
@ -680,9 +680,9 @@ But users could use ``annotationlib.call_evaluate_function`` to get the type in
|
||||||
|
|
||||||
.. code:: pycon
|
.. code:: pycon
|
||||||
|
|
||||||
>>> annotations.call_evaluate_function(field.evaluate_type, annotations.Format.SOURCE)
|
>>> annotationlib.call_evaluate_function(field.evaluate_type, annotationlib.Format.SOURCE)
|
||||||
'undefined'
|
'undefined'
|
||||||
>>> annotations.call_evaluate_function(field.evaluate_type, annotations.Format.FORWARDREF)
|
>>> annotationlib.call_evaluate_function(field.evaluate_type, annotationlib.Format.FORWARDREF)
|
||||||
ForwardRef('undefined')
|
ForwardRef('undefined')
|
||||||
|
|
||||||
Other variations are possible. For example, we could leave the ``type`` attribute unchanged,
|
Other variations are possible. For example, we could leave the ``type`` attribute unchanged,
|
||||||
|
@ -723,7 +723,7 @@ code execution even with no access to any globals or builtins. For example:
|
||||||
|
|
||||||
>>> def f(x: (1).__class__.__base__.__subclasses__()[-1].__init__.__builtins__["print"]("Hello world")): pass
|
>>> def f(x: (1).__class__.__base__.__subclasses__()[-1].__init__.__builtins__["print"]("Hello world")): pass
|
||||||
...
|
...
|
||||||
>>> annotations.get_annotations(f, format=annotations.Format.SOURCE)
|
>>> annotationlib.get_annotations(f, format=annotationlib.Format.SOURCE)
|
||||||
Hello world
|
Hello world
|
||||||
{'x': 'None'}
|
{'x': 'None'}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue