Skip to content

Conversation

@janbjorge
Copy link
Owner

@janbjorge janbjorge commented Oct 9, 2025

The below PR / issues needs to be closed before we can add support for py314.

@janbjorge janbjorge self-assigned this Oct 9, 2025
@janbjorge janbjorge added the enhancement New feature or request label Oct 9, 2025
@janbjorge janbjorge marked this pull request as ready for review October 17, 2025 16:56
@janbjorge janbjorge merged commit 60dc187 into main Oct 17, 2025
36 checks passed
@janbjorge janbjorge deleted the chore/py314 branch October 17, 2025 16:56
return asyncio.iscoroutinefunction(obj) or (
callable(obj) and asyncio.iscoroutinefunction(obj.__call__)
return inspect.iscoroutinefunction(obj) or (
callable(obj) and inspect.iscoroutinefunction(getattr(obj, "__call__", None))
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm sorry to ask a dummy question, is the getattr necessary here?

Copy link
Owner Author

Choose a reason for hiding this comment

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

prob. not, unsure what i was thinking there.

Copy link
Owner Author

@janbjorge janbjorge Oct 17, 2025

Choose a reason for hiding this comment

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

Copy link
Owner Author

@janbjorge janbjorge Oct 18, 2025

Choose a reason for hiding this comment

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

Sorry for the back and forth, i've been writing loads of tests to dig here see.

But the gist of it; Yes, getattr is needed. inspect.iscoroutinefunction(obj) only works for actual async function objects. Instances with async call return False there, so you must look at obj.call. Using getattr(obj, "call", None) avoids an AttributeError and cleanly checks the bound method. Without it you’d misclassify async callable instances or need a try/except.

EDIT;
Make sure to check look at these test cases; https://github.com/janbjorge/pgqueuer/pull/473/files#diff-998ed263122511bfcb910e08f8830fd62a83287a5b2aec5a40e351f5ba5d47adR536

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for your reply, I didn't aware of that

Copy link
Owner Author

Choose a reason for hiding this comment

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

thanks for asking @trim21 it lead me down an crazy rabithole that i enjoyed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants