class documentation

class SemanticAnalyzerPluginInterface: (source)

Known subclasses: mypy.semanal.SemanticAnalyzer

View In Hierarchy

Interface for accessing semantic analyzer functionality in plugins. Methods docstrings contain only basic info. Look for corresponding implementation docstrings in semanal.py for more details. # TODO: clean-up lookup functions.

Method add_plugin_dependency Specify semantic dependencies for generated methods/variables.
Method add_symbol_table_node Add node to global symbol table (or to nearest class if there is one).
Method anal_type Analyze an unbound type.
Method analyze_simple_literal_type Undocumented
Method basic_new_typeinfo Undocumented
Method builtin_type Legacy function -- use named_type() instead.
Method class_type Generate type of first argument of class methods from type of self.
Method defer Call this to defer the processing of the current node.
Method fail Emit an error message at given location.
Method lookup_fully_qualified Lookup a symbol by its fully qualified name.
Method lookup_fully_qualified_or_none Lookup a symbol by its fully qualified name.
Method lookup_qualified Lookup symbol using a name in current scope.
Method named_type Construct an instance of a builtin type with given type arguments.
Method named_type_or_none Construct an instance of a type with given type arguments.
Method parse_bool Parse True/False literals.
Method parse_str_literal Parse string literals.
Method qualified_name Make qualified name using current module and enclosing class (if any).
Class Variable cur_mod_id Undocumented
Class Variable modules Undocumented
Class Variable msg Undocumented
Class Variable options Undocumented
Property final_iteration Is this the final iteration of semantic analysis?
Property is_stub_file Undocumented
@abstractmethod
def add_plugin_dependency(self, trigger: str, target: str|None = None): (source)

Specify semantic dependencies for generated methods/variables. If the symbol with full name given by trigger is found to be stale by mypy, then the body of node with full name given by target will be re-checked. By default, this is the node that is currently analyzed. For example, the dataclass plugin adds a generated __init__ method with a signature that depends on types of attributes in ancestor classes. If any attribute in an ancestor class gets stale (modified), we need to reprocess the subclasses (and thus regenerate __init__ methods). This is used by fine-grained incremental mode (mypy daemon). See mypy/server/deps.py for more details.

@abstractmethod
def add_symbol_table_node(self, name: str, stnode: SymbolTableNode) -> Any: (source)

Add node to global symbol table (or to nearest class if there is one).

@abstractmethod
def anal_type(self, t: Type, *, tvar_scope: TypeVarLikeScope|None = None, allow_tuple_literal: bool = False, allow_unbound_tvars: bool = False, report_invalid_types: bool = True, third_pass: bool = False) -> Type|None: (source)

Analyze an unbound type. Return None if some part of the type is not ready yet. In this case the current target being analyzed will be deferred and analyzed again.

@abstractmethod
def analyze_simple_literal_type(self, rvalue: Expression, is_final: bool) -> Type|None: (source)

Undocumented

@abstractmethod
def basic_new_typeinfo(self, name: str, basetype_or_fallback: Instance, line: int) -> TypeInfo: (source)

Undocumented

@abstractmethod
def builtin_type(self, fully_qualified_name: str) -> Instance: (source)

Legacy function -- use named_type() instead.

@abstractmethod
def class_type(self, self_type: Type) -> Type: (source)

Generate type of first argument of class methods from type of self.

Call this to defer the processing of the current node. This will request an additional iteration of semantic analysis.

@abstractmethod
def fail(self, msg: str, ctx: Context, serious: bool = False, *, blocker: bool = False, code: ErrorCode|None = None): (source)

Emit an error message at given location.

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

Lookup a symbol by its fully qualified name. Raise an error if not found.

@abstractmethod
def lookup_fully_qualified_or_none(self, name: str) -> SymbolTableNode|None: (source)

Lookup a symbol by its fully qualified name. Return None if not found.

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

Lookup symbol using a name in current scope. This follows Python local->non-local->global->builtins rules.

@abstractmethod
def named_type(self, fullname: str, args: list[Type]|None = None) -> Instance: (source)

Construct an instance of a builtin type with given type arguments.

@abstractmethod
def named_type_or_none(self, fullname: str, args: list[Type]|None = None) -> Instance|None: (source)

Construct an instance of a type with given type arguments. Return None if a type could not be constructed for the qualified type name. This is possible when the qualified name includes a module name and the module has not been imported.

@abstractmethod
def parse_bool(self, expr: Expression) -> bool|None: (source)

Parse True/False literals.

@abstractmethod
def parse_str_literal(self, expr: Expression) -> str|None: (source)

Parse string literals.

@abstractmethod
def qualified_name(self, n: str) -> str: (source)

Make qualified name using current module and enclosing class (if any).

cur_mod_id: str = (source)

Undocumented

Undocumented

Undocumented

Is this the final iteration of semantic analysis?