skillfed

unidiff

Unified diff parsing/metadata extraction library.

unidiff Permissive license MIT Active 286 v1.0.0 released

Install

unidiff on PyPI

pip

pip install unidiff

uv

uv add unidiff

poetry

poetry add unidiff

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.9)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 19 days since the last release
Last repo commit
First released
Popularity one of the top 1,000 most-downloaded packages on PyPI (30-day window, as of 2026-08-13)
Known vulnerabilities none known (OSV.dev, checked 2026-08-13)

Evidence: unidiff-1.0.0-py3-none-any.whl

Keywords: unified, diff, parse, metadata

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python Modules

About unidiff

from the package's own PyPI description — quoted content, verbatim

Unidiff

Simple Python library to parse and interact with unified diff data.

CI (image)

Installing unidiff

$ pip install unidiff

Quick start

```python >>> import urllib.request >>> from unidiff import PatchSet >>> diff = urllib.request.urlopen('https://github.com/matiasb/python-unidiff/pull/3.diff') >>> encoding = diff.headers.get_charsets()[0] >>> patch = PatchSet(diff, encoding=encoding) >>> patch <PatchSet: [<PatchedFile: .gitignore>, <PatchedFile: unidiff/patch.py>, <PatchedFile: unidiff/utils.py>]> >>> patch[0] <PatchedFile: .gitignore> >>> patch[0].is_added_file True >>> patch[0].added 6 >>> patch[1] <PatchedFile: unidiff/patch.py> >>> patch[1].added, patch[1].removed (20, 11) >>> len(patch[1]) 6 >>> patch[1][2] <Hunk: @@ 109,14 110,21 @@ def repr(self):> >>> patch[2] <PatchedFile: unidiff/utils.py> >>> print(patch[2]) diff --git a/unidiff/utils.py b/unidiff/utils.py index eae63e6..29c896a 100644 --- a/unidiff/utils.py +++ b/unidiff/utils.py @@ -37,4 +37,3 @@ # - deleted line # \ No newline case...

Read as markdown · JSON record · Source repository · Homepage

AI interpretation — verify before relying

AI-generated interpretation of the package facts above; every digit, version, license, or vulnerability id it cites is grounded in the facts already shown on this page

Parses and inspects unified diff format data, exposing file changes, hunks, and line-level metadata for programmatic analysis or transformation.

Installs cleanly with no runtime dependencies and zero friction. Actively maintained with a recent release (19 days old) and steady repository activity.

MIT license permits unrestricted use, modification, and distribution in both open and proprietary projects, with only attribution required.

Usage

from unidiff import PatchSet
patch = PatchSet.from_filename('example.diff', encoding='utf-8')
for patched_file in patch:
    print(f"{patched_file.path}: +{patched_file.added} -{patched_file.removed}")

Requires Python 3.9 or later.

Verdict: Stable, dependency-free library for diff parsing with active maintenance, no known vulnerabilities, and permissive licensing. Well-suited for tools that need to analyze or transform patch data.

Needs verification

  • Whether the library handles all edge cases in malformed or non-standard unified diff formats reliably.
  • Performance characteristics when parsing very large diff files or patches with thousands of hunks.
parse unified diff formatdiff file parser pythonpatch metadata extractiongit diff parsing libraryunified diff analysisdiff hunk inspectionpatch file reader

Similar packages