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

Fix EnsureListOf() and EnsureTupleOf() for string inputs #7267

Merged

Conversation

nobodyinperson
Copy link
Contributor

EnsureListOf() and EnsureTupleOf() took string inputs as iterables. This PR fixes this.

(I don't understand this scriv thing, scriv create etc. all error out with unfound files, so I'll leave it to you to add this CHANGELOG label.)

@codecov
Copy link

codecov bot commented Jan 19, 2023

Codecov Report

Base: 88.72% // Head: 90.55% // Increases project coverage by +1.82% 🎉

Coverage data is based on head (e581732) compared to base (c92ae3a).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##            maint    #7267      +/-   ##
==========================================
+ Coverage   88.72%   90.55%   +1.82%     
==========================================
  Files         326      326              
  Lines       44423    44425       +2     
  Branches     5919        0    -5919     
==========================================
+ Hits        39415    40229     +814     
+ Misses       4993     4196     -797     
+ Partials       15        0      -15     
Impacted Files Coverage Δ
datalad/support/constraints.py 89.95% <100.00%> (ø)
datalad/tests/test_constraints.py 100.00% <100.00%> (ø)
datalad/support/nda_.py 0.00% <0.00%> (-54.55%) ⬇️
datalad/customremotes/ria_remote.py 55.55% <0.00%> (-11.12%) ⬇️
datalad/cli/interface.py 97.22% <0.00%> (-2.78%) ⬇️
datalad/support/network.py 88.22% <0.00%> (-2.60%) ⬇️
datalad/support/s3.py 40.00% <0.00%> (-2.27%) ⬇️
datalad/utils.py 86.35% <0.00%> (-1.62%) ⬇️
datalad/local/remove.py 95.31% <0.00%> (-1.57%) ⬇️
datalad/support/json_py.py 97.56% <0.00%> (-1.22%) ⬇️
... and 15 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@adswa adswa added semver-patch Increment the patch version when merged CHANGELOG-missing When a PR's description does not contain a changelog item, yet. labels Jan 19, 2023
@github-actions github-actions bot removed the CHANGELOG-missing When a PR's description does not contain a changelog item, yet. label Jan 19, 2023
@@ -157,7 +157,7 @@ def __init__(self, dtype):
super(EnsureTupleOf, self).__init__()

def __call__(self, value):
return tuple(map(self._dtype, value))
return tuple(map(self._dtype, ([value] if isinstance(value, str) else value)))
Copy link
Member

Choose a reason for hiding this comment

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

Well spotted.
To reduce code duplication: I think in this both cases we could just use ensure_list or ensure_tuple in both cases from https://github.com/datalad/datalad/blob/HEAD/datalad/utils.py#L734.

Copy link
Member

@adswa adswa left a comment

Choose a reason for hiding this comment

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

This PR can be merged from my point of view

@yarikoptic
Copy link
Member

Let's do it then. tuneups to reduce code duplication could be done later.

@yarikoptic-gitmate
Copy link
Collaborator

PR released in 0.18.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-patch Increment the patch version when merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants