Skip to content

Commit

Permalink
feat: cythonize helper fns
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler committed Nov 26, 2024
1 parent b4d45a7 commit ce4bf81
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions a_sync/a_sync/function.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class _ModifiedMixin:
return self.modifiers.default


def _validate_wrapped_fn(fn: Callable) -> None:
cpdef void _validate_wrapped_fn(fn: Callable):
"""Ensures 'fn' is an appropriate function for wrapping with a_sync.
Args:
Expand All @@ -102,10 +102,11 @@ def _validate_wrapped_fn(fn: Callable) -> None:
"""
if isinstance(fn, (AsyncPropertyDescriptor, AsyncCachedPropertyDescriptor)):
return # These are always valid
if not callable(fn):
raise TypeError(f"Input is not callable. Unable to decorate {fn}")
if isinstance(fn, _LRUCacheWrapper):
elif isinstance(fn, _LRUCacheWrapper):
fn = fn.__wrapped__
elif not callable(fn):
raise TypeError(f"Input is not callable. Unable to decorate {fn}")

_check_not_genfunc(fn)
try:
_validate_argspec(fn)
Expand Down Expand Up @@ -960,7 +961,7 @@ class ASyncDecorator(_ModifiedMixin):
return ASyncFunctionSyncDefault(func, **self.modifiers)


def _check_not_genfunc(func: Callable) -> None:
cdef void _check_not_genfunc(func: Callable):
"""Raises an error if the function is a generator or async generator.
Args:
Expand Down

0 comments on commit ce4bf81

Please sign in to comment.