unidiff
Unified diff parsing/metadata extraction library.
Install
unidiff on PyPI
pip
pip install unidiffuv
uv add unidiffpoetry
poetry add unidiffPackage 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
About unidiff
from the package's own PyPI description — quoted content, verbatim
Unidiff
Simple Python library to parse and interact with unified diff data.
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.
Similar packages
permissive · top 1,000 on PyPI
diff-coverpermissive · top 1,000 on PyPI
jsonpatchpermissive · top 1,000 on PyPI
tomli-wpermissive · top 1,000 on PyPI
parsopermissive · top 1,000 on PyPI
pathspeccopyleft · top 100 on PyPI
rignorepermissive · top 1,000 on PyPI
gspreadpermissive · top 1,000 on PyPI
stack-datapermissive · top 1,000 on PyPI
nest-asynciopermissive · top 1,000 on PyPI