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

resolve #6733 make empty env vars sequence-safe for sequence parameters #6741

Merged
merged 4 commits into from
Feb 17, 2018

Conversation

kalefranz
Copy link
Contributor

resolve #6733

@mbargull Let's see how this works... I don't even know if there's a situation where we'd actually want an empty string, instead of just an empty sequence.

@kalefranz kalefranz force-pushed the resolve-6733-empty-env-var-config branch from 3b6dfcb to a9981e1 Compare January 17, 2018 19:30
@@ -210,9 +210,9 @@ def value(self, parameter_obj):
# TODO: add stripping of !important, !top, and !bottom
raw_value = self._raw_value
if string_delimiter in raw_value:
Copy link
Member

Choose a reason for hiding this comment

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

self._raw_value is always a str, right?
str.split always returns a list of strings so that you can simplify the whole if-else-block to

value = [v for v in self._raw_value.split(string_delimiter) if v]

. If you want to allow empty strings anywhere in the sequence, you could use a trailing separator to distinguish ""->[] from ","->[""] with

value = self._raw_value.split(string_delimiter)  # str.split always returns a list with length >=1
value = value if value[-1] else value[:-1]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

self._raw_value is always a str, right?

I guess in this case that's safe to assume. I feel like I'd want to add an assert in there though just to be safe.

If you want to allow empty strings anywhere in the sequence

Can you think of a use-case that we currently have, or one that we could potentially have, where you'd ever want an empty string? I can't, at the moment.

Copy link
Member

Choose a reason for hiding this comment

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

The currently available SequenceParameters in base/context.py are lists of packages (specs), features, paths (/subdirs), or channels.
So, no real use case there. Hence this would be more of a "possible forward-compatibility" decision.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I say for now that we don't support empty strings. I can see it just as easily causing us problems in the future, as it could saving us from a future problem.

Copy link
Member

Choose a reason for hiding this comment

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

That's fine by me. My mind is oscillating between 30/70, 50/50, and 70/30 on whether the one or the other possibility would cause more potential issues. Currently I'm slightly more leaning toward removing empty strings, just like you did 😉. So, be fast and merge before I change my mind again and again 😝

@kalefranz kalefranz force-pushed the resolve-6733-empty-env-var-config branch from a2a6abe to 37cbb36 Compare January 17, 2018 21:20
@kalefranz kalefranz added this to the 4.4 milestone Jan 17, 2018
Copy link
Contributor

@mcg1969 mcg1969 left a comment

Choose a reason for hiding this comment

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

What can we / should we do to test this change?

@kalefranz
Copy link
Contributor Author

Unit test added!

Copy link
Member

@mbargull mbargull left a comment

Choose a reason for hiding this comment

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

LGTM

@kalefranz kalefranz modified the milestones: 4.4, 4.4.11 Feb 13, 2018
@jjhelmus jjhelmus merged commit 30523a8 into conda:4.4.x Feb 17, 2018
@jjhelmus jjhelmus deleted the resolve-6733-empty-env-var-config branch February 17, 2018 04:04
@github-actions
Copy link

github-actions bot commented Sep 6, 2021

Hi there, thank you for your contribution to Conda!

This pull request has been automatically locked since it has not had recent activity after it was closed.

Please open a new issue or pull request if needed.

@github-actions github-actions bot added the locked [bot] locked due to inactivity label Sep 6, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked [bot] locked due to inactivity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants