Skip to content

Commit 0785c78

Browse files
committed
Make linter happy after python upgrade
Signed-off-by: Jussi Kukkonen <[email protected]>
1 parent 8513f46 commit 0785c78

File tree

6 files changed

+15
-13
lines changed

6 files changed

+15
-13
lines changed

tests/test_fetcher_ng.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,10 @@ def test_download_file_upper_length(self) -> None:
170170

171171
# Download a file bigger than expected
172172
def test_download_file_length_mismatch(self) -> None:
173-
with self.assertRaises(
174-
exceptions.DownloadLengthMismatchError
175-
), self.fetcher.download_file(self.url, self.file_length - 4):
173+
with (
174+
self.assertRaises(exceptions.DownloadLengthMismatchError),
175+
self.fetcher.download_file(self.url, self.file_length - 4),
176+
):
176177
pass # we never get here as download_file() raises
177178

178179

tests/test_trusted_metadata_set.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
import os
77
import sys
88
import unittest
9-
from collections.abc import Callable
109
from datetime import datetime, timezone
11-
from typing import ClassVar
10+
from typing import TYPE_CHECKING, ClassVar
1211

1312
from securesystemslib.signer import Signer
1413

@@ -31,6 +30,9 @@
3130
)
3231
from tuf.ngclient.config import EnvelopeType
3332

33+
if TYPE_CHECKING:
34+
from collections.abc import Callable
35+
3436
logger = logging.getLogger(__name__)
3537

3638

tests/test_updater_ng.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import sys
1212
import tempfile
1313
import unittest
14-
from collections.abc import Callable, Iterable
14+
from collections.abc import Iterable
1515
from typing import TYPE_CHECKING, ClassVar
1616
from unittest.mock import MagicMock, patch
1717

@@ -30,7 +30,7 @@
3030
from tuf.ngclient import Updater, UpdaterConfig
3131

3232
if TYPE_CHECKING:
33-
from collections.abc import Iterable
33+
from collections.abc import Callable, Iterable
3434

3535
logger = logging.getLogger(__name__)
3636

tests/utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,12 @@
3131
import threading
3232
import time
3333
import warnings
34-
from collections.abc import Callable
3534
from contextlib import contextmanager
3635
from typing import IO, TYPE_CHECKING, Any
3736

3837
if TYPE_CHECKING:
3938
import unittest
40-
from collections.abc import Iterator
39+
from collections.abc import Callable, Iterator
4140

4241
logger = logging.getLogger(__name__)
4342

tuf/api/_payload.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,8 +1191,8 @@ def _is_target_in_pathpattern(targetpath: str, pathpattern: str) -> bool:
11911191

11921192
# Every part in the pathpattern could include a glob pattern, that's why
11931193
# each of the target and pathpattern parts should match.
1194-
for target_dir, pattern_dir in zip(target_parts, pattern_parts):
1195-
if not fnmatch.fnmatch(target_dir, pattern_dir):
1194+
for target, pattern in zip(target_parts, pattern_parts, strict=False):
1195+
if not fnmatch.fnmatch(target, pattern):
11961196
return False
11971197

11981198
return True

tuf/ngclient/_internal/trusted_metadata_set.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
import datetime
6767
import logging
6868
from collections import abc
69-
from typing import TYPE_CHECKING, Union, cast
69+
from typing import TYPE_CHECKING, cast
7070

7171
from tuf.api import exceptions
7272
from tuf.api.dsse import SimpleEnvelope
@@ -88,7 +88,7 @@
8888

8989
logger = logging.getLogger(__name__)
9090

91-
Delegator = Union[Root, Targets]
91+
Delegator = Root | Targets
9292

9393

9494
class TrustedMetadataSet(abc.Mapping):

0 commit comments

Comments
 (0)