Repository navigation
v0.2.6
Pre-release
Pre-release
0.2.6 - alpha - 2026-01-31
Breaking Changes
- when putting source instead of an
FSTorASTnode directly as a slice to an expression, if the source is a delimited sequence then it will always be put as one node and not unpacked, previous behavior of.put_slice('[1, 2, 3]')being put as a slice of three distinct elements can be selected by passingone=None
Added
- coercion expanded greatly, can now put more nodes which are not the exact type but that "should work", e.g.
TupleFST.elts = MatchSequenceFST.patterns.copy()pattern,arguments,arg,alias,withitem,TypeVarandTypeVarTupletoexpr- custom slice types
_Assign_targets,_decorator_list,_arglikes,_comprehension_ifs,_aliases,_withitemsand_type_paramstoTuple,ListorSet - all sequence types, custom and standard, to custom slice types
- all expressions and custom slice types to
pattern keywordtoarguments
FST.as_(mode)for explicit coercion directly tomode(which can be an explicittype[AST]or a parse mode)FST(FST, mode)for constructor default non-destructive coerce copy from otherFSTnode, a-lalist(other_list) is not other_listFST(AST, mode)andFST.fromast(AST, type[AST] or mode)can use the new coercion to convertAST- with these changes,
FST(x[, mode])now works likelist(x)in that it converts source,ASTorFSTto the given modeFSTif possible, or just ANFSTif mode not provided
- with these changes,
- put slice as
one=Truefor_Assign_targets,_decorator_list,_arglikes,_comprehension_ifs,_aliases,_withitems,_type_paramsand_expr_arglikes - prescribed slicing for
MatchClass.patterns - prescribed slicing for
arguments._all, e.g.FunctionDefFST.args[x:y] = 'a: int, /, b=c' unpar('invalid')can remove delimiters fromList,Set,Dict,MatchMapping,ListComp,SetComp,DictCompandGeneratorExp, if needed for some reason
Changed
FST.dump()returnsselfwhen not returning str or lines and those are now specified without='str'orout='lines'- concretized behavior of put slice with
one=Truefor custom special slices, will not put multiple elements now in this mode when one requested parse_withitem('x,')now parses to singletonTuplewithiteminstead of singleNamewithitemwith trailing comma, makes more sense- allow put
Starredtovaluefield ofExpr,Return,AnnAssignandYieldeven though not compilable, for consistency, our metric is parsability, not compilability - REMOVED
norm_putoption as was too annoying to maintain everywhere needed for the little good it did,norm_selfandnorm_getremain - improved put multiline slice aesthetics, specifically better needs-own-line detection and keeping line comment on pre-insert element line instead of moving it
- parse
withitemand_withitemsno longer accept single unparenthesizedYield,NamedExprorTupleas a convenience, causes too many problems downstream - empty
argumentsnow always have a location, having potentially zero-lengthargumentsis less ugly than having arguments with no location DictandMatchMappingslice views dereferenced with a single index will now return a view of that single key:value pair instead of raising
Fixed
- fixed
comprehension_ifsand_arglikescoercions where unparenthesized tuple needed to be parenthesized FST.dump()will no longer output trailing whitespace on lines when the line is completely empty, better for tests- fixed delimit of whole node at root when degenerate last line has line continuation without trailing newline
- fixed parse location correction of multiline unparenthesized tuple with group parenthesized first and / or last elements
- fixed parse of unparenthesized tuple with trailing comma to
_Assign_targets - don't accept
Starrednode for awithitem,_withitemsnormal or_comprehension_ifscoerce - don't try to parse
*starred = valueasTypeVarTuplein place ofAssignon py < 3.13 - allow put
StarredtoTypeVarTuple.default_value - fixed parse
withitemof a soloGeneratorExp - will not parenthesize
argorargumentsif putting multiline to aLambdabut instead parenthesize theLambda - will not parenthesize multiline
withitemput toWith.itemswith existingitemsbut rather the wholeitemsfield - fixed
unpar(node=True)node if first and or last elements are parenthesized