class documentation

class ASTConverter: (source)

View In Hierarchy

Undocumented

Method __init__ Undocumented
Method as_block Undocumented
Method as_required_block Undocumented
Method do_func_def Helper shared between visit_FunctionDef and visit_AsyncFunctionDef.
Method fail Undocumented
Method fail_arg Undocumented
Method fail_merge_overload Undocumented
Method fix_function_overloads Undocumented
Method from_comp_operator Undocumented
Method from_operator Undocumented
Method get_lineno Undocumented
Method group Undocumented
Method in_method_scope Undocumented
Method make_argument Undocumented
Method note Undocumented
Method set_line Undocumented
Method set_type_optional Undocumented
Method transform_args Undocumented
Method translate_expr_list Undocumented
Method translate_module_id Return the actual, internal module id for a source text id.
Method translate_opt_expr_list Undocumented
Method translate_stmt_list Undocumented
Method translate_type_comment Undocumented
Method visit Undocumented
Method visit_AnnAssign Undocumented
Method visit_Assert Undocumented
Method visit_Assign Undocumented
Method visit_AsyncFor Undocumented
Method visit_AsyncFunctionDef Undocumented
Method visit_AsyncWith Undocumented
Method visit_Attribute Undocumented
Method visit_AugAssign Undocumented
Method visit_Await Undocumented
Method visit_BinOp Undocumented
Method visit_BoolOp Undocumented
Method visit_Break Undocumented
Method visit_Bytes Undocumented
Method visit_Call Undocumented
Method visit_ClassDef Undocumented
Method visit_Compare Undocumented
Method visit_Constant Undocumented
Method visit_Continue Undocumented
Method visit_Delete Undocumented
Method visit_Dict Undocumented
Method visit_DictComp Undocumented
Method visit_Ellipsis Undocumented
Method visit_Expr Undocumented
Method visit_ExtSlice Undocumented
Method visit_For Undocumented
Method visit_FormattedValue Undocumented
Method visit_FunctionDef Undocumented
Method visit_GeneratorExp Undocumented
Method visit_Global Undocumented
Method visit_If Undocumented
Method visit_IfExp Undocumented
Method visit_Import Undocumented
Method visit_ImportFrom Undocumented
Method visit_Index Undocumented
Method visit_JoinedStr Undocumented
Method visit_Lambda Undocumented
Method visit_List Undocumented
Method visit_ListComp Undocumented
Method visit_Match Undocumented
Method visit_MatchAs Undocumented
Method visit_MatchClass Undocumented
Method visit_MatchMapping Undocumented
Method visit_MatchOr Undocumented
Method visit_MatchSequence Undocumented
Method visit_MatchSingleton Undocumented
Method visit_MatchStar Undocumented
Method visit_MatchValue Undocumented
Method visit_Module Undocumented
Method visit_Name Undocumented
Method visit_NameConstant Undocumented
Method visit_NamedExpr Undocumented
Method visit_Nonlocal Undocumented
Method visit_Num Undocumented
Method visit_Pass Undocumented
Method visit_Raise Undocumented
Method visit_Return Undocumented
Method visit_Set Undocumented
Method visit_SetComp Undocumented
Method visit_Slice Undocumented
Method visit_Starred Undocumented
Method visit_Str Undocumented
Method visit_Subscript Undocumented
Method visit_Try Undocumented
Method visit_TryStar Undocumented
Method visit_Tuple Undocumented
Method visit_UnaryOp Undocumented
Method visit_While Undocumented
Method visit_With Undocumented
Method visit_Yield Undocumented
Method visit_YieldFrom Undocumented
Constant comp_op_map Undocumented
Constant op_map Undocumented
Instance Variable class_and_function_stack Undocumented
Instance Variable errors Undocumented
Instance Variable imports Undocumented
Instance Variable is_stub Undocumented
Instance Variable options Undocumented
Instance Variable type_ignores Undocumented
Instance Variable visitor_cache Undocumented
Method _check_ifstmt_for_overloads Check if IfStmt contains only overloads with the same name. Return overload_name if found, None otherwise.
Method _get_executable_if_block_with_overloads Return block from IfStmt that will get executed.
Method _is_stripped_if_stmt Check stmt to make sure it is a stripped IfStmt.
Method _strip_contents_from_if_stmt Remove contents from IfStmt.
def __init__(self, options: Options, is_stub: bool, errors: Errors): (source)

