Skip to content

Commit

Permalink
Handle case of list default values in UpdatingDefaultsHelpFormatter
Browse files Browse the repository at this point in the history
Happens because we pass a list from --extra-index-url
  • Loading branch information
Noah Gorny committed Dec 2, 2020
1 parent 8bc9c33 commit 4a19272
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions news/9191.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Handle case of list default values in UpdatingDefaultsHelpFormatter
Happens because we pass a list from --extra-index-url
13 changes: 8 additions & 5 deletions src/pip/_internal/cli/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,18 @@ class UpdatingDefaultsHelpFormatter(PrettyHelpFormatter):
"""

def expand_default(self, option):
default_value = None
default_values = None
if self.parser is not None:
self.parser._update_defaults(self.parser.defaults)
default_value = self.parser.defaults.get(option.dest)
default_values = self.parser.defaults.get(option.dest)
help_text = optparse.IndentedHelpFormatter.expand_default(self, option)

if default_value and option.metavar == 'URL':
help_text = help_text.replace(
default_value, redact_auth_from_url(default_value))
if default_values and option.metavar == 'URL':
if not isinstance(default_values, list):
default_values = [default_values]
for val in default_values:
help_text = help_text.replace(
val, redact_auth_from_url(val))

return help_text

Expand Down

0 comments on commit 4a19272

Please sign in to comment.