module documentation
(source)

Astroid hooks for typing.py support.
Function infer_old_typed​Dict Undocumented
Function infer​_special​_alias Infer call to tuple alias as new subscriptable class typing.Tuple.
Function infer_typed​Dict Replace TypedDict FunctionDef with ClassDef.
Function infer​_typing​_alias Infers the call to _alias function Insert ClassDef, with same name as aliased class, in mro to simulate _GenericAlias.
Function infer​_typing​_attr Infer a typing.X[...] subscript
Function infer​_typing​_cast Infer call to cast() returning same type as casted-from var
Function infer​_typing​_typevar​_or​_newtype Infer a typing.TypeVar(...) or typing.NewType(...) call
Function looks​_like​_typing​_typevar​_or​_newtype Undocumented
Constant CLASS​_GETITEM​_TEMPLATE Undocumented
Constant TYPING​_ALIAS Undocumented
Constant TYPING​_MEMBERS Undocumented
Constant TYPING​_NAMEDTUPLE​_BASENAMES Undocumented
Constant TYPING​_TYPE​_TEMPLATE Undocumented
Constant TYPING​_TYPEVARS Undocumented
Constant TYPING​_TYPEVARS​_QUALIFIED Undocumented
Function _forbid​_class​_getitem​_access Disable the access to __class_getitem__ method for the node in parameters
Function _looks​_like​_special​_alias Return True if call is for Tuple or Callable alias.
Function _looks_like_typed​Dict Check if node is TypedDict FunctionDef.
Function _looks​_like​_typing​_alias Returns True if the node corresponds to a call to _alias function. For example :
Function _looks​_like​_typing​_cast Undocumented
Function _looks​_like​_typing​_subscript Try to figure out if a Subscript node might be a typing-related subscript
def infer_old_typedDict(node, ctx=None): (source)

Undocumented

Parameters
node:ClassDefUndocumented
ctx:typing.Optional[context.InferenceContext]Undocumented
Returns
typing.Iterator[ClassDef]Undocumented
def infer_special_alias(node, ctx=None): (source)
Infer call to tuple alias as new subscriptable class typing.Tuple.
Parameters
node:CallUndocumented
ctx:typing.Optional[context.InferenceContext]Undocumented
Returns
typing.Iterator[ClassDef]Undocumented
def infer_typedDict(node, ctx=None): (source)
Replace TypedDict FunctionDef with ClassDef.
Parameters
node:FunctionDefUndocumented
ctx:typing.Optional[context.InferenceContext]Undocumented
Returns
typing.Iterator[ClassDef]Undocumented
def infer_typing_alias(node, ctx=None): (source)
Infers the call to _alias function Insert ClassDef, with same name as aliased class, in mro to simulate _GenericAlias.
Parameters
node:Callcall node
ctx:typing.Optional[context.InferenceContext]Undocumented
contextinference context
Returns
typing.Iterator[ClassDef]Undocumented
def infer_typing_attr(node, ctx=None): (source)
Infer a typing.X[...] subscript
Parameters
node:SubscriptUndocumented
ctx:typing.Optional[context.InferenceContext]Undocumented
Returns
typing.Iterator[ClassDef]Undocumented
def infer_typing_cast(node, ctx=None): (source)
Infer call to cast() returning same type as casted-from var
Parameters
node:CallUndocumented
ctx:typing.Optional[context.InferenceContext]Undocumented
Returns
typing.Iterator[NodeNG]Undocumented
def infer_typing_typevar_or_newtype(node, context_itton=None): (source)
Infer a typing.TypeVar(...) or typing.NewType(...) call
def looks_like_typing_typevar_or_newtype(node): (source)

Undocumented

CLASS_GETITEM_TEMPLATE: str = (source)

Undocumented

Value
'''
@classmethod
def __class_getitem__(cls, item):
    return cls
'''
TYPING_ALIAS = (source)

Undocumented

Value
frozenset(('typing.Hashable',
           'typing.Awaitable',
           'typing.Coroutine',
           'typing.AsyncIterable',
           'typing.AsyncIterator',
           'typing.Iterable',
           'typing.Iterator',
...
TYPING_MEMBERS = (source)

Undocumented

Value
set(getattr(typing, '__all__', []))
TYPING_NAMEDTUPLE_BASENAMES: set[str] = (source)

Undocumented

Value
set(['NamedTuple', 'typing.NamedTuple'])
TYPING_TYPE_TEMPLATE: str = (source)

Undocumented

Value
'''
class Meta(type):
    def __getitem__(self, item):
        return self

    @property
    def __args__(self):
...
TYPING_TYPEVARS: set[str] = (source)

Undocumented

Value
set(['TypeVar', 'NewType'])
TYPING_TYPEVARS_QUALIFIED: set[str] = (source)

Undocumented

Value
set(['typing.TypeVar', 'typing.NewType'])
def _forbid_class_getitem_access(node): (source)
Disable the access to __class_getitem__ method for the node in parameters
Parameters
node:ClassDefUndocumented
def _looks_like_special_alias(node): (source)

Return True if call is for Tuple or Callable alias.

In PY37 and PY38 the call is to '_VariadicGenericAlias' with 'tuple' as first argument. In PY39+ it is replaced by a call to '_TupleType'.

PY37: Tuple = _VariadicGenericAlias(tuple, (), inst=False, special=True) PY39: Tuple = _TupleType(tuple, -1, inst=False, name='Tuple')

PY37: Callable = _VariadicGenericAlias(collections.abc.Callable, (), special=True) PY39: Callable = _CallableType(collections.abc.Callable, 2)

Parameters
node:CallUndocumented
Returns
boolUndocumented
def _looks_like_typedDict(node): (source)
Check if node is TypedDict FunctionDef.
Parameters
node:typing.Union[FunctionDef, ClassDef]Undocumented
Returns
boolUndocumented
def _looks_like_typing_alias(node): (source)

Returns True if the node corresponds to a call to _alias function. For example :

MutableSet = _alias(collections.abc.MutableSet, T)

Parameters
node:Callcall node
Returns
boolUndocumented
def _looks_like_typing_cast(node): (source)

Undocumented

Parameters
node:CallUndocumented
Returns
boolUndocumented
def _looks_like_typing_subscript(node): (source)
Try to figure out if a Subscript node might be a typing-related subscript