diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-06-10 15:26:39 -0400 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-06-10 15:26:39 -0400 |
commit | 6ba8d96321bf4052105f6f7fb6027d9e7073ea6c (patch) | |
tree | 905201d4fbea778705871d591810b0ae3258d782 /cmd2/utils.py | |
parent | f9de7370c09b382095e4dbde3ff2b0af2f391566 (diff) | |
download | cmd2-git-6ba8d96321bf4052105f6f7fb6027d9e7073ea6c.tar.gz |
Added yet more type hinting
Diffstat (limited to 'cmd2/utils.py')
-rw-r--r-- | cmd2/utils.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/cmd2/utils.py b/cmd2/utils.py index 84b09168..11d48b78 100644 --- a/cmd2/utils.py +++ b/cmd2/utils.py @@ -4,7 +4,7 @@ import collections import os -from typing import Optional +from typing import Any, List, Optional, Union from . import constants @@ -31,7 +31,8 @@ def strip_quotes(arg: str) -> str: return arg -def namedtuple_with_defaults(typename, field_names, default_values=()): +def namedtuple_with_defaults(typename: str, field_names: Union[str, List[str]], + default_values: collections.Iterable=()): """ Convenience function for defining a namedtuple with default values @@ -60,7 +61,8 @@ def namedtuple_with_defaults(typename, field_names, default_values=()): return T -def namedtuple_with_two_defaults(typename, field_names, default_values=('', '')): +def namedtuple_with_two_defaults(typename: str, field_names: Union[str, List[str]], + default_values: collections.Iterable=('', '')): """Wrapper around namedtuple which lets you treat the last value as optional. :param typename: str - type name for the Named tuple @@ -75,7 +77,7 @@ def namedtuple_with_two_defaults(typename, field_names, default_values=('', '')) return T -def cast(current, new): +def cast(current: Any, new: str) -> Any: """Tries to force a new value into the same type as the current when trying to set the value for a parameter. :param current: current value for the parameter, type varies |