Sort Code

The SortCodeCommand is the libcst codemod that performs the reordering. The codesorter CLI applies it to the files you pass it; you can also use it directly as a libcst codemod in your own tooling by constructing it with a CodemodContext and calling transform_module (see the programmatic example in the README).

class codesorter.sort_code.SortCodeCommand(context)

Reorder module- and class-level definitions based on their dependencies.

Parameters:

context (CodemodContext)

The following enumerations define the secondary sort keys used to order members within a class body.

class codesorter.sort_code.MethodType(*values)

Method kinds used to sort methods within a class body.

class codesorter.sort_code.FixtureType(*values)

Pytest fixture scopes used as a secondary sort key for fixture methods.

class codesorter.sort_code.PropertyType(*values)

Property accessor kinds used to group getter/setter/deleter together.