Module opshin.typed_ast

Expand source code
import ast as _ast
import dataclasses as _dataclasses
import typing as _typing
import pluthon as _plt

from .type_impls import NoneInstanceType, Type


class TypedAST(_ast.AST):
    typ: "Type"
    # Set by AnalyzeIntegrity. This is declared here so optimization passes can
    # consume integrity information without relying on an ad-hoc AST attribute.
    integrity_checked: bool


class typedexpr(TypedAST, _ast.expr):
    def typechecks(self) -> _typing.Dict[str, "Type"]:
        """Successful typechecks if this expression evaluates to True"""
        return {}


class typedstmt(TypedAST, _ast.stmt):
    # Statements always have type None
    typ = NoneInstanceType


class typedarg(TypedAST, _ast.arg):
    pass


class typedarguments(TypedAST, _ast.arguments):
    args: _typing.List[typedarg]
    vararg: _typing.Union[typedarg, None]
    kwonlyargs: _typing.List[typedarg]
    kw_defaults: _typing.List[_typing.Union[typedexpr, None]]
    kwarg: _typing.Union[typedarg, None]
    defaults: _typing.List[typedexpr]


class TypedModule(typedstmt, _ast.Module):
    body: _typing.List[typedstmt]


class TypedFunctionDef(typedstmt, _ast.FunctionDef):
    body: _typing.List[typedstmt]
    args: typedarguments
    orig_name: str


class TypedIf(typedstmt, _ast.If):
    test: typedexpr
    body: _typing.List[typedstmt]
    orelse: _typing.List[typedstmt]


class TypedReturn(typedstmt, _ast.Return):
    value: typedexpr


class TypedExpression(typedstmt, _ast.Expression):
    body: typedexpr


class TypedCall(typedexpr, _ast.Call):
    _fields = _ast.Call._fields + (
        "arg_evaluation_order",
        "provided_arg_indices",
    )

    func: typedexpr
    args: _typing.List[typedexpr]
    # Formal-parameter indices in source evaluation order. Keyword binding
    # reorders ``args`` into formal order, so code generation needs this list
    # to retain Python's evaluation semantics.
    arg_evaluation_order: _typing.List[int]
    # Formal-parameter indices for which the caller supplied an expression.
    # Missing indices are resolved by the runtime function's own defaults.
    provided_arg_indices: _typing.List[int]


class TypedExpr(typedstmt, _ast.Expr):
    value: typedexpr


class TypedAssign(typedstmt, _ast.Assign):
    targets: _typing.List[typedexpr]
    value: typedexpr


class TypedDestructuringAssign(typedstmt):
    value: typedexpr
    targets: _typing.List[typedexpr]
    element_typs: _typing.List[Type]

    _attributes = ["lineno", "col_offset", "end_lineno", "end_col_offset"]
    _fields = ["value", "targets"]


class TypedClassDef(typedstmt, _ast.ClassDef):
    class_typ: "Type"


class TypedAnnAssign(typedstmt, _ast.AnnAssign):
    target: typedexpr
    annotation: "Type"
    value: typedexpr


class TypedWhile(typedstmt, _ast.While):
    test: typedexpr
    body: _typing.List[typedstmt]
    orelse: _typing.List[typedstmt]


class TypedFor(typedstmt, _ast.For):
    target: typedexpr
    iter: typedexpr
    body: _typing.List[typedstmt]
    orelse: _typing.List[typedstmt]


class TypedPass(typedstmt, _ast.Pass):
    pass


class TypedName(typedexpr, _ast.Name):
    pass


class Typedkeyword(TypedAST, _ast.keyword):
    arg: typedexpr
    value: typedexpr


class TypedConstant(TypedAST, _ast.Constant):
    pass


class TypedTuple(typedexpr, _ast.Tuple):
    pass


class TypedList(typedexpr, _ast.List):
    pass


class typedcomprehension(typedexpr, _ast.comprehension):
    target: typedexpr
    iter: typedexpr
    ifs: _typing.List[typedexpr]


class TypedListComp(typedexpr, _ast.ListComp):
    elt: typedexpr
    generators: _typing.List[typedcomprehension]


class TypedDictComp(typedexpr, _ast.DictComp):
    key: typedexpr
    value: typedexpr
    generators: _typing.List[typedcomprehension]


class TypedFormattedValue(typedexpr, _ast.FormattedValue):
    value: typedexpr
    conversion: int
    format_spec: _typing.Optional[_ast.JoinedStr]


class TypedJoinedStr(typedexpr, _ast.JoinedStr):
    values: _typing.List[typedexpr]


class TypedDict(typedexpr, _ast.Dict):
    pass


class TypedIfExp(typedstmt, _ast.IfExp):
    test: typedexpr
    body: typedexpr
    orelse: typedexpr


@_dataclasses.dataclass
class DunderCompareOverride:
    """Metadata for a dunder method override used in a comparison expression."""

    method_name: str
    function_type: "Type"
    dunder_name: str
    receiver_right: bool
    negate_result: bool
    receiver: "typedexpr"
    argument: "typedexpr"


class TypedCompare(typedexpr, _ast.Compare):
    left: typedexpr
    ops: _typing.List[_ast.cmpop]
    comparators: _typing.List[typedexpr]
    dunder_overrides: _typing.List[_typing.Optional[DunderCompareOverride]]


class TypedBinOp(typedexpr, _ast.BinOp):
    left: typedexpr
    right: typedexpr


class TypedBoolOp(typedexpr, _ast.BoolOp):
    values: _typing.List[typedexpr]


class TypedUnaryOp(typedexpr, _ast.UnaryOp):
    operand: typedexpr


class TypedSubscript(typedexpr, _ast.Subscript):
    value: typedexpr


class TypedAttribute(typedexpr, _ast.Attribute):
    value: typedexpr
    pos: int


class TypedAssert(typedstmt, _ast.Assert):
    test: typedexpr
    msg: typedexpr


class TypedSlice(typedexpr, _ast.Slice):
    lower: _typing.Optional[typedexpr]
    upper: _typing.Optional[typedexpr]
    step: _typing.Optional[typedexpr]


class RawPlutoExpr(typedexpr):
    typ: "Type"
    expr: _plt.AST

    _attributes = ["lineno", "col_offset", "end_lineno", "end_col_offset"]
    _fields = []

Classes

class DunderCompareOverride (method_name: str, function_type: Type, dunder_name: str, receiver_right: bool, negate_result: bool, receiver: typedexpr, argument: typedexpr)

Metadata for a dunder method override used in a comparison expression.

Expand source code
@_dataclasses.dataclass
class DunderCompareOverride:
    """Metadata for a dunder method override used in a comparison expression."""

    method_name: str
    function_type: "Type"
    dunder_name: str
    receiver_right: bool
    negate_result: bool
    receiver: "typedexpr"
    argument: "typedexpr"

Instance variables

var argumenttypedexpr

The type of the None singleton.

var dunder_name : str

The type of the None singleton.

var function_typeType

The type of the None singleton.

var method_name : str

The type of the None singleton.

var negate_result : bool

The type of the None singleton.

var receivertypedexpr

The type of the None singleton.

var receiver_right : bool

The type of the None singleton.

class RawPlutoExpr (*args, **kwargs)

expr = BoolOp(boolop op, expr values) | NamedExpr(expr target, expr value) | BinOp(expr left, operator op, expr right) | UnaryOp(unaryop op, expr operand) | Lambda(arguments args, expr body) | IfExp(expr test, expr body, expr orelse) | Dict(expr? keys, expr values) | Set(expr elts) | ListComp(expr elt, comprehension generators) | SetComp(expr elt, comprehension generators) | DictComp(expr key, expr value, comprehension generators) | GeneratorExp(expr elt, comprehension generators) | Await(expr value) | Yield(expr? value) | YieldFrom(expr value) | Compare(expr left, cmpop ops, expr comparators) | Call(expr func, expr args, keyword keywords) | FormattedValue(expr value, int conversion, expr? format_spec) | Interpolation(expr value, constant str, int conversion, expr? format_spec) | JoinedStr(expr values) | TemplateStr(expr values) | Constant(constant value, string? kind) | Attribute(expr value, identifier attr, expr_context ctx) | Subscript(expr value, expr slice, expr_context ctx) | Starred(expr value, expr_context ctx) | Name(identifier id, expr_context ctx) | List(expr elts, expr_context ctx) | Tuple(expr elts, expr_context ctx) | Slice(expr? lower, expr? upper, expr? step)

Expand source code
class RawPlutoExpr(typedexpr):
    typ: "Type"
    expr: _plt.AST

    _attributes = ["lineno", "col_offset", "end_lineno", "end_col_offset"]
    _fields = []

Ancestors

Class variables

var expr : pluthon.pluthon_ast.AST

The type of the None singleton.

var integrity_checked : bool

Inherited from: typedexpr.integrity_checked

The type of the None singleton.

var typType

Inherited from: typedexpr.typ

The type of the None singleton.

Methods

def typechecks(self) ‑> Dict[str, Type]

Inherited from: typedexpr.typechecks

Successful typechecks if this expression evaluates to True

class TypedAST (*args, **kwargs)
Expand source code
class TypedAST(_ast.AST):
    typ: "Type"
    # Set by AnalyzeIntegrity. This is declared here so optimization passes can
    # consume integrity information without relying on an ad-hoc AST attribute.
    integrity_checked: bool

Ancestors

  • ast.AST

Subclasses

Class variables

var integrity_checked : bool

The type of the None singleton.

var typType

The type of the None singleton.

class TypedAnnAssign (*args, **kwargs)

AnnAssign(expr target, expr annotation, expr? value, int simple)

Expand source code
class TypedAnnAssign(typedstmt, _ast.AnnAssign):
    target: typedexpr
    annotation: "Type"
    value: typedexpr

Ancestors

Class variables

var annotationType

The type of the None singleton.

var integrity_checked : bool

Inherited from: typedstmt.integrity_checked

The type of the None singleton.

var targettypedexpr

The type of the None singleton.

var typType

Inherited from: typedstmt.typ

The type of the None singleton.

var valuetypedexpr

The type of the None singleton.

class TypedAssert (*args, **kwargs)

Assert(expr test, expr? msg)

Expand source code
class TypedAssert(typedstmt, _ast.Assert):
    test: typedexpr
    msg: typedexpr

Ancestors

Class variables

var integrity_checked : bool

Inherited from: typedstmt.integrity_checked

The type of the None singleton.

var msgtypedexpr

The type of the None singleton.

var testtypedexpr

The type of the None singleton.

var typType

Inherited from: typedstmt.typ

The type of the None singleton.

class TypedAssign (*args, **kwargs)

Assign(expr* targets, expr value, string? type_comment)

