Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
keithasaurus committed Aug 12, 2024
1 parent 8ba404e commit ebb50ff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
9 changes: 3 additions & 6 deletions koda_validate/dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]]
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
9 changes: 5 additions & 4 deletions koda_validate/signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit ebb50ff

Please sign in to comment.