hydra.python.serde module

Python serializer: converts Python AST to concrete syntax.

hydra.python.serde.annotated_rhs_to_expr(arhs: AnnotatedRhs) → Expr

Serialize an annotated RHS.

hydra.python.serde.annotated_statement_to_expr(as_: AnnotatedStatement) → Expr

Serialize an annotated statement (with optional doc comment).

hydra.python.serde.annotation_to_expr(ann: Annotation) → Expr

Serialize a type annotation.

hydra.python.serde.args_to_expr(args: Args) → Expr

Serialize function arguments.

hydra.python.serde.assignment_expression_to_expr(ae: AssignmentExpression) → Expr

Serialize an assignment expression (walrus operator).

hydra.python.serde.assignment_to_expr(a: Assignment) → Expr

Serialize an assignment.

hydra.python.serde.atom_to_expr(atom: Atom) → Expr

Serialize a Python atom (literal or basic expression).

hydra.python.serde.attribute_to_expr(attr: Attribute) → Expr

Serialize an attribute access.

hydra.python.serde.await_primary_to_expr(ap: AwaitPrimary) → Expr

Serialize an await primary expression.

hydra.python.serde.bitwise_and_to_expr(band: BitwiseAnd) → Expr

Serialize a bitwise AND expression.

hydra.python.serde.bitwise_or_to_expr(bor: BitwiseOr) → Expr

Serialize a bitwise OR expression.

hydra.python.serde.bitwise_xor_to_expr(bxor: BitwiseXor) → Expr

Serialize a bitwise XOR expression.

hydra.python.serde.block_to_expr(b: Block) → Expr

Serialize a block.

hydra.python.serde.capture_pattern_to_expr(cp: CapturePattern) → Expr

Serialize a capture pattern.

hydra.python.serde.case_block_to_expr(cb: CaseBlock) → Expr

Serialize a case block.

hydra.python.serde.class_definition_to_expr(cd: ClassDefinition) → Expr

Serialize a class definition.

hydra.python.serde.class_pattern_to_expr(cp: ClassPattern) → Expr

Serialize a class pattern.

hydra.python.serde.closed_pattern_to_expr(cp: ClosedPattern) → Expr

Serialize a closed pattern.

hydra.python.serde.compare_op_bitwise_or_pair_to_expr(pair: CompareOpBitwiseOrPair) → Expr

Serialize a (compare-op, bitwise-or) pair as <op> <rhs>.

hydra.python.serde.compare_op_to_string(op: CompareOp) → str

Render a Python comparison operator to its source-code form.

hydra.python.serde.comparison_to_expr(cmp: Comparison) → Expr

Serialize a comparison expression: <lhs> if rhs is empty, otherwise <lhs> <op1> <rhs1> <op2> <rhs2> ….

hydra.python.serde.compound_statement_to_expr(cs: CompoundStatement) → Expr

Serialize a compound (multi-line) Python statement.

hydra.python.serde.conditional_to_expr(c: Conditional) → Expr

Serialize a conditional expression (ternary).

hydra.python.serde.conjunction_to_expr(c: Conjunction) → Expr

Serialize a conjunction (and expression).

hydra.python.serde.decorators_to_expr(decs: Decorators) → Expr

Serialize decorators.

hydra.python.serde.dict_to_expr(d: Dict) → Expr

Serialize a Python dictionary.

hydra.python.serde.disjunction_to_expr(d: Disjunction) → Expr

Serialize a disjunction (or expression).

hydra.python.serde.dotted_as_name_to_expr(dan: DottedAsName) → Expr

Serialize a dotted as name.

hydra.python.serde.dotted_name_to_expr(dn: DottedName) → Expr

Serialize a dotted name (e.g., module.submodule).

hydra.python.serde.double_starred_kvpair_to_expr(dskv: DoubleStarredKvpair) → Expr

Serialize a double-starred key-value pair.

hydra.python.serde.escape_python_string(double_quoted: bool, s: str) → str

Escape special characters in a Python string and wrap in quotes.

hydra.python.serde.expression_to_expr(expr: Expression) → Expr

Serialize a Python expression.

hydra.python.serde.factor_to_expr(f: Factor) → Expr

Serialize a factor expression.

hydra.python.serde.function_def_raw_to_expr(fdr: FunctionDefRaw) → Expr

Serialize a raw function definition.

hydra.python.serde.function_definition_to_expr(fd: FunctionDefinition) → Expr

