--- id: unidiff2 version: "0.7.8" license: MIT license_treatment: permissive maintenance: aging --- # unidiff2 — Unified diff parsing/metadata extraction library. License: permissive · Maintenance: aging · Downloads: 196.5K/mo ## What it is and what it does unidiff2 is a Python library that parses unified diff format (the standard output of `git diff`, `patch` files, and similar tools) into a structured object model. It lets you programmatically inspect which files changed, how many lines were added or removed, access individual hunks and their line-by-line content, and regenerate diff output from the parsed structure. The package is a maintained fork of the original unidiff library. It has no external runtime dependencies and supports Python 3.7 through 3.11. You can load diffs from files, file-like objects, or iterables, and optionally parse metadata-only for efficiency. It also provides a command-line tool to summarize diff statistics. Use it for: - Analyze git diffs programmatically in CI/CD pipelines to enforce code review policies or generate reports - Parse patch files to determine which files and functions were modified without applying the patch - Build tooling that needs to understand the structure of code changes (e.g., impact analysis, test selection) - Extract and display diff statistics in a custom format or dashboard ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Parses unified diff format into structured Python objects representing patches, files, hunks, and line-by-line changes, with methods to query file status and rebuild diff output. Yes, if you need to parse unified diffs in Python and want a dependency-free solution. The low install friction and permissive license are advantages. However, the package is very new (first release October 2025) and aging maintenance status means you should verify that it meets your stability expectations and that the original unidiff project hasn't resumed active development before committing to it in production. ## Install pip install unidiff2 uv add unidiff2 poetry add unidiff2 ## Installing unidiff2 Before you install: Low friction—pure Python wheel with no runtime dependencies. Maintenance status is aging: last commit was 2025-11-03 and the package is only a few months old (first release 2025-10-03), so long-term stability is unproven. License in practice: MIT license is permissive; you can use, modify, and distribute this package with minimal restrictions, provided you retain the license notice. Quickstart: pip install unidiff2 from unidiff import PatchSet patch = PatchSet.from_filename('file.diff', encoding='utf-8') for patched_file in patch: print(f"{patched_file.path}: +{patched_file.added} -{patched_file.removed}") Verify before relying: - Whether this fork is actively maintained long-term or if the original unidiff package has resumed development - Performance characteristics when parsing very large diff files - Compatibility with edge cases in diff formats from different tools (e.g., Mercurial, Bazaar, Subversion) ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: aging - Downloads: 196.5K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags parse unified diff format, diff parsing library, extract patch metadata, read git diff programmatically, unified diff parser, diff-parsing, version-control [View on SkillFed](https://skillfed.io/packages/unidiff2) · [View on PyPI](https://pypi.org/project/unidiff2/)