Skip to content

Commit 0a07689

Browse files
committed
Made several attributes of StatementParser immutable
The following attributes within StatementParser were converted from mutable lists to immutable tuples: - terminators - multiline_commands - shortcuts
1 parent eb050d7 commit 0a07689

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

cmd2/cmd2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ def allow_redirection(self) -> bool:
555555
return self.statement_parser.allow_redirection
556556

557557
@property
558-
def shortcuts(self) -> List[Tuple[str, str]]:
558+
def shortcuts(self) -> Tuple[Tuple[str, str]]:
559559
"""Read-only property to access the shortcuts stored in the StatementParser."""
560560
return self.statement_parser.shortcuts
561561

cmd2/parsing.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,21 +280,21 @@ def __init__(
280280
):
281281
self.allow_redirection = allow_redirection
282282
if terminators is None:
283-
self.terminators = [constants.MULTILINE_TERMINATOR]
283+
self.terminators = (constants.MULTILINE_TERMINATOR,)
284284
else:
285-
self.terminators = terminators
285+
self.terminators = tuple(terminators)
286286
if multiline_commands is None:
287-
self.multiline_commands = []
287+
self.multiline_commands = ()
288288
else:
289-
self.multiline_commands = multiline_commands
289+
self.multiline_commands = tuple(multiline_commands)
290290
if aliases is None:
291291
self.aliases = {}
292292
else:
293293
self.aliases = aliases
294294
if shortcuts is None:
295-
self.shortcuts = []
295+
self.shortcuts = ()
296296
else:
297-
self.shortcuts = shortcuts
297+
self.shortcuts = tuple(shortcuts)
298298

299299
# commands have to be a word, so make a regular expression
300300
# that matches the first word in the line. This regex has three

0 commit comments

Comments
 (0)