Skip to main content

match-diff-lines

Match a diff to a list of lines from linters and other tools like flake8 or ruff.

Installation

Best to install into a virtual environment with a Python installer like pip or similar.

Usage as tool

Invoke python -m match_diff_lines diff_file tool_output. The diff_file is a file containing the unified diff output you want to check against. The tool_output contains the output of your linter/tool which contains lines in the form of filename:line_num for example:

match_diff_lines.py:59:39: E271 multiple spaces after keyword

If any lines are contained in the diff, then they are printed and exit code 1 is returned.

With bash or zsh you can use temporary named pipes like this:

% python -m match_diff_lines <(git diff HEAD^) <(ruff check)

Usage as library

Call parse_unified_diff with a file like text object or a list of lines of a diff to get a dictionary with filenames as keys and a set of line numbers back.

Changelog

0.3.0 - 2026-03-24

  • Return individually changed line numbers for diffs with context instead of the full block including unchanged lines. [fschulze]

  • parse_unified_diff now works with a list of lines from a splitlines call. [fschulze]

  • Export type annotations for usage as library. [fschulze]

  • Test with Python 3.9 - 3.14. [fschulze]

0.2.0 - 2024-07-21

  • Add match-diff-lines script on installation. [fschulze]

0.1.0 - 2024-07-21

  • Initial release. [fschulze]

Metadata

Release files for match-diff-lines 0.3.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 match-diff-lines 0.3.0
File Size Uploaded Provenance
match_diff_lines-0.3.0.tar.gz 7.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for match-diff-lines 0.3.0
File Interpreter ABI Platform
match_diff_lines-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.1 kB

Release files / match_diff_lines-0.3.0.tar.gz

Download URL match_diff_lines-0.3.0.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
5c0f8abb15cacecef72818a1ac0bdd1e68823be8f989fe72f6f0c23685ca2068
BLAKE2b-256 checksum
How to use checksums
cc381263da8711a884a7843d644013460ae646d16703fc14295db37ff49d9332
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via devpi-server/6.19.1 (py3.11.11; darwin)

Release files / match_diff_lines-0.3.0-py3-none-any.whl

Download URL match_diff_lines-0.3.0-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a370b5a0d54f6d52dfe923ce90e1cda85e820da57f7e7cc4aebfd1fc8bbcee24
BLAKE2b-256 checksum
How to use checksums
d77bd5c7877b0262739612bb69199dd04af7df72b4d1d8b631ad977ea8e9468d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via devpi-server/6.19.1 (py3.11.11; darwin)

Security for match-diff-lines 0.3.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.

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