Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 39eb0e6

Browse filesBrowse files
committed
Add types to cmd.py CatFileContentStream
1 parent f1ace25 commit 39eb0e6
Copy full SHA for 39eb0e6

File tree

1 file changed

+10
-10
lines changed
Filter options

1 file changed

+10
-10
lines changed

‎git/cmd.py

Copy file name to clipboardExpand all lines: git/cmd.py
+10-10Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
# typing ---------------------------------------------------------------------------
4444

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
4646

4747
from git.types import PathLike, TBD
4848

@@ -443,7 +443,7 @@ class CatFileContentStream(object):
443443

444444
__slots__ = ('_stream', '_nbr', '_size')
445445

446-
def __init__(self, size, stream):
446+
def __init__(self, size: int, stream: BinaryIO) -> None:
447447
self._stream = stream
448448
self._size = size
449449
self._nbr = 0 # num bytes read
@@ -454,7 +454,7 @@ def __init__(self, size, stream):
454454
stream.read(1)
455455
# END handle empty streams
456456

457-
def read(self, size=-1):
457+
def read(self, size: int = -1) -> bytes:
458458
bytes_left = self._size - self._nbr
459459
if bytes_left == 0:
460460
return b''
@@ -474,7 +474,7 @@ def read(self, size=-1):
474474
# END finish reading
475475
return data
476476

477-
def readline(self, size=-1):
477+
def readline(self, size: int = -1) -> bytes:
478478
if self._nbr == self._size:
479479
return b''
480480

@@ -496,7 +496,7 @@ def readline(self, size=-1):
496496

497497
return data
498498

499-
def readlines(self, size=-1):
499+
def readlines(self, size: int = -1) -> List[bytes]:
500500
if self._nbr == self._size:
501501
return []
502502

@@ -517,28 +517,28 @@ def readlines(self, size=-1):
517517
return out
518518

519519
# skipcq: PYL-E0301
520-
def __iter__(self):
520+
def __iter__(self) -> 'Git.CatFileContentStream':
521521
return self
522522

523-
def __next__(self):
523+
def __next__(self) -> bytes:
524524
return self.next()
525525

526-
def next(self):
526+
def next(self) -> bytes:
527527
line = self.readline()
528528
if not line:
529529
raise StopIteration
530530

531531
return line
532532

533-
def __del__(self):
533+
def __del__(self) -> None:
534534
bytes_left = self._size - self._nbr
535535
if bytes_left:
536536
# read and discard - seeking is impossible within a stream
537537
# includes terminating newline
538538
self._stream.read(bytes_left + 1)
539539
# END handle incomplete read
540540

541-
def __init__(self, working_dir=None):
541+
def __init__(self, working_dir: Union[None, PathLike]=None):
542542
"""Initialize this instance with:
543543
544544
:param working_dir:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.