Module

nodes.expressions

Expression nodes for Kida AST.

Classes

Expr 0
Base class for expressions.

Base class for expressions.

Const 1
Constant value: string, number, boolean, None.

Constant value: string, number, boolean, None.

Attributes

Name Type Description
value str | int | float | bool | None
Name 2
Variable reference: {{ user }}

Variable reference: {{ user }}

Attributes

Name Type Description
name str
ctx Literal['load', 'store', 'del']
Tuple 2
Tuple expression: (a, b, c)

Tuple expression: (a, b, c)

Attributes

Name Type Description
items Sequence[Expr]
ctx Literal['load', 'store']
List 1
List expression: [a, b, c]

List expression: [a, b, c]

Attributes

Name Type Description
items Sequence[Expr]
Dict 2
Dict expression: {a: b, c: d}

Dict expression: {a: b, c: d}

Attributes

Name Type Description
keys Sequence[Expr]
values Sequence[Expr]
Getattr 2
Attribute access: obj.attr

Attribute access: obj.attr

Attributes

Name Type Description
obj Expr
attr str
OptionalGetattr 2
Optional attribute access: obj?.attr

Optional attribute access: obj?.attr

Attributes

Name Type Description
obj Expr
attr str
Getitem 2
Subscript access: obj[key]

Subscript access: obj[key]

Attributes

Name Type Description
obj Expr
key Expr
OptionalGetitem 2
Optional subscript access: obj?[key]

Optional subscript access: obj?[key]

Attributes

Name Type Description
obj Expr
key Expr
Slice 3
Slice expression: [start:stop:step]

Slice expression: [start:stop:step]

Attributes

Name Type Description
start Expr | None
stop Expr | None
step Expr | None
FuncCall 5
Function call: func(args, **kwargs)

Function call: func(args, **kwargs)

Attributes

Name Type Description
func Expr
args Sequence[Expr]
kwargs dict[str, Expr]
dyn_args Expr | None
dyn_kwargs Expr | None
Filter 4
Filter application: expr | filter(args)

Filter application: expr | filter(args)

Attributes

Name Type Description
value Expr
name str
args Sequence[Expr]
kwargs dict[str, Expr]
Pipeline 2
Pipeline operator: expr |> filter1 |> filter2

Pipeline operator: expr |> filter1 |> filter2

Attributes

Name Type Description
value Expr
steps Sequence[tuple[str, Sequence[Expr], dict[str, Expr]]]
Test 5
Test application: expr is test(args) or expr is not test(args)

Test application: expr is test(args) or expr is not test(args)

Attributes

Name Type Description
value Expr
name str
args Sequence[Expr]
kwargs dict[str, Expr]
negated bool
BinOp 3
Binary operation: left op right

Binary operation: left op right

Attributes

Name Type Description
op str
left Expr
right Expr
UnaryOp 2
Unary operation: op operand

Unary operation: op operand

Attributes

Name Type Description
op str
operand Expr
Compare 3
Comparison: left op1 right1 op2 right2 ...

Comparison: left op1 right1 op2 right2 ...

Attributes

Name Type Description
left Expr
ops Sequence[str]
comparators Sequence[Expr]
BoolOp 2
Boolean operation: expr1 and/or expr2

Boolean operation: expr1 and/or expr2

Attributes

Name Type Description
op Literal['and', 'or']
values Sequence[Expr]
CondExpr 3
Conditional expression: a if cond else b

Conditional expression: a if cond else b

Attributes

Name Type Description
test Expr
if_true Expr
if_false Expr
NullCoalesce 2
Null coalescing: a ?? b

Null coalescing: a ?? b

Attributes

Name Type Description
left Expr
right Expr
Range 4
Range literal: start..end or start...end

Range literal: start..end or start...end

Attributes

Name Type Description
start Expr
end Expr
inclusive bool
step Expr | None
Await 1
Await expression: await expr

Await expression: await expr

Attributes

Name Type Description
value Expr
Concat 1
String concatenation: a ~ b ~ c

String concatenation: a ~ b ~ c

Attributes

Name Type Description
nodes Sequence[Expr]
MarkSafe 1
Mark expression as safe (no escaping): {{ expr | safe }}

Mark expression as safe (no escaping): {{ expr | safe }}

Attributes

Name Type Description
value Expr
LoopVar 1
Loop variable access: {{ loop.index }}

Loop variable access: {{ loop.index }}

Attributes

Name Type Description
attr str
InlinedFilter 3
Inlined filter as direct method call (optimization).

Inlined filter as direct method call (optimization).

Attributes

Name Type Description
value Expr
method str
args Sequence[Expr]