silence linting errors by adding ignore/fixme comments
Project description
silence-lint-error
Silent linting errors by adding ignore
or fixme
comments.
This tool currently works with:
Usage
Install with pip:
python -m pip install silence-lint-error
You must also install the linting tool you wish to use in the same virtual environment.
silence linting errors
Find linting errors and add the ignore
or fixme
comments as applicable.
For example, to add lint-fixme: CollapseIsinstanceChecks
comments to ignore
the fixit.rules:CollapseIsinstanceChecks
rule from fixit
, run:
silence-lint-error fixit fixit.rules:CollapseIsinstanceChecks path/to/files/ path/to/more/files/
To add noqa: F401
comments to ignore the F401
rule in flake8
, run:
silence-lint-error flake8 F401 path/to/files/ path/to/more/files/
To add noqa: F401
comments to ignore the F401
rule in ruff
, run:
silence-lint-error ruff F401 path/to/files/ path/to/more/files/
To add nosemgrep: python.lang.best-practice.sleep.arbitrary-sleep
comments to
ignore the python.lang.best-practice.sleep.arbitrary-sleep
rule in semgrep
,
run:
SEMGREP_RULES=r/python silence-lint-error semgrep python.lang.best-practice.sleep.arbitrary-sleep path/to/files/ path/to/more/files/
N.B. The rules must be configured in an environment variable.
For more information about configuring semgrep rules,
see the --config
entry in the semgrep
documentation
To add type: ignore
comments
to ignore the truthy-bool
error from mypy
,
run:
silence-lint-error mypy truthy-bool path/to/files/ path/to/more/files/
fix silenced errors
If there is an auto-fix for a linting error, you can remove the ignore
or
fixme
comments and apply the auto-fix.
For example, to remove all lint-fixme: CollapseIsinstanceChecks
comments and
apply the auto-fix for that rule, run:
fix-silenced-error fixit fixit.rules:CollapseIsinstanceChecks path/to/files/ path/to/more/files/
To remove noqa: F401
comments and apply the auto-fix for that rule, run:
fix-silenced-error ruff F401 path/to/files/ path/to/more/files/
Rationale
When adding a new rule (or enabling more rules) for a linter on a large code-base, fixing the existing violations can be too large a task to do quickly. However, starting to check the rule sooner will prevent new violations from being introduced.
Ignoring existing violations is a quick way to allow new rules to be enabled. You can then burn down those existing violations over time.
This tool makes it easy to find and ignore all current violations of a rule so that it can be enabled.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file silence_lint_error-1.5.0.tar.gz
.
File metadata
- Download URL: silence_lint_error-1.5.0.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a182189dea35f0804b7df658a608d6d0813d77de7bdb1a7568dd93c3efc075b6 |
|
MD5 | c28f55ba0c8c77e7bc050eeed0a99d60 |
|
BLAKE2b-256 | a6719622999fe86314156feed0eb8b70208a9ae4149ca80168513f6d9b81c36c |
File details
Details for the file silence_lint_error-1.5.0-py2.py3-none-any.whl
.
File metadata
- Download URL: silence_lint_error-1.5.0-py2.py3-none-any.whl
- Upload date:
- Size: 14.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d983d5eb759658617ea94a0fec7ad2cc6ba51f2ac72288a46c730497d4cdc5e |
|
MD5 | d8154cce4c105c3b4ff14992bbb69064 |
|
BLAKE2b-256 | a0ef842061b73ac02161b1c706736760e6e7ec92cb372da733ddc711a33ca208 |