Undocumented

def as_block(self, stmts: list[ast3.stmt], lineno: int) -> Block|None: (source)

Undocumented

def as_required_block(self, stmts: list[ast3.stmt], lineno: int) -> Block: (source)

Undocumented

def do_func_def(self, n: ast3.FunctionDef|ast3.AsyncFunctionDef, is_coroutine: bool = False) -> FuncDef|Decorator: (source)

Helper shared between visit_FunctionDef and visit_AsyncFunctionDef.

def fail(self, msg: str, line: int, column: int, blocker: bool = True, code: codes.ErrorCode = codes.SYNTAX): (source)

Undocumented

def fail_arg(self, msg: str, arg: ast3.arg): (source)

Undocumented

def fail_merge_overload(self, node: IfStmt): (source)

Undocumented

def fix_function_overloads(self, stmts: list[Statement]) -> list[Statement]: (source)

Undocumented

def from_comp_operator(self, op: ast3.cmpop) -> str: (source)

Undocumented

def from_operator(self, op: ast3.operator) -> str: (source)

Undocumented

def get_lineno(self, node: ast3.expr|ast3.stmt) -> int: (source)

Undocumented

def group(self, op: str, vals: list[Expression], n: ast3.expr) -> OpExpr: (source)

Undocumented

def in_method_scope(self) -> bool: (source)

Undocumented

def make_argument(self, arg: ast3.arg, default: ast3.expr|None, kind: ArgKind, no_type_check: bool, pos_only: bool = False) -> Argument: (source)

Undocumented

def note(self, msg: str, line: int, column: int): (source)

Undocumented

def set_line(self, node: N, n: AstNode) -> N: (source)

Undocumented

def set_type_optional(self, type: Type|None, initializer: Expression|None): (source)

Undocumented

def transform_args(self, args: ast3.arguments, line: int, no_type_check: bool = False) -> list[Argument]: (source)

Undocumented

def translate_expr_list(self, l: Sequence[AST]) -> list[Expression]: (source)

Undocumented

def translate_module_id(self, id: str) -> str: (source)

Return the actual, internal module id for a source text id.

def translate_opt_expr_list(self, l: Sequence[AST|None]) -> list[Expression|None]: (source)

Undocumented

def translate_stmt_list(self, stmts: Sequence[ast3.stmt], ismodule: bool = False) -> list[Statement]: (source)

Undocumented

def translate_type_comment(self, n: ast3.stmt|ast3.arg, type_comment: str|None) -> ProperType|None: (source)

Undocumented

def visit(self, node: AST|None) -> Any: (source)

Undocumented

def visit_AnnAssign(self, n: ast3.AnnAssign) -> AssignmentStmt: (source)

Undocumented

def visit_Assert(self, n: ast3.Assert) -> AssertStmt: (source)

Undocumented

def visit_Assign(self, n: ast3.Assign) -> AssignmentStmt: (source)

Undocumented

def visit_AsyncFor(self, n: ast3.AsyncFor) -> ForStmt: (source)

Undocumented

def visit_AsyncFunctionDef(self, n: ast3.AsyncFunctionDef) -> FuncDef|Decorator: (source)

Undocumented

def visit_AsyncWith(self, n: ast3.AsyncWith) -> WithStmt: (source)

Undocumented

def visit_Attribute(self, n: Attribute) -> MemberExpr|SuperExpr: (source)

Undocumented

def visit_AugAssign(self, n: ast3.AugAssign) -> OperatorAssignmentStmt: (source)

Undocumented

