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

Class TypeChecker

mypy/checker.py:383–8450  ·  view source on GitHub ↗

Mypy type checker. Type check mypy source files that have been semantically analyzed. You must create a separate instance for each source file.

Source from the content-addressed store, hash-verified

381
382
383class TypeChecker(NodeVisitor[None], TypeCheckerSharedApi, SplittingVisitor):
384 """Mypy type checker.
385
386 Type check mypy source files that have been semantically analyzed.
387
388 You must create a separate instance for each source file.
389 """
390
391 # Are we type checking a stub?
392 is_stub = False
393 # Error message reporter
394 errors: Errors
395 # Utility for generating messages
396 msg: MessageBuilder
397 # Types of type checked nodes. The first item is the "master" type
398 # map that will store the final, exported types. Additional items
399 # are temporary type maps used during type inference, and these
400 # will be eventually popped and either discarded or merged into
401 # the master type map.
402 #
403 # Avoid accessing this directly, but prefer the lookup_type(),
404 # has_type() etc. helpers instead.
405 _type_maps: list[dict[Expression, Type]]
406
407 # Helper for managing conditional types
408 binder: ConditionalTypeBinder
409 # Helper for type checking expressions
410 _expr_checker: mypy.checkexpr.ExpressionChecker
411
412 pattern_checker: PatternChecker
413
414 tscope: Scope
415 scope: CheckerScope
416 # Stack of function return types
417 return_types: list[Type]
418 # Flags; true for dynamically typed functions
419 dynamic_funcs: list[bool]
420 # Stack of collections of variables with partial types
421 partial_types: list[PartialTypeScope]
422 # Vars for which partial type errors are already reported
423 # (to avoid logically duplicate errors with different error context).
424 partial_reported: set[Var]
425 # Short names of Var nodes whose previous inferred type has been widened via assignment.
426 # NOTE: The names might not be unique, they are only for debugging purposes.
427 widened_vars: list[str]
428 # Global variables widened inside a function body, to be propagated to
429 # the module-level binder after the function is type checked (with --allow-redefinition-new).
430 _globals_widened_in_func: list[tuple[NameExpr, Type]]
431 globals: SymbolTable
432 modules: dict[str, MypyFile]
433 # Nodes that couldn't be checked because some types weren't available. We'll run
434 # another pass and try these again.
435 deferred_nodes: list[DeferredNode]
436 # Type checking pass number (0 = first pass)
437 pass_num = 0
438 # Last pass number to take
439 last_pass = DEFAULT_LAST_PASS
440 # Have we deferred the current function? If yes, don't infer additional

Callers 1

type_checkerMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…