|
1 | 1 | from abc import abstractmethod |
2 | 2 | from collections import OrderedDict |
| 3 | +from sys import version_info |
3 | 4 |
|
4 | 5 | from makefun import with_signature |
5 | 6 |
|
|
11 | 12 | try: # python 3.5.3- |
12 | 13 | from typing import Type |
13 | 14 | except ImportError: |
14 | | - pass |
15 | | - |
16 | | - try: |
17 | | - from mini_lambda import x |
18 | | - CallableType = Union[Callable, type(x)] |
19 | | - except ImportError: |
20 | | - CallableType = Callable |
| 15 | + use_typing = False |
| 16 | + else: |
| 17 | + try: |
| 18 | + from mini_lambda import x |
| 19 | + CallableType = Union[Callable, type(x)] |
| 20 | + except ImportError: |
| 21 | + CallableType = Callable |
21 | 22 |
|
22 | | - CallableAndFailureTuple = Tuple[CallableType, Union[str, 'Type[Failure]']] |
23 | | - """ Represents the allowed construct to define a failure raiser from a validation function: a tuple """ |
| 23 | + CallableAndFailureTuple = Tuple[CallableType, Union[str, 'Type[Failure]']] |
| 24 | + """ Represents the allowed construct to define a failure raiser from a validation function: a tuple """ |
24 | 25 |
|
25 | | - ValidationFunc = Union[CallableType, CallableAndFailureTuple] |
26 | | - """ Represents the 'typing' type for a single validation function """ |
| 26 | + ValidationFunc = Union[CallableType, CallableAndFailureTuple] |
| 27 | + """ Represents the 'typing' type for a single validation function """ |
27 | 28 |
|
28 | | - ValidationFuncs = Union[ValidationFunc, List['ValidationFuncs']] # recursion is used here ('forward reference') |
29 | | - """ Represents the 'typing' type for 'validation_func' arguments in the various methods """ |
| 29 | + ValidationFuncs = Union[ValidationFunc, List['ValidationFuncs']] # recursion is used here ('forward reference') |
| 30 | + """ Represents the 'typing' type for 'validation_func' arguments in the various methods """ |
30 | 31 |
|
31 | | - use_typing = True |
| 32 | + use_typing = version_info > (3, 0) |
32 | 33 |
|
33 | 34 | except TypeError: |
34 | 35 | # this happens with python 3.5.2: typing has an issue. |
|
0 commit comments