Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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

Sign up
Appearance settings

Commit5b880c0

Browse files
committed
Fix more missing types in Symbolic.py
1 parent7cf30c1 commit5b880c0

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

‎git/refs/symbolic.py‎

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
ifTYPE_CHECKING:
2727
fromgit.repoimportRepo
28-
fromgit.refsimportReference
28+
fromgit.refsimportReference,Head,HEAD,TagReference,RemoteReference
2929

3030
T_References=TypeVar('T_References',bound='SymbolicReference')
3131

@@ -141,13 +141,13 @@ def dereference_recursive(cls, repo: 'Repo', ref_path: PathLike) -> str:
141141
intermediate references as required
142142
:param repo: the repository containing the reference at ref_path"""
143143
whileTrue:
144-
hexsha,ref_path=cls._get_ref_info(repo,ref_path)
144+
hexsha,_ref_path_out=cls._get_ref_info(repo,ref_path)
145145
ifhexshaisnotNone:
146146
returnhexsha
147147
# END recursive dereferencing
148148

149149
@classmethod
150-
def_get_ref_info_helper(cls,repo:'Repo',ref_path:PathLike):
150+
def_get_ref_info_helper(cls,repo:'Repo',ref_path:PathLike)->Union[Tuple[str,None],Tuple[None,PathLike]]:
151151
"""Return: (str(sha), str(target_ref_path)) if available, the sha the file at
152152
rela_path points to, or None. target_ref_path is the reference we
153153
point to, or None"""
@@ -186,13 +186,14 @@ def _get_ref_info_helper(cls, repo: 'Repo', ref_path: PathLike):
186186
raiseValueError("Failed to parse reference information from %r"%ref_path)
187187

188188
@classmethod
189-
def_get_ref_info(cls,repo:'Repo',ref_path:PathLike):
189+
def_get_ref_info(cls,repo:'Repo',ref_path:PathLike
190+
)->Union[Tuple[str,None],Tuple[None,PathLike]]:
190191
"""Return: (str(sha), str(target_ref_path)) if available, the sha the file at
191192
rela_path points to, or None. target_ref_path is the reference we
192193
point to, or None"""
193194
returncls._get_ref_info_helper(repo,ref_path)
194195

195-
def_get_object(self):
196+
def_get_object(self)->Commit_ish:
196197
"""
197198
:return:
198199
The object our ref currently refers to. Refs can be cached, they will
@@ -201,7 +202,7 @@ def _get_object(self):
201202
# Our path will be resolved to the hexsha which will be used accordingly
202203
returnObject.new_from_sha(self.repo,hex_to_bin(self.dereference_recursive(self.repo,self.path)))
203204

204-
def_get_commit(self):
205+
def_get_commit(self)->'Commit':
205206
"""
206207
:return:
207208
Commit object we point to, works for detached and non-detached
@@ -216,7 +217,8 @@ def _get_commit(self):
216217
# END handle type
217218
returnobj
218219

219-
defset_commit(self,commit:Union[Commit,'SymbolicReference',str],logmsg=None):
220+
defset_commit(self,commit:Union[Commit,'SymbolicReference',str],
221+
logmsg:Union[str,None]=None)->None:
220222
"""As set_object, but restricts the type of object to be a Commit
221223
222224
:raise ValueError: If commit is not a Commit object or doesn't point to
@@ -243,7 +245,8 @@ def set_commit(self, commit: Union[Commit, 'SymbolicReference', str], logmsg=Non
243245
# we leave strings to the rev-parse method below
244246
self.set_object(commit,logmsg)
245247

246-
returnself
248+
# return self
249+
returnNone
247250

248251
defset_object(self,object,logmsg=None):# @ReservedAssignment
249252
"""Set the object we point to, possibly dereference our symbolic reference first.
@@ -275,7 +278,8 @@ def set_object(self, object, logmsg=None): # @ReservedAssignment
275278
commit=property(_get_commit,set_commit,doc="Query or set commits directly")
276279
object=property(_get_object,set_object,doc="Return the object our ref currently refers to")
277280

278-
def_get_reference(self):
281+
def_get_reference(self
282+
)->Union['HEAD','Head','RemoteReference','TagReference','Reference','SymbolicReference']:
279283
""":return: Reference Object we point to
280284
:raise TypeError: If this symbolic reference is detached, hence it doesn't point
281285
to a reference, but to a commit"""

‎pyproject.toml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ filterwarnings = 'ignore::DeprecationWarning'
1919
# filterwarnings ignore::WarningType # ignores those warnings
2020

2121
[tool.mypy]
22-
# disallow_untyped_defs =True
22+
# disallow_untyped_defs =true
2323
no_implicit_optional =true
2424
warn_redundant_casts =true
25-
# warn_unused_ignores =True
26-
# warn_unreachable =True
25+
# warn_unused_ignores =true
26+
# warn_unreachable =true
2727
show_error_codes =true
2828

2929
# TODO: remove when 'gitdb' is fully annotated

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp