Skip to content

Commit 63d60c7

Browse files
committed
ran black, fixed docstring
1 parent 5aa9182 commit 63d60c7

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

typing_validation/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
validation_aliases,
1212
validated,
1313
validated_iter,
14-
is_valid
14+
is_valid,
1515
)
1616
from .validation_failure import (
1717
get_validation_failure,

typing_validation/validation.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
MissingKeysValidationFailure,
2020
UnionValidationFailure,
2121
ValidationFailure,
22-
_set_latest_validation_failure
22+
_set_latest_validation_failure,
2323
)
2424
from .inspector import TypeInspector
2525

@@ -736,6 +736,7 @@ def can_validate(t: Any) -> TypeInspector:
736736
and :func:`validated_iter`.
737737
"""
738738

739+
739740
def is_valid(val: T, t: Any) -> bool:
740741
"""
741742
Performs the same functionality as :func:`validate`, but returning
@@ -752,6 +753,7 @@ def is_valid(val: T, t: Any) -> bool:
752753
_set_latest_validation_failure(getattr(e, "validation_failure"))
753754
return False
754755

756+
755757
def validated(val: T, t: Any) -> T:
756758
"""
757759
Performs the same functionality as :func:`validate`, but returns ``val``

typing_validation/validation_failure.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,9 @@ def latest_validation_failure() -> Optional[ValidationFailure]:
481481
ValidationFailure([2, 'hi'], list[int],
482482
ValidationFailure('hi', <class 'int'>)))
483483
484-
This validation failure information is also set by :func:`is_valid` in case
485-
of failed validation, even though no error is raised.
484+
This validation failure information is also set by
485+
:func:`~typing_validation.validation.is_valid` in case of failed validation,
486+
even though no error is raised.
486487
"""
487488
type_err: Optional[TypeError] = None
488489
try:
@@ -496,16 +497,18 @@ def latest_validation_failure() -> Optional[ValidationFailure]:
496497
return get_validation_failure(type_err)
497498
return latest_validation_failure
498499

500+
499501
_latest_validation_failure: Optional[ValidationFailure] = None
500502

503+
501504
def _set_latest_validation_failure(
502-
failure: Optional[ValidationFailure]
503-
) -> Optional[ValidationFailure]:
505+
failure: Optional[ValidationFailure],
506+
) -> Optional[ValidationFailure]:
504507
"""
505508
Sets a new value for ``_latest_validation_failure`` and returns
506509
the previous value.
507510
"""
508-
global _latest_validation_failure # pylint: disable = global-statement
511+
global _latest_validation_failure # pylint: disable = global-statement
509512
prev_failure = _latest_validation_failure
510513
_latest_validation_failure = failure
511514
return prev_failure

0 commit comments

Comments
 (0)