v0.2.0
Immutable
release. Only release title and notes can be modified.
Added
- Sort module- and class-level assignments. Within every scope the order is now
assignments, then classes, then functions/methods, so methods always follow nested
classes and assignments are grouped at the top. Assignments are split into uppercase
CONSTANTSfirst and then other variables; each group sorts with a leading
underscore first (so__dunder__and_privateprecede public names), and
dependencies are respected (B = A + 1stays afterA). As a result,
module-level functions now sort after module-level classes. The attribute order of
enums, dataclasses, andNamedTuple/TypedDictclasses is preserved; the base or
decorator is resolved throughQualifiedNameProviderso aliased imports (from enum import IntEnum as IE) are recognized. - Keep blank-line spacing with its position rather than the moved definition, so
reordering no longer drags a blank line onto a different statement (for example the
blank line after a class docstring stays at the top of the block). Comment lines that
sit directly above a definition still travel with it. - Keep an augmented assignment anchored to the constant it augments, so
__all__ += extrastays directly after__all__ = [...]instead of being left behind as a
fixed barrier when another assignment sorts between them. - Sort keyword arguments in calls, keyword-only parameters in function definitions, and
string keys in dict literals alphabetically. In a call, keyword arguments are sorted
and**unpackings moved to the end (positional arguments and*unpackings stay
put), which is safe because a call raisesTypeErroron any duplicate keyword
regardless of order. In a dict literal,**spreads and non-string keys act as
barriers so last-wins merge semantics are preserved.
Changed
- Sort
_-prefixed (private and dunder) names ahead of public names at every level
rather than after capitalized names. A plain string sort placed_after
A-Zbecause of its higher code point; names are now ordered on a
leading-underscore flag first so private definitions, methods, keyword arguments, and
dict keys group together ahead of the public ones.
Fixed
- Ignore a name used only in a lazy annotation (under
from __future__ import annotations) when ordering definitions, since the annotation is never evaluated at
runtime and imposes no real dependency. A forward reference in an annotation (for
examplenxt: list[Instr]whereInstris a type-alias union of classes defined
later) previously forged a false dependency cycle that could hoist the runtime alias
above the classes it unions and raiseNameError. - Order definitions with a proper priority topological sort so a class or function is
always placed after every sibling it depends on. The previous dependency heuristic
compared per-node dependency vectors and could emit a dependent before its dependency
(for example,Subreddit'sSubredditFlairwas sorted ahead of the
flair-template classes it instantiates).