diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2019-03-14 20:15:21 -0400 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2019-03-14 20:15:21 -0400 |
commit | cd8183d463e50f0a5c9a9ff548554dc3c71124da (patch) | |
tree | 3e7d07b96c6127a926aca074c37baabda43bea74 | |
parent | 0a0768977b4bd52f4615da80881e33d8ac2d4358 (diff) | |
download | cmd2-git-cd8183d463e50f0a5c9a9ff548554dc3c71124da.tar.gz |
Improved type hints and documentation in StatementParser.__init__()
-rw-r--r-- | cmd2/parsing.py | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/cmd2/parsing.py b/cmd2/parsing.py index 1ffd3f05..380c9261 100644 --- a/cmd2/parsing.py +++ b/cmd2/parsing.py @@ -5,7 +5,7 @@ import os import re import shlex -from typing import Dict, List, Tuple, Union +from typing import Dict, Iterable, List, Optional, Tuple, Union import attr @@ -270,14 +270,25 @@ class StatementParser: Shortcuts is a list of tuples with each tuple containing the shortcut and the expansion. """ - def __init__( - self, - allow_redirection: bool = True, - terminators: List[str] = None, - multiline_commands: List[str] = None, - aliases: Dict[str, str] = None, - shortcuts: List[Tuple[str, str]] = None, - ): + def __init__(self, + allow_redirection: bool = True, + terminators: Optional[Iterable[str]] = None, + multiline_commands: Optional[Iterable[str]] = None, + aliases: Optional[Dict[str, str]] = None, + shortcuts: Optional[Iterable[Tuple[str, str]]] = None) -> None: + """Initialize an instance of StatementParser. + + The following will get converted to an immutable tuple before storing internally: + * terminators + * multiline commands + * shortcuts + + :param allow_redirection: (optional) should redirection and pipes be allowed? + :param terminators: (optional) iterable containing strings which should terminate multiline commands + :param multiline_commands: (optional) iterable containing the names of commands that accept multiline input + :param aliases: (optional) dictionary contaiing aliases + :param shortcuts (optional) an iterable of tuples with each tuple containing the shortcut and the expansion + """ self.allow_redirection = allow_redirection if terminators is None: self.terminators = (constants.MULTILINE_TERMINATOR,) |