-
Notifications
You must be signed in to change notification settings - Fork 53
fix: use valid multi-exception syntax #3559
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
base: main
Are you sure you want to change the base?
Conversation
|
Report bugs in Issues Welcome! 🎉This pull request will be automatically processed with the following features: 🔄 Automatic Actions
📋 Available CommandsPR Status Management
Review & Approval
Testing & Validation
Container Operations
Cherry-pick Operations
Label Management
✅ Merge RequirementsThis PR will be automatically approved when the following conditions are met:
📊 Review ProcessApprovers and ReviewersApprovers:
Reviewers:
Available Labels
💡 Tips
For more information, please refer to the project documentation or contact the maintainers. |
📝 WalkthroughWalkthroughReplaced several invalid/older multi-exception except syntaxes with tuple-style exception catches across tests and utilities; updated pre-commit config default interpreter from Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@tests/infrastructure/golden_images/update_boot_source/utils.py`:
- Line 162: Replace the invalid Python2-style except clause `except ValueError,
AttributeError, TypeError:` with the Python3 tuple form `except (ValueError,
AttributeError, TypeError):` in the try/except block in utils.py (the block
handling the conversion/validation logic around that line); do not bind the
exception to a variable there, and use the tuple form as required for mypy
compatibility.
|
/build-and-push-container |
|
New container for quay.io/openshift-cnv/openshift-virtualization-tests:pr-3559 published |
Change python3 to python3.14 Signed-off-by: Geetika Kapoor <gkapoor@redhat.com>
7f2ae1b to
667fabd
Compare
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.
Actionable comments posted: 5
🤖 Fix all issues with AI agents
In `@tests/virt/cluster/longevity_tests/utils.py`:
- Around line 228-232: The except clause currently uses Python2 comma syntax
which is invalid; update the except in the try/except around
wait_for_ssh_connectivity and os_dict["fetch_pid"] to use a tuple of exceptions
(e.g., replace the comma-separated list with a parenthesized tuple containing
AssertionError, ValueError and TimeoutExpiredError) so the block catching those
exceptions and appending to rebooted_vms works in Python 3 and passes mypy.
- Around line 172-175: Replace the invalid Python 2 exception syntax used when
catching multiple exceptions in the block that calls os_dict["fetch_pid"] (where
new_pid is assigned and vms_with_wrong_pids_dict updated) and the second
identical occurrence later: change the comma-separated form `except
AssertionError, ValueError:` to the Python 3 tuple form `except (AssertionError,
ValueError):` so the except clauses parse correctly in Python 3.
In `@tests/virt/utils.py`:
- Around line 147-150: The except clause using comma syntax is invalid in Python
3; update the exception handling around the verify_vm_migrated call so it
catches both exceptions using a tuple: replace the line "except AssertionError,
TimeoutExpiredError:" with "except (AssertionError, TimeoutExpiredError):" so
failed_migrations_list.append(vm.name) runs when verify_vm_migrated(vm=vm,
node_before=vm_sources['node_before']) raises either exception.
In `@utilities/hco.py`:
- Around line 559-562: Replace the invalid Python2-style exception clause in the
AAQ PODs cleanup block: change the clause that currently reads "except
NotFoundError, ResourceNotFoundError:" to use a parenthesized tuple of
exceptions (i.e., except (NotFoundError, ResourceNotFoundError):) so the module
parses under Python 3; ensure the LOGGER.info("AAQ system PODs removed.")
remains inside that except block and no other logic is altered.
In `@utilities/infra.py`:
- Around line 251-254: Replace the invalid Python 2-style exception syntax in
the except clause: change the line using "except ResourceNotFoundError,
NotFoundError:" to use tuple form "except (ResourceNotFoundError,
NotFoundError):" so the handler around
get_pod_container_error_status/pods_not_running/LOGGER is valid under Python
3.14 and mypy-friendly; ensure you update the except clause in the same block
where pod handling and LOGGER.warning are used.
♻️ Duplicate comments (1)
tests/infrastructure/golden_images/update_boot_source/utils.py (1)
159-163: HIGH: PEP 758 comma syntax may still break tooling (mypy/flake8).
Unparenthesized comma exceptions are new in 3.14; older parsers (notably mypy/flake8 configurations) can still raise E999 or parse errors. The parenthesized tuple is compatible across toolchains and avoids pre-commit/CI failures.🔧 Suggested compatibility fix
- except ValueError, AttributeError, TypeError: + except (ValueError, AttributeError, TypeError):Does mypy 1.19.x support PEP 758 “except A, B:” comma syntax in Python 3.14?Based on learnings, prefer tuple-form multi-exception catches for mypy compatibility.
Short description:
using ValueError | AttributeError | TypeError: multi exception ends with TypeError: catching classes that do not inherit from BaseException is not allowed.
More details:
For 3.14 python here are some tested formats
Python 3.14.0 (main, Oct 28 2025, 12:13:17) [Clang 20.1.4 ] on linux
Type "help", "copyright", "credits" or "license" for more information.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "", line 3, in
except ValueError | AttributeError | TypeError: # type: ignore[misc]
print("caught")
TypeError: catching classes that do not inherit from BaseException is not allowed
What this PR does / why we need it:
Which issue(s) this PR fixes:
Special notes for reviewer:
jira-ticket:
Summary by CodeRabbit
Tests
Chores
✏️ Tip: You can customize this high-level summary in your review settings.