Skip to main content

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.

Release files for moreorless 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for moreorless 0.6.0
File Size Uploaded
moreorless-0.6.0.tar.gz 15.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for moreorless 0.6.0
File Interpreter ABI Platform
moreorless-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 26.4 kB

Release files / moreorless-0.6.0.tar.gz

Download URL moreorless-0.6.0.tar.gz
Size 15.6 kB
Tags Source
SHA-256 checksum
How to use checksums
175e8afa824006c4356353d97b1cc9699a6ef68a851e0859257cde8d00e88a64
BLAKE2b-256 checksum
How to use checksums
66cd388ad4893c29cc8d54bc35ef6d699f747c7602132361f289dd28ae614448
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 12, 2026.

Transparency log

Release files / moreorless-0.6.0-py3-none-any.whl

Download URL moreorless-0.6.0-py3-none-any.whl
Size 10.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b00997fee924ab86f2e135ba08e4d70d3295a7226d3d083a5c69ec4e2a9e9e83
BLAKE2b-256 checksum
How to use checksums
0341503e35f695f45e2f07c623d9540377761beebf5a3ecb2322769b98f284d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 12, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.6.0 This release

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page