Skip to main content

contains-snippet

A command-line tool that checks whether a given snippet exists anywhere within a file. For plain text files (like .md), it searches the raw content directly. For source code files (.py, .yml, .yaml), it checks for the snippet rendered as comments.

Installation

pip install -e .

Usage

contains-snippet --snippet-file SNIPPET_FILE FILE [FILE ...]

Exit Codes

  • 0 - All files contain the snippet
  • 1 - One or more files are missing the snippet
  • 2 - Usage/configuration/runtime error

Matching Rules (Default)

  • .md files: Raw substring match
  • .py, .yml, .yaml files: Commented match (lines prefixed with #)
  • Other extensions: Raw substring match

Examples

Check if a license notice appears in a README:

contains-snippet --snippet-file license_notice.txt README.md

Check if a header comment exists in multiple Python files:

contains-snippet --snippet-file header.txt src/*.py

Configuring Match Behavior

Force Commented Matching: --comment-prefix

Force all files to use commented matching with a specific prefix:

# Check JavaScript files with // comments
contains-snippet --snippet-file header.txt --comment-prefix "//" src/*.js

# Force .md files to match as comments (not raw)
contains-snippet --snippet-file notice.txt --comment-prefix "#" docs/*.md

Infer from Extension: --infer-comment-prefix

Enable extension-based inference using built-in mapping:

Extension Match Type
.md raw
.py # comments
.yml # comments
.yaml # comments
(other) raw
contains-snippet --snippet-file header.txt --infer-comment-prefix src/*.py docs/*.md

Custom Extension Mapping: --comment-prefix-map

Override or extend the built-in mapping (requires --infer-comment-prefix):

# Add JavaScript and TypeScript support
contains-snippet --snippet-file header.txt \
  --infer-comment-prefix \
  --comment-prefix-map ".js=//,.ts=//" \
  src/*

# Override Python to use raw matching
contains-snippet --snippet-file notice.txt \
  --infer-comment-prefix \
  --comment-prefix-map ".py=raw" \
  src/*.py

Precedence

  1. --comment-prefix (highest) - forces global commented matching
  2. --infer-comment-prefix + --comment-prefix-map - per-file inference
  3. Default behavior - current hardcoded rules

CI Checks

The following checks run on every push and pull request:

  • yamllint - YAML linting for workflow files
  • pylint - Python linting for source and test code
  • mypy - Static type checking for source code
  • jscpd - Duplicate code detection
  • pytest - Unit, integration, and E2E tests

Metadata

Release files for contains-snippet 20260108014512

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

Source distribution (sdist)

Source distribution for contains-snippet 20260108014512
File Size Uploaded Provenance
contains_snippet-20260108014512.tar.gz 17.6 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for contains-snippet 20260108014512
File Interpreter ABI Platform
contains_snippet-20260108014512-py3-none-any.whl Python 3 none any Details

Total release size: 27.0 kB

Release files / contains_snippet-20260108014512.tar.gz

Download URL contains_snippet-20260108014512.tar.gz
Size 17.6 kB
Tags Source
SHA-256 checksum
How to use checksums
aa5a998c650abf04f62fe1c75de7827b368ade79a451160fbfdd4e393bec3730
BLAKE2b-256 checksum
How to use checksums
e135b6dda95a4ae7bd29c1259919f4a7b7c5b0be851d547e11e27b38631eb4b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 8, 2026.

Transparency log

Release files / contains_snippet-20260108014512-py3-none-any.whl

Download URL contains_snippet-20260108014512-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d525e0f64cd74e10cf6284a02af04f1d1ca883c46499b963070c4b91e9e96691
BLAKE2b-256 checksum
How to use checksums
2bd436c831aef232a266219482a207f1f1f38a0a3773f642e3d3428ca2a32489
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 8, 2026.

Transparency log

Security for contains-snippet 20260108014512

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for contains_snippet-20260108014512.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 8, 2026.

Transparency log

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
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