Skip to content

Commit

Permalink
Fix: Fix type hint for Coerce type param (#488)
Browse files Browse the repository at this point in the history
* Fix: Fix type hint for Coerce type param

Coerce can accept a callable as type.

* Update validators.py

Fix: type. hint

* Update voluptuous/validators.py

Co-authored-by: Antoni Szych <antoni.szych@rtbhouse.com>

---------

Co-authored-by: Alec Thomas <alec@swapoff.org>
Co-authored-by: Antoni Szych <antoni.szych@rtbhouse.com>
  • Loading branch information
3 people authored Dec 12, 2023
1 parent b90b3f0 commit 79d9dd7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion voluptuous/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class Coerce(object):
... validate('foo')
"""

def __init__(self, type: type, msg: typing.Optional[str] = None) -> None:
def __init__(self, type: typing.Union[type, typing.Callable], msg: typing.Optional[str] = None) -> None:
self.type = type
self.msg = msg
self.type_name = type.__name__
Expand Down

0 comments on commit 79d9dd7

Please sign in to comment.