Skip to content

Commit 4b55a62

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 of IO[bytes]. Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
1 parent a89bec5 commit 4b55a62

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
@@ -22,8 +22,8 @@
2222
from collections import OrderedDict
2323
from datetime import datetime, timedelta
2424
from typing import (
25+
IO,
2526
Any,
26-
BinaryIO,
2727
ClassVar,
2828
Dict,
2929
List,
@@ -730,7 +730,7 @@ class BaseFile:
730730

731731
@staticmethod
732732
def _verify_hashes(
733-
data: Union[bytes, BinaryIO], expected_hashes: Dict[str, str]
733+
data: Union[bytes, IO[bytes]], expected_hashes: Dict[str, str]
734734
) -> None:
735735
"""Verifies that the hash of 'data' matches 'expected_hashes'"""
736736
is_bytes = isinstance(data, bytes)
@@ -759,7 +759,7 @@ def _verify_hashes(
759759

760760
@staticmethod
761761
def _verify_length(
762-
data: Union[bytes, BinaryIO], expected_length: int
762+
data: Union[bytes, IO[bytes]], expected_length: int
763763
) -> None:
764764
"""Verifies that the length of 'data' matches 'expected_length'"""
765765
if isinstance(data, bytes):
@@ -844,7 +844,7 @@ def to_dict(self) -> Dict[str, Any]:
844844

845845
return res_dict
846846

847-
def verify_length_and_hashes(self, data: Union[bytes, BinaryIO]) -> None:
847+
def verify_length_and_hashes(self, data: Union[bytes, IO[bytes]]) -> None:
848848
"""Verifies that the length and hashes of "data" match expected values.
849849
850850
Args:
@@ -1123,7 +1123,7 @@ def to_dict(self) -> Dict[str, Any]:
11231123
**self.unrecognized_fields,
11241124
}
11251125

1126-
def verify_length_and_hashes(self, data: Union[bytes, BinaryIO]) -> None:
1126+
def verify_length_and_hashes(self, data: Union[bytes, IO[bytes]]) -> None:
11271127
"""Verifies that length and hashes of "data" match expected values.
11281128
11291129
Args:

0 commit comments

Comments
 (0)