skillfed

moreorless

Python diff wrapper

moreorless v0.6.0 3.5M downloads/30d#2,615 on PyPI6
Permissive license MIT Active released

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 moreorless

uv

uv add moreorless

poetry

poetry add moreorless

Installing 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

unified diff wrapperpatch applicationcolored diff outputno newline at eofdifflib wrappergenerate unified diffsapply patch to file
diff-toolspatch-application

More Utilities packages