Skip to content

Commit 831197c

Browse files
committed
Minor fixes to enable Python 3.5.2 support
1 parent 115143a commit 831197c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cmd2/utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import threading
1414
import unicodedata
1515
from enum import Enum
16-
from typing import Any, Callable, Dict, Iterable, List, Optional, TextIO, Type, Union
16+
from typing import Any, Callable, Dict, Iterable, List, Optional, TextIO, Union
1717

1818
from . import constants
1919

@@ -1041,15 +1041,20 @@ def categorize(func: Union[Callable, Iterable[Callable]], category: str) -> None
10411041
setattr(func, constants.CMD_ATTR_HELP_CATEGORY, category)
10421042

10431043

1044-
def get_defining_class(meth: Callable) -> Optional[Type]:
1044+
def get_defining_class(meth):
10451045
"""
10461046
Attempts to resolve the class that defined a method.
10471047
10481048
Inspired by implementation published here:
10491049
https://stackoverflow.com/a/25959545/1956611
10501050
1051+
TODO: Python 3.5.2 is unable to handle the type hints Callable and Optional[Type].
1052+
Restore proper type hints after we drop 3.5.2 support
1053+
10511054
:param meth: method to inspect
1055+
:type meth: Callable
10521056
:return: class type in which the supplied method was defined. None if it couldn't be resolved.
1057+
:rtype: Optional[Type]
10531058
"""
10541059
if isinstance(meth, functools.partial):
10551060
return get_defining_class(meth.func)

0 commit comments

Comments
 (0)