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

Commitb070e93

Browse files
committed
Make some broad mypy suppressions more specific
- Change every bare `# type: ignore` into `# type: ignore[reason]`, where the specific reason is verified by mypy.- Use separate `# type: ignore[X]` and `# type: ignore[Y]` for different parts of statement where a single bare suppression was doing double duty, with each suppression only on the specific parts (splitting the statement into multiple lines for this).- Use the same suppression twice on very long statements where only specific parts need suppressions.This also formats all these comments with the same spacing (mostbut not all already were). This makes them easier to grep for.
1 parentebcfced commitb070e93

File tree

10 files changed

+43
-18
lines changed

10 files changed

+43
-18
lines changed

‎git/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def refresh(path: Optional[PathLike] = None) -> None:
147147
ifnotGit.refresh(path=path):
148148
return
149149
ifnotFetchInfo.refresh():# noqa: F405
150-
return# type: ignore[unreachable]
150+
return# type: ignore[unreachable]
151151

152152
GIT_OK=True
153153

‎git/cmd.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def pump_stream(
172172
p_stdout=process.proc.stdoutifprocess.procelseNone
173173
p_stderr=process.proc.stderrifprocess.procelseNone
174174
else:
175-
process=cast(Popen,process)# type: ignore[redundant-cast]
175+
process=cast(Popen,process)# type: ignore[redundant-cast]
176176
cmdline=getattr(process,"args","")
177177
p_stdout=process.stdout
178178
p_stderr=process.stderr
@@ -215,7 +215,7 @@ def pump_stream(
215215
error_str=error_str.encode()
216216
# We ignore typing on the next line because mypy does not like the way
217217
# we inferred that stderr takes str or bytes.
218-
stderr_handler(error_str)# type: ignore
218+
stderr_handler(error_str)# type: ignore[arg-type]
219219

220220
iffinalizer:
221221
finalizer(process)
@@ -1244,9 +1244,9 @@ def communicate() -> Tuple[AnyStr, AnyStr]:
12441244
ifoutput_streamisNone:
12451245
stdout_value,stderr_value=communicate()
12461246
# Strip trailing "\n".
1247-
ifstdout_value.endswith(newline)andstrip_newline_in_stdout:# type: ignore
1247+
ifstdout_value.endswith(newline)andstrip_newline_in_stdout:# type: ignore[arg-type]
12481248
stdout_value=stdout_value[:-1]
1249-
ifstderr_value.endswith(newline):# type: ignore
1249+
ifstderr_value.endswith(newline):# type: ignore[arg-type]
12501250
stderr_value=stderr_value[:-1]
12511251

12521252
status=proc.returncode
@@ -1256,7 +1256,7 @@ def communicate() -> Tuple[AnyStr, AnyStr]:
12561256
stdout_value=proc.stdout.read()
12571257
stderr_value=proc.stderr.read()
12581258
# Strip trailing "\n".
1259-
ifstderr_value.endswith(newline):# type: ignore
1259+
ifstderr_value.endswith(newline):# type: ignore[arg-type]
12601260
stderr_value=stderr_value[:-1]
12611261
status=proc.wait()
12621262
# END stdout handling

‎git/objects/commit.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,11 @@ def trailers_list(self) -> List[Tuple[str, str]]:
428428
List containing key-value tuples of whitespace stripped trailer information.
429429
"""
430430
cmd= ["git","interpret-trailers","--parse"]
431-
proc:Git.AutoInterrupt=self.repo.git.execute(cmd,as_process=True,istream=PIPE)# type: ignore
431+
proc:Git.AutoInterrupt=self.repo.git.execute(# type: ignore[call-overload]
432+
cmd,
433+
as_process=True,
434+
istream=PIPE,
435+
)
432436
trailer:str=proc.communicate(str(self.message).encode())[0].decode("utf8")
433437
trailer=trailer.strip()
434438

@@ -507,7 +511,7 @@ def _iter_from_process_or_stream(cls, repo: "Repo", proc_or_stream: Union[Popen,
507511
ifproc_or_stream.stdoutisnotNone:
508512
stream=proc_or_stream.stdout
509513
elifhasattr(proc_or_stream,"readline"):
510-
proc_or_stream=cast(IO,proc_or_stream)# type: ignore[redundant-cast]
514+
proc_or_stream=cast(IO,proc_or_stream)# type: ignore[redundant-cast]
511515
stream=proc_or_stream
512516

513517
readline=stream.readline

‎git/objects/submodule/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class Submodule(IndexObject, TraversableIterableObj):
108108
k_default_mode=stat.S_IFDIR|stat.S_IFLNK
109109
"""Submodule flags. Submodules are directories with link-status."""
110110

111-
type:Literal["submodule"]="submodule"# type: ignore
111+
type:Literal["submodule"]="submodule"# type: ignore[assignment]
112112
"""This is a bogus type string for base class compatibility."""
113113

114114
__slots__= ("_parent_commit","_url","_branch_path","_name","__weakref__")

‎git/objects/tree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ def __contains__(self, item: Union[IndexObjUnion, PathLike]) -> bool:
391391
returnFalse
392392

393393
def__reversed__(self)->Iterator[IndexObjUnion]:
394-
returnreversed(self._iter_convert_to_object(self._cache))# type: ignore
394+
returnreversed(self._iter_convert_to_object(self._cache))# type: ignore[call-overload]
395395

396396
def_serialize(self,stream:"BytesIO")->"Tree":
397397
"""Serialize this tree into the stream. Assumes sorted tree data.

‎git/objects/util.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,5 +692,13 @@ def traverse(
692692

693693
returncast(
694694
Union[Iterator[T_TIobj],Iterator[Tuple[Union[None,T_TIobj],T_TIobj]]],
695-
super()._traverse(predicate,prune,depth,branch_first,visit_once,ignore_self,as_edge),# type: ignore
695+
super()._traverse(
696+
predicate,# type: ignore[arg-type]
697+
prune,# type: ignore[arg-type]
698+
depth,
699+
branch_first,
700+
visit_once,
701+
ignore_self,
702+
as_edge,
703+
),
696704
)

‎git/refs/remote.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def iter_items(
5252
# subclasses and recommends Any or "type: ignore".
5353
# (See: https://github.com/python/typing/issues/241)
5454
@classmethod
55-
defdelete(cls,repo:"Repo",*refs:"RemoteReference",**kwargs:Any)->None:# type: ignore
55+
defdelete(cls,repo:"Repo",*refs:"RemoteReference",**kwargs:Any)->None:# type: ignore[override]
5656
"""Delete the given remote references.
5757
5858
:note:

‎git/refs/symbolic.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,17 @@ def set_object(
387387
# set the commit on our reference
388388
returnself._get_reference().set_object(object,logmsg)
389389

390-
commit=property(_get_commit,set_commit,doc="Query or set commits directly")# type: ignore
391-
object=property(_get_object,set_object,doc="Return the object our ref currently refers to")# type: ignore
390+
commit=property(
391+
_get_commit,
392+
set_commit,# type: ignore[arg-type]
393+
doc="Query or set commits directly",
394+
)
395+
396+
object=property(
397+
_get_object,
398+
set_object,# type: ignore[arg-type]
399+
doc="Return the object our ref currently refers to",
400+
)
392401

393402
def_get_reference(self)->"SymbolicReference":
394403
"""
@@ -488,7 +497,11 @@ def set_reference(
488497

489498
# Aliased reference
490499
reference:Union["Head","TagReference","RemoteReference","Reference"]
491-
reference=property(_get_reference,set_reference,doc="Returns the Reference we point to")# type: ignore
500+
reference=property(# type: ignore[assignment]
501+
_get_reference,
502+
set_reference,# type: ignore[arg-type]
503+
doc="Returns the Reference we point to",
504+
)
492505
ref=reference
493506

494507
defis_valid(self)->bool:

‎git/repo/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ def _get_config_path(self, config_level: Lit_config_levels, git_dir: Optional[Pa
636636
else:
637637
returnosp.normpath(osp.join(repo_dir,"config"))
638638
else:
639-
assert_never(# type:ignore[unreachable]
639+
assert_never(# type:ignore[unreachable]
640640
config_level,
641641
ValueError(f"Invalid configuration level:{config_level!r}"),
642642
)

‎git/util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ def expand_path(p: Union[None, PathLike], expand_vars: bool = True) -> Optional[
517517
ifisinstance(p,pathlib.Path):
518518
returnp.resolve()
519519
try:
520-
p=osp.expanduser(p)# type: ignore
520+
p=osp.expanduser(p)# type: ignore[arg-type]
521521
ifexpand_vars:
522522
p=osp.expandvars(p)
523523
returnosp.normpath(osp.abspath(p))
@@ -1209,7 +1209,7 @@ def __getattr__(self, attr: str) -> T_IterableObj:
12091209
# END for each item
12101210
returnlist.__getattribute__(self,attr)
12111211

1212-
def__getitem__(self,index:Union[SupportsIndex,int,slice,str])->T_IterableObj:# type: ignore
1212+
def__getitem__(self,index:Union[SupportsIndex,int,slice,str])->T_IterableObj:# type: ignore[override]
12131213
assertisinstance(index, (int,str,slice)),"Index of IterableList should be an int or str"
12141214

12151215
ifisinstance(index,int):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp