Skip to main content

nocomment-linter

nocomment-linter bans comments in Python code and is designed for coding agents: compact, stable, one-line-per-violation output, safe autofix.

What it does

  • checks only *.py files (never .pyi);
  • reports regular Python comments; #!, coding cookies, # noqa, # type: ignore, # pragma: no cover, # fmt: off/on, # ruff: noqa, # pyright: ignore are preserved (tooling comments);
  • optionally bans and removes docstrings (module, class, function, async function) — detected via AST, exactly what Python treats as a docstring;
  • --fix removes violations in place and never writes a file that would not compile;
  • configured through pyproject.toml; no .gitignore support.

Installation

uv sync

Requires Python 3.11+.

Check

nocomment-linter .
nocomment-linter src tests

Autofix

nocomment-linter --fix .

Exit codes: 0 — no violations (with --fix: everything fixed), 1 — violations found or unfixable violations remain, 2 — execution error (file read, configuration, tokenizing or parsing).

Configuration

[tool.nocomment-linter]
check-docstrings = false
exclude = [
    "migrations/**",
    "generated/**",
]
  • check-docstrings (default false): true also enables the DOC001-DOC004 docstring rules.
  • exclude: glob patterns (fnmatch semantics) relative to the directory containing pyproject.toml. A pattern containing / is matched against the whole relative path (migrations/**); a pattern without / matches any path component, so generated excludes the generated/ directory.
  • The config is the first pyproject.toml with a [tool.nocomment-linter] section found walking up from the first PATH argument, then from the current directory; with no configuration anywhere, defaults apply.

Always skipped directories: .vscode/, .idea/, .git/, .venv/, venv/, __pycache__/, .mypy_cache/, .pytest_cache/, .ruff_cache/, build/, dist/.

Rule codes

Code Violation
CMT001 standalone comment (only whitespace before #)
CMT002 inline comment (code before # on the same line)
DOC001 module docstring
DOC002 class docstring
DOC003 function docstring
DOC004 async function docstring

Output format

One self-sufficient line per violation:

<path>:<start-line>:<start-column>-<end-line>:<end-column> <RULE> <FIX> "<content>"

Coordinates are 1-based; the range is half-open: start points at the first character of the violation, end points one past its last character. <FIX> is delete-line (whole physical line) or delete-range (the violation span). <content> is the exact source text, escaped (\n, \t, \", \\).

src/foo.py:10:5-10:23 CMT001 delete-line "# explanation"
src/foo.py:17:20-17:31 CMT002 delete-range "# legacy"
SUMMARY violations=2 files=1

With no violations:

OK violations=0 files=27

After --fix (all violations fixed):

FIXED violations=4 files=2

files counts the files successfully checked; files with read/parse errors are reported as <path>: error: <message> lines and make the run exit 2. Unfixable violations (autofix would break the file) are printed as ordinary violation lines, the file is left untouched, and the run exits 1.

Metadata

Release files for nocomment-linter 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nocomment-linter 1.0.0
File Size Uploaded Provenance
nocomment_linter-1.0.0.tar.gz 13.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for nocomment-linter 1.0.0
File Interpreter ABI Platform
nocomment_linter-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 25.0 kB

Release files / nocomment_linter-1.0.0.tar.gz

Download URL nocomment_linter-1.0.0.tar.gz
Size 13.6 kB
Tags Source
SHA-256 checksum
How to use checksums
839a9bd3d2da99fe549e0bc44af2442d0396112c284053a42d6caefe22f2599f
BLAKE2b-256 checksum
How to use checksums
90c3f39358319c9dbc9db9f35d6ecc685312fa328ff8e93eff987a6fac5786dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.11 {"installer":{"name":"uv","version":"0.12.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / nocomment_linter-1.0.0-py3-none-any.whl

Download URL nocomment_linter-1.0.0-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b9f0e937775aa6f4eba1d8d106c76059ef797cbbbb0f85366e11c3fcd7ee7f4c
BLAKE2b-256 checksum
How to use checksums
c0f4e5139b3cd834fcd2b2a0f4d9859758cc3c923ae092a717282c8aa2151ee7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.11 {"installer":{"name":"uv","version":"0.12.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for nocomment-linter 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page