From b29af5c410815371e2ae72edcd03e309b5f0fd02 Mon Sep 17 00:00:00 2001 From: Ruth Netser Date: Thu, 14 May 2026 15:37:07 +0300 Subject: [PATCH] CherryPicked: [v4.19]ci(deps): lock file maintenance (v4.20) (#2720) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * CherryPicked: [v4.20] ci(deps): lock file maintenance (main) (#2715) * ci(deps): lock file maintenance (main) (#2702) * ci(deps): lock file maintenance * Update Python compatibility markers and modernize code Update resolution markers to support Python 3.12 as primary version with 3.11 as fallback. Modernize Python 3.10+ syntax by replacing typing constructs with built-in generics (Optional → None union, List → list, Tuple → tuple). Update imports to use traceback at module level and refactor error handling from assert to raise AssertionError. Simplify failure summary output by removing truncation logic. Replace uv.lock with updated dependencies reflecting Python version changes. * chore: update pre-commit dependencies Update ruff to v0.15.12, gitleaks to v8.30.1, and mypy to v1.20.2. Also remove unnecessary space in string join operation in test fixture. * Fix CLI tool invocations with missing configuration flags Update pytest, prek, and ruff commands to include their required configuration flags. Add `--group tests` to pytest invocation, add `-c .pre-commit-config.yaml` to prek invocation, and add `--config pyproject.toml` to ruff invocation. Also remove extra space in string join operation for consistency. * test: Update pytest invocation with test dependency group The pytest command in the CLI test now includes the `--group tests` flag to ensure the test dependencies are available when running pytest through the uv package manager. * Refactor imports in class_generator_template.j2 Reorganize imports to improve readability and add conditional import for MissingRequiredArgumentError. The exception import is now only included when there are required arguments that will actually use it, reducing unnecessary dependencies in generated classes with no required arguments. * Remove extra blank line in class_generator_template.j2 * Improve file formatting with prek and ruff fallback Add ruff as a fallback formatter when prek fails. Extract project root path calculation to module level and pass configuration paths explicitly to prek. Introduce _run_ruff_fallback() helper that runs ruff check and ruff format sequentially. Update logging to clarify fallback behavior and fix typo in prek stdout log message. --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Meni Yakove * fix: revert ruff to v0.14.2, fix mock tests, regenerate manifests - Revert ruff from v0.15.12 to v0.14.2 in pre-commit config to avoid 90+ new lint errors from stricter rules on maintenance branch - Fix TestCheckAndUpdateClusterVersion mock tests by adding _get_open_mode() helper to handle missing positional mode argument - Regenerate 18 test manifest files to match current generator output Assisted-by: Claude --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Meni Yakove Co-authored-by: rnetser * fix: restore OAuth/Pipeline tests and regenerate manifests - Re-add OAuth and Pipeline to test_parse_explain test list — they were accidentally dropped during cherry-pick conflict resolution - Regenerate Image, OAuth, and Pipeline manifest files to match current generator output Assisted-by: Claude --------- Signed-off-by: Ruth Netser --- .pre-commit-config.yaml | 4 ++-- class_generator/manifests/class_generator_template.j2 | 6 +++++- class_generator/tests/manifests/APIServer/api_server.py | 1 + .../tests/manifests/ClusterOperator/cluster_operator.py | 1 + class_generator/tests/manifests/ConfigMap/config_map.py | 1 + .../tests/manifests/DNS/dns_config_openshift_io.py | 1 + .../tests/manifests/DNS/dns_operator_openshift_io.py | 1 + class_generator/tests/manifests/Deployment/deployment.py | 4 +++- .../tests/manifests/Image/image_config_openshift_io.py | 1 + .../tests/manifests/Image/image_image_openshift_io.py | 1 + .../ImageContentSourcePolicy/image_content_source_policy.py | 1 + class_generator/tests/manifests/Machine/machine.py | 1 + class_generator/tests/manifests/NMState/nm_state.py | 1 + class_generator/tests/manifests/OAuth/oauth.py | 1 + class_generator/tests/manifests/Pipeline/pipeline.py | 1 + class_generator/tests/manifests/Pod/pod.py | 4 +++- class_generator/tests/manifests/Secret/secret.py | 1 + .../manifests/ServiceMeshMember/service_mesh_member.py | 4 +++- .../tests/manifests/ServingRuntime/serving_runtime.py | 4 +++- 19 files changed, 32 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 01dbe7a3fa..1ca0ce6c69 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -47,12 +47,12 @@ repos: - id: ruff-format - repo: https://github.com/gitleaks/gitleaks - rev: v8.24.0 + rev: v8.30.1 hooks: - id: gitleaks - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.15.0 + rev: v1.20.2 hooks: - id: mypy exclude: ^(tests/|examples/|docs/) diff --git a/class_generator/manifests/class_generator_template.j2 b/class_generator/manifests/class_generator_template.j2 index e208c5e77d..3070ef9dae 100644 --- a/class_generator/manifests/class_generator_template.j2 +++ b/class_generator/manifests/class_generator_template.j2 @@ -8,7 +8,11 @@ {% endfor %} from typing import Any -from ocp_resources.resource import {{ base_class }}, MissingRequiredArgumentError + +{% if all_required_args %} +from ocp_resources.exceptions import MissingRequiredArgumentError +{% endif %} +from ocp_resources.resource import {{ base_class }} class {{ kind }}({{ base_class }}): diff --git a/class_generator/tests/manifests/APIServer/api_server.py b/class_generator/tests/manifests/APIServer/api_server.py index d6c013da98..8a263877ad 100644 --- a/class_generator/tests/manifests/APIServer/api_server.py +++ b/class_generator/tests/manifests/APIServer/api_server.py @@ -3,6 +3,7 @@ from __future__ import annotations from typing import Any + from ocp_resources.resource import Resource diff --git a/class_generator/tests/manifests/ClusterOperator/cluster_operator.py b/class_generator/tests/manifests/ClusterOperator/cluster_operator.py index e0d6524734..1ff4746568 100644 --- a/class_generator/tests/manifests/ClusterOperator/cluster_operator.py +++ b/class_generator/tests/manifests/ClusterOperator/cluster_operator.py @@ -3,6 +3,7 @@ from __future__ import annotations from typing import Any + from ocp_resources.resource import Resource diff --git a/class_generator/tests/manifests/ConfigMap/config_map.py b/class_generator/tests/manifests/ConfigMap/config_map.py index f719e9076e..522fa1cc8d 100644 --- a/class_generator/tests/manifests/ConfigMap/config_map.py +++ b/class_generator/tests/manifests/ConfigMap/config_map.py @@ -3,6 +3,7 @@ from __future__ import annotations from typing import Any + from ocp_resources.resource import NamespacedResource diff --git a/class_generator/tests/manifests/DNS/dns_config_openshift_io.py b/class_generator/tests/manifests/DNS/dns_config_openshift_io.py index 6b559662b8..de3890a0dc 100644 --- a/class_generator/tests/manifests/DNS/dns_config_openshift_io.py +++ b/class_generator/tests/manifests/DNS/dns_config_openshift_io.py @@ -3,6 +3,7 @@ from __future__ import annotations from typing import Any + from ocp_resources.resource import Resource diff --git a/class_generator/tests/manifests/DNS/dns_operator_openshift_io.py b/class_generator/tests/manifests/DNS/dns_operator_openshift_io.py index 14ada9d251..3cdb5ca94e 100644 --- a/class_generator/tests/manifests/DNS/dns_operator_openshift_io.py +++ b/class_generator/tests/manifests/DNS/dns_operator_openshift_io.py @@ -3,6 +3,7 @@ from __future__ import annotations from typing import Any + from ocp_resources.resource import Resource diff --git a/class_generator/tests/manifests/Deployment/deployment.py b/class_generator/tests/manifests/Deployment/deployment.py index 4f2738b3c3..d6804d27e0 100644 --- a/class_generator/tests/manifests/Deployment/deployment.py +++ b/class_generator/tests/manifests/Deployment/deployment.py @@ -3,7 +3,9 @@ from __future__ import annotations from typing import Any -from ocp_resources.resource import NamespacedResource, MissingRequiredArgumentError + +from ocp_resources.exceptions import MissingRequiredArgumentError +from ocp_resources.resource import NamespacedResource class Deployment(NamespacedResource): diff --git a/class_generator/tests/manifests/Image/image_config_openshift_io.py b/class_generator/tests/manifests/Image/image_config_openshift_io.py index 7fe9806b68..9138051045 100644 --- a/class_generator/tests/manifests/Image/image_config_openshift_io.py +++ b/class_generator/tests/manifests/Image/image_config_openshift_io.py @@ -3,6 +3,7 @@ from __future__ import annotations from typing import Any + from ocp_resources.resource import Resource diff --git a/class_generator/tests/manifests/Image/image_image_openshift_io.py b/class_generator/tests/manifests/Image/image_image_openshift_io.py index cdefd7130f..bdfdd0b558 100644 --- a/class_generator/tests/manifests/Image/image_image_openshift_io.py +++ b/class_generator/tests/manifests/Image/image_image_openshift_io.py @@ -3,6 +3,7 @@ from __future__ import annotations from typing import Any + from ocp_resources.resource import Resource diff --git a/class_generator/tests/manifests/ImageContentSourcePolicy/image_content_source_policy.py b/class_generator/tests/manifests/ImageContentSourcePolicy/image_content_source_policy.py index 1691c20956..5ca3be4219 100644 --- a/class_generator/tests/manifests/ImageContentSourcePolicy/image_content_source_policy.py +++ b/class_generator/tests/manifests/ImageContentSourcePolicy/image_content_source_policy.py @@ -3,6 +3,7 @@ from __future__ import annotations from typing import Any + from ocp_resources.resource import Resource diff --git a/class_generator/tests/manifests/Machine/machine.py b/class_generator/tests/manifests/Machine/machine.py index 70853bd84f..176178419c 100644 --- a/class_generator/tests/manifests/Machine/machine.py +++ b/class_generator/tests/manifests/Machine/machine.py @@ -3,6 +3,7 @@ from __future__ import annotations from typing import Any + from ocp_resources.resource import NamespacedResource diff --git a/class_generator/tests/manifests/NMState/nm_state.py b/class_generator/tests/manifests/NMState/nm_state.py index 19bfc7557d..bedb4ca61e 100644 --- a/class_generator/tests/manifests/NMState/nm_state.py +++ b/class_generator/tests/manifests/NMState/nm_state.py @@ -3,6 +3,7 @@ from __future__ import annotations from typing import Any + from ocp_resources.resource import Resource diff --git a/class_generator/tests/manifests/OAuth/oauth.py b/class_generator/tests/manifests/OAuth/oauth.py index 7d363f8090..fe8718a514 100644 --- a/class_generator/tests/manifests/OAuth/oauth.py +++ b/class_generator/tests/manifests/OAuth/oauth.py @@ -3,6 +3,7 @@ from __future__ import annotations from typing import Any + from ocp_resources.resource import Resource diff --git a/class_generator/tests/manifests/Pipeline/pipeline.py b/class_generator/tests/manifests/Pipeline/pipeline.py index a7a26a6d51..924ef89cf9 100644 --- a/class_generator/tests/manifests/Pipeline/pipeline.py +++ b/class_generator/tests/manifests/Pipeline/pipeline.py @@ -3,6 +3,7 @@ from __future__ import annotations from typing import Any + from ocp_resources.resource import NamespacedResource diff --git a/class_generator/tests/manifests/Pod/pod.py b/class_generator/tests/manifests/Pod/pod.py index e9c069b2a1..d16725e524 100644 --- a/class_generator/tests/manifests/Pod/pod.py +++ b/class_generator/tests/manifests/Pod/pod.py @@ -3,7 +3,9 @@ from __future__ import annotations from typing import Any -from ocp_resources.resource import NamespacedResource, MissingRequiredArgumentError + +from ocp_resources.exceptions import MissingRequiredArgumentError +from ocp_resources.resource import NamespacedResource class Pod(NamespacedResource): diff --git a/class_generator/tests/manifests/Secret/secret.py b/class_generator/tests/manifests/Secret/secret.py index d01e214591..38b682c116 100644 --- a/class_generator/tests/manifests/Secret/secret.py +++ b/class_generator/tests/manifests/Secret/secret.py @@ -3,6 +3,7 @@ from __future__ import annotations from typing import Any + from ocp_resources.resource import NamespacedResource diff --git a/class_generator/tests/manifests/ServiceMeshMember/service_mesh_member.py b/class_generator/tests/manifests/ServiceMeshMember/service_mesh_member.py index f0e59d0ae3..00c51f4a85 100644 --- a/class_generator/tests/manifests/ServiceMeshMember/service_mesh_member.py +++ b/class_generator/tests/manifests/ServiceMeshMember/service_mesh_member.py @@ -3,7 +3,9 @@ from __future__ import annotations from typing import Any -from ocp_resources.resource import NamespacedResource, MissingRequiredArgumentError + +from ocp_resources.exceptions import MissingRequiredArgumentError +from ocp_resources.resource import NamespacedResource class ServiceMeshMember(NamespacedResource): diff --git a/class_generator/tests/manifests/ServingRuntime/serving_runtime.py b/class_generator/tests/manifests/ServingRuntime/serving_runtime.py index fb61db4777..8e2f9d2ed0 100644 --- a/class_generator/tests/manifests/ServingRuntime/serving_runtime.py +++ b/class_generator/tests/manifests/ServingRuntime/serving_runtime.py @@ -3,7 +3,9 @@ from __future__ import annotations from typing import Any -from ocp_resources.resource import NamespacedResource, MissingRequiredArgumentError + +from ocp_resources.exceptions import MissingRequiredArgumentError +from ocp_resources.resource import NamespacedResource class ServingRuntime(NamespacedResource):