def visit_Await(self, n: ast3.Await) -> AwaitExpr: (source)

Undocumented

def visit_BinOp(self, n: ast3.BinOp) -> OpExpr: (source)

Undocumented

def visit_BoolOp(self, n: ast3.BoolOp) -> OpExpr: (source)

Undocumented

def visit_Break(self, n: ast3.Break) -> BreakStmt: (source)

Undocumented

def visit_Bytes(self, n: ast3.Bytes) -> BytesExpr|StrExpr: (source)

Undocumented

def visit_Call(self, n: Call) -> CallExpr: (source)

Undocumented

def visit_ClassDef(self, n: ast3.ClassDef) -> ClassDef: (source)

Undocumented

def visit_Compare(self, n: ast3.Compare) -> ComparisonExpr: (source)

Undocumented

def visit_Constant(self, n: Constant) -> Any: (source)

Undocumented

def visit_Continue(self, n: ast3.Continue) -> ContinueStmt: (source)

Undocumented

def visit_Delete(self, n: ast3.Delete) -> DelStmt: (source)

Undocumented

def visit_Dict(self, n: ast3.Dict) -> DictExpr: (source)

Undocumented

def visit_DictComp(self, n: ast3.DictComp) -> DictionaryComprehension: (source)

Undocumented

def visit_Ellipsis(self, n: ast3_Ellipsis) -> EllipsisExpr: (source)

Undocumented

def visit_Expr(self, n: ast3.Expr) -> ExpressionStmt: (source)

Undocumented

def visit_ExtSlice(self, n: ast3.ExtSlice) -> TupleExpr: (source)

Undocumented

def visit_For(self, n: ast3.For) -> ForStmt: (source)

Undocumented

def visit_FormattedValue(self, n: ast3.FormattedValue) -> Expression: (source)

Undocumented

def visit_FunctionDef(self, n: ast3.FunctionDef) -> FuncDef|Decorator: (source)

Undocumented

def visit_GeneratorExp(self, n: ast3.GeneratorExp) -> GeneratorExpr: (source)

Undocumented

def visit_Global(self, n: ast3.Global) -> GlobalDecl: (source)

Undocumented

def visit_If(self, n: ast3.If) -> IfStmt: (source)

Undocumented

def visit_IfExp(self, n: ast3.IfExp) -> ConditionalExpr: (source)

Undocumented

def visit_Import(self, n: ast3.Import) -> Import: (source)

Undocumented

def visit_ImportFrom(self, n: ast3.ImportFrom) -> ImportBase: (source)

Undocumented

def visit_Index(self, n: Index) -> Node: (source)

Undocumented

def visit_JoinedStr(self, n: ast3.JoinedStr) -> Expression: (source)

Undocumented

def visit_Lambda(self, n: ast3.Lambda) -> LambdaExpr: (source)

Undocumented

def visit_List(self, n: ast3.List) -> ListExpr|TupleExpr: (source)

Undocumented

def visit_ListComp(self, n: ast3.ListComp) -> ListComprehension: (source)

Undocumented

def visit_Match(self, n: Match) -> MatchStmt: (source)

Undocumented

def visit_MatchAs(self, n: MatchAs) -> AsPattern: (source)

Undocumented

def visit_MatchClass(self, n: MatchClass) -> ClassPattern: (source)

Undocumented

def visit_MatchMapping(self, n: MatchMapping) -> MappingPattern: (source)

Undocumented

def visit_MatchOr(self, n: MatchOr) -> OrPattern: (source)

Undocumented

def visit_MatchSequence(self, n: MatchSequence) -> SequencePattern: (source)

Undocumented

def visit_MatchSingleton(self, n: MatchSingleton) -> SingletonPattern: (source)

Undocumented

def visit_MatchStar(self, n: MatchStar) -> StarredPattern: (source)

Undocumented

def visit_MatchValue(self, n: MatchValue) -> ValuePattern: (source)

Undocumented

def visit_Module(self, mod: ast3.Module) -> MypyFile: (source)

Undocumented

def visit_Name(self, n: Name) -> NameExpr: (source)

Undocumented

def visit_NameConstant(self, n: NameConstant) -> NameExpr: (source)

Undocumented

def visit_NamedExpr(self, n: NamedExpr) -> AssignmentExpr: (source)

Undocumented

def visit_Nonlocal(self, n: ast3.Nonlocal) -> NonlocalDecl: (source)

Undocumented

def visit_Num(self, n: ast3.Num) -> (IntExpr|FloatExpr)|ComplexExpr: (source)

Undocumented

def visit_Pass(self, n: ast3.Pass) -> PassStmt: (source)

Undocumented

def visit_Raise(self, n: ast3.Raise) -> RaiseStmt: (source)

Undocumented

def visit_Return(self, n: ast3.Return) -> ReturnStmt: (source)

Undocumented

def visit_Set(self, n: ast3.Set) -> SetExpr: (source)

Undocumented

def visit_SetComp(self, n: ast3.SetComp) -> SetComprehension: (source)

Undocumented

def visit_Slice(self, n: ast3.Slice) -> SliceExpr: (source)

Undocumented

def visit_Starred(self, n: Starred) -> StarExpr: (source)

Undocumented

def visit_Str(self, n: Str) -> StrExpr: (source)

Undocumented

def visit_Subscript(self, n: ast3.Subscript) -> IndexExpr: (source)

Undocumented

def visit_Try(self, n: ast3.Try) -> TryStmt: (source)

Undocumented

def visit_TryStar(self, n: TryStar) -> TryStmt: (source)

Undocumented

def visit_Tuple(self, n: ast3.Tuple) -> TupleExpr: (source)

Undocumented

def visit_UnaryOp(self, n: ast3.UnaryOp) -> UnaryExpr: (source)

Undocumented

def visit_While(self, n: ast3.While) -> WhileStmt: (source)

Undocumented

def visit_With(self, n: ast3.With) -> WithStmt: (source)

Undocumented

def visit_Yield(self, n: ast3.Yield) -> YieldExpr: (source)

Undocumented

def visit_YieldFrom(self, n: ast3.YieldFrom) -> YieldFromExpr: (source)

Undocumented

comp_op_map: dict[type[AST], str] = (source)

Undocumented

Value
{ast3.Gt: '>',
 ast3.Lt: '<',
 ast3.Eq: '==',
 ast3.GtE: '>=',
 ast3.LtE: '<=',
 ast3.NotEq: '!=',
 ast3.Is: 'is',
...

Undocumented

Value
{ast3.Add: '+',
 ast3.Sub: '-',
 ast3.Mult: '*',
 ast3.MatMult: '@',
 ast3.Div: '/',
 ast3.Mod: '%',
 ast3.Pow: '**',
...
class_and_function_stack: list[Literal['C', 'F']] = (source)

Undocumented

Undocumented

Undocumented

Undocumented

Undocumented

type_ignores: dict = (source)

Undocumented

visitor_cache: dict[type, Callable[[AST|None], Any]] = (source)

Undocumented

def _check_ifstmt_for_overloads(self, stmt: IfStmt, current_overload_name: str|None = None) -> str|None: (source)

Check if IfStmt contains only overloads with the same name. Return overload_name if found, None otherwise.

def _get_executable_if_block_with_overloads(self, stmt: IfStmt) -> tuple[Block|None, IfStmt|None]: (source)

Return block from IfStmt that will get executed. Return 0 -> A block if sure that alternative blocks are unreachable. 1 -> An IfStmt if the reachability of it can't be inferred, i.e. the truth value is unknown.

def _is_stripped_if_stmt(self, stmt: Statement) -> bool: (source)

Check stmt to make sure it is a stripped IfStmt. See also: _strip_contents_from_if_stmt

def _strip_contents_from_if_stmt(self, stmt: IfStmt): (source)

Remove contents from IfStmt. Needed to still be able to check the conditions after the contents have been merged with the surrounding function overloads.