summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkotfu <kotfu@kotfu.net>2018-09-05 22:25:37 -0600
committerkotfu <kotfu@kotfu.net>2018-09-05 22:25:37 -0600
commit7801d80ebaf2851ec0647733e385e88e90b2ae18 (patch)
treea21a82a996f1ad4405be8915aec2288524686f5d
parent2b42ac5507acb424fd30534397b60c1089bd09b4 (diff)
downloadcmd2-git-7801d80ebaf2851ec0647733e385e88e90b2ae18.tar.gz
Replace previously removed Statement initialization parameters
Statement is a subclass of str. Statement.__new__ should behave like str.__new__. Meaning it should accept any object as it’s argument, and our extended initialization parameters (i.e. command, arg_list) should not be allowed as positional arguments, only named arguments.
-rw-r--r--cmd2/parsing.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/cmd2/parsing.py b/cmd2/parsing.py
index 082cc7aa..553c5b9a 100644
--- a/cmd2/parsing.py
+++ b/cmd2/parsing.py
@@ -27,7 +27,8 @@ class Statement(str):
the output redirection clauses.
"""
def __new__(cls,
- value: str,
+ obj: object,
+ *,
raw: str = '',
command: str = '',
arg_list: List[str] = None,
@@ -58,7 +59,7 @@ class Statement(str):
We must override __new__ because we are subclassing `str` which is
immutable.
"""
- stmt = super().__new__(cls, value)
+ stmt = super().__new__(cls, obj)
stmt.raw = raw
stmt.command = command