Replace deprecated `asyncio.iscoroutinefunction` with `inspect.iscoroutinefunction` by edgarrmondragon · Pull Request #13890 · fastapi/fastapi · GitHub
Skip to content

Replace deprecated asyncio.iscoroutinefunction with inspect.iscoroutinefunction#13890

Closed
edgarrmondragon wants to merge 2 commits into
fastapi:masterfrom
edgarrmondragon:inspect-iscoroutinefunction
Closed

Replace deprecated asyncio.iscoroutinefunction with inspect.iscoroutinefunction#13890
edgarrmondragon wants to merge 2 commits into
fastapi:masterfrom
edgarrmondragon:inspect-iscoroutinefunction

Conversation

@edgarrmondragon

Copy link
Copy Markdown

Deprecated in Python 3.14 and will be removed in Python 3.16.

@YuriiMotov

Copy link
Copy Markdown
Member

@edgarrmondragon

Copy link
Copy Markdown
Author

I think it's early to do this refactor. We don't have any warning and without it we will miss occurrences of asyncio.iscoroutinefunction in new PRs and merge them. Do you think it's right time for this?

That's a good point. Final release of Python 3.14.0 is scheduled for 2025-10-07, and the first RC is only a little over a week away at this point, so I think

  • the short time frame
  • the fact that more people will start testing their FastAPI apps with Python 3.14 in the coming weeks now that pydantic-core supports it (that's how I discovered this)
  • there's no functional differences between the two methods

are good reasons to do this at this point.

I think we can wait till FastAPI supports Python 3.16 or other versions start to emit deprecation warnings

If you want to wait, the earliest I'd recommend is when final 3.14.0 comes out, but that's of course completely up to you.

@YuriiMotov YuriiMotov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should wait until all pending PRs (or most of them) have been reviewed and merged, then make sure we haven't introduced any new cases where deprecated call is used and then merge this.
Also, we need to check for other deprecated methods used as well.

I think this will happen automatically when Python 3.16 is released and FastAPI officially supports it (will start running tests on Python 3.16)

@YuriiMotov

Copy link
Copy Markdown
Member

See also: #14021

@edgarrmondragon edgarrmondragon deleted the inspect-iscoroutinefunction branch August 31, 2025 00:52
@edgarrmondragon

Copy link
Copy Markdown
Author

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