From c1e4075921fad01b2ddc0a983e615889466a285b Mon Sep 17 00:00:00 2001 From: "d.kovalenko" Date: Thu, 4 Jun 2026 00:35:02 +0300 Subject: [PATCH] fix: OsOperations::readlines defines all the arguments + asserts --- src/local_ops.py | 8 +++++++- src/os_ops.py | 17 ++++++++++++++++- src/remote_ops.py | 8 +++++++- 3 files changed, 30 insertions(+), 3 deletions(-) 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