99 Mapping ,
1010 Optional ,
1111 Type ,
12+ TypeVar ,
1213)
1314
1415from .constants import (
2930#: Further refinements are needed to define the input parameters
3031CommandFunc = Callable [..., Optional [bool ]]
3132
33+ CommandSetType = TypeVar ('CommandSetType' , bound = Type ['CommandSet' ])
3234
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 ]:
3437 """
3538 Decorator that applies a category to all ``do_*`` command methods in a class that do not already
3639 have a category specified.
@@ -41,15 +44,15 @@ def with_default_category(category: str, *, heritable: bool = True) -> Callable[
4144 override the default category.
4245
4346 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
4548 category.
4649
4750 :param category: category to put all uncategorized commands in
4851 :param heritable: Flag whether this default category should apply to sub-classes. Defaults to True
4952 :return: decorator function
5053 """
5154
52- def decorate_class (cls : Type [ CommandSet ] ) -> Type [ CommandSet ] :
55+ def decorate_class (cls : CommandSetType ) -> CommandSetType :
5356 if heritable :
5457 setattr (cls , CLASS_ATTR_DEFAULT_HELP_CATEGORY , category )
5558
0 commit comments