From ebb50ffc588d758a96100d51de483b12620b0e90 Mon Sep 17 00:00:00 2001 From: Keith Philpott Date: Mon, 12 Aug 2024 08:55:35 -0700 Subject: [PATCH] fix types --- koda_validate/dictionary.py | 9 +++------ koda_validate/signature.py | 9 +++++---- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/koda_validate/dictionary.py b/koda_validate/dictionary.py index fb9a25ed..b27f1660 100644 --- a/koda_validate/dictionary.py +++ b/koda_validate/dictionary.py @@ -303,9 +303,7 @@ def __init__( self, *, into: Callable[[T1], Ret], - keys: Tuple[ - KeyValidator[T1], - ], + keys: Tuple[KeyValidator[T1],], validate_object: Optional[Callable[[Ret], Optional[ErrType]]] = None, validate_object_async: Optional[ Callable[[Ret], Awaitable[Optional[ErrType]]] @@ -867,7 +865,6 @@ def __init__( ] = None, fail_on_unknown_keys: bool = False, ) -> None: - self.into = into # needs to be `Any` until we have variadic generics presumably self.keys: Tuple[KeyValidator[Any], ...] = keys @@ -891,8 +888,8 @@ def __init__( for key, val in keys: is_required = not isinstance(val, KeyNotRequired) - self._fast_keys_sync.append((key, _wrap_sync_validator(val), is_required)) # type: ignore # noqa: E501 - self._fast_keys_async.append((key, _wrap_async_validator(val), is_required)) # type: ignore # noqa: E501 + self._fast_keys_sync.append((key, _wrap_sync_validator(val), is_required)) + self._fast_keys_async.append((key, _wrap_async_validator(val), is_required)) self._key_set.add(key) self._unknown_keys_err: ExtraKeysErr = ExtraKeysErr(self._key_set) diff --git a/koda_validate/signature.py b/koda_validate/signature.py index ddbd216b..d2479871 100644 --- a/koda_validate/signature.py +++ b/koda_validate/signature.py @@ -59,7 +59,8 @@ ReturnOverrideKey = Tuple[Literal["return_key"]] RETURN_OVERRIDE_KEY: ReturnOverrideKey = ("return_key",) -OverridesDict = Dict[Union[str, ReturnOverrideKey], Validator[Any]] +OverridesDictKey = Union[str, ReturnOverrideKey] +OverridesDict = Dict[OverridesDictKey, Validator[Any]] def resolve_signature_typehint_default(annotation: Any) -> Validator[Any]: @@ -100,7 +101,7 @@ def resolve_signature_typehint_default(annotation: Any) -> Validator[Any]: def _get_validator( overrides: OverridesDict, typehint_resolver: Callable[[Any], Validator[Any]], - param_name: str, + param_name: OverridesDictKey, annotation: Any, ) -> Validator[Any]: return ( @@ -382,12 +383,12 @@ def validate_signature( def inner(func_inner: _DecoratedFunc) -> _DecoratedFunc: # there may be a good way to replace this cast with ParamSpec in the future - return cast(_DecoratedFunc, _wrap_fn_partial(func_inner)) + return _wrap_fn_partial(func_inner) return inner else: # there may be a good way to replace this cast with ParamSpec in the future - return cast(_DecoratedFunc, _wrap_fn_partial(func)) + return _wrap_fn_partial(func) def _trunc_str(s: str, max_chars: int) -> str: