The fixit library allows developers to create their own custom linters, in addition to providing "autofixers" for fixing current errors.
One common workflow is the following:
If autofix is not available for the particular linter, errors must be silenced before they can be fixed manually.
There are two ways I have found of doing this:
After you have coded your fixup rule, change the code block that reports on the violation to something like this:
fixit_comment = cst.Comment("# lint-fixme: MyRuleName")
new_module = cst.Module(
body=[
# existing node that failed the verification.
node.deep_clone(),
fixit_comment,
]
)
self.report(node, replacement=new_module)
And then run the command to "fix" all errors by adding the string comment:
fixit fix --automatic .
silent-lint-error
This is a 3rd party package:
pip install silence-lint-error
And then running:
silence-lint-error fixit tools.fixit.rules.common:MyCustomRule src/octoenergy/
Where tools.fixit.rules.common
is the path denominated in your pyproject.toml