Python diff wrapper
Project Links
Meta
Author: Tim Hatch
Requires Python: >=3.9
Classifiers
moreorless
This is a thin wrapper around difflib.unified_diff that Does The Right Thing
for "No newline at eof". The args are also simplified compared to difflib:
moreorless.unified_diff(
astr: str,
bstr: str,
filename: str,
n: int = 3,
) -> str:
...
# raises moreorless.patch.PatchException
moreorless.patch.apply_single_file(
contents: str,
patch: str,
allow_offsets: bool = True,
) -> str:
...
# uses click to write to stdout with colors
moreorless.click.echo_color_unified_diff(
astr: str,
bstr: str,
filename: str,
n: int = 3
) -> None:
...
# if you want to use unified_diff yourself first (e.g. in another process)
moreorless.click.echo_color_precomputed_diff(
diff: str,
) -> None:
...
# if you want to produce a combined (merge) diff:
moreorless.combined.combined_diff(
[astr, bstr], [cstr]
) -> str:
...
Version Compat
This library is compatible with Python 3.9+, but should be linted under the newest stable version.
Versioning
This library follows meanver, which basically means semver along with a promise to rename when the major version changes.
Install the optional cli extra if you want the colored diff helpers:
pip install moreorless[cli]
License
moreorless is copyright Tim Hatch, and licensed under
the MIT license. I am providing code in this repository to you under an open
source license. This is my personal repository; the license you receive to
my code is from me and not from my employer. See the LICENSE file for details.
0.6.0
May 12, 2026
0.5.0
May 04, 2025
0.4.0
Mar 30, 2021
0.3.0
Mar 11, 2020
0.2.0
Mar 10, 2020
0.1.0
Mar 08, 2020
0.0.0
May 04, 2025