9
9
Mapping ,
10
10
Optional ,
11
11
Type ,
12
+ TypeVar ,
12
13
)
13
14
14
15
from .constants import (
29
30
#: Further refinements are needed to define the input parameters
30
31
CommandFunc = Callable [..., Optional [bool ]]
31
32
33
+ CommandSetType = TypeVar ('CommandSetType' , bound = Type ['CommandSet' ])
32
34
33
- def with_default_category (category : str , * , heritable : bool = True ) -> Callable [[Type ['CommandSet' ]], Type ['CommandSet' ]]:
35
+
36
+ def with_default_category (category : str , * , heritable : bool = True ) -> Callable [[CommandSetType ], CommandSetType ]:
34
37
"""
35
38
Decorator that applies a category to all ``do_*`` command methods in a class that do not already
36
39
have a category specified.
@@ -41,15 +44,15 @@ def with_default_category(category: str, *, heritable: bool = True) -> Callable[
41
44
override the default category.
42
45
43
46
If `heritable` is set to False, then only the commands declared locally to this CommandSet will be placed in the
44
- specified category. Dynamically created commands, and commands declared in sub-classes will not receive this
47
+ specified category. Dynamically created commands and commands declared in sub-classes will not receive this
45
48
category.
46
49
47
50
:param category: category to put all uncategorized commands in
48
51
:param heritable: Flag whether this default category should apply to sub-classes. Defaults to True
49
52
:return: decorator function
50
53
"""
51
54
52
- def decorate_class (cls : Type [ CommandSet ] ) -> Type [ CommandSet ] :
55
+ def decorate_class (cls : CommandSetType ) -> CommandSetType :
53
56
if heritable :
54
57
setattr (cls , CLASS_ATTR_DEFAULT_HELP_CATEGORY , category )
55
58
0 commit comments