Skip to content

chore: update to python 3.14#1160

Merged
dbasunag merged 5 commits intoopendatahub-io:mainfrom
dbasunag:python_version
Mar 10, 2026
Merged

chore: update to python 3.14#1160
dbasunag merged 5 commits intoopendatahub-io:mainfrom
dbasunag:python_version

Conversation

@dbasunag
Copy link
Copy Markdown
Collaborator

@dbasunag dbasunag commented Mar 2, 2026

Pull Request

Summary

Related Issues

  • Fixes:
  • JIRA:

How it has been tested

  • Locally
  • Jenkins

Additional Requirements

  • If this PR introduces a new test image, did you create a PR to mirror it in disconnected environment?
  • If this PR introduces new marker(s)/adds a new component, was relevant ticket created to update relevant Jenkins job?

Summary by CodeRabbit

  • Chores
    • Updated project Python requirement from 3.13 to 3.14 across configuration files.
    • Updated Docker base image from Fedora 42 to Fedora 43.
    • Aligned development and test tooling (pre-commit, tox, CI/test environments) to use Python 3.14 for consistency.
    • Minor internal error-handling and test-related updates; no intended user-facing behavior changes.

@dbasunag dbasunag requested a review from a team as a code owner March 2, 2026 19:37
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 2, 2026

The following are automatically added/executed:

  • PR size label.
  • Run pre-commit
  • Run tox
  • Add PR author as the PR assignee
  • Build image based on the PR

Available user actions:

  • To mark a PR as WIP, add /wip in a comment. To remove it from the PR comment /wip cancel to the PR.
  • To block merging of a PR, add /hold in a comment. To un-block merging of PR comment /hold cancel.
  • To mark a PR as approved, add /lgtm in a comment. To remove, add /lgtm cancel.
    lgtm label removed on each new commit push.
  • To mark PR as verified comment /verified to the PR, to un-verify comment /verified cancel to the PR.
    verified label removed on each new commit push.
  • To Cherry-pick a merged PR /cherry-pick <target_branch_name> to the PR. If <target_branch_name> is valid,
    and the current PR is merged, a cherry-picked PR would be created and linked to the current PR.
  • To build and push image to quay, add /build-push-pr-image in a comment. This would create an image with tag
    pr-<pr_number> to quay repository. This image tag, however would be deleted on PR merge or close action.
Supported labels

{'/hold', '/verified', '/lgtm', '/cherry-pick', '/wip', '/build-push-pr-image'}

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 2, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 411e3ab9-c39a-4fab-b7b1-635438db2e3a

📥 Commits

Reviewing files that changed from the base of the PR and between ba4d009 and 86012f6.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • .pre-commit-config.yaml
  • tests/conftest.py
  • tests/model_registry/model_catalog/search/utils.py
  • utilities/infra.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • .pre-commit-config.yaml

📝 Walkthrough

Walkthrough

Bumps Python references from 3.13 → 3.14 across configs and Dockerfile (also Fedora 42 → 43). Multiple files replace tuple multi-except syntax except (A, B): with a non-tuple form except A, B:, which is invalid in Python 3 and will produce parse errors. One type-hint change in RedactedString.__new__. Actionable issue: invalid except syntax (CWE-20).

Changes

Cohort / File(s) Summary
Config & Build
\.pre-commit-config.yaml, pyproject.toml, tox.ini, Dockerfile
Updated Python references from 3.133.14; Dockerfile base image bumped fedora:42fedora:43 and adjusted system package/python package names.
Tests — except syntax changed
tests/conftest.py, tests/model_registry/model_catalog/search/utils.py, tests/model_serving/model_server/kserve/inference_graph/conftest.py, tests/model_serving/model_server/maas_billing/utils.py
Replaced except (A, B): with except A, B: in multiple test files — invalid Python 3 syntax that will fail to parse.
Utilities — except syntax changed
utilities/infra.py, utilities/plugins/openai_plugin.py
Replaced tuple-based multi-except with non-tuple form, introducing Python 3 parse errors.
Type hint tweak
utilities/logger.py
Changed return annotation of RedactedString.__new__ from string literal ("RedactedString") to direct class reference RedactedString (type-hint only).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning PR description is entirely empty except for the template structure; no actual summary, related issues, testing details, or additional context provided. Fill in the Summary section with specifics on Python 3.14 changes, note any breaking changes (e.g., MR client issue), document testing performed, and check off or explain additional requirements.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed Title clearly and concisely describes the main change: updating Python version to 3.14 across configuration files, dependencies, and Docker setup.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a 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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tox.ini (1)

7-21: ⚠️ Potential issue | 🟠 Major

Pin the pytest tox env to Python 3.14 as well.

Line 7 is pinned, but Lines 16-21 still allow interpreter drift. That can validate tests on a non-3.14 runtime and miss compatibility issues.

🔧 Proposed fix
 [testenv:pytest]
+basepython = python3.14
 deps =
   uv
 commands =
   uv run pytest --collect-only
   uv run pytest --setup-plan
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tox.ini` around lines 7 - 21, The [testenv:pytest] tox environment is not
pinned to Python 3.14, allowing interpreter drift; add a basepython = python3.14
setting inside the [testenv:pytest] block (the section headed
"[testenv:pytest]") so pytest runs use the same Python version as the global
basepython and avoid validating tests on a different runtime.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Dockerfile`:
- Around line 6-17: The dnf install line includes a non-existent package
python3.14-pip which breaks the build; edit the RUN dnf install command to
remove "python3.14-pip" and instead install pip after Python is present (e.g.,
use python3.14 -m ensurepip or python3.14 -m pip to bootstrap/upgrade pip in a
later RUN), and optionally set ENV UV_PYTHON to "3.14" instead of "python3.14"
(see ENV UV_PYTHON) to follow the recommended version format; keep the BIN_DIR
and PATH ENV entries as-is.

---

Outside diff comments:
In `@tox.ini`:
- Around line 7-21: The [testenv:pytest] tox environment is not pinned to Python
3.14, allowing interpreter drift; add a basepython = python3.14 setting inside
the [testenv:pytest] block (the section headed "[testenv:pytest]") so pytest
runs use the same Python version as the global basepython and avoid validating
tests on a different runtime.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between e4fada5 and 14d35ad.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • .pre-commit-config.yaml
  • Dockerfile
  • pyproject.toml
  • tox.ini

Comment thread Dockerfile
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 7

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/conftest.py`:
- Line 834: The except clause "except ValueError, TypeError:" is invalid in
Python 3; replace it with a parenthesized multi-except form "except (ValueError,
TypeError):" in the try/except block containing that clause (locate the exact
"except ValueError, TypeError" token and update it to use parentheses so the
module imports under Python 3).

In `@tests/model_registry/model_catalog/search/utils.py`:
- Line 407: The except clause using Python 2 comma syntax ("except ValueError,
TypeError:") is invalid in Python 3; locate that except statement in
tests/model_registry/model_catalog/search/utils.py and change it to either a
tuple-style multi-exception handler using parentheses (i.e., catch both
ValueError and TypeError in one except) or split into two separate except blocks
handling ValueError and TypeError individually, ensuring proper colon and
indentation.

In `@tests/model_serving/model_server/kserve/inference_graph/conftest.py`:
- Line 131: Replace the invalid Python2-style except clauses written as "except
AttributeError, KeyError:" with the Python3 tuple form "except (AttributeError,
KeyError):" for each occurrence (the three except clauses currently using that
syntax), ensuring the except statements around those blocks (e.g., in the test
conftest exception handlers) use the tuple form so both exceptions are caught
correctly.

In `@tests/model_serving/model_server/maas_billing/utils.py`:
- Line 102: Replace the invalid Python 2-style comma-separated exception
handlers with a tuple for Python 3: change occurrences of "except
JSONDecodeError, ValueError:" to "except (JSONDecodeError, ValueError):" (both
the instance around the JSON parsing at the location referencing JSONDecodeError
and the similar handler near line 403). Ensure the exception names
(JSONDecodeError and ValueError) remain imported/available in the module so the
new tuple-form except works.

In `@utilities/infra.py`:
- Line 990: The except line currently uses Python 2-style comma-separated
exceptions; update the exception handler handling ResourceNotFoundError and
NotFoundError by replacing the comma form with a tuple form (i.e., use a
parenthesized tuple of exceptions) so the except statement is valid in Python 3;
locate the handler that references ResourceNotFoundError and NotFoundError and
change its except clause accordingly.

In `@utilities/logger.py`:
- Line 17: The __new__ method's return annotation references RedactedString
before the class is fully defined; change the annotation to a forward reference
by quoting it (use "RedactedString") or use typing.Self (import Self from typing
or typing_extensions as appropriate) and update the import; specifically edit
def __new__(cls, *, value: object) -> RedactedString to either ->
"RedactedString" or -> Self and add the corresponding import so the annotation
resolves at runtime/type-check time.

In `@utilities/plugins/openai_plugin.py`:
- Line 107: Replace the invalid Python2-style exception clause `except
requests.exceptions.RequestException, json.JSONDecodeError:` with the Python3
multi-exception tuple form `except (requests.exceptions.RequestException,
json.JSONDecodeError):` in both places where that clause appears (the two
handlers shown in the diff); ensure you update both occurrences so they
correctly catch either RequestException or JSONDecodeError using the tuple
syntax and maintain the existing exception handling body.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 14d35ad and b9cbb07.

📒 Files selected for processing (7)
  • tests/conftest.py
  • tests/model_registry/model_catalog/search/utils.py
  • tests/model_serving/model_server/kserve/inference_graph/conftest.py
  • tests/model_serving/model_server/maas_billing/utils.py
  • utilities/infra.py
  • utilities/logger.py
  • utilities/plugins/openai_plugin.py

Comment thread tests/conftest.py
Comment thread tests/model_registry/model_catalog/search/utils.py
Comment thread tests/model_serving/model_server/kserve/inference_graph/conftest.py
Comment thread tests/model_serving/model_server/maas_billing/utils.py
Comment thread utilities/infra.py
Comment thread utilities/logger.py
Comment thread utilities/plugins/openai_plugin.py
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
Dockerfile (2)

11-12: Pre-existing issue: $HOME_DIR is undefined.

While not introduced by this PR, note that HOME_DIR is referenced here and at line 27 (WORKDIR $HOME_DIR), but only HOME is defined in the ARG declarations (line 4). This could cause unexpected behavior. Consider addressing this in a follow-up.

📝 Suggested fix (outside PR scope)
-ENV BIN_DIR="$HOME_DIR/.local/bin"
+ENV BIN_DIR="$HOME/.local/bin"

And at line 27:

-WORKDIR $HOME_DIR
+WORKDIR $HOME
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Dockerfile` around lines 11 - 12, The Dockerfile references an undefined
variable HOME_DIR in ENV BIN_DIR and WORKDIR; update the Dockerfile to either
define ARG/ENV HOME_DIR (e.g., set HOME_DIR to the same value as the existing
ARG/ENV HOME) or replace HOME_DIR with the already-defined HOME variable so ENV
BIN_DIR="$HOME/.local/bin" and WORKDIR use $HOME; modify the lines that set ENV
BIN_DIR, ENV PATH and WORKDIR to consistently use the defined symbol (HOME or
newly added HOME_DIR) to eliminate the undefined variable.

6-6: Consider using version-only format for UV_PYTHON.

The current UV_PYTHON=python3.14 works correctly. However, per uv documentation, the version-only format (UV_PYTHON=3.14) is the recommended approach. This is a minor nit and both formats are valid.

📝 Optional: Use recommended version format
-ENV UV_PYTHON=python3.14
+ENV UV_PYTHON=3.14
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Dockerfile` at line 6, Update the ENV setting for UV_PYTHON to use the
version-only format recommended by uv documentation: change the value of the ENV
variable UV_PYTHON from "python3.14" to "3.14" (i.e., modify the ENV UV_PYTHON
declaration to use "3.14" while keeping the ENV key name UV_PYTHON intact).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@Dockerfile`:
- Around line 11-12: The Dockerfile references an undefined variable HOME_DIR in
ENV BIN_DIR and WORKDIR; update the Dockerfile to either define ARG/ENV HOME_DIR
(e.g., set HOME_DIR to the same value as the existing ARG/ENV HOME) or replace
HOME_DIR with the already-defined HOME variable so ENV
BIN_DIR="$HOME/.local/bin" and WORKDIR use $HOME; modify the lines that set ENV
BIN_DIR, ENV PATH and WORKDIR to consistently use the defined symbol (HOME or
newly added HOME_DIR) to eliminate the undefined variable.
- Line 6: Update the ENV setting for UV_PYTHON to use the version-only format
recommended by uv documentation: change the value of the ENV variable UV_PYTHON
from "python3.14" to "3.14" (i.e., modify the ENV UV_PYTHON declaration to use
"3.14" while keeping the ENV key name UV_PYTHON intact).

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between b9cbb07 and fbc7e3b.

📒 Files selected for processing (1)
  • Dockerfile

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (7)
tests/model_serving/model_server/maas_billing/utils.py (1)

102-102: ⚠️ Potential issue | 🔴 Critical

Fix invalid multi-exception syntax in Python 3.

Line 102 and Line 403 use except A, B:, which is a SyntaxError in Python 3 and will break module import.

Proposed fix
-    except JSONDecodeError, ValueError:
+    except (JSONDecodeError, ValueError):
         body = {}
@@
-        except TypeError, ValueError:
+        except (TypeError, ValueError):
             if fail_if_missing:
#!/bin/bash
rg -nP '^\s*except\s+[^\(\n][^:\n]*,\s*[^:\n]+:' tests/model_serving/model_server/maas_billing/utils.py
python3 -m py_compile tests/model_serving/model_server/maas_billing/utils.py

Also applies to: 403-403

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/model_serving/model_server/maas_billing/utils.py` at line 102, Replace
the invalid Python2-style multi-exception syntax used in the except clauses with
the Python3 tuple form; specifically change occurrences like "except
JSONDecodeError, ValueError:" to "except (JSONDecodeError, ValueError):" (or use
two separate except blocks) in utils.py where the handlers for JSONDecodeError
and ValueError appear (also fix the similar clause around the other occurrence
near line 403), ensuring imports for JSONDecodeError are correct and the
exception handling logic remains the same.
utilities/plugins/openai_plugin.py (1)

107-107: ⚠️ Potential issue | 🔴 Critical

Use valid Python 3 except tuple syntax in both handlers.

Line 107 and Line 140 currently use invalid Python 2-style exception syntax.

Proposed fix
-        except requests.exceptions.RequestException, json.JSONDecodeError:
+        except (requests.exceptions.RequestException, json.JSONDecodeError):
             LOGGER.error("Streaming request error")
             raise
@@
-        except requests.exceptions.RequestException, json.JSONDecodeError:
+        except (requests.exceptions.RequestException, json.JSONDecodeError):
             LOGGER.exception("Request error")
#!/bin/bash
rg -nP '^\s*except\s+[^\(\n][^:\n]*,\s*[^:\n]+:' utilities/plugins/openai_plugin.py
python3 -m py_compile utilities/plugins/openai_plugin.py

Also applies to: 140-140

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@utilities/plugins/openai_plugin.py` at line 107, Replace the Python‑2 style
exception separators with a tuple in the except handlers: change occurrences of
"except requests.exceptions.RequestException, json.JSONDecodeError:" to "except
(requests.exceptions.RequestException, json.JSONDecodeError):" (and likewise for
the other handler) so the code uses valid Python 3 except tuple syntax; ensure
json is imported and update both exception lines in
utilities/plugins/openai_plugin.py where that pattern appears.
utilities/logger.py (1)

17-17: ⚠️ Potential issue | 🔴 Critical

Avoid unresolved self-reference in return annotation.

Line 17 now uses -> RedactedString, which is flagged as undefined (F821) and can break lint checks. Keep it as a forward reference string (or use Self).

Proposed fix
-    def __new__(cls, *, value: object) -> RedactedString:  # noqa: PYI034
+    def __new__(cls, *, value: object) -> "RedactedString":  # noqa: PYI034
         return super().__new__(cls, value)
#!/bin/bash
rg -n 'def __new__\(cls, \*, value: object\) -> RedactedString' utilities/logger.py
rg -n 'from __future__ import annotations' utilities/logger.py
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@utilities/logger.py` at line 17, The return annotation on the __new__ method
references RedactedString directly which is unresolved; update the annotation to
a forward-reference string or use a supported typing alias (e.g., change the
signature in the __new__ method to use "RedactedString" as a quoted forward
reference or import from __future__ import annotations or use typing.Self) so
lint F821 is resolved; modify the def __new__(cls, *, value: object) -> ... in
utilities/logger.py (method __new__ and the RedactedString type) accordingly and
ensure imports are adjusted if you opt to add from __future__ import annotations
or typing.Self.
utilities/infra.py (1)

990-990: ⚠️ Potential issue | 🔴 Critical

Fix Python 3 exception clause syntax.

Line 990 uses Python 2-style comma exception syntax and will raise SyntaxError in Python 3.

Proposed fix
-        except ResourceNotFoundError, NotFoundError:
+        except (ResourceNotFoundError, NotFoundError):
             LOGGER.info(f"Pod {pod.name} is deleted")
#!/bin/bash
rg -nP '^\s*except\s+[^\(\n][^:\n]*,\s*[^:\n]+:' utilities/infra.py
python3 -m py_compile utilities/infra.py
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@utilities/infra.py` at line 990, Replace the Python 2-style exception clause
"except ResourceNotFoundError, NotFoundError:" with a valid Python 3 form;
locate the except handling around ResourceNotFoundError and NotFoundError (the
single-line clause in utilities/infra.py) and change it to either a tuple-based
except (except (ResourceNotFoundError, NotFoundError):) or split into two except
blocks (except ResourceNotFoundError: and except NotFoundError:) so the syntax
is Python 3 compatible and the original error handling logic in that try/except
region remains intact.
tests/conftest.py (1)

834-834: ⚠️ Potential issue | 🔴 Critical

Use tuple-form multi-exception catch.

Line 834 uses invalid Python 3 syntax and must be parenthesized.

Proposed fix
-                except ValueError, TypeError:
+                except (ValueError, TypeError):
                     LOGGER.debug(f"Skipping non-integer allocatable for {key} on {node.name}: {val!r}")
                     continue
