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.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file silence_lint_error-1.7.0.tar.gz.
File metadata
- Download URL: silence_lint_error-1.7.0.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1b41dac7a795bbd08228d7f724f80e090e74670c19f6051b03dee03f2a6dee3
|
|
| MD5 |
ed2b7474c423b1dc332504b3a664c322
|
|
| BLAKE2b-256 |
ca61e6b3c6fd012ec6ab8e9352aebb0b7fe02a255f0da3055168956ee837353a
|
Provenance
The following attestation bundles were made for silence_lint_error-1.7.0.tar.gz:
Publisher:
build_publish.yaml on samueljsb/silence-lint-error
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
silence_lint_error-1.7.0.tar.gz -
Subject digest:
b1b41dac7a795bbd08228d7f724f80e090e74670c19f6051b03dee03f2a6dee3 - Sigstore transparency entry: 533563843
- Sigstore integration time:
-
Permalink:
samueljsb/silence-lint-error@ece57c25a091eaced43f6dc3a270d0e6bb6f2dc2 -
Branch / Tag:
refs/tags/v1.7.0 - Owner: https://github.com/samueljsb
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_publish.yaml@ece57c25a091eaced43f6dc3a270d0e6bb6f2dc2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file silence_lint_error-1.7.0-py3-none-any.whl.
File metadata
- Download URL: silence_lint_error-1.7.0-py3-none-any.whl
- Upload date:
- Size: 14.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a20c47a4d843e58e2c5cb1d16a74166b2f3002ce6c773f6fc2ecf89c63280755
|
|
| MD5 |
f8cf848c8853edd2fd467ea140da1e05
|
|
| BLAKE2b-256 |
0d966386bded3f7bb2b538ae3f0ce43d98718279552f8142bd42a3f8584e15c8
|
Provenance
The following attestation bundles were made for silence_lint_error-1.7.0-py3-none-any.whl:
Publisher:
build_publish.yaml on samueljsb/silence-lint-error
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
silence_lint_error-1.7.0-py3-none-any.whl -
Subject digest:
a20c47a4d843e58e2c5cb1d16a74166b2f3002ce6c773f6fc2ecf89c63280755 - Sigstore transparency entry: 533563847
- Sigstore integration time:
-
Permalink:
samueljsb/silence-lint-error@ece57c25a091eaced43f6dc3a270d0e6bb6f2dc2 -
Branch / Tag:
refs/tags/v1.7.0 - Owner: https://github.com/samueljsb
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_publish.yaml@ece57c25a091eaced43f6dc3a270d0e6bb6f2dc2 -
Trigger Event:
push
-
Statement type: