Skip to main content

Module comparable

Module comparable 

Source
Expand description

An equivalent object hierarchy to the RustPython AST hierarchy, but with the ability to compare expressions for equality (via Eq and Hash).

Two ComparableExprs are considered equal if the underlying AST nodes have the same shape, ignoring trivia (e.g., parentheses, comments, and whitespace), the location in the source code, and other contextual information (e.g., whether they represent reads or writes, which is typically encoded in the Python AST).

For example, in [(a, b) for a, b in c], the (a, b) and a, b expressions are considered equal, despite the former being parenthesized, and despite the former being a write (ast::ExprContext::Store) and the latter being a read (ast::ExprContext::Load).

Similarly, "a" "b" and "ab" would be considered equal, despite the former being an implicit concatenation of string literals, as these expressions are considered to have the same shape in that they evaluate to the same value.

Structs§

ComparableAlias
ComparableArguments
ComparableBytesLiteral
ComparableComprehension
ComparableDecorator
ComparableDictItem
ComparableElifElseClause
ComparableFString
ComparableKeyword
ComparableMatchCase
ComparableModExpression
ComparableModModule
ComparableParameter
ComparableParameterWithDefault
ComparableParameters
ComparablePatternArguments
ComparablePatternKeyword
ComparableStringLiteral
ComparableTString
ComparableTypeParams
ComparableWithItem
ExceptHandlerExceptHandler
ExprAttribute
ExprAwait
ExprBinOp
ExprBoolLiteral
ExprBoolOp
ExprBytesLiteral
ExprCall
ExprCompare
ExprDict
ExprDictComp
ExprFString
ExprGenerator
ExprIf
ExprInterpolatedElement
ExprIpyEscapeCommand
ExprLambda
ExprList
ExprListComp
ExprName
ExprNamed
ExprNumberLiteral
ExprSet
ExprSetComp
ExprSlice
ExprStarred
ExprStringLiteral
ExprSubscript
ExprTString
ExprTuple
ExprUnaryOp
ExprYield
ExprYieldFrom
HashableExpr
Wrapper around Expr that implements Hash and PartialEq according to Python semantics:
InterpolatedElement
PatternMatchAs
PatternMatchClass
PatternMatchMapping
PatternMatchOr
PatternMatchSequence
PatternMatchSingleton
PatternMatchStar
PatternMatchValue
StmtAnnAssign
StmtAssert
StmtAssign
StmtAugAssign
StmtClassDef
StmtDelete
StmtExpr
StmtFor
StmtFunctionDef
StmtGlobal
StmtIf
StmtImport
StmtImportFrom
StmtIpyEscapeCommand
StmtMatch
StmtNonlocal
StmtRaise
StmtReturn
StmtTry
StmtTypeAlias
StmtWhile
StmtWith
TypeParamParamSpec
TypeParamTypeVar
TypeParamTypeVarTuple

Enums§

ComparableBoolOp
ComparableCmpOp
ComparableExceptHandler
ComparableExpr
ComparableInterpolatedStringElement
ComparableLiteral
ComparableMod
ComparableNumber
ComparableOperator
ComparablePattern
ComparableSingleton
ComparableStmt
ComparableTypeParam
ComparableUnaryOp