Skip to main content

CLI tool to assert that files contain no inline directives

Project description

assert-no-inline-directives

A CLI tool to assert that files contain no inline directives for yamllint, pylint, mypy, and coverage.

Installation

pip install assert-no-inline-directives

Usage

assert-no-inline-directives --tools TOOLS [OPTIONS] PATH [PATH ...]

Required Arguments

  • --tools TOOLS - Comma-separated list of tools: coverage,mypy,pylint,yamllint
  • PATH - One or more file paths, directory paths, or glob patterns to scan (directories are scanned recursively, globs support hidden directories)

Optional Arguments

  • --exclude PATTERNS - Comma-separated glob patterns to exclude files
  • --quiet - Suppress output, exit code only
  • --count - Print finding count only
  • -v, --verbose - Show tools, files scanned, findings, and summary
  • --fail-fast - Exit on first finding
  • --warn-only - Always exit 0, report only
  • --allow PATTERNS - Comma-separated patterns to allow

Examples

# Check for pylint and mypy suppressions in files
assert-no-inline-directives --tools pylint,mypy src/*.py

# Scan a directory recursively
assert-no-inline-directives --tools pylint,mypy src/

# Use glob patterns (including hidden directories like .github)
assert-no-inline-directives --tools yamllint "**/*.yml" "**/*.yaml"

# Check all tools, exclude vendor files
assert-no-inline-directives --tools coverage,mypy,pylint,yamllint \
    --exclude "*vendor*" src/ config/

# Allow specific type: ignore patterns
assert-no-inline-directives --tools mypy \
    --allow "type: ignore[import]" src/*.py

# Check for coverage pragmas
assert-no-inline-directives --tools coverage src/

# CI mode: quiet, just exit code
assert-no-inline-directives --tools pylint,mypy --quiet src/

# Verbose mode: show progress
assert-no-inline-directives --tools pylint,mypy --verbose src/

# Non-blocking check (always exit 0)
assert-no-inline-directives --tools mypy --warn-only src/

Exit Codes

  • 0 - No inline directives found
  • 1 - One or more inline directives found
  • 2 - Usage or runtime error (e.g., file not found, invalid tool)

Output Formats

Default format (one finding per line):

src/example.py:10:pylint:pylint: disable
src/example.py:15:mypy:type: ignore
src/example.py:20:coverage:pragma: no cover
config.yaml:5:yamllint:yamllint disable

Count format (--count):

2

Detected Directives

coverage

  • pragma: no cover
  • pragma: no branch

mypy (suppressions only)

  • type: ignore (including bracketed forms like type: ignore[attr-defined])
  • mypy: ignore-errors

pylint (suppressions only)

  • pylint: disable
  • pylint: disable-next
  • pylint: disable-line
  • pylint: skip-file

yamllint (suppressions only)

  • yamllint disable-line
  • yamllint disable
  • yamllint disable-file

Matching Behavior

  • Case-insensitive matching
  • Tolerates extra whitespace (e.g., pylint: disable, type: ignore)
  • Only detects directives in comments (after #), not in string literals
  • Does not flag "enable" directives (e.g., yamllint enable)
  • Files are scanned in alphabetical order for consistent output
  • Glob patterns support hidden directories (e.g., .github)
  • Tools only check files with matching extensions:
    • coverage: .py, .toml
    • mypy: .py, .toml
    • pylint: .py, .toml
    • yamllint: .yaml, .yml, .toml

License

Apache 2.0 - see LICENSE.txt

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

assert_no_inline_directives-20260104131927.tar.gz (30.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file assert_no_inline_directives-20260104131927.tar.gz.

File metadata

File hashes

Hashes for assert_no_inline_directives-20260104131927.tar.gz
Algorithm Hash digest
SHA256 7bce1424cb3a9f3ad11d290971103095c1ec982ebcb6e766325d009b1555ad55
MD5 2253ccd19226b050a9f71d779d7cf3f9
BLAKE2b-256 65cdd9c51a5f0c71955f670c8f3565444f372723df401f7face8605178669c3e

See more details on using hashes here.

Provenance

The following attestation bundles were made for assert_no_inline_directives-20260104131927.tar.gz:

Publisher: release.yml on 10U-Labs-LLC/assert-no-inline-directives

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file assert_no_inline_directives-20260104131927-py3-none-any.whl.

File metadata

File hashes

Hashes for assert_no_inline_directives-20260104131927-py3-none-any.whl
Algorithm Hash digest
SHA256 051cf72665385975ce959f0249b5391931e76d7f8f6f4a6b2e7aead3d37d0a24
MD5 480124504244a609f83cb5228b7666e6
BLAKE2b-256 e95cf86cf9803bf9171d316c0ded03a8484e036c1698c9b89eff08e5a4e3c35e

See more details on using hashes here.

Provenance

The following attestation bundles were made for assert_no_inline_directives-20260104131927-py3-none-any.whl:

Publisher: release.yml on 10U-Labs-LLC/assert-no-inline-directives

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page