Skip to content

Commit 4e3d6e4

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

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
@@ -21,8 +21,8 @@
2121
from collections import OrderedDict
2222
from datetime import datetime, timedelta
2323
from typing import (
24+
IO,
2425
Any,
25-
BinaryIO,
2626
ClassVar,
2727
Dict,
2828
List,
@@ -652,7 +652,7 @@ class BaseFile:
652652

653653
@staticmethod
654654
def _verify_hashes(
655-
data: Union[bytes, BinaryIO], expected_hashes: Dict[str, str]
655+
data: Union[bytes, IO[bytes]], expected_hashes: Dict[str, str]
656656
) -> None:
657657
"""Verifies that the hash of 'data' matches 'expected_hashes'"""
658658
is_bytes = isinstance(data, bytes)
@@ -681,7 +681,7 @@ def _verify_hashes(
681681

682682
@staticmethod
683683
def _verify_length(
684-
data: Union[bytes, BinaryIO], expected_length: int
684+
data: Union[bytes, IO[bytes]], expected_length: int
685685
) -> None:
686686
"""Verifies that the length of 'data' matches 'expected_length'"""
687687
if isinstance(data, bytes):
@@ -766,7 +766,7 @@ def to_dict(self) -> Dict[str, Any]:
766766

767767
return res_dict
768768

769-
def verify_length_and_hashes(self, data: Union[bytes, BinaryIO]) -> None:
769+
def verify_length_and_hashes(self, data: Union[bytes, IO[bytes]]) -> None:
770770
"""Verifies that the length and hashes of "data" match expected values.
771771
772772
Args:
@@ -1045,7 +1045,7 @@ def to_dict(self) -> Dict[str, Any]:
10451045
**self.unrecognized_fields,
10461046
}
10471047

1048-
def verify_length_and_hashes(self, data: Union[bytes, BinaryIO]) -> None:
1048+
def verify_length_and_hashes(self, data: Union[bytes, IO[bytes]]) -> None:
10491049
"""Verifies that length and hashes of "data" match expected values.
10501050
10511051
Args:

0 commit comments

Comments
 (0)