class documentation

class TypeAnalyser(SyntheticTypeVisitor[Type], TypeAnalyzerPluginInterface): (source)

View In Hierarchy

Semantic analyzer for types. Converts unbound types into bound types. This is a no-op for already bound types. If an incomplete reference is encountered, this does a defer. The caller never needs to defer.

Method __init__ Undocumented
Method anal_array Undocumented
Method anal_star_arg_type Analyze signature argument type for *args and **kwargs argument.
Method anal_type Undocumented
Method anal_type_guard Undocumented
Method anal_type_guard_arg Undocumented
Method anal_var_def Undocumented
Method anal_var_defs Undocumented
Method analyze_callable_args Find types, kinds, and names of arguments from extended callable syntax.
Method analyze_callable_args_for_concatenate Construct a 'Callable[C, RET]', where C is Concatenate[..., P], returning None if we cannot.
Method analyze_callable_args_for_paramspec Construct a 'Callable[P, RET]', where P is ParamSpec, return None if we cannot.
Method analyze_callable_type Undocumented
Method analyze_literal_param Undocumented
Method analyze_literal_type Undocumented
Method analyze_type Analyze an unbound type using the default mypy logic.
Method analyze_type_with_type_info Bind unbound type when were able to find target TypeInfo.
Method analyze_unbound_type_without_type_info Figure out what an unbound type that doesn't refer to a TypeInfo node means.
Method apply_concatenate_operator Undocumented
Method bind_function_type_variables Find the type variables of the function type and bind them in our tvar_scope
Method cannot_resolve_type Undocumented
Method check_unpacks_in_list Undocumented
Method fail Emit an error message at given location.
Method find_type_var_likes Undocumented
Method get_omitted_any Undocumented
Method infer_type_variables Return list of unique type variables referred to in a callable.
Method is_defined_type_var Undocumented
Method lookup_fully_qualified Undocumented
Method lookup_qualified Undocumented
Method named_type Construct an instance of a builtin type with given name.
Method note Undocumented
Method pack_paramspec_args Undocumented
Method try_analyze_special_unbound_type Bind special type that is recognized through magic name such as 'typing.Any'.
Method tuple_type Undocumented
Method tvar_scope_frame Undocumented
Method visit_any Undocumented
Method visit_callable_argument Undocumented
Method visit_callable_type Undocumented
Method visit_deleted_type Undocumented
Method visit_ellipsis_type Undocumented
Method visit_erased_type Undocumented
Method visit_instance Undocumented
Method visit_literal_type Undocumented
Method visit_none_type Undocumented
Method visit_overloaded Undocumented
Method visit_param_spec Undocumented
Method visit_parameters Undocumented
Method visit_partial_type Undocumented
Method visit_placeholder_type Undocumented
Method visit_raw_expression_type Undocumented
Method visit_tuple_type Undocumented
Method visit_type_alias_type Undocumented
Method visit_type_list Undocumented
Method visit_type_type Undocumented
Method visit_type_var Undocumented
Method visit_type_var_tuple Undocumented
Method visit_typeddict_type Undocumented
Method visit_unbound_type Undocumented
Method visit_unbound_type_nonoptional Undocumented
Method visit_uninhabited_type Undocumented
Method visit_union_type Undocumented
Method visit_unpack_type Undocumented
Class Variable global_scope Undocumented
Class Variable in_dynamic_func Undocumented
Instance Variable aliases_used Undocumented
Instance Variable allow_param_spec_literals Undocumented
Instance Variable allow_placeholder Undocumented
Instance Variable allow_required Undocumented
Instance Variable allow_tuple_literal Undocumented
Instance Variable allow_type_any Undocumented
Instance Variable allow_unbound_tvars Undocumented
Instance Variable allowed_alias_tvars Undocumented
Instance Variable always_allow_new_syntax Undocumented
Instance Variable api Undocumented
Instance Variable defining_alias Undocumented
Instance Variable fail_func Undocumented
Instance Variable is_typeshed_stub Undocumented
Instance Variable nesting_level Undocumented
Instance Variable note_func Undocumented
Instance Variable options Undocumented
Instance Variable plugin Undocumented
Instance Variable prohibit_self_type Undocumented
Instance Variable report_invalid_types Undocumented
Instance Variable tvar_scope Undocumented
def __init__(self, api: SemanticAnalyzerCoreInterface, tvar_scope: TypeVarLikeScope, plugin: Plugin, options: Options, is_typeshed_stub: bool, *, defining_alias: bool = False, allow_tuple_literal: bool = False, allow_unbound_tvars: bool = False, allow_placeholder: bool = False, allow_required: bool = False, allow_param_spec_literals: bool = False, report_invalid_types: bool = True, prohibit_self_type: str|None = None, allowed_alias_tvars: list[TypeVarLikeType]|None = None, allow_type_any: bool = False): (source)

