Skip to main content

Better-Diff

The problem we're solving:

Why is my code linting tool telling me there's a difference here?

--- a
+++ b
@@ -1,6 +1,6 @@
-Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
+Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
 incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
 nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

With a normal unified-diff, trailing whitespace that is removed is not highlighted (depending on how the log is saved, may even be removed...)

Similar issues exist with the last line being an empty line or not:

---a

+++b

@@ -4,4 +4,3 @@

 Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
 fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
 culpa qui officia deserunt mollit anim id est laborum.
-

What about that line is getting removed?

Our solution

Write this module to share a wrapper that calls difflib.unified_diff and augments the formatting output with lines to highlight:

  • The difference between the last and the new line is whitespace being removed
  • The difference is the absence of line endings at the end.
--- a
+++ b
@@ -1,3 +1,3 @@
-Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
?                                                                              ^^
+Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
 incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
 nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
\ No newline at end of file (b)

Metadata

Release files for better-diff 0.1.4

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

Source distribution (sdist)

Source distribution for better-diff 0.1.4
File Size Uploaded
better_diff-0.1.4.tar.gz 3.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for better-diff 0.1.4
File Interpreter ABI Platform
better_diff-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 7.7 kB

Release files / better_diff-0.1.4.tar.gz

Download URL better_diff-0.1.4.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
920ca76bdbcd2f0c361fa5d9a2d4727624a3545d6cb467b1b6616cad8a634de7
BLAKE2b-256 checksum
How to use checksums
9567f57edc19d02f51ffbbc340dd00a7953f74f5eeb88d5b7c706abef2ecc26f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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 29, 2025.

Transparency log

Release files / better_diff-0.1.4-py3-none-any.whl

Download URL better_diff-0.1.4-py3-none-any.whl
Size 4.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
06e63358b2047ae2695abd96316f47c6d3c38b9e641f53012279878d66d8792e
BLAKE2b-256 checksum
How to use checksums
9f6490cc70ddc1b6fffe8cbf91102725593178601b8a5345476098a63b2e658f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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 29, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.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