Metadata-Version: 2.4
Name: match-diff-lines
Version: 0.3.0
Maintainer-email: Florian Schulze <mail@florian-schulze.net>
License-Expression: MIT
Project-URL: Bug Tracker, https://github.com/fschulze/match-diff-lines/issues
Project-URL: Changelog, https://github.com/fschulze/match-diff-lines/blob/main/CHANGELOG.rst
Project-URL: Homepage, https://github.com/fschulze/match-diff-lines
Project-URL: Source Code, https://github.com/fschulze/match-diff-lines
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Typing :: Typed
Requires-Python: >=3.9
Description-Content-Type: text/x-rst
License-File: LICENSE
Dynamic: license-file

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]
