--- id: moreorless version: "0.6.0" license: MIT license_treatment: permissive maintenance: active --- # moreorless — Python diff wrapper License: permissive · Maintenance: active · Downloads: 3.5M/mo ## 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 above — 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 pip install moreorless uv add moreorless 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_current - Install friction: low - Maintenance: active - Downloads: 3.5M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags unified diff wrapper, patch application, colored diff output, no newline at eof, difflib wrapper, generate unified diffs, apply patch to file, diff-tools, patch-application [View on SkillFed](https://skillfed.io/packages/moreorless) · [View on PyPI](https://pypi.org/project/moreorless/)