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

Commit18c777b

Browse files
authored
Merge pull request#1282 from Yobmod/main
Start adding types to Submodule, add py.typed to manifest
2 parents8ad4f59 +d4a9eab commit18c777b

20 files changed

+19128
-203
lines changed

‎MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ include README.md
66
include VERSION
77
include requirements.txt
88
include test-requirements.txt
9+
include git/py.typed
910

1011
recursive-include doc *
1112
recursive-exclude test *

‎git/cmd.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,11 +342,11 @@ def polish_url(cls, url: str, is_cygwin: Literal[False] = ...) -> str:
342342

343343
@overload
344344
@classmethod
345-
defpolish_url(cls,url:PathLike,is_cygwin:Union[None,bool]=None)->str:
345+
defpolish_url(cls,url:str,is_cygwin:Union[None,bool]=None)->str:
346346
...
347347

348348
@classmethod
349-
defpolish_url(cls,url:PathLike,is_cygwin:Union[None,bool]=None)->PathLike:
349+
defpolish_url(cls,url:str,is_cygwin:Union[None,bool]=None)->PathLike:
350350
ifis_cygwinisNone:
351351
is_cygwin=cls.is_cygwin()
352352

‎git/config.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929

3030
importconfigparserascp
3131

32-
frompathlibimportPath
33-
3432
# typing-------------------------------------------------------
3533

3634
fromtypingimportAny,Callable,IO,List,Dict,Sequence,TYPE_CHECKING,Tuple,Union,cast,overload
@@ -330,7 +328,7 @@ def _acquire_lock(self) -> None:
330328
"Write-ConfigParsers can operate on a single file only, multiple files have been passed")
331329
# END single file check
332330

333-
ifisinstance(self._file_or_files, (str,Path)):# cannot narrow by os._pathlike until 3.5 dropped
331+
ifisinstance(self._file_or_files, (str,os.PathLike)):
334332
file_or_files=self._file_or_files
335333
else:
336334
file_or_files=cast(IO,self._file_or_files).name
@@ -696,6 +694,16 @@ def read_only(self) -> bool:
696694
""":return: True if this instance may change the configuration file"""
697695
returnself._read_only
698696

697+
@overload
698+
defget_value(self,section:str,option:str,default:str
699+
)->str:
700+
...
701+
702+
@overload
703+
defget_value(self,section:str,option:str,default:float
704+
)->float:
705+
...
706+
699707
defget_value(self,section:str,option:str,default:Union[int,float,str,bool,None]=None
700708
)->Union[int,float,str,bool]:
701709
# can default or return type include bool?

‎git/index/base.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# This module is part of GitPython and is released under
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
6-
fromgit.refs.referenceimportReference
6+
77
importglob
88
fromioimportBytesIO
99
importos
@@ -74,6 +74,8 @@
7474
ifTYPE_CHECKING:
7575
fromsubprocessimportPopen
7676
fromgit.repoimportRepo
77+
fromgit.refs.referenceimportReference
78+
fromgit.utilimportActor
7779

7880

7981
StageType=int
@@ -966,8 +968,8 @@ def move(self, items: Sequence[Union[PathLike, Blob, BaseIndexEntry, Submodule]]
966968

967969
returnout
968970

969-
defcommit(self,message:str,parent_commits=None,head:bool=True,author:str=None,
970-
committer:str=None,author_date:str=None,commit_date:str=None,
971+
defcommit(self,message:str,parent_commits=None,head:bool=True,author:Union[None,'Actor']=None,
972+
committer:Union[None,'Actor']=None,author_date:str=None,commit_date:str=None,
971973
skip_hooks:bool=False)->Commit:
972974
"""Commit the current default index file, creating a commit object.
973975
For more information on the arguments, see tree.commit.
@@ -1191,7 +1193,7 @@ def handle_stderr(proc: 'Popen[bytes]', iter_checked_out_files: Iterable[PathLik
11911193
assert"Should not reach this point"
11921194

11931195
@default_index
1194-
defreset(self,commit:Union[Commit,Reference,str]='HEAD',working_tree:bool=False,
1196+
defreset(self,commit:Union[Commit,'Reference',str]='HEAD',working_tree:bool=False,
11951197
paths:Union[None,Iterable[PathLike]]=None,
11961198
head:bool=False,**kwargs:Any)->'IndexFile':
11971199
"""Reset the index to reflect the tree at the given commit. This will not

‎git/objects/base.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@
1717

1818
fromtypingimportAny,TYPE_CHECKING,Optional,Union
1919

20-
fromgit.typesimportPathLike
20+
fromgit.typesimportPathLike,Commit_ish
2121

2222
ifTYPE_CHECKING:
2323
fromgit.repoimportRepo
2424
fromgitdb.baseimportOStream
2525
from .treeimportTree
2626
from .blobimportBlob
27-
from .tagimportTagObject
28-
from .commitimportCommit
27+
from .submodule.baseimportSubmodule
28+
29+
IndexObjUnion=Union['Tree','Blob','Submodule']
2930

3031
# --------------------------------------------------------------------------
3132

@@ -71,7 +72,7 @@ def new(cls, repo: 'Repo', id): # @ReservedAssignment
7172
returnrepo.rev_parse(str(id))
7273

7374
@classmethod
74-
defnew_from_sha(cls,repo:'Repo',sha1:bytes)->Union['Commit','TagObject','Tree','Blob']:
75+
defnew_from_sha(cls,repo:'Repo',sha1:bytes)->Commit_ish:
7576
"""
7677
:return: new object instance of a type appropriate to represent the given
7778
binary sha1

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp