Upgrading¶
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.
This page will attempt to concisely cover major changes between the versions. See the User Guide, API Reference, and Changelog for more information about the latest version.
From Fixit 1 (v0.1.x)¶
Fixit 2.0 features a foundational rewrite of the linting engine, configuration system, CLI commands, and more.
Configuration¶
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
fixit.toml file.
Most options can be migrated to the new format as such:
allow_list_rules/block_list_rules/packages:Rules are now referenced by fully qualified package name, with an optional rule name, via the
enableanddisableoptions. It is no longer required to specify thepackageslist separately, and omitting a rule name will automatically all rules from the given package:Fixit 1: .fixit.config.yaml¶allow_list_rules: [CustomLintRule] packages: [mypackage.rules]
Fixit 2: pyproject.toml¶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.
formatter:Files can be formatted after linting, using one of the supported formatters, with the
formatteroption:Fixit 2: pyproject.toml¶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.repo_root:rule_config:
The following options are no longer supported:
block_list_patterns:An alternative option may be available in the future. See issue #354.
fixture_dirThere is no expected use case for this option in Fixit 2.
use_noqaFixit 2 drops support for running Flake8 as part of Fixit, and does not support Flake8-style suppressions via
# noqadirectives.See Silencing Errors for supported lint suppression directives.
API¶
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.
Renames¶
These types have been renamed, but have temporary aliases that will be removed in a future release:
fixit.CstLintRule→fixit.LintRulefixit.ValidTestCase→fixit.Validfixit.InvalidTestCase→fixit.Invalid
All renames should be automatically upgraded with the fixit upgrade command.
Changes¶
-
This type now takes an optional
CodeRangeinstead of line and column indexes. Theconfig,filename, andkindparameters have been removed. -
The
configandfilenameparameters have been removed.
Removals¶
fixit.LintConfigThis type has been replaced with the new
fixit.Configtype that represents the merged configuration options matching a specific path.fixit.CstContextThis type has been removed. The current filename can be retrieved using the
FilePathProvidermetadata with the top-levelModuleobject.
Commands¶
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.
