Skip to content

Commit

Permalink
Update @contextmanager's return type
Browse files Browse the repository at this point in the history
The @contextmanager decorator returns an Iterator[BinaryIO]
which a generalisation of Generator[BinaryIO, None, None].

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
  • Loading branch information
sechkova committed Jun 7, 2021
1 parent 32ab712 commit e04ddaa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions securesystemslib/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import shutil
from contextlib import contextmanager
from securesystemslib import exceptions
from typing import BinaryIO, Generator, IO, List
from typing import BinaryIO, IO, Iterator, List

logger = logging.getLogger(__name__)

Expand All @@ -39,7 +39,7 @@ class StorageBackendInterface():

@abc.abstractmethod
@contextmanager
def get(self, filepath: str) -> Generator[BinaryIO, None, None]:
def get(self, filepath: str) -> Iterator[BinaryIO]:
"""
<Purpose>
A context manager for 'with' statements that is used for retrieving files
Expand Down Expand Up @@ -195,7 +195,7 @@ def __new__(cls, *args, **kwargs):


@contextmanager
def get(self, filepath:str) -> Generator[BinaryIO, None, None]:
def get(self, filepath:str) -> Iterator[BinaryIO]:
file_object = None
try:
file_object = open(filepath, 'rb')
Expand Down

0 comments on commit e04ddaa

Please sign in to comment.