cmd2
cmd2 copied to clipboard
parameterize type declaration of with_default_category
The current type signature of with_default_category is:
def with_default_category(category: str, *, heritable: bool = True) -> Callable[[Type['CommandSet']], Type['CommandSet']]:
as a result, type analyzers such as pyright may treat the decorated class as if it is just a CommandSet rather than an actual subclass. Instead, the decorator should use a type variable. I think something along these lines might work:
CS = TypeVar("CS", bound=Type[CommandSet])
def with_default_category(category: str, *, heritable: bool = True) -> Callable[[CS], CS]: