Skip to content

Commit 00a9ac6

Browse files
author
Sylvain MARIE
committed
removed makefun usage in validate_n_convert.py : was overkill. Also fixed a few type hints.
1 parent cdd5402 commit 00a9ac6

1 file changed

Lines changed: 4 additions & 18 deletions

File tree

‎pyfields/validate_n_convert.py‎

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import sys
55
from collections import OrderedDict
66

7-
from makefun import with_signature
8-
97
from valid8 import Validator, failure_raiser, ValidationError, ValidationFailure
108
from valid8.base import getfullargspec as v8_getfullargspec, get_callable_name, is_mini_lambda
119
from valid8.common_syntax import FunctionDefinitionError, make_validation_func_callables
@@ -16,7 +14,7 @@
1614

1715
try: # python 3.5+
1816
# noinspection PyUnresolvedReferences
19-
from typing import Callable, Type, Any, TypeVar, Union, Iterable, Tuple, Mapping, Optional
17+
from typing import Callable, Type, Any, TypeVar, Union, Iterable, Tuple, Mapping, Optional, Dict
2018
from valid8.common_syntax import ValidationFuncs
2119
use_type_hints = sys.version_info > (3, 0)
2220
except ImportError:
@@ -65,29 +63,15 @@
6563
Validators = OneOrSeveralVFDefinitions
6664

6765

68-
# Python 3+: load the 'more explicit api'
69-
if use_type_hints:
70-
new_sig = """(self,
71-
validated_field: 'DescriptorField',
72-
*validation_func: ValidationFuncs,
73-
error_type: 'Type[ValidationError]' = None,
74-
help_msg: str = None,
75-
none_policy: int = None,
76-
**kw_context_args):"""
77-
else:
78-
new_sig = None
79-
80-
8166
class FieldValidator(Validator):
8267
"""
8368
Represents a `Validator` responsible to validate a `field`
8469
"""
8570
__slots__ = '__weakref__', 'validated_field', 'base_validation_funcs'
8671

87-
@with_signature(new_sig)
8872
def __init__(self,
8973
validated_field, # type: 'DescriptorField'
90-
validators,
74+
validators, # type: Validators
9175
**kwargs
9276
):
9377
"""
@@ -210,11 +194,13 @@ def new_validation_callable(val, **ctx):
210194
return make_validator_callable
211195

212196
def get_additional_info_for_repr(self):
197+
# type: (...) -> str
213198
return 'validated_field=%s' % self.validated_field.qualname
214199

215200
def _get_name_for_errors(self,
216201
name # type: str
217202
):
203+
# type: (...) -> str
218204
""" override this so that qualname is only called if an error is raised, not before """
219205
return self.validated_field.qualname
220206

0 commit comments

Comments
 (0)