Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

io.metadata: Fix newline handling when reading CSV/TSV #1561

Merged
merged 2 commits into from
Jul 30, 2024

Conversation

tsibley
Copy link
Member

@tsibley tsibley commented Jul 30, 2024

The csv module very clearly documents¹ that the "newline" parameter should be set to the empty string so that the csv module can itself do proper embedded newline handling. Follow that recommendation. This change shouldn't affect existing inputs that worked fine but now allows inputs with embedded newlines in fields.

The previously-added failing test now passes.

¹ https://docs.python.org/3/library/csv.html#id4

Checklist

  • Automated checks pass
  • Check if you need to add a changelog message
  • Check if you need to add tests
  • Check if you need to update docs

The "newline" parameter in write_lines() is changed so that newline
translation doesn't take place, which would make it harder to reason
about what our tests are actually testing.
The csv module very clearly documents¹ that the "newline" parameter
should be set to the empty string so that the csv module can itself do
proper embedded newline handling.  Follow that recommendation.  This
change shouldn't affect existing inputs that worked fine but now allows
inputs with embedded newlines in fields.

The previously-added failing test now passes.

¹ <https://docs.python.org/3/library/csv.html#id4>
@tsibley tsibley force-pushed the trs/metadata-newline-handling branch from f399316 to a6b7265 Compare July 30, 2024 23:33
@tsibley tsibley merged commit 2c88298 into master Jul 30, 2024
28 checks passed
@tsibley tsibley deleted the trs/metadata-newline-handling branch July 30, 2024 23:45
@genehack genehack mentioned this pull request Jul 31, 2024
12 tasks
Copy link

codecov bot commented Oct 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.22%. Comparing base (f814e86) to head (a6b7265).
Report is 132 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1561   +/-   ##
=======================================
  Coverage   70.22%   70.22%           
=======================================
  Files          74       74           
  Lines        7952     7952           
  Branches     1945     1945           
=======================================
  Hits         5584     5584           
  Misses       2082     2082           
  Partials      286      286           

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

@tsibley
Copy link
Member Author

tsibley commented Oct 29, 2024

wtf @codecov?

@victorlin
Copy link
Member

I've noticed this here and there within the last few months, on PRs that have been merged over a year ago. Looks like it's a known issue: codecov/feedback#497

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants