Repository navigation
Conversation
asyncio.iscoroutinefunction is deprecated since Python 3.14 and slated for removal in 3.16. CallbackQueryHandler (callable pattern) and Updater.start_polling (error_callback) called it, emitting a DeprecationWarning on 3.14+. inspect.iscoroutinefunction gives the same results on the supported Python versions (3.11+). Closes python-telegram-bot#5388
maoxor
force-pushed
the
inspect-iscoroutinefunction
branch
from
October 29, 2026 16:00
d0633d1 to
e4a7433
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #5388.
CallbackQueryHandler(with a callablepattern) andUpdater.start_polling(with anerror_callback) useasyncio.iscoroutinefunction, which emits aDeprecationWarningon Python 3.14+ and is slated for removal in 3.16. This switches them, and thecall_aftertest helper, toinspect.iscoroutinefunction.The swap doesn't change behaviour on the supported versions. On CPython 3.11, 3.12, 3.13, 3.14 and 3.15, both functions return the same result for
async def, plain functions, lambdas,functools.partialof each,AsyncMock(),MagicMock(), a boundasyncmethod and an instance with anasync __call__. (The difference withAsyncMockthat came up elsewhere only affects 3.10, which PTB no longer supports.)What I ran:
test_callbackqueryhandler.py,test_updater.py,test_application.pyandtest_baseupdateprocessor.py(the last two usecall_after), withTEST_WITH_OPT_DEPS=true:-W "error:'asyncio.iscoroutinefunction':DeprecationWarning": 29 + 72 + 162 + 9 passed. Onmaster, that flag makes 4 tests intest_callbackqueryhandler.pyand 6 intest_updater.pyfail.I didn't run the rest of the suite or the tests that need bot tokens.
Check-list for PRs
.. versionadded:: NEXT.VERSIONetc. (not needed: no user-facing change)AUTHORS.rst(optional)__all__s (not applicable)