Fixit includes a command to perform automatic upgrades of lint rules and other client code for compatibility with the latest version of Fixit. This command will apply simple renames and structure changes where possible:
$ fixit upgrade <path>
Once lint rules have been upgraded, they can be tested against their defined valid/invalid test cases, using their fully qualified package and/or rule name:
$ fixit test "mypackage.rules"
Details about upgrades and changes from old releases can be found below, including any changes now covered by the automated upgrade tools.
From Fixit 1 (v0.1.x)¶
Fixit 2.0 features a foundational rewrite of the linting engine, configuration system, CLI commands, and more.
Fixit 2 uses TOML format for configuration, as opposed to
the YAML format from previous versions. Configuration options can now be
located in either the standard
pyproject.toml file, or a dedicated
Most options can be migrated to the new format as such:
Rules are now referenced by fully qualified package name, with an optional rule name, via the
disableoptions. It is no longer required to specify the
packageslist separately, and omitting a rule name will automatically all rules from the given package:
allow_list_rules: [CustomLintRule] packages: [mypackage.rules]
enable = [ "mypackage.rules:CustomLintRule", # single rule "mypackage.rules", # all rules from package ]
Built-in lint rules are mostly unchanged, though most of them no longer contain the
Rulesuffix. See the Built-in Rules for a full list of rules included with Fixit.
Note that all built-in rules are enabled by default.
Files can be formatted after linting, using one of the supported formatters, with the
formatter = "ufmt" # or "black"
Using arbitrary formatters via subprocess commands and stdin/stdout is no longer supported. Alternative
Formatterimplementations can be built, but a discovery mechanism is not yet defined.
The repository or project root is inferred based on the furthest location of a
fixit.tomlfile, or explicitly by the nearest configuration file with the
root = true # equivalent to "."
root = "src/"
The following options are no longer supported:
An alternative option may be available in the future. See issue #354.
There is no expected use case for this option in Fixit 2.
Fixit 2 drops support for running Flake8 as part of Fixit, and does not support Flake8-style suppressions via
See Silencing Errors for supported lint suppression directives.
Lint rules written for Fixit 1 need some minor structural changes to work with
Fixit 2, and a number of core types have been renamed to be more concise, and
reduce the need for
import LongName as Short style imports.
These types have been renamed, but have temporary aliases that will be removed in a future release:
All renames should be automatically upgraded with the
fixit upgrade command.
This type has been replaced with the new
fixit.Configtype that represents the merged configuration options matching a specific path.
This type has been removed. The current filename can be retrieved using the
FilePathProvidermetadata with the top-level
The following CLI commands from previous versions are roughly equivalent:
python -m fixit.cli.run_rules [--rules ...] <path>
$ fixit lint [--rules ...] <path>
python -m fixit.cli.apply_fix [--rules ...] <path>
$ fixit fix [--rules ...] <path>
See the full Commands list for details.