Skip to content

Commit 9914407

Browse files
committed
Renamed variable and updated comment.
1 parent 0281e5c commit 9914407

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

cmd2/command_set.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ def __init__(self) -> None:
4040
This will be set when the CommandSet is registered and it should be
4141
accessed by child classes using the self._cmd property.
4242
"""
43-
self.__cmd_internal: Cmd | None = None
43+
self._cmd_internal: Cmd | None = None
4444

4545
self._settables: dict[str, Settable] = {}
4646
self._settable_prefix = self.__class__.__name__
4747

4848
@property
4949
def _cmd(self) -> 'Cmd':
50-
"""Property for child classes to access self.__cmd_internal.
50+
"""Property for child classes to access self._cmd_internal.
5151
52-
Using this property ensures that self.__cmd_internal has been set
53-
and it tells type checkers that it's no longer a None type.
52+
Using this property ensures that the CommandSet has been registered
53+
and tells type checkers that self._cmd_internal is not None.
5454
5555
Override this property to specify a more specific return type for static
5656
type checking. The typing.cast function can be used to assert to the
@@ -66,9 +66,9 @@ def _cmd(self) -> CustomCmdApp:
6666
6767
:raises CommandSetRegistrationError: if CommandSet is not registered.
6868
"""
69-
if self.__cmd_internal is None:
69+
if self._cmd_internal is None:
7070
raise CommandSetRegistrationError('This CommandSet is not registered')
71-
return self.__cmd_internal
71+
return self._cmd_internal
7272

7373
def on_register(self, cmd: 'Cmd') -> None:
7474
"""First step to registering a CommandSet, called by cmd2.Cmd.
@@ -80,8 +80,8 @@ def on_register(self, cmd: 'Cmd') -> None:
8080
:param cmd: The cmd2 main application
8181
:raises CommandSetRegistrationError: if CommandSet is already registered.
8282
"""
83-
if self.__cmd_internal is None:
84-
self.__cmd_internal = cmd
83+
if self._cmd_internal is None:
84+
self._cmd_internal = cmd
8585
else:
8686
raise CommandSetRegistrationError('This CommandSet has already been registered')
8787

@@ -103,7 +103,7 @@ def on_unregistered(self) -> None:
103103
104104
Subclasses can override this to perform remaining cleanup steps.
105105
"""
106-
self.__cmd_internal = None
106+
self._cmd_internal = None
107107

108108
@property
109109
def settable_prefix(self) -> str:
@@ -120,7 +120,7 @@ def add_settable(self, settable: Settable) -> None:
120120
121121
:param settable: Settable object being added
122122
"""
123-
if self.__cmd_internal is not None:
123+
if self._cmd_internal is not None:
124124
if not self._cmd.always_prefix_settables:
125125
if settable.name in self._cmd.settables and settable.name not in self._settables:
126126
raise KeyError(f'Duplicate settable: {settable.name}')

0 commit comments

Comments
 (0)