Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/13703.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix fallthrough logic for options (allowing for overriding global options with default again from user config)
22 changes: 12 additions & 10 deletions src/pip/_internal/cli/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,23 +185,25 @@ def _get_ordered_configuration_items(
override_order = ["global", self.name, ":env:"]

# Pool the options into different groups
section_items: dict[str, list[tuple[str, Any]]] = {
name: [] for name in override_order
# Use a dict because we need to implement the fallthrough logic after PR 12201
# was merged which removed the fallthrough logic for options
section_items_dict: dict[str, dict[str, Any]] = {
name: {} for name in override_order
}

for _, value in self.config.items():
for section_key, val in value.items():
# ignore empty values
if not val:
logger.debug(
"Ignoring configuration key '%s' as its value is empty.",
section_key,
)
continue

section, key = section_key.split(".", 1)
if section in override_order:
section_items[section].append((key, val))
section_items_dict[section][key] = val

# Now that we a dict of items per section, convert to list of tuples
# Make sure we completely remove empty values again
section_items = {
name: [(k, v) for k, v in section_items_dict[name].items() if v]
for name in override_order
}

# Yield each group in their override order
for section in override_order:
Expand Down