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

Commit215abfd

Browse files
committed
Readd typeguard to Diff.py
1 parent1eceb89 commit215abfd

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

‎git/diff.py‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# typing ------------------------------------------------------------------
1717

1818
fromtypingimportAny,Iterator,List,Match,Optional,Tuple,Type,Union,TYPE_CHECKING,cast
19-
fromgit.typesimportPathLike,TBD,Literal
19+
fromgit.typesimportPathLike,TBD,Literal,TypeGuard
2020

2121
ifTYPE_CHECKING:
2222
from .objects.treeimportTree
@@ -26,8 +26,13 @@
2626

2727
Lit_change_type=Literal['A','D','C','M','R','T']
2828

29+
30+
defis_change_type(inp:str)->TypeGuard[Lit_change_type]:
31+
returninpin ['A','D','C','M','R','T']
32+
2933
# ------------------------------------------------------------------------
3034

35+
3136
__all__= ('Diffable','DiffIndex','Diff','NULL_TREE')
3237

3338
# Special object to compare against the empty tree in diffs
@@ -202,6 +207,7 @@ def iter_change_type(self, change_type: Lit_change_type) -> Iterator['Diff']:
202207

203208
fordiffinself:
204209
diff=cast('Diff',diff)
210+
205211
ifdiff.change_type==change_type:
206212
yielddiff
207213
elifchange_type=="A"anddiff.new_file:
@@ -505,7 +511,8 @@ def _handle_diff_line(lines_bytes: bytes, repo: 'Repo', index: DiffIndex) -> Non
505511
# Change type can be R100
506512
# R: status letter
507513
# 100: score (in case of copy and rename)
508-
change_type:Lit_change_type=_change_type[0]# type: ignore
514+
assertis_change_type(_change_type[0])
515+
change_type:Lit_change_type=_change_type[0]
509516
score_str=''.join(_change_type[1:])
510517
score=int(score_str)ifscore_str.isdigit()elseNone
511518
path=path.strip()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp