Skip to content

Commit 559ddb3

Browse files
committed
add types to _from_line()
1 parent 90fefb0 commit 559ddb3

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

‎git/remote.py‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,10 @@ class PushInfo(object):
131131
'=': UP_TO_DATE,
132132
'!': ERROR}
133133

134-
def__init__(self, flags: int, local_ref: SymbolicReference, remote_ref_string: str, remote,
135-
old_commit: Optional[bytes] =None, summary: str='') ->None:
136-
""" Initialize a new instance """
134+
def__init__(self, flags: int, local_ref: Union[SymbolicReference, None], remote_ref_string: str, remote,
135+
old_commit: Optional[str] =None, summary: str='') ->None:
136+
""" Initialize a new instance
137+
local_ref: HEAD | Head | RemoteReference | TagReference | Reference | SymbolicReference | None """
137138
self.flags=flags
138139
self.local_ref=local_ref
139140
self.remote_ref_string=remote_ref_string
@@ -162,7 +163,7 @@ def remote_ref(self) -> Union[RemoteReference, TagReference]:
162163
# END
163164

164165
@classmethod
165-
def_from_line(cls, remote, line):
166+
def_from_line(cls, remote, line: str) ->'PushInfo':
166167
"""Create a new PushInfo instance as parsed from line which is expected to be like
167168
refs/heads/master:refs/heads/master 05d2687..1d0568e as bytes"""
168169
control_character, from_to, summary=line.split('\t', 3)
@@ -178,15 +179,15 @@ def _from_line(cls, remote, line):
178179
# from_to handling
179180
from_ref_string, to_ref_string=from_to.split(':')
180181
ifflags&cls.DELETED:
181-
from_ref=None
182+
from_ref=None# type: Union[SymbolicReference, None]
182183
else:
183184
iffrom_ref_string=="(delete)":
184185
from_ref=None
185186
else:
186187
from_ref=Reference.from_path(remote.repo, from_ref_string)
187188

188189
# commit handling, could be message or commit info
189-
old_commit=None
190+
old_commit=None# type: Optional[str]
190191
ifsummary.startswith('['):
191192
if"[rejected]"insummary:
192193
flags|=cls.REJECTED

0 commit comments

Comments
(0)