File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -102,8 +102,17 @@ def _cmd(self) -> 'cmd2.Cmd':
102102 Using this property ensures that self.__cmd_internal has been set
103103 and it tells type checkers that it's no longer a None type.
104104
105- Override this property if you need to change its return type to a
106- child class of Cmd.
105+ Override this property to specify a more specific return type for static
106+ type checking. The typing.cast function can be used to assert to the
107+ type checker that the parent cmd2.Cmd instance is of a more specific
108+ subclass, enabling better autocompletion and type safety in the child class.
109+
110+ For example:
111+
112+ @property
113+ def _cmd(self) -> CustomCmdApp:
114+ return cast(CustomCmdApp, super()._cmd)
115+
107116
108117 :raises CommandSetRegistrationError: if CommandSet is not registered.
109118 """
You can’t perform that action at this time.
0 commit comments