-
Notifications
You must be signed in to change notification settings - Fork 308
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
Allow defining empty username and password in .pypirc #426
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,7 @@ | |
def get_config(path="~/.pypirc"): | ||
# even if the config file does not exist, set up the parser | ||
# variable to reduce the number of if/else statements | ||
parser = configparser.RawConfigParser() | ||
parser = configparser.RawConfigParser(allow_no_value=True) | ||
|
||
# this list will only be used if index-servers | ||
# is not defined in the config file | ||
|
@@ -195,7 +195,7 @@ def get_userpass_value(cli_value, config, key, prompt_strategy=None): | |
""" | ||
if cli_value is not None: | ||
return cli_value | ||
elif config.get(key): | ||
elif key in config: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that config always defaults with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you don't add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's where you're mistaken. Keys are set unconditionally to default to None. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if I don't have a
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The defaults still get copied into every repository. |
||
return config[key] | ||
elif prompt_strategy: | ||
return prompt_strategy() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Today I learned that
allow_no_value=True
allows for:But with
allow_no_value=False
,username=
andpassword=
are still valid and still result in empty strings.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With
allow_no_value=False
, if the config file is of the form:the
username
andpassword
key won't be available in the parsed config.Or am I mistaking?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, the parser will raise an Exception, but naked
username
orpassword
was not the prescribed syntax; ratherusername:
(which I assume is equivalent tousername=
) was.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, now I remember why I had to add
allow_no_value=True
in order to allow empty value.What's the difference between adding
:
(or=
), and using naked keys?Is it parsed differently?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Adding the separator causes the value to be parsed as the empty string. Not including the separator creates a ParseException unless
allow_no_value=True
in which case the value isNone
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. The intent of my PR was to be able to provide a
None
value in the configuration file in order to be anonymous.Without this PR, you wouldn't be able to provide such value, so the CLI would systematically ask for a login/password (which I didn't want).