Skip to content

Commit 63dc83b

Browse files
Refactor: Updates and fixes for Ruff 0.15.0 (#6499)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Mahesh Kumar <122076792+MaheshGSLAB@users.noreply.github.com> Co-authored-by: MaheshGSLAB <mahesh.kumar-ext@arista.com>
1 parent aa964c4 commit 63dc83b

9 files changed

Lines changed: 13 additions & 13 deletions

File tree

.github/generate_release.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def increase_indent(self, flow: bool = False, *_args: Any, **_kwargs: Any) -> No
8585
# First add Breaking Changes EXCEPT `pyavd`
8686
# TODO: should we consider changing this and adding back pyavd?
8787
breaking_label_categories = ["Feat", "Fix", "Cut", "Revert", "Refactor", "Bump"]
88-
breaking_labels = [f"rn: {cc_type}({scope})!" for cc_type in breaking_label_categories for scope in SCOPES if scope not in ["pyavd"]]
88+
breaking_labels = [f"rn: {cc_type}({scope})!" for cc_type in breaking_label_categories for scope in SCOPES if scope != "pyavd"]
8989
breaking_labels.extend([f"rn: {cc_type}!" for cc_type in breaking_label_categories])
9090

9191
categories_list.append(

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ repos:
110110

111111
- repo: https://github.com/astral-sh/ruff-pre-commit
112112
# Ruff version.
113-
rev: v0.14.14
113+
rev: v0.15.0
114114
hooks:
115115
# Run the linter.
116116
- id: ruff

ansible_collections/arista/avd/extensions/scripts/processor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def process_config(config_path: str, output_dir: str | None = None) -> None:
139139

140140
# Use job-specific output_dir if provided, otherwise use the global one
141141
job_output_dir: str | None = job.get("output_dir")
142-
final_output_dir: str | None = job_output_dir if job_output_dir else output_dir
142+
final_output_dir: str | None = job_output_dir or output_dir
143143

144144
if not final_output_dir:
145145
logger.error("ERROR: No output_dir specified for artifact '%s'", artifact_filename)

python-avd/pyavd/_cv/client/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ async def proxy_connection() -> H2Protocol:
107107

108108
# Create the gRPC protocol using the proxy socket
109109
_, protocol = await loop.create_connection(
110-
lambda: channel._protocol_factory(),
110+
channel._protocol_factory,
111111
sock=proxy_sock,
112112
ssl=channel._ssl,
113113
server_hostname=self._servers[0] if ssl_context else None,

python-avd/pyavd/_cv/client/configlet.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# that can be found in the LICENSE file.
44
from __future__ import annotations
55

6-
from asyncio import gather
6+
from asyncio import gather, to_thread
77
from logging import getLogger
88
from pathlib import Path
99
from typing import TYPE_CHECKING, Literal, Protocol
@@ -349,7 +349,7 @@ async def set_configlet_from_file(
349349
key=ConfigletKey(workspace_id=workspace_id, configlet_id=configlet_id),
350350
display_name=display_name,
351351
description=description,
352-
body=Path(file).read_text(encoding="UTF-8"),
352+
body=await to_thread(Path.read_text, Path(file), encoding="UTF-8"),
353353
),
354354
)
355355
client = ConfigletConfigServiceStub(self._channel)
@@ -384,7 +384,7 @@ async def set_configlets_from_files(
384384
key=ConfigletKey(workspace_id=workspace_id, configlet_id=configlet_id),
385385
display_name=display_name,
386386
description=description,
387-
body=Path(file).read_text(encoding="UTF-8"),
387+
body=await to_thread(Path.read_text, Path(file), encoding="UTF-8"),
388388
)
389389
)
390390
client = ConfigletConfigServiceStub(self._channel)

python-avd/pyavd/_eos_designs/structured_config/base/platform_mixin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def _build_interface_with_rx_queue_settings(
115115
name=l3_ethernet_interface.name,
116116
rx_queue=EosCliConfigGen.Platform.Sfe.Interface.ProfilesItem.InterfacesItem.RxQueue(
117117
count=l3_ethernet_interface.rx_queue.count,
118-
worker=rx_queue_workers_range if rx_queue_workers_range else None,
118+
worker=rx_queue_workers_range or None,
119119
mode=l3_ethernet_interface.rx_queue.mode,
120120
),
121121
)

python-avd/pyavd/_eos_designs/structured_config/network_services/ethernet_interfaces.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def _set_l3_port_channel_members(
7474
interface_description = member_intf.description
7575
# derive values for peer from parent L3 port-channel
7676
# if not defined explicitly for member interface
77-
peer = member_intf.peer if member_intf.peer else l3_port_channel.peer
77+
peer = member_intf.peer or l3_port_channel.peer
7878
if not interface_description:
7979
elems = [peer, member_intf.peer_interface]
8080
if elems:
@@ -84,7 +84,7 @@ def _set_l3_port_channel_members(
8484
name=member_intf.name,
8585
description=interface_description or None,
8686
shutdown=not l3_port_channel.enabled,
87-
speed=member_intf.speed if member_intf.speed else None,
87+
speed=member_intf.speed or None,
8888
)
8989
ethernet_interface.metadata._update(peer_interface=member_intf.peer_interface or None, peer_type="l3_port_channel_member", peer=peer or None)
9090
ethernet_interface.channel_group.id = int(channel_group_id)

python-avd/pyavd/_eos_designs/structured_config/network_services/port_channel_interfaces.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def _set_l3_port_channels(
131131
vrf=vrf.name if vrf.name != "default" else None,
132132
)
133133
port_channel_interface.metadata._update(
134-
peer_interface=l3_port_channel.peer_port_channel if l3_port_channel.peer_port_channel else None,
134+
peer_interface=l3_port_channel.peer_port_channel or None,
135135
peer=l3_port_channel.peer,
136136
peer_type="l3_port_channel",
137137
)

python-avd/pyavd/_eos_designs/structured_config/underlay/ethernet_interfaces.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def _set_l3_port_channel_member_ports(
325325
for member_intf in l3_port_channel.member_interfaces:
326326
# derive values for peer from parent L3 port-channel
327327
# if not defined explicitly for member interface
328-
peer = member_intf.peer if member_intf.peer else l3_port_channel.peer
328+
peer = member_intf.peer or l3_port_channel.peer
329329
interface_description = self.shared_utils.interface_descriptions.underlay_ethernet_interface(
330330
InterfaceDescriptionData(
331331
shared_utils=self.shared_utils,
@@ -339,7 +339,7 @@ def _set_l3_port_channel_member_ports(
339339
name=member_intf.name,
340340
description=interface_description or None,
341341
shutdown=not l3_port_channel.enabled,
342-
speed=member_intf.speed if member_intf.speed else None,
342+
speed=member_intf.speed or None,
343343
channel_group=EosCliConfigGen.EthernetInterfacesItem.ChannelGroup(id=int(channel_group_id), mode=l3_port_channel.mode),
344344
)
345345
ethernet_interface.metadata._update(peer_interface=member_intf.peer_interface, peer_type="l3_port_channel_member", peer=peer)

0 commit comments

Comments
 (0)