Skip to main content

A simple library for printing better diffs based on the stdlib unified_diff format.

Project description

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

better_diff-0.1.4.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

better_diff-0.1.4-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file better_diff-0.1.4.tar.gz.

File metadata

  • Download URL: better_diff-0.1.4.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for better_diff-0.1.4.tar.gz
Algorithm Hash digest
SHA256 920ca76bdbcd2f0c361fa5d9a2d4727624a3545d6cb467b1b6616cad8a634de7
MD5 ef3abd0fa812b3dc554731498341d08f
BLAKE2b-256 9567f57edc19d02f51ffbbc340dd00a7953f74f5eeb88d5b7c706abef2ecc26f

See more details on using hashes here.

Provenance

The following attestation bundles were made for better_diff-0.1.4.tar.gz:

Publisher: Release.yml on ni/py_better_diff

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file better_diff-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: better_diff-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for better_diff-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 06e63358b2047ae2695abd96316f47c6d3c38b9e641f53012279878d66d8792e
MD5 c2c46f51322aaf5e482760bd1e127a76
BLAKE2b-256 9f6490cc70ddc1b6fffe8cbf91102725593178601b8a5345476098a63b2e658f

See more details on using hashes here.

Provenance

The following attestation bundles were made for better_diff-0.1.4-py3-none-any.whl:

Publisher: Release.yml on ni/py_better_diff

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page