Undocumented

def anal_array(self, a: Iterable[Type], nested: bool = True, *, allow_param_spec: bool = False, allow_param_spec_literals: bool = False) -> list[Type]: (source)

Undocumented

def anal_star_arg_type(self, t: Type, kind: ArgKind, nested: bool) -> Type: (source)

Analyze signature argument type for *args and **kwargs argument.

def anal_type(self, t: Type, nested: bool = True, *, allow_param_spec: bool = False) -> Type: (source)

Undocumented

def anal_type_guard(self, t: Type) -> Type|None: (source)

Undocumented

def anal_type_guard_arg(self, t: UnboundType, fullname: str) -> Type|None: (source)

Undocumented

def anal_var_def(self, var_def: TypeVarLikeType) -> TypeVarLikeType: (source)

Undocumented

def anal_var_defs(self, var_defs: Sequence[TypeVarLikeType]) -> list[TypeVarLikeType]: (source)

Undocumented

def analyze_callable_args(self, arglist: TypeList) -> tuple[list[Type], list[ArgKind], list[str|None]]|None: (source)

Find types, kinds, and names of arguments from extended callable syntax.

def analyze_callable_args_for_concatenate(self, callable_args: Type, ret_type: Type, fallback: Instance) -> CallableType|None: (source)

Construct a 'Callable[C, RET]', where C is Concatenate[..., P], returning None if we cannot.

def analyze_callable_args_for_paramspec(self, callable_args: Type, ret_type: Type, fallback: Instance) -> CallableType|None: (source)

Construct a 'Callable[P, RET]', where P is ParamSpec, return None if we cannot.

def analyze_callable_type(self, t: UnboundType) -> Type: (source)

Undocumented

def analyze_literal_param(self, idx: int, arg: Type, ctx: Context) -> list[Type]|None: (source)

Undocumented

def analyze_literal_type(self, t: UnboundType) -> Type: (source)

Undocumented

def analyze_type(self, t: Type) -> Type: (source)

Analyze an unbound type using the default mypy logic.

def analyze_type_with_type_info(self, info: TypeInfo, args: Sequence[Type], ctx: Context) -> Type: (source)

Bind unbound type when were able to find target TypeInfo. This handles simple cases like 'int', 'modname.UserClass[str]', etc.

def analyze_unbound_type_without_type_info(self, t: UnboundType, sym: SymbolTableNode, defining_literal: bool) -> Type: (source)

Figure out what an unbound type that doesn't refer to a TypeInfo node means. This is something unusual. We try our best to find out what it is.

def apply_concatenate_operator(self, t: UnboundType) -> Type: (source)

Undocumented

def bind_function_type_variables(self, fun_type: CallableType, defn: Context) -> tuple[Sequence[TypeVarLikeType], bool]: (source)

Find the type variables of the function type and bind them in our tvar_scope

def cannot_resolve_type(self, t: UnboundType): (source)

Undocumented

def check_unpacks_in_list(self, items: list[Type]) -> list[Type]: (source)

Undocumented

def fail(self, msg: str, ctx: Context, *, code: ErrorCode|None = None): (source)

Emit an error message at given location.

def find_type_var_likes(self, t: Type, include_callables: bool = True) -> TypeVarLikeList: (source)

Undocumented

def get_omitted_any(self, typ: Type, fullname: str|None = None) -> AnyType: (source)

Undocumented

def infer_type_variables(self, type: CallableType) -> list[tuple[str, TypeVarLikeExpr]]: (source)

Return list of unique type variables referred to in a callable.

def is_defined_type_var(self, tvar: str, context: Context) -> bool: (source)

Undocumented

def lookup_fully_qualified(self, name: str) -> SymbolTableNode: (source)

Undocumented

def lookup_qualified(self, name: str, ctx: Context, suppress_errors: bool = False) -> SymbolTableNode|None: (source)

Undocumented

def named_type(self, fully_qualified_name: str, args: list[Type]|None = None, line: int = -1, column: int = -1) -> Instance: (source)

Construct an instance of a builtin type with given name.

def note(self, msg: str, ctx: Context, *, code: ErrorCode|None = None): (source)

Undocumented

def pack_paramspec_args(self, an_args: Sequence[Type]) -> list[Type]: (source)

Undocumented

def try_analyze_special_unbound_type(self, t: UnboundType, fullname: str) -> Type|None: (source)

Bind special type that is recognized through magic name such as 'typing.Any'. Return the bound type if successful, and return None if the type is a normal type.

def tuple_type(self, items: list[Type]) -> TupleType: (source)

Undocumented

@contextmanager
def tvar_scope_frame(self) -> Iterator[None]: (source)

Undocumented

def visit_any(self, t: AnyType) -> Type: (source)

Undocumented

def visit_callable_argument(self, t: CallableArgument) -> Type: (source)

Undocumented

def visit_callable_type(self, t: CallableType, nested: bool = True) -> Type: (source)

Undocumented

def visit_deleted_type(self, t: DeletedType) -> Type: (source)

Undocumented

def visit_ellipsis_type(self, t: EllipsisType) -> Type: (source)

Undocumented

def visit_erased_type(self, t: ErasedType) -> Type: (source)

Undocumented

def visit_instance(self, t: Instance) -> Type: (source)

Undocumented

def visit_literal_type(self, t: LiteralType) -> Type: (source)

Undocumented

def visit_none_type(self, t: NoneType) -> Type: (source)

Undocumented

def visit_overloaded(self, t: Overloaded) -> Type: (source)

Undocumented

def visit_param_spec(self, t: ParamSpecType) -> Type: (source)

Undocumented

def visit_parameters(self, t: Parameters) -> Type: (source)

Undocumented

def visit_partial_type(self, t: PartialType) -> Type: (source)

Undocumented

def visit_placeholder_type(self, t: PlaceholderType) -> Type: (source)

Undocumented

def visit_raw_expression_type(self, t: RawExpressionType) -> Type: (source)

Undocumented

def visit_tuple_type(self, t: TupleType) -> Type: (source)

Undocumented

def visit_type_alias_type(self, t: TypeAliasType) -> Type: (source)

Undocumented

def visit_type_list(self, t: TypeList) -> Type: (source)

Undocumented

def visit_type_type(self, t: TypeType) -> Type: (source)

Undocumented

def visit_type_var(self, t: TypeVarType) -> Type: (source)

Undocumented

def visit_type_var_tuple(self, t: TypeVarTupleType) -> Type: (source)

Undocumented

def visit_typeddict_type(self, t: TypedDictType) -> Type: (source)

Undocumented

def visit_unbound_type(self, t: UnboundType, defining_literal: bool = False) -> Type: (source)

Undocumented

def visit_unbound_type_nonoptional(self, t: UnboundType, defining_literal: bool) -> Type: (source)

Undocumented

def visit_uninhabited_type(self, t: UninhabitedType) -> Type: (source)

Undocumented

def visit_union_type(self, t: UnionType) -> Type: (source)

Undocumented

def visit_unpack_type(self, t: UnpackType) -> Type: (source)

Undocumented

global_scope: bool = (source)

Undocumented

in_dynamic_func: bool = (source)

Undocumented

aliases_used: set[str] = (source)

Undocumented

allow_param_spec_literals = (source)

Undocumented

allow_placeholder = (source)

Undocumented

allow_required: bool = (source)

Undocumented

allow_tuple_literal = (source)

Undocumented

allow_type_any = (source)

Undocumented

allow_unbound_tvars = (source)

Undocumented

allowed_alias_tvars = (source)

Undocumented

always_allow_new_syntax = (source)

Undocumented

Undocumented

defining_alias = (source)

Undocumented

fail_func = (source)

Undocumented

is_typeshed_stub = (source)

Undocumented

nesting_level: int = (source)

Undocumented

note_func = (source)

Undocumented

Undocumented

prohibit_self_type = (source)

Undocumented

report_invalid_types = (source)

Undocumented

tvar_scope = (source)

Undocumented