class SemanticAnalyzerPluginInterface: (source)
Known subclasses: mypy.semanal.SemanticAnalyzer
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 |
Specify semantic dependencies for generated methods/variables. |
Method | add |
Add node to global symbol table (or to nearest class if there is one). |
Method | anal |
Analyze an unbound type. |
Method | analyze |
Undocumented |
Method | basic |
Undocumented |
Method | builtin |
Legacy function -- use named_type() instead. |
Method | class |
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 |
Lookup a symbol by its fully qualified name. |
Method | lookup |
Lookup a symbol by its fully qualified name. |
Method | lookup |
Lookup symbol using a name in current scope. |
Method | named |
Construct an instance of a builtin type with given type arguments. |
Method | named |
Construct an instance of a type with given type arguments. |
Method | parse |
Parse True/False literals. |
Method | parse |
Parse string literals. |
Method | qualified |
Make qualified name using current module and enclosing class (if any). |
Class Variable | cur |
Undocumented |
Class Variable | modules |
Undocumented |
Class Variable | msg |
Undocumented |
Class Variable | options |
Undocumented |
Property | final |
Is this the final iteration of semantic analysis? |
Property | is |
Undocumented |
mypy.semanal.SemanticAnalyzer
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.
def add_symbol_table_node(self, name:
str
, stnode: SymbolTableNode
) -> Any
:
(source)
¶
mypy.semanal.SemanticAnalyzer
Add node to global symbol table (or to nearest class if there is one).
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)
¶
mypy.semanal.SemanticAnalyzer
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.
def analyze_simple_literal_type(self, rvalue:
Expression
, is_final: bool
) -> Type|None
:
(source)
¶
mypy.semanal.SemanticAnalyzer
Undocumented
def basic_new_typeinfo(self, name:
str
, basetype_or_fallback: Instance
, line: int
) -> TypeInfo
:
(source)
¶
mypy.semanal.SemanticAnalyzer
Undocumented
mypy.semanal.SemanticAnalyzer
Generate type of first argument of class methods from type of self.
mypy.semanal.SemanticAnalyzer
Call this to defer the processing of the current node. This will request an additional iteration of semantic analysis.
def fail(self, msg:
str
, ctx: Context
, serious: bool
= False, *, blocker: bool
= False, code: ErrorCode|None
= None):
(source)
¶
mypy.semanal.SemanticAnalyzer
Emit an error message at given location.
mypy.semanal.SemanticAnalyzer
Lookup a symbol by its fully qualified name. Raise an error if not found.
def lookup_fully_qualified_or_none(self, name:
str
) -> SymbolTableNode|None
:
(source)
¶
mypy.semanal.SemanticAnalyzer
Lookup a symbol by its fully qualified name. Return None if not found.
def lookup_qualified(self, name:
str
, ctx: Context
, suppress_errors: bool
= False) -> SymbolTableNode|None
:
(source)
¶
mypy.semanal.SemanticAnalyzer
Lookup symbol using a name in current scope. This follows Python local->non-local->global->builtins rules.
def named_type(self, fullname:
str
, args: list[ Type]|None
= None) -> Instance
:
(source)
¶
mypy.semanal.SemanticAnalyzer
Construct an instance of a builtin type with given type arguments.
def named_type_or_none(self, fullname:
str
, args: list[ Type]|None
= None) -> Instance|None
:
(source)
¶
mypy.semanal.SemanticAnalyzer
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.
mypy.semanal.SemanticAnalyzer
Make qualified name using current module and enclosing class (if any).