| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -42,7 +42,7 @@ | |||
| 42 | 42 | ||
| 43 | 43 | # typing --------------------------------------------------------------------------- | |
| 44 | 44 | ||
| 45 | - from typing import Any, BinaryIO, Callable, Dict, Mapping, Sequence, TYPE_CHECKING, Union | ||
| 45 | + from typing import Any, BinaryIO, Callable, Dict, List, Mapping, Sequence, TYPE_CHECKING, Union | ||
| 46 | 46 | ||
| 47 | 47 | from git.types import PathLike, TBD | |
| 48 | 48 | ||
@@ -443,7 +443,7 @@ class CatFileContentStream(object): | |||
| 443 | 443 | ||
| 444 | 444 | __slots__ = ('_stream', '_nbr', '_size') | |
| 445 | 445 | ||
| 446 | - def __init__(self, size, stream): | ||
| 446 | + def __init__(self, size: int, stream: BinaryIO) -> None: | ||
| 447 | 447 | self._stream = stream | |
| 448 | 448 | self._size = size | |
| 449 | 449 | self._nbr = 0 # num bytes read | |
@@ -454,7 +454,7 @@ def __init__(self, size, stream): | |||
| 454 | 454 | stream.read(1) | |
| 455 | 455 | # END handle empty streams | |
| 456 | 456 | ||
| 457 | - def read(self, size=-1): | ||
| 457 | + def read(self, size: int = -1) -> bytes: | ||
| 458 | 458 | bytes_left = self._size - self._nbr | |
| 459 | 459 | if bytes_left == 0: | |
| 460 | 460 | return b'' | |
@@ -474,7 +474,7 @@ def read(self, size=-1): | |||
| 474 | 474 | # END finish reading | |
| 475 | 475 | return data | |
| 476 | 476 | ||
| 477 | - def readline(self, size=-1): | ||
| 477 | + def readline(self, size: int = -1) -> bytes: | ||
| 478 | 478 | if self._nbr == self._size: | |
| 479 | 479 | return b'' | |
| 480 | 480 | ||
@@ -496,7 +496,7 @@ def readline(self, size=-1): | |||
| 496 | 496 | ||
| 497 | 497 | return data | |
| 498 | 498 | ||
| 499 | - def readlines(self, size=-1): | ||
| 499 | + def readlines(self, size: int = -1) -> List[bytes]: | ||
| 500 | 500 | if self._nbr == self._size: | |
| 501 | 501 | return [] | |
| 502 | 502 | ||
@@ -517,28 +517,28 @@ def readlines(self, size=-1): | |||
| 517 | 517 | return out | |
| 518 | 518 | ||
| 519 | 519 | # skipcq: PYL-E0301 | |
| 520 | - def __iter__(self): | ||
| 520 | + def __iter__(self) -> 'Git.CatFileContentStream': | ||
| 521 | 521 | return self | |
| 522 | 522 | ||
| 523 | - def __next__(self): | ||
| 523 | + def __next__(self) -> bytes: | ||
| 524 | 524 | return self.next() | |
| 525 | 525 | ||
| 526 | - def next(self): | ||
| 526 | + def next(self) -> bytes: | ||
| 527 | 527 | line = self.readline() | |
| 528 | 528 | if not line: | |
| 529 | 529 | raise StopIteration | |
| 530 | 530 | ||
| 531 | 531 | return line | |
| 532 | 532 | ||
| 533 | - def __del__(self): | ||
| 533 | + def __del__(self) -> None: | ||
| 534 | 534 | bytes_left = self._size - self._nbr | |
| 535 | 535 | if bytes_left: | |
| 536 | 536 | # read and discard - seeking is impossible within a stream | |
| 537 | 537 | # includes terminating newline | |
| 538 | 538 | self._stream.read(bytes_left + 1) | |
| 539 | 539 | # END handle incomplete read | |
| 540 | 540 | ||
| 541 | - def __init__(self, working_dir=None): | ||
| 541 | + def __init__(self, working_dir: Union[None, PathLike]=None): | ||
| 542 | 542 | """Initialize this instance with: | |
| 543 | 543 | ||
| 544 | 544 | :param working_dir: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments