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

Commitefe6833

Browse files
committed
Add types to config.py CONFIG_LEVELS, MetaParserBuilder.__new__() .needs_values() .set_dirty_and_flush_changes()
1 parent37cef23 commitefe6833

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

‎git/config.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131

3232
# typing-------------------------------------------------------
3333

34-
fromtypingimportTYPE_CHECKING,Tuple
34+
fromtypingimportAny,Callable,Mapping,TYPE_CHECKING,Tuple
3535

36-
fromgit.typesimportLiteral
36+
fromgit.typesimportLiteral,Lit_config_levels,TBD
3737

3838
ifTYPE_CHECKING:
3939
pass
@@ -59,7 +59,7 @@
5959
classMetaParserBuilder(abc.ABCMeta):
6060

6161
"""Utlity class wrapping base-class methods into decorators that assure read-only properties"""
62-
def__new__(cls,name,bases,clsdict):
62+
def__new__(cls,name:str,bases:TBD,clsdict:Mapping[str,Any])->TBD:
6363
"""
6464
Equip all base-class methods with a needs_values decorator, and all non-const methods
6565
with a set_dirty_and_flush_changes decorator in addition to that."""
@@ -85,23 +85,23 @@ def __new__(cls, name, bases, clsdict):
8585
returnnew_type
8686

8787

88-
defneeds_values(func):
88+
defneeds_values(func:Callable)->Callable:
8989
"""Returns method assuring we read values (on demand) before we try to access them"""
9090

9191
@wraps(func)
92-
defassure_data_present(self,*args,**kwargs):
92+
defassure_data_present(self,*args:Any,**kwargs:Any)->Any:
9393
self.read()
9494
returnfunc(self,*args,**kwargs)
9595
# END wrapper method
9696
returnassure_data_present
9797

9898

99-
defset_dirty_and_flush_changes(non_const_func):
99+
defset_dirty_and_flush_changes(non_const_func:Callable)->Callable:
100100
"""Return method that checks whether given non constant function may be called.
101101
If so, the instance will be set dirty.
102102
Additionally, we flush the changes right to disk"""
103103

104-
defflush_changes(self,*args,**kwargs):
104+
defflush_changes(self,*args:Any,**kwargs:Any)->Any:
105105
rval=non_const_func(self,*args,**kwargs)
106106
self._dirty=True
107107
self.write()
@@ -206,7 +206,7 @@ def items_all(self):
206206
return [(k,self.getall(k))forkinself]
207207

208208

209-
defget_config_path(config_level:Literal['system','global','user','repository'])->str:
209+
defget_config_path(config_level:Lit_config_levels)->str:
210210

211211
# we do not support an absolute path of the gitconfig on windows ,
212212
# use the global config instead

‎git/repo/base.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
# typing ------------------------------------------------------
3636

37-
fromgit.typesimportTBD,PathLike,Literal
37+
fromgit.typesimportTBD,PathLike,Lit_config_levels
3838
fromtypingimport (Any,BinaryIO,Callable,Dict,
3939
Iterator,List,Mapping,Optional,
4040
TextIO,Tuple,Type,Union,
@@ -45,7 +45,6 @@
4545
fromgit.refs.symbolicimportSymbolicReference
4646
fromgit.objectsimportTagObject,Blob,Tree# NOQA: F401
4747

48-
Lit_config_levels=Literal['system','global','user','repository']
4948

5049
# -----------------------------------------------------------
5150

‎git/types.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
fromtyping_extensionsimportFinal,Literal# noqa: F401
1313

1414

15-
TBD=Any
16-
1715
ifsys.version_info[:2]< (3,6):
1816
# os.PathLike (PEP-519) only got introduced with Python 3.6
1917
PathLike=str
@@ -23,3 +21,7 @@
2321
elifsys.version_info[:2]>= (3,9):
2422
# os.PathLike only becomes subscriptable from Python 3.9 onwards
2523
PathLike=Union[str,os.PathLike[str]]
24+
25+
TBD=Any
26+
27+
Lit_config_levels=Literal['system','global','user','repository']

‎mypy.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
[mypy]
33

44
# TODO: enable when we've fully annotated everything
5-
#disallow_untyped_defs = True
5+
disallow_untyped_defs = True
66

77
# TODO: remove when 'gitdb' is fully annotated
88
[mypy-gitdb.*]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp