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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
920ca76bdbcd2f0c361fa5d9a2d4727624a3545d6cb467b1b6616cad8a634de7
|
|
| MD5 |
ef3abd0fa812b3dc554731498341d08f
|
|
| BLAKE2b-256 |
9567f57edc19d02f51ffbbc340dd00a7953f74f5eeb88d5b7c706abef2ecc26f
|
Provenance
The following attestation bundles were made for better_diff-0.1.4.tar.gz:
Publisher:
Release.yml on ni/py_better_diff
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
better_diff-0.1.4.tar.gz -
Subject digest:
920ca76bdbcd2f0c361fa5d9a2d4727624a3545d6cb467b1b6616cad8a634de7 - Sigstore transparency entry: 224747625
- Sigstore integration time:
-
Permalink:
ni/py_better_diff@5684b56e105e46ff93e011518a045979eea11916 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/ni
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
Release.yml@5684b56e105e46ff93e011518a045979eea11916 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06e63358b2047ae2695abd96316f47c6d3c38b9e641f53012279878d66d8792e
|
|
| MD5 |
c2c46f51322aaf5e482760bd1e127a76
|
|
| BLAKE2b-256 |
9f6490cc70ddc1b6fffe8cbf91102725593178601b8a5345476098a63b2e658f
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
better_diff-0.1.4-py3-none-any.whl -
Subject digest:
06e63358b2047ae2695abd96316f47c6d3c38b9e641f53012279878d66d8792e - Sigstore transparency entry: 224747632
- Sigstore integration time:
-
Permalink:
ni/py_better_diff@5684b56e105e46ff93e011518a045979eea11916 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/ni
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
Release.yml@5684b56e105e46ff93e011518a045979eea11916 -
Trigger Event:
release
-
Statement type: