Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatible with cyfunction #21

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

FrostyLeaf
Copy link

No description provided.

# This change helps to work with some modules like `pydantic`, which wraps
# functions (includes coroutine functions) into cyfunctions. The method
# `inspect.isfunction()` cannot recognize them for now.
def is_func_or_cyfunc(object):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FrostyLeaf could you please add the description underneath the function as pydoc suggests?

# Compatible with coroutine cyfunction or other kind of functions which return coroutines
# but are not coroutine functions
co_or_ret = method(*request.args, **request.kwargs)
# Maybe `inspect.isawaitable()` is better?
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please elaborate on this comment? What are pros/cons of inspect.isawaitable? If we pick it, do we need this comment?

# functions (includes coroutine functions) into cyfunctions. The method
# `inspect.isfunction()` cannot recognize them for now.
def is_func_or_cyfunc(object):
return isfunction(object) or (type(object).__name__ == "cython_function_or_method")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FrostyLeaf could you please add test for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants