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

Improve error handling, documentation and tests of itertools #548

Merged
merged 4 commits into from
Nov 27, 2023

Conversation

mih
Copy link
Member

@mih mih commented Nov 27, 2023

Extracted and modified from #539

mypy complains:

datalad_next/itertools/itemize.py:110: error: Argument "sep" to "split" of "bytes" has incompatible type "str | bytes"; expected "Buffer | None"  [arg-type]
datalad_next/itertools/itemize.py:110: error: Argument "sep" to "split" of "str" has incompatible type "str | bytes"; expected "str | None"  [arg-type]
datalad_next/itertools/itemize.py:114: error: Argument 1 to "endswith" of "bytes" has incompatible type "str | bytes"; expected "Buffer | tuple[Buffer, ...]"  [arg-type]
datalad_next/itertools/itemize.py:114: error: Argument 1 to "endswith" of "str" has incompatible type "str | bytes"; expected "str | tuple[str, ...]"  [arg-type]
datalad_next/itertools/itemize.py:121: error: Unsupported operand types for + ("bytes" and "str")  [operator]
datalad_next/itertools/itemize.py:121: error: Unsupported operand types for + ("str" and "bytes")  [operator]
datalad_next/itertools/itemize.py:121: note: Both left and right operands are unions

Copy link
Contributor

@christian-monch christian-monch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for including the documentation here.

I just have a few remarks regarding the runtime of itemize when keep_ends=True is specified. The runtime is only depending on the value of keep_ends if sep is not None.

datalad_next/itertools/itemize.py Outdated Show resolved Hide resolved
datalad_next/itertools/decode_bytes.py Outdated Show resolved Hide resolved
datalad_next/itertools/decode_bytes.py Outdated Show resolved Hide resolved
datalad_next/itertools/itemize.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Nov 27, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (54f8abe) 83.65% compared to head (4a54380) 92.66%.

❗ Current head 4a54380 differs from pull request most recent head 73a3d31. Consider uploading reports for the commit 73a3d31 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #548      +/-   ##
==========================================
+ Coverage   83.65%   92.66%   +9.00%     
==========================================
  Files         137      137              
  Lines       10035    10049      +14     
  Branches     1085     1086       +1     
==========================================
+ Hits         8395     9312     +917     
+ Misses       1632      713     -919     
- Partials        8       24      +16     

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

This commit fixes a bug in `decode_bytes`
where an empty string was yielded as a
result.

A regression test was added as well.

The bug was the reason for one of the
errors created by `doctest-modules`
This commit adds a number of `+SKIP`
flags to code examples in order to
prevent their execution. The execution
would fail since the example code lines
are not generic tests.
@mih mih merged commit 4cf164b into datalad:main Nov 27, 2023
5 of 7 checks passed
@mih mih deleted the enh-itertools branch November 27, 2023 14:01
@mih mih added this to the 1.1 milestone Dec 6, 2023
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.

2 participants