31
31
32
32
# typing-------------------------------------------------------
33
33
34
- from typing import TYPE_CHECKING , Tuple
34
+ from typing import Any , Callable , Mapping , TYPE_CHECKING , Tuple
35
35
36
- from git .types import Literal
36
+ from git .types import Literal , Lit_config_levels , TBD
37
37
38
38
if TYPE_CHECKING :
39
39
pass
59
59
class MetaParserBuilder (abc .ABCMeta ):
60
60
61
61
"""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 :
63
63
"""
64
64
Equip all base-class methods with a needs_values decorator, and all non-const methods
65
65
with a set_dirty_and_flush_changes decorator in addition to that."""
@@ -85,23 +85,23 @@ def __new__(cls, name, bases, clsdict):
85
85
return new_type
86
86
87
87
88
- def needs_values (func ) :
88
+ def needs_values (func : Callable ) -> Callable :
89
89
"""Returns method assuring we read values (on demand) before we try to access them"""
90
90
91
91
@wraps (func )
92
- def assure_data_present (self , * args , ** kwargs ) :
92
+ def assure_data_present (self , * args : Any , ** kwargs : Any ) -> Any :
93
93
self .read ()
94
94
return func (self , * args , ** kwargs )
95
95
# END wrapper method
96
96
return assure_data_present
97
97
98
98
99
- def set_dirty_and_flush_changes (non_const_func ) :
99
+ def set_dirty_and_flush_changes (non_const_func : Callable ) -> Callable :
100
100
"""Return method that checks whether given non constant function may be called.
101
101
If so, the instance will be set dirty.
102
102
Additionally, we flush the changes right to disk"""
103
103
104
- def flush_changes (self , * args , ** kwargs ) :
104
+ def flush_changes (self , * args : Any , ** kwargs : Any ) -> Any :
105
105
rval = non_const_func (self , * args , ** kwargs )
106
106
self ._dirty = True
107
107
self .write ()
@@ -206,7 +206,7 @@ def items_all(self):
206
206
return [(k , self .getall (k )) for k in self ]
207
207
208
208
209
- def get_config_path (config_level : Literal [ 'system' , 'global' , 'user' , 'repository' ] ) -> str :
209
+ def get_config_path (config_level : Lit_config_levels ) -> str :
210
210
211
211
# we do not support an absolute path of the gitconfig on windows ,
212
212
# use the global config instead
0 commit comments