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

Commit1bcccd5

Browse files
committed
Fix Literal Typeguards
1 parent3578355 commit1bcccd5

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

‎git/diff.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929

3030
defis_change_type(inp:str)->TypeGuard[Lit_change_type]:
31-
returninpinLit_change_type.__args__# type: ignore
31+
returninpin('A','D','M','R','T')
3232

3333
# ------------------------------------------------------------------------
3434

‎git/types.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
Lit_config_levels=Literal['system','global','user','repository']
3939

4040

41+
defis_config_level(inp:str)->TypeGuard[Lit_config_levels]:
42+
returninpin ('system','global','user','repository')
43+
44+
4145
classConfigLevels_NT(NamedTuple):
4246
"""NamedTuple of allowed CONFIG_LEVELS"""
4347
# works for pylance, but not mypy
@@ -51,10 +55,6 @@ class ConfigLevels_NT(NamedTuple):
5155
# Typing this as specific literals breaks for mypy
5256

5357

54-
defis_config_level(inp:str)->TypeGuard[Lit_config_levels]:
55-
returninpinLit_config_levels.__args__# type: ignore # mypy lies about __args__
56-
57-
5858
defassert_never(inp:NoReturn,exc:Union[Exception,None]=None)->NoReturn:
5959
ifexcisNone:
6060
assertFalse,f"An unhandled Literal ({inp}) in an if else chain was found"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp