No project description provided
Project description
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]
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 match_diff_lines-0.3.0.tar.gz.
File metadata
- Download URL: match_diff_lines-0.3.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: devpi-server/6.19.1 (py3.11.11; darwin)
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c0f8abb15cacecef72818a1ac0bdd1e68823be8f989fe72f6f0c23685ca2068
|
|
| MD5 |
c52aa09d72c440aaafe8ac89638ce6e4
|
|
| BLAKE2b-256 |
cc381263da8711a884a7843d644013460ae646d16703fc14295db37ff49d9332
|
File details
Details for the file match_diff_lines-0.3.0-py3-none-any.whl.
File metadata
- Download URL: match_diff_lines-0.3.0-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: devpi-server/6.19.1 (py3.11.11; darwin)
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a370b5a0d54f6d52dfe923ce90e1cda85e820da57f7e7cc4aebfd1fc8bbcee24
|
|
| MD5 |
3d2166befdcd2fddb42fad1dad3cca63
|
|
| BLAKE2b-256 |
d77bd5c7877b0262739612bb69199dd04af7df72b4d1d8b631ad977ea8e9468d
|