#!/bin/bash
rg -nP '^\s*except\s+[^\(\n][^:\n]*,\s*[^:\n]+:' tests/conftest.py
python3 -m py_compile tests/conftest.py
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/conftest.py` at line 834, Replace the invalid Python2-style except
clause "except ValueError, TypeError:" with the tuple-form multi-exception catch
by changing it to "except (ValueError, TypeError):" so the except block in
tests/conftest.py correctly catches both exceptions under Python 3; ensure the
indentation and any exception handling inside that block remain unchanged.
tests/model_serving/model_server/kserve/inference_graph/conftest.py (1)

131-131: ⚠️ Potential issue | 🔴 Critical

Restore Python 3-compatible exception handlers.

Line 131, Line 137, and Line 259 use comma-separated exceptions, which are invalid in Python 3.

Proposed fix
-    except AttributeError, KeyError:
+    except (AttributeError, KeyError):
         name = "dog-breed-pipeline"
@@
-    except AttributeError, KeyError:
+    except (AttributeError, KeyError):
         pass
@@
-    except AttributeError, KeyError:
+    except (AttributeError, KeyError):
         name = "sa-" + token_hex(4)
#!/bin/bash
rg -nP '^\s*except\s+[^\(\n][^:\n]*,\s*[^:\n]+:' tests/model_serving/model_server/kserve/inference_graph/conftest.py
python3 -m py_compile tests/model_serving/model_server/kserve/inference_graph/conftest.py

Also applies to: 137-137, 259-259

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/model_serving/model_server/kserve/inference_graph/conftest.py` at line
131, The except clauses use Python 2-style comma-separated exceptions (e.g.
"except AttributeError, KeyError:") which is invalid in Python 3; update each
such handler (the ones catching AttributeError and KeyError around the conftest
exception blocks referenced) to use a tuple form "except (AttributeError,
KeyError):" so both exceptions are caught properly, and repeat the same fix for
the other occurrences noted (the similar handlers at the other two locations)
then run a quick python3 -m py_compile to verify syntax.
tests/model_registry/model_catalog/search/utils.py (1)

407-407: ⚠️ Potential issue | 🔴 Critical

Fix Python 3 multi-exception syntax.

Line 407 uses comma-separated exceptions, which is invalid syntax in Python 3.

Proposed fix
-    except ValueError, TypeError:
+    except (ValueError, TypeError):
         return False, f"{key_name}: conversion error"
#!/bin/bash
rg -nP '^\s*except\s+[^\(\n][^:\n]*,\s*[^:\n]+:' tests/model_registry/model_catalog/search/utils.py
python3 -m py_compile tests/model_registry/model_catalog/search/utils.py
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/model_registry/model_catalog/search/utils.py` at line 407, Replace the
invalid Python 3 multi-exception syntax "except ValueError, TypeError:" with the
tuple form "except (ValueError, TypeError):" (or split into separate except
blocks) wherever that exact line appears (look for the "except ValueError,
TypeError:" token), update any associated error handling if splitting
exceptions, and re-run python3 -m py_compile to verify the file compiles.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@tests/conftest.py`:
- Line 834: Replace the invalid Python2-style except clause "except ValueError,
TypeError:" with the tuple-form multi-exception catch by changing it to "except
(ValueError, TypeError):" so the except block in tests/conftest.py correctly
catches both exceptions under Python 3; ensure the indentation and any exception
handling inside that block remain unchanged.

In `@tests/model_registry/model_catalog/search/utils.py`:
- Line 407: Replace the invalid Python 3 multi-exception syntax "except
ValueError, TypeError:" with the tuple form "except (ValueError, TypeError):"
(or split into separate except blocks) wherever that exact line appears (look
for the "except ValueError, TypeError:" token), update any associated error
handling if splitting exceptions, and re-run python3 -m py_compile to verify the
file compiles.

In `@tests/model_serving/model_server/kserve/inference_graph/conftest.py`:
- Line 131: The except clauses use Python 2-style comma-separated exceptions
(e.g. "except AttributeError, KeyError:") which is invalid in Python 3; update
each such handler (the ones catching AttributeError and KeyError around the
conftest exception blocks referenced) to use a tuple form "except
(AttributeError, KeyError):" so both exceptions are caught properly, and repeat
the same fix for the other occurrences noted (the similar handlers at the other
two locations) then run a quick python3 -m py_compile to verify syntax.

