module documentation

Undocumented

Class ArgsTypeProcotol protocol for types that have ``__args__``
Class CallableReference a descriptor that refers to a callable.
Class DescriptorProto Undocumented
Class DescriptorReference a descriptor that refers to a descriptor.
Class GenericProtocol protocol for generic types.
Class RODescriptorReference a descriptor that refers to a descriptor.
Class SupportsKeysAndGetItem Undocumented
Function de_optionalize_fwd_ref_union_types return the non-optional type for Optional[], Union[None, ...], x|None, etc. without de-stringifying forward refs.
Function de_optionalize_union_types Given a type, filter out ``Union`` types that include ``NoneType`` to not include the ``NoneType``.
Function de_stringify_annotation Resolve annotations that may be string based into real objects.
Function de_stringify_union_elements Undocumented
Function eval_expression Undocumented
Function eval_name_only Undocumented
Function expand_unions Return a type as a tuple of individual types, expanding for ``Union`` types.
Function flatten_newtype Undocumented
Function is_fwd_ref Undocumented
Function is_generic Undocumented
Function is_literal Undocumented
Function is_newtype Undocumented
Function is_optional Undocumented
Function is_optional_union Undocumented
Function is_origin_of return True if the given type has an __origin__ with the given name and optional module.
Function is_origin_of_cls return True if the given type has an __origin__ that shares a base with the given class
Function is_pep593 Undocumented
Function is_union Undocumented
Function make_union_type Make a Union type.
Function resolve_name_to_real_class_name Undocumented
Variable NoneFwd Undocumented
Function _copy_generic_annotation_with Undocumented
Function _get_type_name Undocumented
Type Variable _DESC Undocumented
Type Variable _DESC_co Undocumented
Type Variable _FN Undocumented
Type Variable _KT Undocumented
Type Variable _KT_co Undocumented
Type Variable _KT_contra Undocumented
Type Variable _T Undocumented
Type Variable _VT Undocumented
Type Variable _VT_co Undocumented
Type Alias _AnnotationScanType Undocumented
Variable _LiteralStar Undocumented
def de_optionalize_fwd_ref_union_types(type_: ForwardRef) -> _AnnotationScanType: (source)

return the non-optional type for Optional[], Union[None, ...], x|None, etc. without de-stringifying forward refs. unfortunately this seems to require lots of hardcoded heuristics

@overload
def de_optionalize_union_types(type_: str) -> str:
@overload
def de_optionalize_union_types(type_: Type[Any]) -> Type[Any]:
@overload
def de_optionalize_union_types(type_: _AnnotationScanType) -> _AnnotationScanType:
(source)

Given a type, filter out ``Union`` types that include ``NoneType`` to not include the ``NoneType``.

def de_stringify_annotation(cls: Type[Any], annotation: _AnnotationScanType, originating_module: str, locals_: Mapping[str, Any], *, str_cleanup_fn: Optional[Callable[[str, str], str]] = None, include_generic: bool = False) -> Type[Any]: (source)

Resolve annotations that may be string based into real objects. This is particularly important if a module defines "from __future__ import annotations", as everything inside of __annotations__ is a string. We want to at least have generic containers like ``Mapped``, ``Union``, ``List``, etc.

def de_stringify_union_elements(cls: Type[Any], annotation: ArgsTypeProcotol, originating_module: str, locals_: Mapping[str, Any], *, str_cleanup_fn: Optional[Callable[[str, str], str]] = None) -> Type[Any]: (source)

Undocumented

def eval_expression(expression: str, module_name: str, *, locals_: Optional[Mapping[str, Any]] = None) -> Any: (source)

Undocumented

def eval_name_only(name: str, module_name: str, *, locals_: Optional[Mapping[str, Any]] = None) -> Any: (source)

Undocumented

def expand_unions(type_: Type[Any], include_union: bool = False, discard_none: bool = False) -> Tuple[Type[Any], ...]: (source)

Return a type as a tuple of individual types, expanding for ``Union`` types.

def flatten_newtype(type_: NewType) -> Type[Any]: (source)

Undocumented

def is_fwd_ref(type_: _AnnotationScanType, check_generic: bool = False) -> bool: (source)

Undocumented

def is_generic(type_: _AnnotationScanType) -> TypeGuard[GenericProtocol[Any]]: (source)

Undocumented

def is_literal(type_: _AnnotationScanType) -> bool: (source)

Undocumented

def is_newtype(type_: Optional[_AnnotationScanType]) -> TypeGuard[NewType]: (source)

Undocumented

def is_optional(type_: Any) -> TypeGuard[ArgsTypeProcotol]: (source)

Undocumented

def is_optional_union(type_: Any) -> bool: (source)

Undocumented

def is_origin_of(type_: Any, *names: str, module: Optional[str] = None) -> bool: (source)

return True if the given type has an __origin__ with the given name and optional module.

def is_origin_of_cls(type_: Any, class_obj: Union[Tuple[Type[Any], ...], Type[Any]]) -> bool: (source)

return True if the given type has an __origin__ that shares a base with the given class

Undocumented

def is_union(type_: Any) -> TypeGuard[ArgsTypeProcotol]: (source)

Undocumented

def make_union_type(*types: _AnnotationScanType) -> Type[Any]: (source)

Make a Union type. This is needed by :func:`.de_optionalize_union_types` which removes ``NoneType`` from a ``Union``.

def resolve_name_to_real_class_name(name: str, module_name: str) -> str: (source)

Undocumented

Undocumented

def _copy_generic_annotation_with(annotation: GenericProtocol[_T], elements: Tuple[_AnnotationScanType, ...]) -> Type[_T]: (source)

Undocumented

def _get_type_name(type_: Type[Any]) -> str: (source)

Undocumented

Undocumented

Value
TypeVar('_DESC',
        bound=DescriptorProto)
_DESC_co = (source)

Undocumented

Value
TypeVar('_DESC_co',
        bound=DescriptorProto, covariant=True)

Undocumented

Value
TypeVar('_FN',
        bound=Optional[Callable[..., Any]])

Undocumented

Value
TypeVar('_KT')

Undocumented

Value
TypeVar('_KT_co',
        covariant=True)
_KT_contra = (source)

Undocumented

Value
TypeVar('_KT_contra',
        contravariant=True)

Undocumented

Value
TypeVar('_T',
        bound=Any)

Undocumented

Value
TypeVar('_VT')

Undocumented

Value
TypeVar('_VT_co',
        covariant=True)
_AnnotationScanType = (source)

Undocumented

Value
Union[Type[Any], str, ForwardRef, NewType, 'GenericProtocol[Any]']
_LiteralStar = (source)

Undocumented