Expand source code
class TypedAssign(typedstmt, _ast.Assign):
    targets: _typing.List[typedexpr]
    value: typedexpr

Ancestors

Class variables

var integrity_checked : bool

Inherited from: typedstmt.integrity_checked

The type of the None singleton.

var targets : List[typedexpr]

The type of the None singleton.

var typType

Inherited from: typedstmt.typ

The type of the None singleton.

var valuetypedexpr

The type of the None singleton.

class TypedAttribute (*args, **kwargs)

Attribute(expr value, identifier attr, expr_context ctx)

Expand source code
class TypedAttribute(typedexpr, _ast.Attribute):
    value: typedexpr
    pos: int

Ancestors

Class variables

var integrity_checked : bool

Inherited from: typedexpr.integrity_checked

The type of the None singleton.

var pos : int

The type of the None singleton.

var typType

Inherited from: typedexpr.typ

The type of the None singleton.

var valuetypedexpr

The type of the None singleton.

Methods

def typechecks(self) ‑> Dict[str, Type]

Inherited from: typedexpr.typechecks

Successful typechecks if this expression evaluates to True

class TypedBinOp (*args, **kwargs)

BinOp(expr left, operator op, expr right)

Expand source code
class TypedBinOp(typedexpr, _ast.BinOp):
    left: typedexpr
    right: typedexpr

Ancestors

Class variables

var integrity_checked : bool

Inherited from: typedexpr.integrity_checked

The type of the None singleton.

var lefttypedexpr

The type of the None singleton.

var righttypedexpr

The type of the None singleton.

var typType

Inherited from: typedexpr.typ

The type of the None singleton.

Methods

def typechecks(self) ‑> Dict[str, Type]

Inherited from: typedexpr.typechecks

Successful typechecks if this expression evaluates to True

class TypedBoolOp (*args, **kwargs)

BoolOp(boolop op, expr* values)

Expand source code
class TypedBoolOp(typedexpr, _ast.BoolOp):
    values: _typing.List[typedexpr]

Ancestors

Class variables

var integrity_checked : bool

Inherited from: typedexpr.integrity_checked

The type of the None singleton.

var typType

Inherited from: typedexpr.typ

The type of the None singleton.

var values : List[typedexpr]

The type of the None singleton.

Methods

def typechecks(self) ‑> Dict[str, Type]

Inherited from: typedexpr.typechecks

Successful typechecks if this expression evaluates to True

class TypedCall (*args, **kwargs)

Call(expr func, expr args, keyword keywords)

Expand source code
class TypedCall(typedexpr, _ast.Call):
    _fields = _ast.Call._fields + (
        "arg_evaluation_order",
        "provided_arg_indices",
    )

    func: typedexpr
    args: _typing.List[typedexpr]
    # Formal-parameter indices in source evaluation order. Keyword binding
    # reorders ``args`` into formal order, so code generation needs this list
    # to retain Python's evaluation semantics.
    arg_evaluation_order: _typing.List[int]
    # Formal-parameter indices for which the caller supplied an expression.
    # Missing indices are resolved by the runtime function's own defaults.
    provided_arg_indices: _typing.List[int]

Ancestors

Class variables

var arg_evaluation_order : List[int]

The type of the None singleton.

var args : List[typedexpr]

The type of the None singleton.

var functypedexpr

The type of the None singleton.

var integrity_checked : bool

Inherited from: typedexpr.integrity_checked

The type of the None singleton.

var provided_arg_indices : List[int]

The type of the None singleton.

var typType

Inherited from: typedexpr.typ

The type of the None singleton.

Methods

def typechecks(self) ‑> Dict[str, Type]

Inherited from: typedexpr.typechecks

Successful typechecks if this expression evaluates to True

class TypedClassDef (*args, **kwargs)

ClassDef(identifier name, expr bases, keyword keywords, stmt body, expr decorator_list, type_param* type_params)

Expand source code
class TypedClassDef(typedstmt, _ast.ClassDef):
    class_typ: "Type"

Ancestors

Class variables

var class_typType

The type of the None singleton.

var integrity_checked : bool

Inherited from: typedstmt.integrity_checked

The type of the None singleton.

var typType

Inherited from: typedstmt.typ

The type of the None singleton.

class TypedCompare (*args, **kwargs)

Compare(expr left, cmpop ops, expr comparators)

Expand source code
class TypedCompare(typedexpr, _ast.Compare):
    left: typedexpr
    ops: _typing.List[_ast.cmpop]
    comparators: _typing.List[typedexpr]
    dunder_overrides: _typing.List[_typing.Optional[DunderCompareOverride]]

Ancestors

Class variables

var comparators : List[typedexpr]

The type of the None singleton.

var dunder_overrides : List[DunderCompareOverride | None]

The type of the None singleton.

var integrity_checked : bool

Inherited from: typedexpr.integrity_checked

The type of the None singleton.

var lefttypedexpr

The type of the None singleton.

var ops : List[ast.cmpop]

The type of the None singleton.

var typType

Inherited from: typedexpr.typ

The type of the None singleton.

Methods

def typechecks(self) ‑> Dict[str, Type]

Inherited from: typedexpr.typechecks

Successful typechecks if this expression evaluates to True

class TypedConstant (*args, **kwargs)

Constant(constant value, string? kind)

Expand source code
class TypedConstant(TypedAST, _ast.Constant):
    pass

Ancestors

  • TypedAST
  • ast.Constant
  • ast.expr
  • ast.AST

