Package hydra.python

Interface Serde


  • public interface Serde
    Python serializer: converts Python AST to concrete syntax
    • Method Detail

      • annotatedRhsToExpr

        static Expr annotatedRhsToExpr​(AnnotatedRhs arhs)
        Serialize an annotated RHS
      • annotatedStatementToExpr

        static Expr annotatedStatementToExpr​(AnnotatedStatement as_)
        Serialize an annotated statement (with optional doc comment)
      • annotationToExpr

        static Expr annotationToExpr​(Annotation ann)
        Serialize a type annotation
      • argsToExpr

        static Expr argsToExpr​(Args args)
        Serialize function arguments
      • assignmentExpressionToExpr

        static Expr assignmentExpressionToExpr​(AssignmentExpression ae)
        Serialize an assignment expression (walrus operator)
      • assignmentToExpr

        static Expr assignmentToExpr​(Assignment a)
        Serialize an assignment
      • atomToExpr

        static Expr atomToExpr​(Atom atom)
        Serialize a Python atom (literal or basic expression)
      • attributeToExpr

        static Expr attributeToExpr​(Attribute attr)
        Serialize an attribute access
      • awaitPrimaryToExpr

        static Expr awaitPrimaryToExpr​(AwaitPrimary ap)
        Serialize an await primary expression
      • bitwiseAndToExpr

        static Expr bitwiseAndToExpr​(BitwiseAnd band)
        Serialize a bitwise AND expression
      • bitwiseOrToExpr

        static Expr bitwiseOrToExpr​(BitwiseOr bor)
        Serialize a bitwise OR expression
      • bitwiseXorToExpr

        static Expr bitwiseXorToExpr​(BitwiseXor bxor)
        Serialize a bitwise XOR expression
      • blockToExpr

        static Expr blockToExpr​(Block b)
        Serialize a block
      • capturePatternToExpr

        static Expr capturePatternToExpr​(CapturePattern cp)
        Serialize a capture pattern
      • caseBlockToExpr

        static Expr caseBlockToExpr​(CaseBlock cb)
        Serialize a case block
      • classDefinitionToExpr

        static Expr classDefinitionToExpr​(ClassDefinition cd)
        Serialize a class definition
      • classPatternToExpr

        static Expr classPatternToExpr​(ClassPattern cp)
        Serialize a class pattern
      • closedPatternToExpr

        static Expr closedPatternToExpr​(ClosedPattern cp)
        Serialize a closed pattern
      • compareOpBitwiseOrPairToExpr

        static Expr compareOpBitwiseOrPairToExpr​(CompareOpBitwiseOrPair pair)
        Serialize a (compare-op, bitwise-or) pair as `<op> <rhs>`
      • compareOpToString

        static java.lang.String compareOpToString​(CompareOp op)
        Render a Python comparison operator to its source-code form
      • comparisonToExpr

        static Expr comparisonToExpr​(Comparison cmp)
        Serialize a comparison expression: `<lhs>` if rhs is empty, otherwise `<lhs> <op1> <rhs1> <op2> <rhs2> ...`
      • compoundStatementToExpr

        static Expr compoundStatementToExpr​(CompoundStatement cs)
        Serialize a compound (multi-line) Python statement
      • conditionalToExpr

        static Expr conditionalToExpr​(Conditional c)
        Serialize a conditional expression (ternary)
      • conjunctionToExpr

        static Expr conjunctionToExpr​(Conjunction c)
        Serialize a conjunction (and expression)
      • decoratorsToExpr

        static Expr decoratorsToExpr​(Decorators decs)
        Serialize decorators
      • dictToExpr

        static Expr dictToExpr​(Dict d)
        Serialize a Python dictionary
      • disjunctionToExpr

        static Expr disjunctionToExpr​(Disjunction d)
        Serialize a disjunction (or expression)
      • dottedAsNameToExpr

        static Expr dottedAsNameToExpr​(DottedAsName dan)
        Serialize a dotted as name
      • dottedNameToExpr

        static Expr dottedNameToExpr​(DottedName dn)
        Serialize a dotted name (e.g., module.submodule)
      • doubleStarredKvpairToExpr

        static Expr doubleStarredKvpairToExpr​(DoubleStarredKvpair dskv)
        Serialize a double-starred key-value pair
      • escapePythonString

        static java.lang.String escapePythonString​(java.lang.Boolean doubleQuoted,
                                                   java.lang.String s)
        Escape special characters in a Python string and wrap in quotes
      • expressionToExpr

        static Expr expressionToExpr​(Expression expr)
        Serialize a Python expression
      • factorToExpr

        static Expr factorToExpr​(Factor f)
        Serialize a factor expression
      • functionDefRawToExpr

        static Expr functionDefRawToExpr​(FunctionDefRaw fdr)
        Serialize a raw function definition
      • functionDefinitionToExpr

        static Expr functionDefinitionToExpr​(FunctionDefinition fd)
        Serialize a function definition
      • groupToExpr

        static Expr groupToExpr​(Group g)
        Serialize a parenthesized group
      • guardToExpr

        static Expr guardToExpr​(Guard g)
        Serialize a guard clause
      • importFromAsNameToExpr

        static Expr importFromAsNameToExpr​(ImportFromAsName ifan)
        Serialize an import from as name
      • importFromTargetsToExpr

        static Expr importFromTargetsToExpr​(ImportFromTargets t)
        Serialize import from targets
      • importFromToExpr

        static Expr importFromToExpr​(ImportFrom if_)
        Serialize an import from statement
      • importNameToExpr

        static Expr importNameToExpr​(ImportName in_)
        Serialize an import name
      • importStatementToExpr

        static Expr importStatementToExpr​(ImportStatement is_)
        Serialize an import statement
      • inversionToExpr

        static Expr inversionToExpr​(Inversion i)
        Serialize an inversion (not expression)
      • keywordPatternToExpr

        static Expr keywordPatternToExpr​(KeywordPattern kp)
        Serialize a keyword pattern
      • keywordPatternsToExpr

        static Expr keywordPatternsToExpr​(KeywordPatterns kp)
        Serialize keyword patterns
      • kvpairToExpr

        static Expr kvpairToExpr​(Kvpair kv)
        Serialize a key-value pair
      • kwargOrDoubleStarredToExpr

        static Expr kwargOrDoubleStarredToExpr​(KwargOrDoubleStarred kds)
        Serialize a kwarg or double starred
      • kwargOrStarredToExpr

        static Expr kwargOrStarredToExpr​(KwargOrStarred ks)
        Serialize a kwarg or starred
      • kwargToExpr

        static Expr kwargToExpr​(Kwarg k)
        Serialize a keyword argument
      • lambdaParamNoDefaultToExpr

        static Expr lambdaParamNoDefaultToExpr​(LambdaParamNoDefault p)
        Serialize a lambda parameter without default
      • lambdaParametersToExpr

        static Expr lambdaParametersToExpr​(LambdaParameters lp)
        Serialize lambda parameters
      • lambdaStarEtcToExpr

        static Expr lambdaStarEtcToExpr​(LambdaStarEtc lse)
        Serialize lambda star etc
      • lambdaToExpr

        static Expr lambdaToExpr​(Lambda l)
        Serialize a lambda expression
      • listToExpr

        static Expr listToExpr​(List l)
        Serialize a Python list
      • matchStatementToExpr

        static Expr matchStatementToExpr​(MatchStatement ms)
        Serialize a match statement
      • moduleToExpr

        static Expr moduleToExpr​(Module mod)
        Serialize a Python module to an AST expression
      • nameOrAttributeToExpr

        static Expr nameOrAttributeToExpr​(NameOrAttribute noa)
        Serialize a name or attribute
      • nameToExpr

        static Expr nameToExpr​(Name n)
        Serialize a Python name/identifier
      • namedExpressionToExpr

        static Expr namedExpressionToExpr​(NamedExpression ne)
        Serialize a named expression
      • numberToExpr

        static Expr numberToExpr​(Number_ num)
        Serialize a Python number literal
      • orPatternToExpr

        static Expr orPatternToExpr​(OrPattern op)
        Serialize an or pattern
      • paramNoDefaultParametersToExpr

        static Expr paramNoDefaultParametersToExpr​(ParamNoDefaultParameters pndp)
        Serialize parameters without defaults
      • paramNoDefaultToExpr

        static Expr paramNoDefaultToExpr​(ParamNoDefault pnd)
        Serialize a parameter without default
      • paramToExpr

        static Expr paramToExpr​(Param p)
        Serialize a parameter
      • parametersToExpr

        static Expr parametersToExpr​(Parameters p)
        Serialize function parameters
      • patternCaptureTargetToExpr

        static Expr patternCaptureTargetToExpr​(PatternCaptureTarget pct)
        Serialize a pattern capture target
      • patternToExpr

        static Expr patternToExpr​(Pattern p)
        Serialize a pattern
      • patternsToExpr

        static Expr patternsToExpr​(Patterns ps)
        Serialize patterns
      • posArgToExpr

        static Expr posArgToExpr​(PosArg pa)
        Serialize a positional argument
      • positionalPatternsToExpr

        static Expr positionalPatternsToExpr​(PositionalPatterns pp)
        Serialize positional patterns
      • powerToExpr

        static Expr powerToExpr​(Power p)
        Serialize a power expression
      • primaryRhsToExpr

        static Expr primaryRhsToExpr​(PrimaryRhs rhs)
        Serialize a primary RHS
      • primaryToExpr

        static Expr primaryToExpr​(Primary p)
        Serialize a primary expression
      • primaryWithRhsToExpr

        static Expr primaryWithRhsToExpr​(PrimaryWithRhs pwr)
        Serialize a primary with RHS
      • pythonDocEntityRef

        static java.lang.String pythonDocEntityRef​(EntityReference ref)
        Render a hydra.packaging.EntityReference as Sphinx/RST link syntax
      • pythonFloatLiteralText

        static java.lang.String pythonFloatLiteralText​(java.lang.String s)
      • raiseExpressionToExpr

        static Expr raiseExpressionToExpr​(RaiseExpression re)
        Serialize a raise expression
      • raiseStatementToExpr

        static Expr raiseStatementToExpr​(RaiseStatement rs)
        Serialize a raise statement
      • relativeImportPrefixToExpr

        static Expr relativeImportPrefixToExpr​(RelativeImportPrefix p)
        Serialize a relative import prefix
      • returnStatementToExpr

        static Expr returnStatementToExpr​(ReturnStatement rs)
        Serialize a return statement
      • setToExpr

        static Expr setToExpr​(Set s)
        Serialize a Python set
      • shiftExpressionToExpr

        static Expr shiftExpressionToExpr​(ShiftExpression se)
        Serialize a shift expression
      • simpleStatementToExpr

        static Expr simpleStatementToExpr​(SimpleStatement ss)
        Serialize a simple (single-line) Python statement
      • simpleTypeParameterToExpr

        static Expr simpleTypeParameterToExpr​(SimpleTypeParameter stp)
        Serialize a simple type parameter
      • singleTargetToExpr

        static Expr singleTargetToExpr​(SingleTarget st)
        Serialize a single target
      • sliceOrStarredExpressionToExpr

        static Expr sliceOrStarredExpressionToExpr​(SliceOrStarredExpression s)
        Serialize a slice or starred expression
      • sliceToExpr

        static Expr sliceToExpr​(Slice s)
        Serialize a slice
      • slicesToExpr

        static Expr slicesToExpr​(Slices s)
        Serialize slices
      • starAtomToExpr

        static Expr starAtomToExpr​(StarAtom sa)
        Serialize a star atom
      • starExpressionToExpr

        static Expr starExpressionToExpr​(StarExpression se)
        Serialize a star expression
      • starNamedExpressionToExpr

        static Expr starNamedExpressionToExpr​(StarNamedExpression sne)
        Serialize a star named expression
      • starTargetToExpr

        static Expr starTargetToExpr​(StarTarget st)
        Serialize a star target
      • starredExpressionToExpr

        static Expr starredExpressionToExpr​(StarredExpression se)
        Serialize a starred expression
      • statementToExpr

        static Expr statementToExpr​(Statement stmt)
        Serialize a Python statement
      • stringPrefixToText

        static java.lang.String stringPrefixToText​(StringPrefix p)
        Serialize a Python string prefix to its source-form characters
      • stringToExpr

        static Expr stringToExpr​(String_ s)
        Serialize a Python string literal
      • subjectExpressionToExpr

        static Expr subjectExpressionToExpr​(SubjectExpression se)
        Serialize a subject expression
      • sumToExpr

        static Expr sumToExpr​(Sum s)
        Serialize a sum expression
      • tPrimaryAndNameToExpr

        static Expr tPrimaryAndNameToExpr​(TPrimaryAndName pn)
        Serialize a TPrimaryAndName as primary.name
      • tPrimaryToExpr

        static Expr tPrimaryToExpr​(TPrimary tp)
        Serialize a target-side primary expression
      • targetWithStarAtomToExpr

        static Expr targetWithStarAtomToExpr​(TargetWithStarAtom t)
        Serialize a target with star atom
      • termToExpr

        static Expr termToExpr​(Term t)
        Serialize a term expression
      • toPythonComments

        static java.lang.String toPythonComments​(java.lang.String doc_)
        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.
      • tupleToExpr

        static Expr tupleToExpr​(Tuple t)
        Serialize a Python tuple
      • typeAliasToExpr

        static Expr typeAliasToExpr​(TypeAlias ta)
        Serialize a type alias
      • typeParameterToExpr

        static Expr typeParameterToExpr​(TypeParameter tp)
        Serialize a type parameter
      • typedAssignmentToExpr

        static Expr typedAssignmentToExpr​(TypedAssignment ta)
        Serialize a typed assignment
      • untypedAssignmentToExpr

        static Expr untypedAssignmentToExpr​(UntypedAssignment ua)
        Serialize an untyped assignment
      • valuePatternToExpr

        static Expr valuePatternToExpr​(ValuePattern vp)
        Serialize a value pattern
      • whileStatementToExpr

        static Expr whileStatementToExpr​(WhileStatement ws)
        Serialize a while statement