VariableSymbol

class VariableSymbol(name: str, lineno: int, live_value: Any = None, annotation_str: str | None = None, inferred_type_str: str | None = None, ast_info: VariableInfo | None = None)[source]

Bases: StubSymbol

A module-level variable or constant.

Parameters:
  • live_value (Any) – The runtime value of the variable. None in AST-only mode or when the variable evaluates to None.

  • annotation_str (str or None) – Type annotation as an unparsed string, from the AST.

  • inferred_type_str (str or None) – type(live_value).__name__ when no annotation is available.

  • ast_info (VariableInfo or None)

Examples

>>> sym = VariableSymbol(name="MAX", lineno=1, annotation_str="int")
>>> sym.kind
<SymbolKind.VARIABLE: 'variable'>
__init__(name: str, lineno: int, live_value: Any = None, annotation_str: str | None = None, inferred_type_str: str | None = None, ast_info: VariableInfo | None = None) None[source]
live_value: Any = None
annotation_str: str | None = None
inferred_type_str: str | None = None
ast_info: VariableInfo | None = None
property effective_type_str: str | None

Return annotation_str if available, else inferred_type_str.

See also

Public API reference — overview of all public names.