Skip to content

Commit fa8d08d

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent f137664 commit fa8d08d

131 files changed

Lines changed: 546 additions & 539 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

conftest.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
Pytest conftest file for CNV tests
43
"""
@@ -704,10 +703,9 @@ def pytest_runtest_makereport(item, call):
704703

705704
elif report.failed:
706705
if reprcrash := getattr(report.longrepr, "reprcrash", None):
707-
if message := getattr(report.longrepr, "message", None):
708-
setattr(report, SETUP_ERROR, message)
709-
710-
elif message := getattr(reprcrash, "message", None):
706+
if (message := getattr(report.longrepr, "message", None)) or (
707+
message := getattr(reprcrash, "message", None)
708+
):
711709
setattr(report, SETUP_ERROR, message)
712710

713711

@@ -902,7 +900,7 @@ def is_skip_must_gather(node: Node) -> bool:
902900

903901
def get_inspect_command_namespace_string(node: Node, test_name: str) -> str:
904902
namespace_str = ""
905-
components = [key for key in NAMESPACE_COLLECTION.keys() if f"tests/{key}/" in test_name]
903+
components = [key for key in NAMESPACE_COLLECTION if f"tests/{key}/" in test_name]
906904
if not components:
907905
LOGGER.warning(f"{test_name} does not require special data collection on failure")
908906
else:

libs/net/netattachdef.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class IpamStatic(Ipam):
3535
"""
3636

3737
type: str = field(default="static", init=False)
38-
addresses: list["IpamStatic.Address"]
38+
addresses: list[IpamStatic.Address]
3939
routes: list[IpamRoute] | None = None
4040

4141
@dataclass
@@ -61,7 +61,7 @@ class CNIPluginBridgeConfig(CNIPluginConfig):
6161
mtu: int | None = None
6262
vlan: int | None = None
6363
macspoofchk: bool | None = None
64-
disableContainerInterface: bool | None = None # noqa: N815
64+
disableContainerInterface: bool | None = None
6565

6666

6767
@dataclass
@@ -76,8 +76,8 @@ class CNIPluginOvnK8sConfig(CNIPluginConfig):
7676

7777
type: str = field(default="ovn-k8s-cni-overlay", init=False)
7878
topology: str
79-
netAttachDefName: str # noqa: N815
80-
vlanID: int | None = None # noqa: N815
79+
netAttachDefName: str
80+
vlanID: int | None = None
8181
subnets: str | None = None
8282

8383
class Topology(Enum):
@@ -106,7 +106,7 @@ class NetConfig:
106106

107107
name: str
108108
plugins: list[CNIPluginConfig]
109-
cniVersion: str = _DEFAULT_CNI_VERSION # noqa: N815
109+
cniVersion: str = _DEFAULT_CNI_VERSION
110110

111111

112112
class NetworkAttachmentDefinition(NamespacedResource):

libs/net/traffic_generator.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import contextlib
22
import logging
33
from abc import ABC, abstractmethod
4-
from typing import Final, Generator
4+
from collections.abc import Generator
5+
from typing import Final
56

67
from ocp_resources.pod import Pod
78
from ocp_utilities.exceptions import CommandExecFailed
@@ -32,7 +33,7 @@ def server_ip(self) -> str:
3233
return self._server_ip
3334

3435
@abstractmethod
35-
def __enter__(self) -> "BaseTcpClient":
36+
def __enter__(self) -> BaseTcpClient:
3637
pass
3738

3839
@abstractmethod
@@ -66,7 +67,7 @@ def __init__(
6667
self._cmd = f"{_IPERF_BIN} --server --port {self._port} --one-off"
6768
self._cmd += f" --bind {bind_ip}" if bind_ip else ""
6869

69-
def __enter__(self) -> "TcpServer":
70+
def __enter__(self) -> TcpServer:
7071
self._vm.console(
7172
commands=[f"{self._cmd} &"],
7273
timeout=_DEFAULT_CMD_TIMEOUT_SEC,
@@ -113,7 +114,7 @@ def __init__(
113114
self._vm = vm
114115
self._cmd += f" --set-mss {maximum_segment_size}" if maximum_segment_size else ""
115116

116-
def __enter__(self) -> "VMTcpClient":
117+
def __enter__(self) -> VMTcpClient:
117118
self._vm.console(
118119
commands=[f"{self._cmd} &"],
119120
timeout=_DEFAULT_CMD_TIMEOUT_SEC,
@@ -174,7 +175,7 @@ def __init__(self, pod: Pod, server_ip: str, server_port: int, bind_interface: s
174175
self._container = _IPERF_BIN
175176
self._cmd += f" --bind {bind_interface}" if bind_interface else ""
176177

177-
def __enter__(self) -> "PodTcpClient":
178+
def __enter__(self) -> PodTcpClient:
178179
# run the command in the background using nohup to ensure it keeps running after the exec session ends
179180
self._pod.execute(
180181
command=["sh", "-c", f"nohup {self._cmd} >/tmp/{_IPERF_BIN}.log 2>&1 &"], container=self._container
@@ -204,7 +205,7 @@ def active_tcp_connections(
204205
client_vm: BaseVirtualMachine,
205206
server_vm: BaseVirtualMachine,
206207
iface_name: str,
207-
) -> Generator[list[tuple[VMTcpClient, TcpServer]], None, None]:
208+
) -> Generator[list[tuple[VMTcpClient, TcpServer]]]:
208209
"""Start iperf3 client-server connections for all IPs on the server's interface.
209210
The helper assumed the ip addresses are up.
210211
@@ -242,7 +243,7 @@ def client_server_active_connection(
242243
port: int = IPERF_SERVER_PORT,
243244
maximum_segment_size: int = 0,
244245
ip_family: int = 4,
245-
) -> Generator[tuple[VMTcpClient, TcpServer], None, None]:
246+
) -> Generator[tuple[VMTcpClient, TcpServer]]:
246247
"""Start iperf3 client-server connection with continuous TCP traffic flow.
247248
248249
Automatically starts an iperf3 server and client, with traffic flowing continuously
@@ -265,11 +266,13 @@ def client_server_active_connection(
265266
Traffic runs with infinite duration until context exits.
266267
"""
267268
server_ip = str(lookup_iface_status_ip(vm=server_vm, iface_name=spec_logical_network, ip_family=ip_family))
268-
with TcpServer(vm=server_vm, port=port, bind_ip=server_ip) as server:
269-
with VMTcpClient(
269+
with (
270+
TcpServer(vm=server_vm, port=port, bind_ip=server_ip) as server,
271+
VMTcpClient(
270272
vm=client_vm,
271273
server_ip=server_ip,
272274
server_port=port,
273275
maximum_segment_size=maximum_segment_size,
274-
) as client:
275-
yield client, server
276+
) as client,
277+
):
278+
yield client, server

libs/storage/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def __init__(self, name: str):
2626
self.name = name
2727
self.storage_config = self.get_storage_config()
2828

29-
def supported_storage_classes(self) -> list["StorageClass"]:
29+
def supported_storage_classes(self) -> list[StorageClass]:
3030
return [
3131
StorageClass(
3232
name=StorageClassNames.CEPH_RBD_VIRTUALIZATION,

libs/vm/spec.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
@dataclass
1010
class VMSpec:
1111
template: Template
12-
runStrategy: str = VirtualMachine.RunStrategy.HALTED # noqa: N815
12+
runStrategy: str = VirtualMachine.RunStrategy.HALTED
1313

1414

1515
@dataclass
@@ -29,7 +29,7 @@ class VMISpec:
2929
domain: Domain
3030
networks: list[Network] | None = None
3131
volumes: list[Volume] | None = None
32-
terminationGracePeriodSeconds: int | None = None # noqa: N815
32+
terminationGracePeriodSeconds: int | None = None
3333
affinity: Affinity | None = None
3434

3535

@@ -74,7 +74,7 @@ class Interface:
7474
masquerade: dict[Any, Any] | None = None
7575
bridge: dict[Any, Any] | None = None
7676
sriov: dict[Any, Any] | None = None
77-
passtBinding: dict[Any, Any] | None = None # noqa: N815
77+
passtBinding: dict[Any, Any] | None = None
7878
binding: NetBinding | None = None
7979
state: str | None = None
8080

@@ -93,30 +93,30 @@ class Network:
9393

9494
@dataclass
9595
class Multus:
96-
networkName: str # noqa: N815
96+
networkName: str
9797

9898

9999
@dataclass
100100
class Affinity:
101-
podAntiAffinity: PodAntiAffinity # noqa: N815
101+
podAntiAffinity: PodAntiAffinity
102102

103103

104104
@dataclass
105105
class PodAntiAffinity:
106-
requiredDuringSchedulingIgnoredDuringExecution: list[PodAffinityTerm] # noqa: N815
106+
requiredDuringSchedulingIgnoredDuringExecution: list[PodAffinityTerm]
107107

108108

109109
@dataclass
110110
class PodAffinityTerm:
111-
labelSelector: LabelSelector # noqa: N815
112-
topologyKey: str # noqa: N815
113-
namespaceSelector: dict[str, Any] | None = None # noqa: N815
111+
labelSelector: LabelSelector
112+
topologyKey: str
113+
namespaceSelector: dict[str, Any] | None = None
114114
namespaces: list[str] | None = None
115115

116116

117117
@dataclass
118118
class LabelSelector:
119-
matchExpressions: list[LabelSelectorRequirement] # noqa: N815
119+
matchExpressions: list[LabelSelectorRequirement]
120120

121121

122122
@dataclass
@@ -129,8 +129,8 @@ class LabelSelectorRequirement:
129129
@dataclass
130130
class Volume:
131131
name: str
132-
containerDisk: ContainerDisk | None = None # noqa: N815
133-
cloudInitNoCloud: CloudInitNoCloud | None = None # noqa: N815
132+
containerDisk: ContainerDisk | None = None
133+
cloudInitNoCloud: CloudInitNoCloud | None = None
134134

135135

136136
@dataclass
@@ -140,5 +140,5 @@ class ContainerDisk:
140140

141141
@dataclass
142142
class CloudInitNoCloud:
143-
networkData: str # noqa: N815
144-
userData: str | None = None # noqa: N815
143+
networkData: str
144+
userData: str | None = None

scripts/tests_analyzer/pytest_marker_analyzer.py

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env -S uv run python
22

3-
# flake8: noqa: N802
43

54
"""
65
Pytest Marker Analyzer
@@ -949,10 +948,9 @@ def _process_test_file_for_markers(
949948
if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)):
950949
if node.name.startswith("test_"):
951950
for decorator in node.decorator_list:
952-
if is_marker(decorator=decorator, marker_names=marker_names):
953-
tests.append(node.name)
954-
break
955-
elif check_parametrize_marks(decorator=decorator, marker_names=marker_names):
951+
if is_marker(decorator=decorator, marker_names=marker_names) or check_parametrize_marks(
952+
decorator=decorator, marker_names=marker_names
953+
):
956954
tests.append(node.name)
957955
break
958956
elif isinstance(node, ast.ClassDef):
@@ -971,10 +969,9 @@ def _process_test_file_for_markers(
971969
if isinstance(item, (ast.FunctionDef, ast.AsyncFunctionDef)):
972970
if item.name.startswith("test_"):
973971
for decorator in item.decorator_list:
974-
if is_marker(decorator=decorator, marker_names=marker_names):
975-
tests.append(f"{node.name}::{item.name}")
976-
break
977-
elif check_parametrize_marks(decorator=decorator, marker_names=marker_names):
972+
if is_marker(
973+
decorator=decorator, marker_names=marker_names
974+
) or check_parametrize_marks(decorator=decorator, marker_names=marker_names):
978975
tests.append(f"{node.name}::{item.name}")
979976
break
980977

@@ -2294,9 +2291,7 @@ def _check_test_impact(
22942291
narrowed_func_symbols: set[str] = set()
22952292
for sym in common_symbols:
22962293
# Keep class symbols (already handled by member narrowing above)
2297-
if sym in classification.modified_members:
2298-
narrowed_func_symbols.add(sym)
2299-
elif sym in test_calls:
2294+
if sym in classification.modified_members or sym in test_calls:
23002295
narrowed_func_symbols.add(sym)
23012296
elif sym[0].isupper():
23022297
# Uppercase = likely a class name — keep conservatively
@@ -3093,11 +3088,9 @@ def _extract_marked_tests_from_file(self, file_path: Path) -> list[str]:
30933088
# Module-level function with marker
30943089
if node.name.startswith("test_"):
30953090
for decorator in node.decorator_list:
3096-
if is_marker(decorator=decorator, marker_names=self.marker_names):
3097-
tests.append(node.name)
3098-
break
3099-
# Also check for markers in parametrize pytest.param(..., marks=...)
3100-
elif check_parametrize_marks(decorator=decorator, marker_names=self.marker_names):
3091+
if is_marker(
3092+
decorator=decorator, marker_names=self.marker_names
3093+
) or check_parametrize_marks(decorator=decorator, marker_names=self.marker_names):
31013094
tests.append(node.name)
31023095
break
31033096

@@ -3122,11 +3115,9 @@ def _extract_marked_tests_from_file(self, file_path: Path) -> list[str]:
31223115
if item.name.startswith("test_"):
31233116
# Check method-level markers
31243117
for decorator in item.decorator_list:
3125-
if is_marker(decorator=decorator, marker_names=self.marker_names):
3126-
tests.append(f"{node.name}::{item.name}")
3127-
break
3128-
# Also check parametrize marks
3129-
elif check_parametrize_marks(
3118+
if is_marker(
3119+
decorator=decorator, marker_names=self.marker_names
3120+
) or check_parametrize_marks(
31303121
decorator=decorator, marker_names=self.marker_names
31313122
):
31323123
tests.append(f"{node.name}::{item.name}")

tests/chaos/oadp/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ def rebooted_vm_source_node(rhel_vm_with_dv_running, oadp_backup_in_progress, wo
7676

7777
LOGGER.info(f"Waiting for node {vm_node.name} to come back online")
7878
wait_for_node_status(node=vm_node, status=True, wait_timeout=TIMEOUT_10MIN)
79-
return
8079

8180

8281
@pytest.fixture()

tests/conftest.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import tempfile
1515
from bisect import bisect_left
1616
from collections import defaultdict
17-
from datetime import datetime, timezone
17+
from datetime import UTC, datetime
1818
from signal import SIGINT, SIGTERM, getsignal, signal
1919
from subprocess import check_output
2020

@@ -266,7 +266,7 @@ def session_start_time() -> datetime:
266266
Returns:
267267
datetime: UTC timestamp when test session began (timezone-naive)
268268
"""
269-
return datetime.now(timezone.utc).replace(tzinfo=None)
269+
return datetime.now(UTC).replace(tzinfo=None)
270270

271271

272272
@pytest.fixture(scope="session")
@@ -2311,16 +2311,16 @@ def rhel_vm_with_instance_type_and_preference(
23112311
with (
23122312
instance_type_for_test_scope_class as vm_instance_type,
23132313
vm_preference_for_test as vm_preference,
2314-
):
2315-
with VirtualMachineForTests(
2314+
VirtualMachineForTests(
23162315
client=unprivileged_client,
23172316
name="rhel-vm-with-instance-type",
23182317
namespace=namespace.name,
23192318
image=Images.Rhel.RHEL9_REGISTRY_GUEST_IMG,
23202319
vm_instance_type=vm_instance_type,
23212320
vm_preference=vm_preference,
2322-
) as vm:
2323-
yield vm
2321+
) as vm,
2322+
):
2323+
yield vm
23242324

23252325

23262326
@pytest.fixture(scope="session")

tests/global_config_amd64.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@
3131
if _dir in ["encoding", "py_file"]:
3232
continue
3333

34-
config[_dir] = locals()[_dir] # noqa: F821
34+
config[_dir] = locals()[_dir]

tests/global_config_arm64.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,4 @@
6363
if _dir in ["encoding", "py_file"]:
6464
continue
6565

66-
config[_dir] = locals()[_dir] # noqa: F821
66+
config[_dir] = locals()[_dir]

0 commit comments

Comments
 (0)