Tin mới
inspect — Inspect live objects
site — Site-specific configuration hook
The annotationlib module provides tools for introspecting annotations on modules, classes, and functions.
The annotationlib module provides tools for introspecting annotations on modules, classes, and functions.
PEP 649 proposed the current model for how annotations work in Python.
The way annotations are evaluated has changed over the history of Python 3, and currently still depends on a future import. There have been execution models for annotations:
An IntEnum describing the formats in which annotations can be returned. Members of the enum, or their equivalent integer values, can be passed to get_annotations() and other functions in this module, as well as to __anno
Special value used to signal that an annotate function is being evaluated in a special environment with fake globals. When passed this value, annotate functions should either return the same value as for the Format.VALUE
typing.TypeAliasType.evaluate_value()
typing.TypeAliasType.evaluate_value(), the value of type aliases
If obj is a callable, globals defaults to obj.__globals__, although if obj is a wrapped function (using functools.update_wrapper()) or a functools.partial object, it is unwrapped until a non-wrapped function is found.
ast: Abstract Syntax Tree classes and manipulation.
The STRING format is meant to approximate the source code of the annotation, but the implementation strategy used means that it is not always possible to recover the exact source code.