Skip to content
Merged
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
16 changes: 15 additions & 1 deletion scripts/populate_tox/populate_tox.py
Original file line number Diff line number Diff line change
Expand Up @@ -1215,6 +1215,12 @@ def parse_args() -> argparse.Namespace:
default=[],
help="Integrations to skip version updates for.",
)
parser.add_argument(
"--only-update",
nargs="*",
default=[],
help="Only update versions for these integrations (all others will be skipped).",
)
Comment on lines +1218 to +1223

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Using the --only-update flag without any integration names causes all integrations to be updated, which is counter-intuitive and the opposite of the flag's intent.
Severity: LOW

Suggested Fix

Add a check after parsing arguments to ensure that if the --only-update flag was provided, its corresponding list of integrations is not empty. If it is empty, print an error message informing the user that they must provide at least one integration name and exit.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: scripts/populate_tox/populate_tox.py#L1218-L1223

Potential issue: When the `--only-update` flag is used without any integration names, it
is parsed as an empty list. This empty list is treated as a falsy value in the script's
logic. Consequently, the condition `only_update and integration not in only_update` in
the skip logic always evaluates to `False`. This causes the script to bypass the
intended filtering and proceed to update all integrations, which is the opposite of the
flag's purpose and happens without any warning to the user.

Also affects:

  • scripts/populate_tox/populate_tox.py:1286~1288
  • scripts/populate_tox/populate_tox.py:1306~1308

Did we get this right? 👍 / 👎 to inform future reviews.

return parser.parse_args()


Expand Down Expand Up @@ -1277,6 +1283,11 @@ def main() -> dict[str, list]:
}

args = parse_args()
if args.skip_version_update and args.only_update:
print("--skip-version-update and --only-update are mutually exclusive.")
sys.exit(1)

only_update = set(args.only_update)
skip_version_updates = set(args.skip_version_update)

# Process packages
Expand All @@ -1292,7 +1303,10 @@ def main() -> dict[str, list]:
package, extra = _get_package_name(integration)

test_releases = None
if integration in skip_version_updates:
skip = integration in skip_version_updates or (
only_update and integration not in only_update
)
if skip:
test_releases = get_existing_releases_to_test(integration)
else:
test_releases = get_releases_to_test(integration, package)
Expand Down
Loading