summaryrefslogtreecommitdiff
path: root/cmd2/utils.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2021-02-20 20:19:23 -0500
committerTodd Leonhardt <todd.leonhardt@gmail.com>2021-02-20 20:19:23 -0500
commit67ea0627879e10e47380482156b1421862e3c956 (patch)
tree6539268b30382d59d5d77fbc1b36e8e4daecbc92 /cmd2/utils.py
parenta7119e1b26a8bae531b118b7cb8c4b195f731df6 (diff)
downloadcmd2-git-67ea0627879e10e47380482156b1421862e3c956.tar.gz
Deprecate Python 3.5
Diffstat (limited to 'cmd2/utils.py')
-rw-r--r--cmd2/utils.py7
1 files changed, 1 insertions, 6 deletions
diff --git a/cmd2/utils.py b/cmd2/utils.py
index 9920ad64..3f928e5f 100644
--- a/cmd2/utils.py
+++ b/cmd2/utils.py
@@ -1049,20 +1049,15 @@ def categorize(func: Union[Callable, Iterable[Callable]], category: str) -> None
setattr(func, constants.CMD_ATTR_HELP_CATEGORY, category)
-def get_defining_class(meth) -> Type:
+def get_defining_class(meth: Callable) -> Optional[Type]:
"""
Attempts to resolve the class that defined a method.
Inspired by implementation published here:
https://stackoverflow.com/a/25959545/1956611
- TODO: Python 3.5.2 is unable to handle the type hints Callable and Optional[Type].
- Restore proper type hints after we drop 3.5.2 support
-
:param meth: method to inspect
- :type meth: Callable
:return: class type in which the supplied method was defined. None if it couldn't be resolved.
- :rtype: Optional[Type]
"""
if isinstance(meth, functools.partial):
return get_defining_class(meth.func)