--- id: unidiff version: "1.0.0" license: MIT license_treatment: permissive maintenance: active --- # unidiff — Unified diff parsing/metadata extraction library. License: permissive · Maintenance: active · Popularity: top 1,000 on PyPI ## Install pip install unidiff uv add unidiff poetry add unidiff ## Description # Unidiff Simple Python library to parse and interact with unified diff data. [![CI](https://github.com/matiasb/python-unidiff/actions/workflows/ci.yml/badge.svg)](https://github.com/matiasb/python-unidiff/actions/workflows/ci.yml) ## Installing unidiff ```console $ 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 , , ]> >>> patch[0] >>> patch[0].is_added_file True >>> patch[0].added 6 >>> patch[1] >>> patch[1].added, patch[1].removed (20, 11) >>> len(patch[1]) 6 >>> patch[1][2] >>> patch[2] >>> 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... ## AI interpretation — verify before relying Parses and inspects unified diff format data, exposing file changes, hunks, and line-level metadata for programmatic analysis or transformation. 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. [View on SkillFed](https://skillfed.io/packages/unidiff) · [View on PyPI](https://pypi.org/project/unidiff/)