All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Fixed bug where comparing OrderedNode's with cycles would break the sort.
- Update README.md + pyproject.toml description
- Moved project to Development Status :: 4 - Beta
- Added support for TATO_DEBUG_EXPLAIN=1 to include explanations of the sorted code.
- Changed order algorithm:
- The first pass only uses import time dependencies (global scope + class scope).
- Nodes that participate in cycles are ignored.
- Added a
tato index
command to create an index of symbol definitions and references. - Added a
tato format --with-index <path>
to use index when ordering symbols. A symbol used more is "more important" and sorts earlier in the file.
Indexer notes:
The indexer currently does a two pass algorithm. It finds all definitions.
Then, it passes over the source files again to find references.
A reference can have more than one definition (e.g. if True: a = 1 else: a = 2
),
so a many-to-many table stores the relationships (called 'DefRef').
Imported definitions are tracked with the 'DefDef' table and is recursively
searched to find the original definition.
tato
command is nowtato format
- Unaccessed symbols correctly sort to the top of files (assuming these symbols are exported and used elsewhere, so they are "important")
- Functions used in global scope (decorator, default args) are sorted correctly.
- Module docstrings stay sorted above imports.
- Add cycle detection. No longer removes nodes from files with cycles.
- Fixed bug where using an imported symbol would cause the target symbol to sort too high in the output, creating invalid code.
- Sort
if TYPE_CHECKING:
blocks into the "imports" section
- Functions should now more stably sort by call hierarchy order. Added a second pass of sorting to make this logic easier.
- Hacky, but better argument parsing from CLI. Supports --version and --help.
- Ignore usages of imports when topological sorting
- Allow multiple passes of codemod until stable. This lays out functions in order of usage.
- Ignore self-edges; Fixes bug causing top-level nodes to disappear.
- Generically, fixes the bug where nodes were appearing out of order by hardening the concept of a Section.
- Functions will correctly be sorted before classes is the function is used in the class scope.
- Order functions by leafs last.
- Secondarily order nodes by their first access.
- Robustly handle most top-level nodes in a module body.
- Order should be more deterministic
- Use libcst codemod interface instead of click
- Initial release