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

Commit0eae33d

Browse files
committed
Add is_flatLiteral() Typeguard[] to remote.py
1 parenta2d9011 commit0eae33d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

‎git/remote.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
fromtypingimportAny,Callable,Dict,Iterator,List,Optional,Sequence,TYPE_CHECKING,Union,cast,overload
4040

41-
fromgit.typesimportPathLike,Literal,TBD
41+
fromgit.typesimportPathLike,Literal,TBD,TypeGuard
4242

4343
ifTYPE_CHECKING:
4444
fromgit.repo.baseimportRepo
@@ -48,8 +48,15 @@
4848
fromgit.objects.tagimportTagObject
4949

5050
flagKeyLiteral=Literal[' ','!','+','-','*','=','t']
51+
52+
53+
defis_flagKeyLiteral(inp:str)->TypeGuard[flagKeyLiteral]:
54+
returninpin [' ','!','+','-','=','*','t']
55+
56+
5157
# -------------------------------------------------------------
5258

59+
5360
log=logging.getLogger('git.remote')
5461
log.addHandler(logging.NullHandler())
5562

@@ -325,7 +332,7 @@ def _from_line(cls, repo: 'Repo', line: str, fetch_line: str) -> 'FetchInfo':
325332

326333
# parse lines
327334
control_character,operation,local_remote_ref,remote_local_ref_str,note=match.groups()
328-
control_character=cast(flagKeyLiteral,control_character)# can do this neater once 3.5 dropped
335+
assertis_flagKeyLiteral(control_character)
329336

330337
try:
331338
_new_hex_sha,_fetch_operation,fetch_note=fetch_line.split("\t")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp