Fix CRLF being counted as two line breaks with preserve_blank_lines #104
All Vouch review confidence checks passed
Residual risk 0.04 = Change Risk (0.20) × (1 − Review Confidence (0.81)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.20 · 13 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.71 · 2 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.158
Real PR Conversation Timeline
5 items
Approved
Approved these changes.
Ugh... line endings... :/
It seems like preserve should probably preserve blank lines from the input stream, i.e., not convert the line endings:
self.assertEqual(titlecase('a\r\nb', preserve_blank_lines=True), 'A\r\nB')
Thoughts? I just maintain this as a convenience for people — honestly I don't even use the library anymore — so if you have a compelling use case one way or the other I'm open to it.
Changes Requested
Requested changes.
Part of a general cleanup on my end, closing this along with the rest of what I had open.
alerque
afonsojanu
Closes #103.
preserve_blank_lines=Truesplits the input on the character class[\r\n], which matches each of\rand\nseparately. A Windows-style\r\nline ending is therefore split into two pieces with an empty string between them, and that empty string turns into an extra blank line once the pieces are joined back together with\n.This changes the split to match a full line-ending sequence (
\r\n,\r, or\n) instead of any single character in that class, so CRLF is treated as one line break like it should be. Thepreserve_blank_lines=Falsebranch already used[\r\n]+and doesn't have this problem, so it's untouched.Added a test case covering CRLF and lone-CR input under
preserve_blank_lines=True, since the existing blank-line tests only exercised\n.