Skip to content

Commit b63cf71

Browse files
committed
lint fixes
Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
1 parent 7a8edd9 commit b63cf71

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

tests/test_updater_delegation_graphs.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ def _assert_files_exist(self, roles: Iterable[str]) -> None:
136136
"""Assert that local metadata files match 'roles'"""
137137
expected_files = [f"{role}.json" for role in roles]
138138
found_files = [
139-
e.name for e in os.scandir(self.metadata_dir) if e.is_file() and e.name != ".lock"
139+
e.name
140+
for e in os.scandir(self.metadata_dir)
141+
if e.is_file() and e.name != ".lock"
140142
]
141143

142144
self.assertListEqual(sorted(found_files), sorted(expected_files))

tests/test_updater_ng.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ def _assert_files_exist(self, roles: Iterable[str]) -> None:
158158
"""Assert that local metadata files match 'roles'"""
159159
expected_files = [f"{role}.json" for role in roles]
160160
found_files = [
161-
e.name for e in os.scandir(self.client_directory) if e.is_file() and e.name != ".lock"
161+
e.name
162+
for e in os.scandir(self.client_directory)
163+
if e.is_file() and e.name != ".lock"
162164
]
163165

164166
self.assertListEqual(sorted(found_files), sorted(expected_files))
@@ -375,10 +377,16 @@ def test_parallel_updaters(self) -> None:
375377
]
376378

377379
p1 = subprocess.Popen(
378-
command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=project_root
380+
command,
381+
stdout=subprocess.PIPE,
382+
stderr=subprocess.PIPE,
383+
cwd=project_root,
379384
)
380385
p2 = subprocess.Popen(
381-
command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=project_root
386+
command,
387+
stdout=subprocess.PIPE,
388+
stderr=subprocess.PIPE,
389+
cwd=project_root,
382390
)
383391

384392
stdout1, stderr1 = p1.communicate()
@@ -393,6 +401,7 @@ def test_parallel_updaters(self) -> None:
393401
f"\nprocess 2 stderr: \n{stderr2.decode()}"
394402
)
395403

404+
396405
if __name__ == "__main__":
397406
utils.configure_test_logging(sys.argv)
398407
unittest.main()

tests/test_updater_top_level_update.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ def _assert_files_exist(self, roles: Iterable[str]) -> None:
9494
"""Assert that local metadata files match 'roles'"""
9595
expected_files = [f"{role}.json" for role in roles]
9696
found_files = [
97-
e.name for e in os.scandir(self.metadata_dir) if e.is_file() and e.name != ".lock"
97+
e.name
98+
for e in os.scandir(self.metadata_dir)
99+
if e.is_file() and e.name != ".lock"
98100
]
99101

100102
self.assertListEqual(sorted(found_files), sorted(expected_files))

tuf/ngclient/updater.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
try:
7979
# advisory file locking for posix
8080
import fcntl
81+
8182
def _lock_file(f: IO) -> None:
8283
if f.writable():
8384
fcntl.lockf(f, fcntl.LOCK_EX)
@@ -87,7 +88,7 @@ def _lock_file(f: IO) -> None:
8788
import msvcrt
8889

8990
def _lock_file(f: IO) -> None:
90-
# On Windows we lock bytes, not the file
91+
# On Windows we lock a byte range and file must not be empty
9192
f.write(b"\0")
9293
f.flush()
9394
f.seek(0)
@@ -163,7 +164,6 @@ def __init__(
163164
self._persist_root(self._trusted_set.root.version, bootstrap)
164165
self._update_root_symlink()
165166

166-
167167
@contextlib.contextmanager
168168
def _lock_metadata(self) -> Iterator[None]:
169169
"""Context manager for locking the metadata directory."""

0 commit comments

Comments
 (0)