Class variables

var integrity_checked : bool

Inherited from: TypedAST.integrity_checked

The type of the None singleton.

var typType

Inherited from: TypedAST.typ

The type of the None singleton.

class TypedDestructuringAssign (*args, **kwargs)

stmt = FunctionDef(identifier name, arguments args, stmt body, expr decorator_list, expr? returns, string? type_comment, type_param type_params) | AsyncFunctionDef(identifier name, arguments args, stmt body, expr decorator_list, expr? returns, string? type_comment, type_param type_params) | ClassDef(identifier name, expr bases, keyword keywords, stmt body, expr decorator_list, type_param type_params) | Return(expr? value) | Delete(expr targets) | Assign(expr targets, expr value, string? type_comment) | TypeAlias(expr name, type_param type_params, expr value) | AugAssign(expr target, operator op, expr value) | AnnAssign(expr target, expr annotation, expr? value, int simple) | For(expr target, expr iter, stmt body, stmt orelse, string? type_comment) | AsyncFor(expr target, expr iter, stmt body, stmt orelse, string? type_comment) | While(expr test, stmt body, stmt orelse) | If(expr test, stmt body, stmt orelse) | With(withitem items, stmt body, string? type_comment) | AsyncWith(withitem items, stmt body, string? type_comment) | Match(expr subject, match_case cases) | Raise(expr? exc, expr? cause) | Try(stmt body, excepthandler handlers, stmt orelse, stmt finalbody) | TryStar(stmt body, excepthandler handlers, stmt orelse, stmt finalbody) | Assert(expr test, expr? msg) | Import(alias names) | ImportFrom(identifier? module, alias names, int? level) | Global(identifier names) | Nonlocal(identifier* names) | Expr(expr value) | Pass | Break | Continue

Expand source code
class TypedDestructuringAssign(typedstmt):
    value: typedexpr
    targets: _typing.List[typedexpr]
    element_typs: _typing.List[Type]

    _attributes = ["lineno", "col_offset", "end_lineno", "end_col_offset"]
    _fields = ["value", "targets"]

Ancestors

Class variables

var element_typs : List[Type]

The type of the None singleton.

var integrity_checked : bool

Inherited from: typedstmt.integrity_checked

The type of the None singleton.

var targets : List[typedexpr]

The type of the None singleton.

var typType

Inherited from: typedstmt.typ

The type of the None singleton.

var valuetypedexpr

The type of the None singleton.

class TypedDict (*args, **kwargs)

Dict(expr? keys, expr values)

Expand source code
class TypedDict(typedexpr, _ast.Dict):
    pass

Ancestors

Class variables

var integrity_checked : bool

Inherited from: typedexpr.integrity_checked

The type of the None singleton.

var typType

Inherited from: typedexpr.typ

The type of the None singleton.

Methods

def typechecks(self) ‑> Dict[str, Type]

Inherited from: typedexpr.typechecks

Successful typechecks if this expression evaluates to True

class TypedDictComp (*args, **kwargs)

DictComp(expr key, expr value, comprehension* generators)

Expand source code
class TypedDictComp(typedexpr, _ast.DictComp):
    key: typedexpr
    value: typedexpr
    generators: _typing.List[typedcomprehension]

Ancestors

Class variables

var generators : List[typedcomprehension]

The type of the None singleton.

var integrity_checked : bool

Inherited from: typedexpr.integrity_checked

The type of the None singleton.

var keytypedexpr

The type of the None singleton.

var typType

Inherited from: typedexpr.typ

The type of the None singleton.

var valuetypedexpr

The type of the None singleton.

Methods

def typechecks(self) ‑> Dict[str, Type]

Inherited from: typedexpr.typechecks

Successful typechecks if this expression evaluates to True

class TypedExpr (*args, **kwargs)

Expr(expr value)

Expand source code
class TypedExpr(typedstmt, _ast.Expr):
    value: typedexpr

Ancestors

Class variables

var integrity_checked : bool

Inherited from: typedstmt.integrity_checked

The type of the None singleton.

var typType

Inherited from: typedstmt.typ

The type of the None singleton.

var valuetypedexpr

The type of the None singleton.

class TypedExpression (*args, **kwargs)

stmt = FunctionDef(identifier name, arguments args, stmt body, expr decorator_list, expr? returns, string? type_comment, type_param type_params) | AsyncFunctionDef(identifier name, arguments args, stmt body, expr decorator_list, expr? returns, string? type_comment, type_param type_params) | ClassDef(identifier name, expr bases, keyword keywords, stmt body, expr decorator_list, type_param type_params) | Return(expr? value) | Delete(expr targets) | Assign(expr targets, expr value, string? type_comment) | TypeAlias(expr name, type_param type_params, expr value) | AugAssign(expr target, operator op, expr value) | AnnAssign(expr target, expr annotation, expr? value, int simple) | For(expr target, expr iter, stmt body, stmt orelse, string? type_comment) | AsyncFor(expr target, expr iter, stmt body, stmt orelse, string? type_comment) | While(expr test, stmt body, stmt orelse) | If(expr test, stmt body, stmt orelse) | With(withitem items, stmt body, string? type_comment) | AsyncWith(withitem items, stmt body, string? type_comment) | Match(expr subject, match_case cases) | Raise(expr? exc, expr? cause) | Try(stmt body, excepthandler handlers, stmt orelse, stmt finalbody) | TryStar(stmt body, excepthandler handlers, stmt orelse, stmt finalbody) | Assert(expr test, expr? msg) | Import(alias names) | ImportFrom(identifier? module, alias names, int? level) | Global(identifier names) | Nonlocal(identifier* names) | Expr(expr value) | Pass | Break | Continue

Expand source code
class TypedExpression(typedstmt, _ast.Expression):
    body: typedexpr

Ancestors

Class variables

var bodytypedexpr

The type of the None singleton.

var integrity_checked : bool

Inherited from: typedstmt.integrity_checked

The type of the None singleton.

var typType

Inherited from: typedstmt.typ

The type of the None singleton.

class TypedFor (*args, **kwargs)

For(expr target, expr iter, stmt body, stmt orelse, string? type_comment)

Expand source code
class TypedFor(typedstmt, _ast.For):
    target: typedexpr
    iter: typedexpr
    body: _typing.List[typedstmt]
    orelse: _typing.List[typedstmt]

Ancestors

Class variables

var body : List[typedstmt]

The type of the None singleton.

var integrity_checked : bool

Inherited from: typedstmt.integrity_checked

The type of the None singleton.

var itertypedexpr

The type of the None singleton.

var orelse : List[typedstmt]

The type of the None singleton.

var targettypedexpr

The type of the None singleton.

var typType

Inherited from: typedstmt.typ

The type of the None singleton.

class TypedFormattedValue (*args, **kwargs)

FormattedValue(expr value, int conversion, expr? format_spec)

Expand source code
class TypedFormattedValue(typedexpr, _ast.FormattedValue):
    value: typedexpr
    conversion: int
    format_spec: _typing.Optional[_ast.JoinedStr]

Ancestors

Class variables

var conversion : int

The type of the None singleton.

var format_spec : ast.JoinedStr | None

The type of the None singleton.

var integrity_checked : bool

Inherited from: typedexpr.integrity_checked

The type of the None singleton.

var typType

Inherited from: typedexpr.typ

The type of the None singleton.

var valuetypedexpr

The type of the None singleton.

Methods

def typechecks(self) ‑> Dict[str, Type]

Inherited from: typedexpr.typechecks

Successful typechecks if this expression evaluates to True

class TypedFunctionDef (*args, **kwargs)

FunctionDef(identifier name, arguments args, stmt body, expr decorator_list, expr? returns, string? type_comment, type_param* type_params)

Expand source code
class TypedFunctionDef(typedstmt, _ast.FunctionDef):
    body: _typing.List[typedstmt]
    args: typedarguments
    orig_name: str

Ancestors

Class variables

var argstypedarguments

The type of the None singleton.

var body : List[typedstmt]

The type of the None singleton.

var integrity_checked : bool

Inherited from: typedstmt.integrity_checked

The type of the None singleton.

var orig_name : str

The type of the None singleton.

var typType

Inherited from: typedstmt.typ

The type of the None singleton.

class TypedIf (*args, **kwargs)

If(expr test, stmt body, stmt orelse)

Expand source code
class TypedIf(typedstmt, _ast.If):
    test: typedexpr
    body: _typing.List[typedstmt]
    orelse: _typing.List[typedstmt]

Ancestors

Class variables

var body : List[typedstmt]

The type of the None singleton.

var integrity_checked : bool

Inherited from: typedstmt.integrity_checked

The type of the None singleton.

var orelse : List[typedstmt]

The type of the None singleton.

var testtypedexpr

The type of the None singleton.

var typType

Inherited from: typedstmt.typ

The type of the None singleton.

class TypedIfExp (*args, **kwargs)

stmt = FunctionDef(identifier name, arguments args, stmt body, expr decorator_list, expr? returns, string? type_comment, type_param type_params) | AsyncFunctionDef(identifier name, arguments args, stmt body, expr decorator_list, expr? returns, string? type_comment, type_param type_params) | ClassDef(identifier name, expr bases, keyword keywords, stmt body, expr decorator_list, type_param type_params) | Return(expr? value) | Delete(expr targets) | Assign(expr targets, expr value, string? type_comment) | TypeAlias(expr name, type_param type_params, expr value) | AugAssign(expr target, operator op, expr value) | AnnAssign(expr target, expr annotation, expr? value, int simple) | For(expr target, expr iter, stmt body, stmt orelse, string? type_comment) | AsyncFor(expr target, expr iter, stmt body, stmt orelse, string? type_comment) | While(expr test, stmt body, stmt orelse) | If(expr test, stmt body, stmt orelse) | With(withitem items, stmt body, string? type_comment) | AsyncWith(withitem items, stmt body, string? type_comment) | Match(expr subject, match_case cases) | Raise(expr? exc, expr? cause) | Try(stmt body, excepthandler handlers, stmt orelse, stmt finalbody) | TryStar(stmt body, excepthandler handlers, stmt orelse, stmt finalbody) | Assert(expr test, expr? msg) | Import(alias names) | ImportFrom(identifier? module, alias names, int? level) | Global(identifier names) | Nonlocal(identifier* names) | Expr(expr value) | Pass | Break | Continue

Expand source code
class TypedIfExp(typedstmt, _ast.IfExp):
    test: typedexpr
    body: typedexpr
    orelse: typedexpr

Ancestors

Class variables

var bodytypedexpr

The type of the None singleton.

var integrity_checked : bool

Inherited from: typedstmt.integrity_checked

The type of the None singleton.

var orelsetypedexpr