Serialize a function definition.

hydra.python.serde.group_to_expr(g: Group) → Expr

Serialize a parenthesized group.

hydra.python.serde.guard_to_expr(g: Guard) → Expr

Serialize a guard clause.

hydra.python.serde.import_from_as_name_to_expr(ifan: ImportFromAsName) → Expr

Serialize an import from as name.

hydra.python.serde.import_from_targets_to_expr(t: ImportFromTargets) → Expr

Serialize import from targets.

hydra.python.serde.import_from_to_expr(if_: ImportFrom) → Expr

Serialize an import from statement.

hydra.python.serde.import_name_to_expr(in_: ImportName) → Expr

Serialize an import name.

hydra.python.serde.import_statement_to_expr(is_: ImportStatement) → Expr

Serialize an import statement.

hydra.python.serde.inversion_to_expr(i: Inversion) → Expr

Serialize an inversion (not expression).

hydra.python.serde.keyword_pattern_to_expr(kp: KeywordPattern) → Expr

Serialize a keyword pattern.

hydra.python.serde.keyword_patterns_to_expr(kp: KeywordPatterns) → Expr

Serialize keyword patterns.

hydra.python.serde.kvpair_to_expr(kv: Kvpair) → Expr

Serialize a key-value pair.

hydra.python.serde.kwarg_or_double_starred_to_expr(kds: KwargOrDoubleStarred) → Expr

Serialize a kwarg or double starred.

hydra.python.serde.kwarg_or_starred_to_expr(ks: KwargOrStarred) → Expr

Serialize a kwarg or starred.

hydra.python.serde.kwarg_to_expr(k: Kwarg) → Expr

Serialize a keyword argument.

hydra.python.serde.lambda_param_no_default_to_expr(p: LambdaParamNoDefault) → Expr

Serialize a lambda parameter without default.

hydra.python.serde.lambda_parameters_to_expr(lp: LambdaParameters) → Expr

Serialize lambda parameters.

hydra.python.serde.lambda_star_etc_to_expr(lse: LambdaStarEtc) → Expr

Serialize lambda star etc.

hydra.python.serde.lambda_to_expr(l: Lambda) → Expr

Serialize a lambda expression.

hydra.python.serde.list_to_expr(l: List) → Expr

Serialize a Python list.

hydra.python.serde.match_statement_to_expr(ms: MatchStatement) → Expr

Serialize a match statement.

hydra.python.serde.module_to_expr(mod: Module) → Expr

Serialize a Python module to an AST expression.

hydra.python.serde.name_or_attribute_to_expr(noa: NameOrAttribute) → Expr

Serialize a name or attribute.

hydra.python.serde.name_to_expr(n: Name) → Expr

Serialize a Python name/identifier.

hydra.python.serde.named_expression_to_expr(ne: NamedExpression) → Expr

Serialize a named expression.

hydra.python.serde.number_to_expr(num: Number) → Expr

Serialize a Python number literal.

hydra.python.serde.or_pattern_to_expr(op: OrPattern) → Expr

Serialize an or pattern.

hydra.python.serde.param_no_default_parameters_to_expr(pndp: ParamNoDefaultParameters) → Expr

Serialize parameters without defaults.

hydra.python.serde.param_no_default_to_expr(pnd: ParamNoDefault) → Expr

Serialize a parameter without default.

hydra.python.serde.param_to_expr(p: Param) → Expr

Serialize a parameter.

hydra.python.serde.parameters_to_expr(p: Parameters) → Expr

Serialize function parameters.

hydra.python.serde.pattern_capture_target_to_expr(pct: PatternCaptureTarget) → Expr

Serialize a pattern capture target.

hydra.python.serde.pattern_to_expr(p: Pattern) → Expr

Serialize a pattern.

hydra.python.serde.patterns_to_expr(ps: Patterns) → Expr

Serialize patterns.

hydra.python.serde.pos_arg_to_expr(pa: PosArg) → Expr

Serialize a positional argument.

hydra.python.serde.positional_patterns_to_expr(pp: PositionalPatterns) → Expr

Serialize positional patterns.

hydra.python.serde.power_to_expr(p: Power) → Expr

Serialize a power expression.

hydra.python.serde.primary_rhs_to_expr(rhs: PrimaryRhs) → Expr

Serialize a primary RHS.

hydra.python.serde.primary_to_expr(p: Primary) → Expr

