Skip to content

Commit 2c164dd

Browse files
committed
Replace BinaryIO with IO[bytes] in metadata.py
Needed in order to be compatible with the return type of download_file (TemporaryFile is typed as IO[bytes]). BinaryIO is a subclass of IO[bytes]. Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
1 parent 39f5992 commit 2c164dd

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

tuf/api/metadata.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
from collections import OrderedDict
2525
from datetime import datetime, timedelta
2626
from typing import (
27+
IO,
2728
Any,
28-
BinaryIO,
2929
ClassVar,
3030
Dict,
3131
Generic,
@@ -753,7 +753,7 @@ class BaseFile:
753753

754754
@staticmethod
755755
def _verify_hashes(
756-
data: Union[bytes, BinaryIO], expected_hashes: Dict[str, str]
756+
data: Union[bytes, IO[bytes]], expected_hashes: Dict[str, str]
757757
) -> None:
758758
"""Verifies that the hash of 'data' matches 'expected_hashes'"""
759759
is_bytes = isinstance(data, bytes)
@@ -782,7 +782,7 @@ def _verify_hashes(
782782

783783
@staticmethod
784784
def _verify_length(
785-
data: Union[bytes, BinaryIO], expected_length: int
785+
data: Union[bytes, IO[bytes]], expected_length: int
786786
) -> None:
787787
"""Verifies that the length of 'data' matches 'expected_length'"""
788788
if isinstance(data, bytes):
@@ -867,7 +867,7 @@ def to_dict(self) -> Dict[str, Any]:
867867

868868
return res_dict
869869

870-
def verify_length_and_hashes(self, data: Union[bytes, BinaryIO]) -> None:
870+
def verify_length_and_hashes(self, data: Union[bytes, IO[bytes]]) -> None:
871871
"""Verifies that the length and hashes of "data" match expected values.
872872
873873
Args:
@@ -1178,7 +1178,7 @@ def to_dict(self) -> Dict[str, Any]:
11781178
**self.unrecognized_fields,
11791179
}
11801180

1181-
def verify_length_and_hashes(self, data: Union[bytes, BinaryIO]) -> None:
1181+
def verify_length_and_hashes(self, data: Union[bytes, IO[bytes]]) -> None:
11821182
"""Verifies that length and hashes of "data" match expected values.
11831183
11841184
Args:

0 commit comments

Comments
 (0)