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

Commit8469a12

Browse files
committed
Fix or ignore all mypy errors
1 parent50762f1 commit8469a12

File tree

16 files changed

+34
-40
lines changed

16 files changed

+34
-40
lines changed

‎git/config.py‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ def _included_paths(self) -> List[Tuple[str, str]]:
574574
ifkeyword.endswith("/i"):
575575
value=re.sub(
576576
r"[a-zA-Z]",
577-
lambdam:"[{}{}]".format(m.group().lower(),m.group().upper()),
577+
lambdam:f"[{m.group().lower()!r}{m.group().upper()!r}]",
578578
value,
579579
)
580580
ifself._repo.git_dir:
@@ -633,8 +633,6 @@ def read(self) -> None: # type: ignore[override]
633633
file_path=cast(IO[bytes],file_path)
634634
self._read(file_path,file_path.name)
635635
else:
636-
# Assume a path if it is not a file-object.
637-
file_path=cast(PathLike,file_path)
638636
try:
639637
withopen(file_path,"rb")asfp:
640638
file_ok=True
@@ -768,7 +766,7 @@ def _assure_writable(self, method_name: str) -> None:
768766
ifself.read_only:
769767
raiseIOError("Cannot execute non-constant method %s.%s"% (self,method_name))
770768

771-
defadd_section(self,section:str)->None:
769+
defadd_section(self,section:str|cp._UNNAMED_SECTION)->None:
772770
"""Assures added options will stay in order."""
773771
returnsuper().add_section(section)
774772

‎git/diff.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@
2121
Any,
2222
Iterator,
2323
List,
24+
Literal,
2425
Match,
2526
Optional,
27+
Sequence,
2628
Tuple,
2729
TYPE_CHECKING,
2830
TypeVar,
2931
Union,
3032
cast,
3133
)
32-
fromgit.typesimportLiteral,PathLike
34+
fromgit.typesimportPathLike
3335

3436
ifTYPE_CHECKING:
3537
fromsubprocessimportPopen
@@ -289,7 +291,7 @@ class DiffIndex(List[T_Diff]):
289291
The class improves the diff handling convenience.
290292
"""
291293

292-
change_type= ("A","C","D","R","M","T")
294+
change_type:Sequence[Literal["A","C","D","R","M","T"]]= ("A","C","D","R","M","T")
293295
"""Change type invariant identifying possible ways a blob can have changed:
294296
295297
* ``A`` = Added

‎git/index/typ.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def from_base(cls, base: "BaseIndexEntry") -> "IndexEntry":
192192
Instance of type :class:`BaseIndexEntry`.
193193
"""
194194
time=pack(">LL",0,0)
195-
returnIndexEntry((base.mode,base.binsha,base.flags,base.path,time,time,0,0,0,0,0))
195+
returnIndexEntry((base.mode,base.binsha,base.flags,base.path,time,time,0,0,0,0,0))# type: ignore[arg-type]
196196

197197
@classmethod
198198
deffrom_blob(cls,blob:Blob,stage:int=0)->"IndexEntry":
@@ -211,5 +211,5 @@ def from_blob(cls, blob: Blob, stage: int = 0) -> "IndexEntry":
211211
0,
212212
0,
213213
blob.size,
214-
)
214+
)# type: ignore[arg-type]
215215
)

‎git/objects/commit.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ def co_authors(self) -> List[Actor]:
900900
ifself.message:
901901
results=re.findall(
902902
r"^Co-authored-by: (.*) <(.*?)>$",
903-
self.message,
903+
str(self.message),
904904
re.MULTILINE,
905905
)
906906
forauthorinresults:

‎git/objects/submodule/base.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
)
2626
fromgit.objects.baseimportIndexObject,Object
2727
fromgit.objects.utilimportTraversableIterableObj
28+
from ...refs.remoteimportRemoteReference
2829
fromgit.utilimport (
2930
IterableList,
3031
RemoteProgress,
@@ -355,7 +356,7 @@ def _clone_repo(
355356
module_checkout_path=osp.join(str(repo.working_tree_dir),path)
356357

357358
ifurl.startswith("../"):
358-
remote_name=repo.active_branch.tracking_branch().remote_name
359+
remote_name=cast(RemoteReference,repo.active_branch.tracking_branch()).remote_name
359360
repo_remote_url=repo.remote(remote_name).url
360361
url=os.path.join(repo_remote_url,url)
361362

‎git/refs/head.py‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
fromgit.typesimportCommit_ish,PathLike
2323

2424
ifTYPE_CHECKING:
25-
fromgit.objectsimportCommit
2625
fromgit.refsimportRemoteReference
2726
fromgit.repoimportRepo
2827

@@ -44,9 +43,6 @@ class HEAD(SymbolicReference):
4443

4544
__slots__= ()
4645

47-
# TODO: This can be removed once SymbolicReference.commit has static type hints.
48-
commit:"Commit"
49-
5046
def__init__(self,repo:"Repo",path:PathLike=_HEAD_NAME)->None:
5147
ifpath!=self._HEAD_NAME:
5248
raiseValueError("HEAD instance must point to %r, got %r"% (self._HEAD_NAME,path))
@@ -149,7 +145,7 @@ class Head(Reference):
149145
k_config_remote_ref="merge"# Branch to merge from remote.
150146

151147
@classmethod
152-
defdelete(cls,repo:"Repo",*heads:"Union[Head, str]",force:bool=False,**kwargs:Any)->None:
148+
defdelete(cls,repo:"Repo",*heads:"Union[Head, str]",force:bool=False,**kwargs:Any)->None:# type: ignore[override]
153149
"""Delete the given heads.
154150
155151
:param force:

‎git/refs/log.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def from_line(cls, line: bytes) -> "RefLogEntry":
145145
actor=Actor._from_string(info[82 :email_end+1])
146146
time,tz_offset=parse_date(info[email_end+2 :])# skipcq: PYL-W0621
147147

148-
returnRefLogEntry((oldhexsha,newhexsha,actor, (time,tz_offset),msg))
148+
returnRefLogEntry(oldhexsha,newhexsha,actor, (time,tz_offset),msg)# type: ignore[call-arg]
149149

150150

151151
classRefLog(List[RefLogEntry],Serializable):

‎git/refs/symbolic.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -916,8 +916,7 @@ def from_path(cls: Type[T_References], repo: "Repo", path: PathLike) -> T_Refere
916916
SymbolicReference,
917917
):
918918
try:
919-
instance:T_References
920-
instance=ref_type(repo,path)
919+
instance=cast(T_References,ref_type(repo,path))
921920
ifinstance.__class__isSymbolicReferenceandinstance.is_detached:
922921
raiseValueError("SymbolicRef was detached, we drop it")
923922
else:

‎git/refs/tag.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ class TagReference(Reference):
4545
_common_default="tags"
4646
_common_path_default=Reference._common_path_default+"/"+_common_default
4747

48-
@property
49-
defcommit(self)->"Commit":#type: ignore[override] #LazyMixin has unrelated commit method
48+
@property# type: ignore[misc]
49+
defcommit(self)->"Commit":# LazyMixin has unrelated commit method
5050
""":return: Commit object the tag ref points to
5151
5252
:raise ValueError:
@@ -80,8 +80,8 @@ def tag(self) -> Union["TagObject", None]:
8080
returnNone
8181

8282
# Make object read-only. It should be reasonably hard to adjust an existing tag.
83-
@property
84-
defobject(self)->AnyGitObject:# type: ignore[override]
83+
@property# type: ignore[misc]
84+
defobject(self)->AnyGitObject:
8585
returnReference._get_object(self)
8686

8787
@classmethod

‎git/repo/base.py‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -684,11 +684,7 @@ def _config_reader(
684684
git_dir:Optional[PathLike]=None,
685685
)->GitConfigParser:
686686
ifconfig_levelisNone:
687-
files= [
688-
self._get_config_path(cast(Lit_config_levels,f),git_dir)
689-
forfinself.config_level
690-
ifcast(Lit_config_levels,f)
691-
]
687+
files= [self._get_config_path(f,git_dir)forfinself.config_leveliff]
692688
else:
693689
files= [self._get_config_path(config_level,git_dir)]
694690
returnGitConfigParser(files,read_only=True,repo=self)
@@ -1484,7 +1480,7 @@ def clone(
14841480
self.common_dir,
14851481
path,
14861482
type(self.odb),
1487-
progress,
1483+
progress,# type: ignore[arg-type]
14881484
multi_options,
14891485
allow_unsafe_protocols=allow_unsafe_protocols,
14901486
allow_unsafe_options=allow_unsafe_options,
@@ -1545,7 +1541,7 @@ def clone_from(
15451541
url,
15461542
to_path,
15471543
GitCmdObjectDB,
1548-
progress,
1544+
progress,# type: ignore[arg-type]
15491545
multi_options,
15501546
allow_unsafe_protocols=allow_unsafe_protocols,
15511547
allow_unsafe_options=allow_unsafe_options,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp