Skip to content

chore: enforce LF line endings, align Ruff/mypy with pre-commit, and normalize formatting#974

Draft
b-l-u-e wants to merge 3 commits into
cashubtc:mainfrom
b-l-u-e:chore/lf-line-endings-and-pre-commit-ci
Draft

chore: enforce LF line endings, align Ruff/mypy with pre-commit, and normalize formatting#974
b-l-u-e wants to merge 3 commits into
cashubtc:mainfrom
b-l-u-e:chore/lf-line-endings-and-pre-commit-ci

Conversation

@b-l-u-e
Copy link
Copy Markdown
Contributor

@b-l-u-e b-l-u-e commented Apr 4, 2026

This fixes the issue #970

Establish explicit LF line ending policy

Problem
Experiencing noisy whitespace-only diffs when making small changes:

  • make format didn't normalize line endings
  • .pre-commit-config.yaml used auto mode for mixed-line-ending (inconsistent behavior)
  • No .gitattributes to define repository line ending standard
  • Pre-commit sometimes settled files to CRLF, making the intended standard unclear
  • Small PRs showed unrelated whitespace changes, increasing review noise

Solution

Establish an explicit LF (Unix-style) line ending policy with enforcement at multiple levels:

Configuration added:

  • .gitattributes - Git normalizes line endings to LF on commit
  • .editorconfig - Editors default to LF for new files
  • .pre-commit-config.yaml - Explicit --fix=lf for mixed-line-ending hook
  • Makefile - Updated pre-commit target with SKIP=ruff-format to match CI

Files normalized:

  • Mixed line endings (CRLF → LF)
  • Trailing whitespace removed
  • Missing final newlines added
  • 3 files: Docstring placement fixed

Impact

Prevents future issues: New files will automatically use LF
Clean PRs: Contributors won't accidentally introduce whitespace noise
CI alignment: Local make pre-commit now matches CI behavior
No code changes: All modifications are whitespace-only

For Contributors

  • Windows users: Run git config core.autocrlf input after cloning (one-time setup)
  • All users: Pre-commit hooks now enforce LF automatically
  • Workflow unchanged: Continue using make format before committing

Breaking Changes

None. This is purely a whitespace normalization.

Checklist

  • Added .gitattributes and .editorconfig
  • Updated .pre-commit-config.yaml with explicit --fix=lf
  • Updated Makefile to match CI behavior
  • Normalized existing files (whitespace only)
  • Documentation updated (CONTRIBUTING.md)

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 4, 2026

Codecov Report

❌ Patch coverage is 29.65517% with 204 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.78%. Comparing base (85c959e) to head (2e2c4a6).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
cashu/core/models.py 0.00% 197 Missing ⚠️
cashu/core/crypto/b_dhke.py 92.39% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #974      +/-   ##
==========================================
- Coverage   74.92%   73.78%   -1.14%     
==========================================
  Files         111      112       +1     
  Lines       12065    12262     +197     
==========================================
+ Hits         9040     9048       +8     
- Misses       3025     3214     +189     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@b-l-u-e b-l-u-e marked this pull request as draft April 4, 2026 04:49
@b-l-u-e b-l-u-e marked this pull request as ready for review April 7, 2026 14:12
@b-l-u-e b-l-u-e force-pushed the chore/lf-line-endings-and-pre-commit-ci branch from b78f424 to 40965ef Compare May 9, 2026 21:50
@b-l-u-e b-l-u-e marked this pull request as draft May 9, 2026 21:50
@b-l-u-e b-l-u-e force-pushed the chore/lf-line-endings-and-pre-commit-ci branch 2 times, most recently from 40965ef to 6f1a5f0 Compare May 10, 2026 20:48
@b-l-u-e b-l-u-e force-pushed the chore/lf-line-endings-and-pre-commit-ci branch from 6f1a5f0 to 6537613 Compare May 21, 2026 18:16
b-l-u-e added 3 commits May 21, 2026 21:45
Add .gitattributes with  plus explicit binary marks
for the Tor bundle executables, versioned shared libraries
(libssl.so.1.1 etc.), and the bundled SQLite database. Previously these
relied on Git's content-based auto-detection and would otherwise have
inherited  from the wildcard rule.
Add .editorconfig so editors apply the same LF / final-newline /
trim-trailing-whitespace policy on save.
Add  to the mixed-line-ending pre-commit hook so it
no longer falls back to auto behavior.
No tool versions or other hook configurations are changed.

Signed-off-by: b-l-u-e <8102260+blue@users.noreply.github.com>
`make format` now operates only on files staged in the current commit:
after `ruff check --fix` on staged .py files, it runs a small Python
one-liner that rewrites CRLF -> LF on staged text files (whitelist of
known text extensions, so binaries are never touched).
Scoping to staged files keeps focused PRs from accidentally rewriting
unrelated files. Whole-tree lint fix is still `make ruff` and full CI
parity is still `make pre-commit`.
Signed-off-by: b-l-u-e <8102260+blue@users.noreply.github.com>
@b-l-u-e b-l-u-e force-pushed the chore/lf-line-endings-and-pre-commit-ci branch from 6537613 to 2e2c4a6 Compare May 21, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant