moreorless
Python diff wrapper
What it is and what it does
moreorless is a thin wrapper around Python's standard `difflib.unified_diff` that simplifies the API and correctly handles the edge case of files without trailing newlines—a common source of bugs in diff tools. It provides three main entry points: a core `unified_diff()` function that takes two strings and returns a unified diff, a `patch.apply_single_file()` function to apply patches to file contents, and optional colored output helpers via the `cli` extra that use click to display diffs with syntax highlighting.
The package is lightweight with zero runtime dependencies in its base form, making it suitable for embedding in other tools or libraries that need reliable diff generation. It follows semantic versioning and is compatible with Python 3.9 and later. The colored output and patch-application features are available as optional add-ons, so you can install just the core diffing functionality if you don't need click-based terminal output.
Use it for:
- Generate clean unified diffs in code review or testing tools that need correct newline-at-eof handling
- Apply patches programmatically to file contents with optional offset tolerance for resilience
- Display side-by-side or colored diffs in CLI tools using the click integration
- Merge diffs from multiple sources using the combined_diff function for complex version control scenarios
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Generates unified diffs with correct handling of files without trailing newlines, and optionally applies patches or displays colored diff output.
Yes. The package solves a real edge case (newline-at-eof handling) that the standard library doesn't address cleanly, has zero base dependencies, is actively maintained, carries no known vulnerabilities, and uses a permissive MIT license. Install the base package for diff generation; add the `[cli]` extra only if you need colored terminal output.
Install
moreorless on PyPI
pip
pip install moreorlessuv
uv add moreorlesspoetry
poetry add moreorlessInstalling moreorless
Before you install
Low install friction with no runtime dependencies. Actively maintained as of May 2026, with a recent release.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and proprietary projects.
Quickstart
pip install moreorless
import moreorless
diff_output = moreorless.unified_diff('old content', 'new content', 'file.txt')
print(diff_output)
Requires Python 3.9 or later. Optional `cli` extra (click dependency) needed for colored output functions.
Verify before relying
- Whether the package is actively used in production or primarily for development tooling
- Performance characteristics when diffing large files or applying complex patches
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 — 94 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 3,459,933/month — #2,615 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: moreorless-0.6.0-py3-none-any.whl
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
patchParses and applies unified diff patches to…
permissive · top 15,000 on PyPI
ydiffYdiff displays colored, incremental diffs in a…
permissive · top 15,000 on PyPI
patch-ngParses and applies unified diff patches to…
permissive · top 5,000 on PyPI
unidiffParses unified diff format data into structured…
permissive · top 1,000 on PyPI
unidiff2Parses unified diff format into structured…
permissive · top 15,000 on PyPI
patchyPatchy modifies Python functions at runtime by…
permissive · top 5,000 on PyPI
diff-match-patchProvides diff, match, and patch algorithms for…
permissive · top 5,000 on PyPI
fast-diff-match-patchWraps the C++ implementation of…
permissive · top 15,000 on PyPI
icdiffIcdiff displays file differences in a…
permissive · top 5,000 on PyPI
whatthepatchParses and applies patch files in multiple diff…
permissive · top 5,000 on PyPI