Skip to content

Commit 8d2508d

Browse files
committed
fix: Fix upcoming ruff 0.15 lints
1 parent ef853ff commit 8d2508d

7 files changed

Lines changed: 15 additions & 13 deletions

File tree

src/gallia/command/config.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def err_int(x: str, base: int) -> int:
6565
HexBytes = Annotated[
6666
bytes,
6767
BeforeValidator(lambda x: x if isinstance(x, bytes) else binascii.unhexlify(x)),
68-
PlainSerializer(lambda x: binascii.hexlify(x)),
68+
PlainSerializer(binascii.hexlify),
6969
]
7070
"""
7171
Special type for a field, which parses bytes from hex strings.
@@ -96,11 +96,13 @@ def _process_ranges(value: Any) -> Any:
9696
Ranges2D = Annotated[
9797
dict[int, list[int] | None],
9898
BeforeValidator(
99-
lambda x: x
100-
if isinstance(x, dict)
101-
else unravel_2d(" ".join(x))
102-
if isinstance(x, list)
103-
else unravel_2d(x)
99+
lambda x: (
100+
x
101+
if isinstance(x, dict)
102+
else unravel_2d(" ".join(x))
103+
if isinstance(x, list)
104+
else unravel_2d(x)
105+
)
104106
),
105107
]
106108
"""

src/gallia/commands/scan/uds/memory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ async def scan_memory_address(self, addr_offset: int = 0) -> None:
8888
pdu += bytes([0])
8989
pdu += bytes([addr_and_length_identifier])
9090
pdu += addr_bytes + mem_size_bytes
91-
pdu += data if data else b""
91+
pdu += data or b""
9292

9393
if (
9494
self.config.session is not None

src/gallia/db/handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ async def insert_scan_result(
389389
response_attributes["sub_function"] = response.sub_function
390390

391391
for attr, value in response.__dict__.items():
392-
if not attr.startswith("_") and attr not in ["trigger_request"]:
392+
if not attr.startswith("_") and attr != "trigger_request":
393393
response_attributes[attr] = value
394394

395395
if isinstance(value, bytes | bytearray):

src/gallia/dumpcap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ async def dumpcap_argument_list_eth(host: str, port: int | None = None) -> list[
5454
if proxy := os.getenv("all_proxy"):
5555
url = urlparse(proxy)
5656
host = str(url.hostname) if url.hostname else "localhost"
57-
port = url.port if url.port else 1080 # Default SOCKS port
57+
port = url.port or 1080 # Default SOCKS port
5858

5959
# Resolve host string to ip address
6060
loop = asyncio.get_running_loop()

src/gallia/net.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ def split_host_port(
3737
if host == "":
3838
# urlparse() and urlsplit() insists on absolute URLs starting with "//".
3939
url = urlparse(f"//{hostport}")
40-
host = url.hostname if url.hostname else url.netloc
41-
port = url.port if url.port else default_port
40+
host = url.hostname or url.netloc
41+
port = url.port or default_port
4242
return host, port
4343

4444

src/gallia/services/uds/core/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ async def request_unsafe(
122122
MAX_N_PENDING = 120
123123
n_timeout = 0
124124
waiting_time = 0.5
125-
max_n_timeout = max(timeout if timeout else 0, 20) / waiting_time
125+
max_n_timeout = max(timeout or 0, 20) / waiting_time
126126
while (
127127
isinstance(resp, service.NegativeResponse)
128128
and resp.response_code == UDSErrorCodes.requestCorrectlyReceivedResponsePending

src/gallia/services/uds/core/service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ def __repr__(self) -> str:
351351
relevant_attributes = {}
352352

353353
for attr, value in self.__dict__.items():
354-
if not attr.startswith("_") and attr not in ["trigger_request"]:
354+
if not attr.startswith("_") and attr != "trigger_request":
355355
relevant_attributes[attr] = any_repr(value)
356356

357357
attributes = ", ".join(f"{attr}={value}" for attr, value in relevant_attributes.items())

0 commit comments

Comments
 (0)