bolt_control_flow.types#
Module Contents#
Classes#
The status of a match |
|
Information about a match |
|
The type of multibranch being processed |
|
Information about the multibranch being processed |
|
Return this from a binary logical operator to request fallback/default behaviour |
|
Marker class to indicate that it is safe for nested conditions to use return without making new functions |
Attributes#
The |
|
The case being matched against |
- class bolt_control_flow.types.CaseMatchType#
Bases:
enum.EnumThe status of a match
- FAILED#
The match failed at build time
- MATCHED#
The match succeeded at build time
- MAYBE#
Whether the match passed isn't known until runtime
- class bolt_control_flow.types.CaseResult#
Information about a match
- class Codegen#
Helpers for generating code for accessing members of
CaseResultDanger
This is an internal helper, not meant for public usage
- property match_type: str#
Generate code for accessing the
match_type
- name: str#
Name of the variable holding this
CaseResult
- match_type: CaseMatchType#
The match status
- bindings: dict[str, Any]#
Any bindings to be assigned in the condition caller's scope
Must contain all the bindings that the case pattern is expecting, and any extra bindings will be ignored
Note
If
match_typeisCaseMatchType.FAILEDthese bindings will be ignored
- static failed() CaseResult#
yieldthis value to indicate that the match failed at build time
- static matched(**bindings: Any) CaseResult#
yieldthis value to indicate that the match passed at build time and run the body of the condition- Parameters:
**bindings -- The bindings to be assigned in the condition caller's scope
- static maybe(**bindings: Any) CaseResult#
yieldthis value to indicate that the match can't be determined until runtimeIt is expected for the runtime check to wrap the
yield, so that running the body of the condition will be wrapped in the check- Parameters:
**bindings -- The bindings to be assigned in the condition caller's scope
- bolt_control_flow.types.CasePartialResult: TypeAlias#
The
yieldtype of a__case__that doesn't implement allCasetypes- Type:
CaseResult | NotImplementedType
- bolt_control_flow.types.Case: TypeAlias#
The case being matched against
Possible values:
TrueThe
ifcase of anif ... elseFalseThe
elsecase of anif ... else- Anything else
A pattern used in a
casewithin amatch
- Type:
bool | Any
Note
This type is currently a placeholder, it will be made more specific once pattern matching is implemented
- class bolt_control_flow.types.BranchType#
Bases:
enum.EnumThe type of multibranch being processed
- property helper: str#
Get the name of the runtime helper for the
MultibranchDriverof this typeDanger
This is an internal helper, not meant for public usage
- IF_ELSE#
An
if ... else
- MATCH#
A
match
- class bolt_control_flow.types.BranchInfo#
Information about the multibranch being processed
- branch_type: BranchType#
The type of multibranch being processed
- parent_cases: Any | None#
The result of the parent
__multibranch__- Will be
Noneif any of these are true: there is no parent
there are more cases in the parent following the current case
this conditional isn't the only piece of the body of the current case
Useful for merging separate nested multibranches into a single multibranch. e.g.
eliforcase _:- Will be
- class bolt_control_flow.types.BinaryLogicalFallback#
Return this from a binary logical operator to request fallback/default behaviour
During fallback, it will attempt to call
__rlogical_{op}__on therightvalue, and if that also requests fallback it will use the plain-bolt implementation of the logical operator- right: Any#
The result of evaluating the lazy right value callback
This is so that the value isn't calculated again during fallback
- class bolt_control_flow.types.WrappedCases#
Marker class to indicate that it is safe for nested conditions to use return without making new functions
i.e. there are no commands after the cases that must be run