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