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

Commit23b5d6b

Browse files
committed
Add types to submodule.util.py
1 parent41e9781 commit23b5d6b

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

‎git/config.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
ifTYPE_CHECKING:
4040
fromgit.repo.baseimportRepo
41+
fromioimportBytesIO
4142

4243
# -------------------------------------------------------------
4344

@@ -274,7 +275,7 @@ class GitConfigParser(with_metaclass(MetaParserBuilder, cp.RawConfigParser, obje
274275
# list of RawConfigParser methods able to change the instance
275276
_mutating_methods_= ("add_section","remove_section","remove_option","set")
276277

277-
def__init__(self,file_or_files:Union[None,PathLike,IO,Sequence[Union[PathLike,IO]]]=None,
278+
def__init__(self,file_or_files:Union[None,PathLike,BytesIO,Sequence[Union[PathLike,BytesIO]]]=None,
278279
read_only:bool=True,merge_includes:bool=True,
279280
config_level:Union[Lit_config_levels,None]=None,
280281
repo:Union['Repo',None]=None)->None:
@@ -303,7 +304,7 @@ def __init__(self, file_or_files: Union[None, PathLike, IO, Sequence[Union[PathL
303304
self._proxies=self._dict()
304305

305306
iffile_or_filesisnotNone:
306-
self._file_or_files:Union[PathLike,IO,Sequence[Union[PathLike,IO]]]=file_or_files
307+
self._file_or_files:Union[PathLike,'BytesIO',Sequence[Union[PathLike,'BytesIO']]]=file_or_files
307308
else:
308309
ifconfig_levelisNone:
309310
ifread_only:
@@ -650,7 +651,7 @@ def write(self) -> None:
650651
a file lock"""
651652
self._assure_writable("write")
652653
ifnotself._dirty:
653-
return
654+
returnNone
654655

655656
ifisinstance(self._file_or_files, (list,tuple)):
656657
raiseAssertionError("Cannot write back if there is not exactly a single file to write to, have %i files"
@@ -675,7 +676,7 @@ def write(self) -> None:
675676
withopen(fp,"wb")asfp_open:
676677
self._write(fp_open)
677678
else:
678-
fp=cast(IO,fp)
679+
fp=cast(BytesIO,fp)
679680
fp.seek(0)
680681
# make sure we do not overwrite into an existing file
681682
ifhasattr(fp,'truncate'):

‎git/objects/submodule/util.py‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
# typing -----------------------------------------------------------------------
99

10-
fromtypingimportAny,TYPE_CHECKING,Union
10+
fromtypingimportAny,Sequence,TYPE_CHECKING,Union
1111

1212
fromgit.typesimportPathLike
1313

@@ -16,6 +16,8 @@
1616
fromweakrefimportReferenceType
1717
fromgit.repoimportRepo
1818
fromgit.refsimportHead
19+
fromgitimportRemote
20+
fromgit.refsimportRemoteReference
1921

2022

2123
__all__= ('sm_section','sm_name','mkhead','find_first_remote_branch',
@@ -24,12 +26,12 @@
2426
#{ Utilities
2527

2628

27-
defsm_section(name):
29+
defsm_section(name:str)->str:
2830
""":return: section title used in .gitmodules configuration file"""
29-
return'submodule"%s"'%name
31+
returnf'submodule{name}'
3032

3133

32-
defsm_name(section):
34+
defsm_name(section:str)->str:
3335
""":return: name of the submodule as parsed from the section name"""
3436
section=section.strip()
3537
returnsection[11:-1]
@@ -40,7 +42,7 @@ def mkhead(repo: 'Repo', path: PathLike) -> 'Head':
4042
returngit.Head(repo,git.Head.to_full_path(path))
4143

4244

43-
deffind_first_remote_branch(remotes,branch_name):
45+
deffind_first_remote_branch(remotes:Sequence['Remote'],branch_name:str)->'RemoteReference':
4446
"""Find the remote branch matching the name of the given branch or raise InvalidGitRepositoryError"""
4547
forremoteinremotes:
4648
try:
@@ -99,7 +101,7 @@ def flush_to_index(self) -> None:
99101

100102
#{ Overridden Methods
101103
defwrite(self)->None:
102-
rval=super(SubmoduleConfigParser,self).write()
104+
rval:None=super(SubmoduleConfigParser,self).write()
103105
self.flush_to_index()
104106
returnrval
105107
# END overridden methods

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp