You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- **All validation functions are now transformed into failure raisers**, including single callables, and including the code wrapped by `validator` context-manager entry point. `ValidationError.validation_outcome` is therefore renamed `ValidationError.failure` because it is now always guaranteed to be a `Failure`. `Validator` subclasses are now able to specify a `callable_creator`, to override the default `failure_raiser` implementation. Fixes#44
- Validation functions can now either have signature `f(v)`, `f(*args)`, `f(*args, **ctx)` or `f(v, **ctx)`. Fixes#39
- `ValidationFailed` class was merged with `Failure` class for simplification. So there are two main exception classes in valid8 now: `ValidationError` and `ValidationFailure`. When failures are not directly raised by the inner validation callable, `failure_raiser` raises instances of `Invalid` (either `InvalidValue` or `InvalidType` according to the case). Fixes#41
- The string representation of `ValidationError` and `ValidationFailure` was improved. In particular `ValidationError` does not display the name and outcome of the validation function anymore (since it is always a failure), and `ValidationFailure` now has a "compact" string representation option in a new `to_str()` method, used in composition messages to simplify the result.
----Details----
Validation functions:
- `_make_validation_func_callable` renamed `make_validation_func_callable`
- All validation functions are now transformed into failure raisers by `make_validation_func_callable`, including single callables.
- `make_validation_func_callable` can now receive a custom `callable_creator` (default is `failure_raiser`) that is applied to transform each callable to a failure raiser.
- validation callables can receive context dictionary if their signature contains a var-keyword arg. For this **all** internal composition and wrapping methods have been modified so as to pass the context along. Also, a new method `make_callable` is called by `failure_raiser` to inspect the provided function signature and wrap it accordingly so as to either pass or not pass the context `**ctx`. A new module `utils_signatures` is used behind the scenes to provide a version of `getfullargspec` capable of supporting partial methods, builtins and bound class and instance methods.
`Validator`:
- `Validator` is now a class with slots
- simplified `Validator._create_validation_error` because we are now sure that the outcome is a `Failure`
- `Validator` subclasses are now able to specify a `callable_creator`, to override the default `failure_raiser`
- `Validator._create_validation_error` is not anymore responsible for merging the call context and self context. `assert_valid` does.
`ValidationError`:
- `ValidationError.validation_outcome` renamed `ValidationError.failure` because it is now always guaranteed to be a `Failure`
- `ValidationError.create_manually` renamed `ValidationError.create_without_validator`
- New method `ValidationError.create_with_dynamic_type`, `add_base_type_dynamically` with a `@lru_cache` to improve performance (added `functools32` dependency for python 2).
`ValidationFailed` / `Failure`:
- class `ValidationFailed` merged with class `Failure` for simplification, into a `ValidationFailure`.
- when failures are not directly raised by the wrapped validation callable, `failure_raiser` raises instances of a subclass of `Invalid`: either `InvalidValue` or `InvalidType` according to the case.
Big `ValidationError` and `Failure` string representation simplification
- new method `to_str`
- removed `display_prefix_for_exc_outcomes`
- `compact_mode` argument in `get_details`, to get a
- `HelpMsgMixIn` simplification. Improved `HelpMsgFormattingException` to have better error messages in case of formatting issue
- `utils_string`: merged util methods `end_with_dot` and `end_with_dot_space`.
`validator` context-manager entry point:
- replaced `_DummyCallable` with a function.
- wrapped code validation errors now raises a failure like in `failure_raiser`
- new internal method `_get_wrapped_lines`
Misc:
- `pop_kwargs` is now in `base` submodule
Copy file name to clipboardExpand all lines: setup.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,8 @@
11
11
here=path.abspath(path.dirname(__file__))
12
12
13
13
# *************** Dependencies *********
14
-
INSTALL_REQUIRES= ['makefun', 'six', 'future;python_version<"3.3"', 'funcsigs;python_version<"3.3"', 'decopatch'] # 'typing_inspect' is now copied internally so as to be compliant with very old versions of typing module
0 commit comments