diff --git a/src/local_ops.py b/src/local_ops.py index 327f608..a1f5874 100644 --- a/src/local_ops.py +++ b/src/local_ops.py @@ -513,7 +513,13 @@ def _read__binary(self, filename): assert type(content) is bytes return content - def readlines(self, filename, num_lines=0, binary=False, encoding=None): + def readlines( + self, + filename: str, + num_lines: int = 0, + binary: bool = False, + encoding: typing.Optional[str] = None, + ) -> typing.Union[typing.List[str], typing.List[bytes]]: """ Read lines from a local file. If num_lines is greater than 0, only the last num_lines lines will be read. diff --git a/src/os_ops.py b/src/os_ops.py index 0b8c990..2f23648 100644 --- a/src/os_ops.py +++ b/src/os_ops.py @@ -120,7 +120,22 @@ def touch(self, filename): def read(self, filename, encoding, binary): raise NotImplementedError() - def readlines(self, filename): + def readlines( + self, + filename: str, + num_lines: int = 0, + binary: bool = False, + encoding: typing.Optional[str] = None, + ) -> typing.Union[typing.List[str], typing.List[bytes]]: + """ + Read lines from a local file. + If num_lines is greater than 0, only the last num_lines lines will be read. + """ + assert type(num_lines) is int + assert type(filename) is str + assert type(binary) is bool + assert encoding is None or type(encoding) is str + assert num_lines >= 0 raise NotImplementedError() def read_binary(self, filename, offset): diff --git a/src/remote_ops.py b/src/remote_ops.py index 156b009..92f77a4 100644 --- a/src/remote_ops.py +++ b/src/remote_ops.py @@ -551,7 +551,13 @@ def _read__binary(self, filename): assert type(content) is bytes return content - def readlines(self, filename, num_lines=0, binary=False, encoding=None): + def readlines( + self, + filename: str, + num_lines: int = 0, + binary: bool = False, + encoding: typing.Optional[str] = None, + ) -> typing.Union[typing.List[str], typing.List[bytes]]: assert type(num_lines) is int assert type(filename) is str assert type(binary) is bool