Serialize a primary expression.

hydra.python.serde.primary_with_rhs_to_expr(pwr: PrimaryWithRhs) → Expr

Serialize a primary with RHS.

hydra.python.serde.python_doc_entity_ref(ref: EntityReference) → str

Render a hydra.packaging.EntityReference as Sphinx/RST link syntax.

hydra.python.serde.python_float_literal_text(s: str) → str
hydra.python.serde.raise_expression_to_expr(re: RaiseExpression) → Expr

Serialize a raise expression.

hydra.python.serde.raise_statement_to_expr(rs: RaiseStatement) → Expr

Serialize a raise statement.

hydra.python.serde.relative_import_prefix_to_expr(p: RelativeImportPrefix) → Expr

Serialize a relative import prefix.

hydra.python.serde.return_statement_to_expr(rs: ReturnStatement) → Expr

Serialize a return statement.

hydra.python.serde.set_to_expr(s: Set) → Expr

Serialize a Python set.

hydra.python.serde.shift_expression_to_expr(se: ShiftExpression) → Expr

Serialize a shift expression.

hydra.python.serde.simple_statement_to_expr(ss: SimpleStatement) → Expr

Serialize a simple (single-line) Python statement.

hydra.python.serde.simple_type_parameter_to_expr(stp: SimpleTypeParameter) → Expr

Serialize a simple type parameter.

hydra.python.serde.single_target_to_expr(st: SingleTarget) → Expr

Serialize a single target.

hydra.python.serde.slice_or_starred_expression_to_expr(s: SliceOrStarredExpression) → Expr

Serialize a slice or starred expression.

hydra.python.serde.slice_to_expr(s: Slice) → Expr

Serialize a slice.

hydra.python.serde.slices_to_expr(s: Slices) → Expr

Serialize slices.

hydra.python.serde.star_atom_to_expr(sa: StarAtom) → Expr

Serialize a star atom.

hydra.python.serde.star_expression_to_expr(se: StarExpression) → Expr

Serialize a star expression.

hydra.python.serde.star_named_expression_to_expr(sne: StarNamedExpression) → Expr

Serialize a star named expression.

hydra.python.serde.star_target_to_expr(st: StarTarget) → Expr

Serialize a star target.

hydra.python.serde.starred_expression_to_expr(se: StarredExpression) → Expr

Serialize a starred expression.

hydra.python.serde.statement_to_expr(stmt: Statement) → Expr

Serialize a Python statement.

hydra.python.serde.string_prefix_to_text(p: StringPrefix) → str

Serialize a Python string prefix to its source-form characters.

hydra.python.serde.string_to_expr(s: String) → Expr

Serialize a Python string literal.

hydra.python.serde.subject_expression_to_expr(se: SubjectExpression) → Expr

Serialize a subject expression.

hydra.python.serde.sum_to_expr(s: Sum) → Expr

Serialize a sum expression.

hydra.python.serde.t_primary_and_name_to_expr(pn: TPrimaryAndName) → Expr

Serialize a TPrimaryAndName as primary.name.

hydra.python.serde.t_primary_to_expr(tp: TPrimary) → Expr

Serialize a target-side primary expression.

hydra.python.serde.target_with_star_atom_to_expr(t: TargetWithStarAtom) → Expr

Serialize a target with star atom.

hydra.python.serde.term_to_expr(t: Term) → Expr

Serialize a term expression.

hydra.python.serde.to_python_comments(doc_: str) → str

Convert a doc string to Python comment format. Empty source lines emit # (no trailing space) so blank comment lines don’t carry trailing whitespace into the generated file.

hydra.python.serde.tuple_to_expr(t: Tuple) → Expr

Serialize a Python tuple.

hydra.python.serde.type_alias_to_expr(ta: TypeAlias) → Expr

Serialize a type alias.

hydra.python.serde.type_parameter_to_expr(tp: TypeParameter) → Expr

Serialize a type parameter.

hydra.python.serde.typed_assignment_to_expr(ta: TypedAssignment) → Expr

Serialize a typed assignment.

hydra.python.serde.untyped_assignment_to_expr(ua: UntypedAssignment) → Expr

Serialize an untyped assignment.

hydra.python.serde.value_pattern_to_expr(vp: ValuePattern) → Expr

Serialize a value pattern.

hydra.python.serde.while_statement_to_expr(ws: WhileStatement) → Expr

Serialize a while statement.