Comply or explain - justify every ignored linting rule.
Project description
noqaexplain
Comply or explain - justify every ignored linting rule.
✨ Features 🚀 Quick start 📚 Documentation 🤝 Contribute 👍 Adopters 📜 Legal
Features
noqaexplain is a linter which enforces justifying every ignored linting rule supporting multiple formats/linters:
- Python -
ruffandflake8# noqa,coveragepy# pragma: no cover - JavaScript/TypeScript -
eslint - Rust -
clippy - Dockerfiles -
hadolint - YAML -
yamllint - Shell -
shellcheck
[!IMPORTANT] You can expand this list with any language and linter by using
extend_suffix_mappingand/orextend_name_mapping! Feel free to open a request to add support for more linters.
Table of contents
Quick start
Installation
[!TIP] You can use your favorite package manager like
uv,hatchorpdminstead ofpip.
> pip install noqaexplain
Usage
To check against all files (the ones with defined mappings from file extension to error disable comment format), run:
> noqaxplain check
You can pass additional arguments to noqaexplain check, like files
to check:
> noqaexplain check path/to/file.py maybe.rs other.yml formats.js
If a certain file has a line with disabled check without an explanation, the tool will report it:
path/to/file.py:10:5: ENQ0 Missing explanation (enoqa) for disabled linting rule
to fix it, just add an explanation after the disable comment prefixed by enq:,
e.g.:
import some_library
# enq: Disabled private access check as there is no other workaround currently.
# noqa: SLF001
some_library._private_function()
Advanced
Configuration
You can configure pynudger in pyproject.toml (or .noqaexplain.toml
in the root of your project, just remove the [tool.noqaexplain] section),
for example:
[tool.noqexplain]
# include rules by their code
include_codes = [0] # default: all rules included
# exclude rules by their code (takes precedence over include)
exclude_codes = [1] # default: no rules excluded
# whether to exit after first error or all errors
end_mode = "first" # default: "all"
# Extends Python noqas mappings
# Now every # my_noqa_header: will be treated as a noqa comment
# and checked for explanations.
extend_suffix_mapping = {".py" = ["# my_noqa_header:"]}
# Target any MySuperFile.md file(s) and look for explanations
extend_name_mapping = {"MySuperFile.md" = ["# my_noqa_header:"]}
[!TIP] Rule-specific configuration can be found in the section below.
Run as a pre-commit hook
noqaexplain can be used as a pre-commit hook, to add as a plugin:
repos:
- repo: "https://github.com/open-nudge/noqaexplain"
rev: ... # select the tag or revision you want, or run `pre-commit autoupdate`
hooks:
- id: "noqaexplain"
Rules
[!TIP] Run
noqaexplain rulesto see the list of available rules.
noqaexplain provides the following rules:
| Name | Description |
|---|---|
NQE0 |
Ensures that all disabled linting rules have an associated explanation one line above them |
NQE1 |
Ensures that all disabled linting rules have an associated explanation of at least |
and the following configurable options (in pyproject.toml
or .noqaexplain.toml):
| Option | Description | Affected rules | Default |
|---|---|---|---|
extend_suffix_mapping |
Additional file suffix to noqa comment(s) format mappings (dict of lists) | All | {} |
extend_name_mapping |
Additional file name to noqas comment(s) format mappings (dict of lists) | All | {} |
suffix_mapping |
File suffix to noqa comment format(s) mappings (dict of lists, overrides default!) | All | {} |
name_mapping |
File name to noqa comment format(s) mappings (dict of lists, overrides default!) | All | {} |
min_explain_length |
Minimum length of explanation for disabled linting rules | NQE1 | 10 |
explain_noqa_pattern |
String identifying explanation for disabled linting rule | NQE0 | "enq:" |
Contribute
We welcome your contributions! Start here:
Legal
- This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
- This project is copyrighted by open-nudge - the appropriate copyright notice is included in each file.
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 noqaexplain-0.1.0.tar.gz.
File metadata
- Download URL: noqaexplain-0.1.0.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
311ca99687e2124c0b37a820011c200edc4526d14240a97d4ac44c6deb5b8249
|
|
| MD5 |
f31e16b2ca4fd92ac03a632f71cf972a
|
|
| BLAKE2b-256 |
e65c0eb08e07714e8a9285bf2b3a1b6e3ef41b06d426cd38a03614f6d1e53399
|
Provenance
The following attestation bundles were made for noqaexplain-0.1.0.tar.gz:
Publisher:
release.yml on open-nudge/noqaexplain
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
noqaexplain-0.1.0.tar.gz -
Subject digest:
311ca99687e2124c0b37a820011c200edc4526d14240a97d4ac44c6deb5b8249 - Sigstore transparency entry: 692052661
- Sigstore integration time:
-
Permalink:
open-nudge/noqaexplain@5d8747019df0fa30fc2785fa6fcfad370a7b0d70 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/open-nudge
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5d8747019df0fa30fc2785fa6fcfad370a7b0d70 -
Trigger Event:
release
-
Statement type:
File details
Details for the file noqaexplain-0.1.0-py3-none-any.whl.
File metadata
- Download URL: noqaexplain-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.1 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 |
b0fb460f82d870fb3968ce8a6dafdc71985e0dff8a285297a00e1595e69f22a0
|
|
| MD5 |
44f34439781da606eddb90df370559f5
|
|
| BLAKE2b-256 |
f0f539d883818927ed7d1fef2058ab0a5717d5040d18b4070b0ea7be3c1835ef
|
Provenance
The following attestation bundles were made for noqaexplain-0.1.0-py3-none-any.whl:
Publisher:
release.yml on open-nudge/noqaexplain
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
noqaexplain-0.1.0-py3-none-any.whl -
Subject digest:
b0fb460f82d870fb3968ce8a6dafdc71985e0dff8a285297a00e1595e69f22a0 - Sigstore transparency entry: 692052696
- Sigstore integration time:
-
Permalink:
open-nudge/noqaexplain@5d8747019df0fa30fc2785fa6fcfad370a7b0d70 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/open-nudge
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5d8747019df0fa30fc2785fa6fcfad370a7b0d70 -
Trigger Event:
release
-
Statement type: