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

Commit1f03e7f

Browse files
committed
Fix other submodule.base parent_commit annotations
This finishes the work in git.objects.submodule.base begun in1541c62. Some remaining occurrences of the old Commit_ish type arein git.objects.submodule.root, which still need to be replaced.Even once that is done, this will not havefixed#1869, though itwill be somewhat mitigated because each method's annotationsrelated to parent_commit will reflect the types that can actuallybe used reliably under the current implementation, even if in somecases that may not be as broad as was meant, or hoped, to besupported. I expect this may lead the way to a fix for#1869, sincethe existing behavior and relationships will be clearer.Where the old Commit_ish annotations were changed here to "Commit",it reflects assumptions found by examining the implementation thatother alternatives are not usable becuse something beloning to aCommit is used and no conversion or fallback is performed for it.Where a commit is looked up (which uses rev_parse), broader typesare annotated. Where the argument is used without conversion andmust have a `tree` attribute, it must be a Commit. Where theargument could be broader but must be compared meaningfully withsomething known to be a commit, it must at minimum have a binshaattribute to allow that equality comparison, implemented in Object,to be meaningful, so in such cases its type cannot include str.
1 parent1541c62 commit1f03e7f

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

‎git/objects/submodule/base.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,19 @@
4242

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

45-
fromtypingimportCallable,Dict,Mapping,Sequence,TYPE_CHECKING,cast
46-
fromtypingimportAny,Iterator,Union
45+
fromtypingimport (
46+
Any,
47+
Callable,
48+
Dict,
49+
Iterator,
50+
Mapping,
51+
Sequence,
52+
TYPE_CHECKING,
53+
Union,
54+
cast,
55+
)
4756

48-
fromgit.typesimportCommit_ish,Literal,Old_commit_ish,PathLike,TBD
57+
fromgit.typesimportCommit_ish,Literal,PathLike,TBD
4958

5059
ifTYPE_CHECKING:
5160
fromgit.indeximportIndexFile
@@ -113,7 +122,7 @@ def __init__(
113122
mode:Union[int,None]=None,
114123
path:Union[PathLike,None]=None,
115124
name:Union[str,None]=None,
116-
parent_commit:Union[Old_commit_ish,None]=None,
125+
parent_commit:Union["Commit",None]=None,
117126
url:Union[str,None]=None,
118127
branch_path:Union[PathLike,None]=None,
119128
)->None:
@@ -145,7 +154,6 @@ def __init__(
145154
ifurlisnotNone:
146155
self._url=url
147156
ifbranch_pathisnotNone:
148-
# assert isinstance(branch_path, str)
149157
self._branch_path=branch_path
150158
ifnameisnotNone:
151159
self._name=name
@@ -214,7 +222,7 @@ def __repr__(self) -> str:
214222

215223
@classmethod
216224
def_config_parser(
217-
cls,repo:"Repo",parent_commit:Union[Old_commit_ish,None],read_only:bool
225+
cls,repo:"Repo",parent_commit:Union["Commit",None],read_only:bool
218226
)->SubmoduleConfigParser:
219227
"""
220228
:return:
@@ -265,7 +273,7 @@ def _clear_cache(self) -> None:
265273
# END for each name to delete
266274

267275
@classmethod
268-
def_sio_modules(cls,parent_commit:Old_commit_ish)->BytesIO:
276+
def_sio_modules(cls,parent_commit:"Commit")->BytesIO:
269277
"""
270278
:return:
271279
Configuration file as :class:`~io.BytesIO` - we only access it through the
@@ -278,7 +286,7 @@ def _sio_modules(cls, parent_commit: Old_commit_ish) -> BytesIO:
278286
def_config_parser_constrained(self,read_only:bool)->SectionConstraint:
279287
""":return: Config parser constrained to our submodule in read or write mode"""
280288
try:
281-
pc:Union["Old_commit_ish",None]=self.parent_commit
289+
pc=self.parent_commit
282290
exceptValueError:
283291
pc=None
284292
# END handle empty parent repository

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp