Skip to content

Commit 7f2b02f

Browse files
committed
Minor cleanup
Additional changes made by pypgrade which are not relevant for typing
1 parent c8f916a commit 7f2b02f

File tree

5 files changed

+7
-26
lines changed

5 files changed

+7
-26
lines changed

docs/_generate_requests_docstrings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def get_pydantic_fields(cls: type[BaseModel]) -> str:
109109

110110
def parse_file(file_path: str) -> list[ClassInfo]:
111111
"""Parse the file and extract class definitions."""
112-
with open(file_path, 'r') as file:
112+
with open(file_path) as file:
113113
lines = file.readlines()
114114
tree = ast.parse(''.join(lines))
115115

@@ -146,7 +146,7 @@ def update_class_docstrings(file_path: str) -> None:
146146
full_docstring = parent_docstring + args_section
147147
class_info.add_docstring(full_docstring)
148148

149-
with open(file_path, 'r', encoding="utf-8") as file:
149+
with open(file_path, encoding="utf-8") as file:
150150
lines = file.readlines()
151151

152152
updated_lines = []

examples/usb/download_file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ async def main() -> None:
2121
file_data = await client.download_file(file_location)
2222
end_s = time.time()
2323
duration = end_s - start_s
24-
speed = round(len(file_data) / ((duration)) / 1000, 2)
24+
speed = round(len(file_data) / duration / 1000, 2)
2525

2626
print(f"Speed {speed} KB/s")
2727

smpclient/transport/serial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ async def read_serial(self, delimiter: bytes | None = None) -> bytes:
227227
try:
228228
first_match, remaining_data = self._serial_buffer.split(delimiter, 1)
229229
except ValueError:
230-
return bytes()
230+
return b''
231231
self._serial_buffer = remaining_data
232232
return bytes(first_match)
233233

tests/fixtures/analyze-mcuboot-img.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def main():
107107
print('Initial image bytes:')
108108
start = img_header.hdr_size
109109
end = start + min(20, img_header.img_size)
110-
print('\t' + ' '.join('{:02x}'.format(b) for b in contents[start:end]))
110+
print('\t' + ' '.join(f'{b:02x}' for b in contents[start:end]))
111111

112112
tlv_info_offset = img_header.hdr_size + img_header.img_size
113113
tlv_info = TLVInfo(*struct.unpack_from(TLV_INFO_FMT, contents, offset=tlv_info_offset))
@@ -117,11 +117,11 @@ def main():
117117
tlv_num = 0
118118
while tlv_off < tlv_end:
119119
tlv_hdr = TLVHeader(*struct.unpack_from(TLV_HDR_FMT, contents, offset=tlv_off))
120-
print('TLV {}:'.format(tlv_num), tlv_hdr)
120+
print(f'TLV {tlv_num}:', tlv_hdr)
121121
if tlv_hdr.len <= 32:
122122
start = tlv_off + TLV_HDR_SIZE
123123
end = start + tlv_hdr.len
124-
print('\t' + ' '.join('{:02x}'.format(b) for b in contents[start:end]))
124+
print('\t' + ' '.join(f'{b:02x}' for b in contents[start:end]))
125125
tlv_off += TLV_HDR_SIZE + tlv_hdr.len
126126
tlv_num += 1
127127

tests/test_smp_client.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Tests for `SMPClient`."""
22

3-
import sys
43
from hashlib import sha256
54
from pathlib import Path
65
from unittest.mock import AsyncMock, PropertyMock, call, patch
@@ -39,24 +38,6 @@
3938
from smpclient.requests.os_management import ResetWrite
4039
from smpclient.transport.serial import SMPSerialTransport
4140

42-
if sys.version_info < (3, 10):
43-
from typing import Any
44-
45-
async def anext(iterator: Any, default: Any = None) -> Any:
46-
try:
47-
return await iterator.__anext__()
48-
except StopAsyncIteration:
49-
if default is None:
50-
raise
51-
return default
52-
53-
def aiter(iterable: Any) -> Any:
54-
if hasattr(iterable, '__aiter__'):
55-
return iterable.__aiter__()
56-
else:
57-
raise TypeError(f"{iterable} is not async iterable")
58-
59-
6041
class SMPMockTransport:
6142
"""Satisfies the `SMPTransport` `Protocol`."""
6243

0 commit comments

Comments
 (0)