The type of the None singleton.

var testtypedexpr

The type of the None singleton.

var typType

Inherited from: typedstmt.typ

The type of the None singleton.

class TypedJoinedStr (*args, **kwargs)

JoinedStr(expr* values)

Expand source code
class TypedJoinedStr(typedexpr, _ast.JoinedStr):
    values: _typing.List[typedexpr]

Ancestors

Class variables

var integrity_checked : bool

Inherited from: typedexpr.integrity_checked

The type of the None singleton.

var typType

Inherited from: typedexpr.typ

The type of the None singleton.

var values : List[typedexpr]

The type of the None singleton.

Methods

def typechecks(self) ‑> Dict[str, Type]

Inherited from: typedexpr.typechecks

Successful typechecks if this expression evaluates to True

class TypedList (*args, **kwargs)

List(expr* elts, expr_context ctx)

Expand source code
class TypedList(typedexpr, _ast.List):
    pass

Ancestors

Class variables

var integrity_checked : bool

Inherited from: typedexpr.integrity_checked

The type of the None singleton.

var typType

Inherited from: typedexpr.typ

The type of the None singleton.

Methods

def typechecks(self) ‑> Dict[str, Type]

Inherited from: typedexpr.typechecks

Successful typechecks if this expression evaluates to True

class TypedListComp (*args, **kwargs)

ListComp(expr elt, comprehension* generators)

Expand source code
class TypedListComp(typedexpr, _ast.ListComp):
    elt: typedexpr
    generators: _typing.List[typedcomprehension]

Ancestors

Class variables

var elttypedexpr

The type of the None singleton.

var generators : List[typedcomprehension]

The type of the None singleton.

var integrity_checked : bool

Inherited from: typedexpr.integrity_checked

The type of the None singleton.

var typType

Inherited from: typedexpr.typ

The type of the None singleton.

Methods

def typechecks(self) ‑> Dict[str, Type]

Inherited from: typedexpr.typechecks

Successful typechecks if this expression evaluates to True

class TypedModule (*args, **kwargs)

stmt = FunctionDef(identifier name, arguments args, stmt body, expr decorator_list, expr? returns, string? type_comment, type_param type_params) | AsyncFunctionDef(identifier name, arguments args, stmt body, expr decorator_list, expr? returns, string? type_comment, type_param type_params) | ClassDef(identifier name, expr bases, keyword keywords, stmt body, expr decorator_list, type_param type_params) | Return(expr? value) | Delete(expr targets) | Assign(expr targets, expr value, string? type_comment) | TypeAlias(expr name, type_param type_params, expr value) | AugAssign(expr target, operator op, expr value) | AnnAssign(expr target, expr annotation, expr? value, int simple) | For(expr target, expr iter, stmt body, stmt orelse, string? type_comment) | AsyncFor(expr target, expr iter, stmt body, stmt orelse, string? type_comment) | While(expr test, stmt body, stmt orelse) | If(expr test, stmt body, stmt orelse) | With(withitem items, stmt body, string? type_comment) | AsyncWith(withitem items, stmt body, string? type_comment) | Match(expr subject, match_case cases) | Raise(expr? exc, expr? cause) | Try(stmt body, excepthandler handlers, stmt orelse, stmt finalbody) | TryStar(stmt body, excepthandler handlers, stmt orelse, stmt finalbody) | Assert(expr test, expr? msg) | Import(alias names) | ImportFrom(identifier? module, alias names, int? level) | Global(identifier names) | Nonlocal(identifier* names) | Expr(expr value) | Pass | Break | Continue

Expand source code
class TypedModule(typedstmt, _ast.Module):
    body: _typing.List[typedstmt]

Ancestors

Class variables

var body : List[typedstmt]

The type of the None singleton.

var integrity_checked : bool

Inherited from: typedstmt.integrity_checked

The type of the None singleton.

var typType

Inherited from: typedstmt.typ

The type of the None singleton.

class TypedName (*args, **kwargs)

Name(identifier id, expr_context ctx)

Expand source code
class TypedName(typedexpr, _ast.Name):
    pass

Ancestors

Class variables

var integrity_checked : bool

Inherited from: typedexpr.integrity_checked

The type of the None singleton.

var typType

Inherited from: typedexpr.typ

The type of the None singleton.

Methods

def typechecks(self) ‑> Dict[str, Type]

Inherited from: typedexpr.typechecks

Successful typechecks if this expression evaluates to True

class TypedPass (*args, **kwargs)

Pass

Expand source code
class TypedPass(typedstmt, _ast.Pass):
    pass

Ancestors

Class variables

var integrity_checked : bool

Inherited from: typedstmt.integrity_checked

The type of the None singleton.

var typType

Inherited from: typedstmt.typ

The type of the None singleton.

class TypedReturn (*args, **kwargs)

Return(expr? value)

Expand source code
class TypedReturn(typedstmt, _ast.Return):
    value: typedexpr

Ancestors

Class variables

var integrity_checked : bool

Inherited from: typedstmt.integrity_checked

The type of the None singleton.

var typType

Inherited from: typedstmt.typ

The type of the None singleton.

var valuetypedexpr

The type of the None singleton.

class TypedSlice (*args, **kwargs)

Slice(expr? lower, expr? upper, expr? step)

Expand source code
class TypedSlice(typedexpr, _ast.Slice):
    lower: _typing.Optional[typedexpr]
    upper: _typing.Optional[typedexpr]
    step: _typing.Optional[typedexpr]

Ancestors

Class variables

var integrity_checked : bool

Inherited from: typedexpr.integrity_checked

The type of the None singleton.

var lowertypedexpr | None

The type of the None singleton.

var steptypedexpr | None

The type of the None singleton.

var typType

Inherited from: typedexpr.typ

The type of the None singleton.

var uppertypedexpr | None

The type of the None singleton.

Methods

def typechecks(self) ‑> Dict[str, Type]

Inherited from: typedexpr.typechecks

Successful typechecks if this expression evaluates to True

class TypedSubscript (*args, **kwargs)

Subscript(expr value, expr slice, expr_context ctx)

Expand source code
class TypedSubscript(typedexpr, _ast.Subscript):
    value: typedexpr

Ancestors

Class variables

var integrity_checked : bool

Inherited from: typedexpr.integrity_checked

The type of the None singleton.

var typType

Inherited from: typedexpr.typ

The type of the None singleton.

var valuetypedexpr

The type of the None singleton.

Methods

def typechecks(self) ‑> Dict[str, Type]

Inherited from: typedexpr.typechecks

Successful typechecks if this expression evaluates to True

class TypedTuple (*args, **kwargs)

Tuple(expr* elts, expr_context ctx)

Expand source code
class TypedTuple(typedexpr, _ast.Tuple):
    pass

Ancestors

Class variables

var integrity_checked : bool

Inherited from: typedexpr.integrity_checked

The type of the None singleton.

var typType

Inherited from: typedexpr.typ

The type of the None singleton.

Methods

def typechecks(self) ‑> Dict[str, Type]

Inherited from: typedexpr.typechecks

Successful typechecks if this expression evaluates to True

class TypedUnaryOp (*args, **kwargs)

UnaryOp(unaryop op, expr operand)

Expand source code
class TypedUnaryOp(typedexpr, _ast.UnaryOp):
    operand: typedexpr

Ancestors

Class variables

var integrity_checked : bool

Inherited from: typedexpr.integrity_checked

The type of the None singleton.

var operandtypedexpr

The type of the None singleton.

var typType

Inherited from: typedexpr.typ

The type of the None singleton.

Methods

def typechecks(self) ‑> Dict[str, Type]

Inherited from: typedexpr.typechecks

Successful typechecks if this expression evaluates to True

class TypedWhile (*args, **kwargs)

While(expr test, stmt body, stmt orelse)

Expand source code
class TypedWhile(typedstmt, _ast.While):
    test: typedexpr
    body: _typing.List[typedstmt]
    orelse: _typing.List[typedstmt]

Ancestors

Class variables

var body : List[typedstmt]

The type of the None singleton.

var integrity_checked : bool

Inherited from: typedstmt.integrity_checked

The type of the None singleton.

var orelse : List[typedstmt]

The type of the None singleton.

var testtypedexpr

The type of the None singleton.

var typType

Inherited from: typedstmt.typ

The type of the None singleton.

class Typedkeyword (*args, **kwargs)

keyword(identifier? arg, expr value)

Expand source code
class Typedkeyword(TypedAST, _ast.keyword):
    arg: typedexpr
    value: typedexpr

Ancestors

Class variables

var argtypedexpr

The type of the None singleton.

var integrity_checked : bool

Inherited from: TypedAST.integrity_checked

The type of the None singleton.

var typType

Inherited from: TypedAST.typ

The type of the None singleton.

var valuetypedexpr

The type of the None singleton.

class typedarg (*args, **kwargs)

arg(identifier arg, expr? annotation, string? type_comment)

Expand source code
class typedarg(TypedAST, _ast.arg):
    pass

Ancestors

Class variables

var integrity_checked : bool

Inherited from: TypedAST.integrity_checked

The type of the None singleton.

var typType

Inherited from: TypedAST.typ

The type of the None singleton.

class typedarguments (*args, **kwargs)

arguments(arg posonlyargs, arg args, arg? vararg, arg kwonlyargs, expr? kw_defaults, arg? kwarg, expr* defaults)

Expand source code
class typedarguments(TypedAST, _ast.arguments):
    args: _typing.List[typedarg]
    vararg: _typing.Union[typedarg, None]
    kwonlyargs: _typing.List[typedarg]
    kw_defaults: _typing.List[_typing.Union[typedexpr, None]]
    kwarg: _typing.Union[typedarg, None]
    defaults: _typing.List[typedexpr]

Ancestors

Class variables

var args : List[typedarg]

The type of the None singleton.

var defaults : List[typedexpr]

The type of the None singleton.

var integrity_checked : bool

Inherited from: TypedAST.integrity_checked

The type of the None singleton.

var kw_defaults : List[typedexpr | None]

The type of the None singleton.

var kwargtypedarg | None

The type of the None singleton.

var kwonlyargs : List[typedarg]

The type of the None singleton.

var typType

Inherited from: TypedAST.typ

The type of the None singleton.

var varargtypedarg | None

The type of the None singleton.

class typedcomprehension (*args, **kwargs)

expr = BoolOp(boolop op, expr values) | NamedExpr(expr target, expr value) | BinOp(expr left, operator op, expr right) | UnaryOp(unaryop op, expr operand) | Lambda(arguments args, expr body) | IfExp(expr test, expr body, expr orelse) | Dict(expr? keys, expr values) | Set(expr elts) | ListComp(expr elt, comprehension generators) | SetComp(expr elt, comprehension generators) | DictComp(expr key, expr value, comprehension generators) | GeneratorExp(expr elt, comprehension generators) | Await(expr value) | Yield(expr? value) | YieldFrom(expr value) | Compare(expr left, cmpop ops, expr comparators) | Call(expr func, expr args, keyword keywords) | FormattedValue(expr value, int conversion, expr? format_spec) | Interpolation(expr value, constant str, int conversion, expr? format_spec) | JoinedStr(expr values) | TemplateStr(expr values) | Constant(constant value, string? kind) | Attribute(expr value, identifier attr, expr_context ctx) | Subscript(expr value, expr slice, expr_context ctx) | Starred(expr value, expr_context ctx) | Name(identifier id, expr_context ctx) | List(expr elts, expr_context ctx) | Tuple(expr elts, expr_context ctx) | Slice(expr? lower, expr? upper, expr? step)

Expand source code
class typedcomprehension(typedexpr, _ast.comprehension):
    target: typedexpr
    iter: typedexpr
    ifs: _typing.List[typedexpr]

Ancestors

Class variables

var ifs : List[typedexpr]

The type of the None singleton.

var integrity_checked : bool

Inherited from: typedexpr.integrity_checked

The type of the None singleton.

var itertypedexpr

The type of the None singleton.

var targettypedexpr

The type of the None singleton.

var typType

Inherited from: typedexpr.typ

The type of the None singleton.

Methods

def typechecks(self) ‑> Dict[str, Type]

Inherited from: typedexpr.typechecks

Successful typechecks if this expression evaluates to True

class typedexpr (*args, **kwargs)

expr = BoolOp(boolop op, expr values) | NamedExpr(expr target, expr value) | BinOp(expr left, operator op, expr right) | UnaryOp(unaryop op, expr operand) | Lambda(arguments args, expr body) | IfExp(expr test, expr body, expr orelse) | Dict(expr? keys, expr values) | Set(expr elts) | ListComp(expr elt, comprehension generators) | SetComp(expr elt, comprehension generators) | DictComp(expr key, expr value, comprehension generators) | GeneratorExp(expr elt, comprehension generators) | Await(expr value) | Yield(expr? value) | YieldFrom(expr value) | Compare(expr left, cmpop ops, expr comparators) | Call(expr func, expr args, keyword keywords) | FormattedValue(expr value, int conversion, expr? format_spec) | Interpolation(expr value, constant str, int conversion, expr? format_spec) | JoinedStr(expr values) | TemplateStr(expr values) | Constant(constant value, string? kind) | Attribute(expr value, identifier attr, expr_context ctx) | Subscript(expr value, expr slice, expr_context ctx) | Starred(expr value, expr_context ctx) | Name(identifier id, expr_context ctx) | List(expr elts, expr_context ctx) | Tuple(expr elts, expr_context ctx) | Slice(expr? lower, expr? upper, expr? step)

Expand source code
class typedexpr(TypedAST, _ast.expr):
    def typechecks(self) -> _typing.Dict[str, "Type"]:
        """Successful typechecks if this expression evaluates to True"""
        return {}

Ancestors

Subclasses

Class variables

var integrity_checked : bool

Inherited from: TypedAST.integrity_checked

The type of the None singleton.

var typType

Inherited from: TypedAST.typ

The type of the None singleton.

Methods

def typechecks(self) ‑> Dict[str, Type]

Successful typechecks if this expression evaluates to True

Expand source code
def typechecks(self) -> _typing.Dict[str, "Type"]:
    """Successful typechecks if this expression evaluates to True"""
    return {}
class typedstmt (*args, **kwargs)

stmt = FunctionDef(identifier name, arguments args, stmt body, expr decorator_list, expr? returns, string? type_comment, type_param type_params) | AsyncFunctionDef(identifier name, arguments args, stmt body, expr decorator_list, expr? returns, string? type_comment, type_param type_params) | ClassDef(identifier name, expr bases, keyword keywords, stmt body, expr decorator_list, type_param type_params) | Return(expr? value) | Delete(expr targets) | Assign(expr targets, expr value, string? type_comment) | TypeAlias(expr name, type_param type_params, expr value) | AugAssign(expr target, operator op, expr value) | AnnAssign(expr target, expr annotation, expr? value, int simple) | For(expr target, expr iter, stmt body, stmt orelse, string? type_comment) | AsyncFor(expr target, expr iter, stmt body, stmt orelse, string? type_comment) | While(expr test, stmt body, stmt orelse) | If(expr test, stmt body, stmt orelse) | With(withitem items, stmt body, string? type_comment) | AsyncWith(withitem items, stmt body, string? type_comment) | Match(expr subject, match_case cases) | Raise(expr? exc, expr? cause) | Try(stmt body, excepthandler handlers, stmt orelse, stmt finalbody) | TryStar(stmt body, excepthandler handlers, stmt orelse, stmt finalbody) | Assert(expr test, expr? msg) | Import(alias names) | ImportFrom(identifier? module, alias names, int? level) | Global(identifier names) | Nonlocal(identifier* names) | Expr(expr value) | Pass | Break | Continue

Expand source code
class typedstmt(TypedAST, _ast.stmt):
    # Statements always have type None
    typ = NoneInstanceType

Ancestors

Subclasses

Class variables

var integrity_checked : bool

Inherited from: TypedAST.integrity_checked

The type of the None singleton.

var typType

Inherited from: TypedAST.typ

The type of the None singleton.