MCPcopy Index your code
hub / github.com/python/mypy / TypeAnalyser

Class TypeAnalyser

mypy/typeanal.py:186–2015  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

184
185
186class TypeAnalyser(SyntheticTypeVisitor[Type], TypeAnalyzerPluginInterface):
187 """Semantic analyzer for types.
188
189 Converts unbound types into bound types. This is a no-op for already
190 bound types.
191
192 If an incomplete reference is encountered, this does a defer. The
193 caller never needs to defer.
194 """
195
196 # Is this called from an untyped function definition?
197 in_dynamic_func: bool = False
198 # Is this called from global scope?
199 global_scope: bool = True
200
201 def __init__(
202 self,
203 api: SemanticAnalyzerCoreInterface,
204 tvar_scope: TypeVarLikeScope,
205 plugin: Plugin,
206 options: Options,
207 cur_mod_node: MypyFile,
208 is_typeshed_stub: bool,
209 *,
210 defining_alias: bool = False,
211 python_3_12_type_alias: bool = False,
212 allow_tuple_literal: bool = False,
213 allow_unbound_tvars: bool = False,
214 allow_placeholder: bool = False,
215 allow_typed_dict_special_forms: bool = False,
216 allow_final: bool = True,
217 allow_param_spec_literals: bool = False,
218 allow_unpack: bool = False,
219 report_invalid_types: bool = True,
220 prohibit_self_type: str | None = None,
221 prohibit_special_class_field_types: str | None = None,
222 allowed_alias_tvars: list[TypeVarLikeType] | None = None,
223 allow_type_any: bool = False,
224 alias_type_params_names: list[str] | None = None,
225 ) -> None:
226 self.api = api
227 self.fail_func = api.fail
228 self.note_func = api.note
229 self.tvar_scope = tvar_scope
230 # Are we analysing a type alias definition rvalue?
231 self.defining_alias = defining_alias
232 self.python_3_12_type_alias = python_3_12_type_alias
233 self.allow_tuple_literal = allow_tuple_literal
234 # Positive if we are analyzing arguments of another (outer) type
235 self.nesting_level = 0
236 # Should we accept unbound type variables? This is currently used for class bases,
237 # and alias right hand sides (before they are analyzed as type aliases).
238 self.allow_unbound_tvars = allow_unbound_tvars
239 if allowed_alias_tvars is None:
240 allowed_alias_tvars = []
241 self.allowed_alias_tvars = allowed_alias_tvars
242 self.alias_type_params_names = alias_type_params_names
243 # If false, record incomplete ref if we generate PlaceholderType.

Callers 3

type_analyzerMethod · 0.90
analyze_type_aliasFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…