In `@tests/model_serving/model_server/maas_billing/utils.py`:
- Line 102: Replace the invalid Python2-style multi-exception syntax used in the
except clauses with the Python3 tuple form; specifically change occurrences like
"except JSONDecodeError, ValueError:" to "except (JSONDecodeError, ValueError):"
(or use two separate except blocks) in utils.py where the handlers for
JSONDecodeError and ValueError appear (also fix the similar clause around the
other occurrence near line 403), ensuring imports for JSONDecodeError are
correct and the exception handling logic remains the same.

In `@utilities/infra.py`:
- Line 990: Replace the Python 2-style exception clause "except
ResourceNotFoundError, NotFoundError:" with a valid Python 3 form; locate the
except handling around ResourceNotFoundError and NotFoundError (the single-line
clause in utilities/infra.py) and change it to either a tuple-based except
(except (ResourceNotFoundError, NotFoundError):) or split into two except blocks
(except ResourceNotFoundError: and except NotFoundError:) so the syntax is
Python 3 compatible and the original error handling logic in that try/except
region remains intact.

In `@utilities/logger.py`:
- Line 17: The return annotation on the __new__ method references RedactedString
directly which is unresolved; update the annotation to a forward-reference
string or use a supported typing alias (e.g., change the signature in the
__new__ method to use "RedactedString" as a quoted forward reference or import
from __future__ import annotations or use typing.Self) so lint F821 is resolved;
modify the def __new__(cls, *, value: object) -> ... in utilities/logger.py
(method __new__ and the RedactedString type) accordingly and ensure imports are
adjusted if you opt to add from __future__ import annotations or typing.Self.

In `@utilities/plugins/openai_plugin.py`:
- Line 107: Replace the Python‑2 style exception separators with a tuple in the
except handlers: change occurrences of "except
requests.exceptions.RequestException, json.JSONDecodeError:" to "except
(requests.exceptions.RequestException, json.JSONDecodeError):" (and likewise for
the other handler) so the code uses valid Python 3 except tuple syntax; ensure
json is imported and update both exception lines in
utilities/plugins/openai_plugin.py where that pattern appears.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between fbc7e3b and ba4d009.

📒 Files selected for processing (7)
  • tests/conftest.py
  • tests/model_registry/model_catalog/search/utils.py
  • tests/model_serving/model_server/kserve/inference_graph/conftest.py
  • tests/model_serving/model_server/maas_billing/utils.py
  • utilities/infra.py
  • utilities/logger.py
  • utilities/plugins/openai_plugin.py

@dbasunag
Copy link
Copy Markdown
Collaborator Author

dbasunag commented Mar 2, 2026

/build-push-pr-image

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 2, 2026

Status of building tag pr-1160: success.
Status of pushing tag pr-1160 to image registry: success.

@dbasunag
Copy link
Copy Markdown
Collaborator Author

dbasunag commented Mar 2, 2026

/hold @fege , @lugi0 mr client breaks with 3.14, I need to put a fix and see if it would be accepted first.

jgarciao
jgarciao previously approved these changes Mar 3, 2026
mwaykole
mwaykole previously approved these changes Mar 4, 2026
@github-actions github-actions bot added size/xxl and removed size/s labels Mar 9, 2026
Copy link
Copy Markdown
Contributor

@sheltoncyril sheltoncyril left a comment

Choose a reason for hiding this comment

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

/lgtm

Copy link
Copy Markdown
Contributor

@fege fege left a comment

Choose a reason for hiding this comment

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

/lgtm

@dbasunag
Copy link
Copy Markdown
Collaborator Author

/hold cancel

@dbasunag dbasunag merged commit 9a1ab3b into opendatahub-io:main Mar 10, 2026
12 checks passed
@dbasunag dbasunag deleted the python_version branch March 10, 2026 12:04
@github-actions
Copy link
Copy Markdown

Status of building tag latest: success.
Status of pushing tag latest to image registry: success.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants