Skip to content

Conversation

@Creeper19472
Copy link

@Creeper19472 Creeper19472 commented Dec 24, 2025

Description

This PR will replace all instances of asyncio.iscoroutinefunction in the codebase with inspect.iscoroutinefunction, because the former was marked as deprecated in Python 3.14 and will be removed in Python 3.16.

Fixes #5927

Test Code

# Test code for the review of this PR

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I signed the CLA.
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • New and existing tests pass locally with my changes
  • I have made corresponding changes to the documentation (if applicable)

Screenshots

Additional details

Summary by Sourcery

Enhancements:

  • Standardize coroutine function detection on inspect.iscoroutinefunction across page controls, app lifecycle hooks, messaging, and pubsub components for future Python compatibility.

Copilot AI review requested due to automatic review settings December 24, 2025 03:03
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

We've reviewed this pull request using the Sourcery rules engine

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses Python 3.14 deprecation warnings by replacing all instances of asyncio.iscoroutinefunction with inspect.iscoroutinefunction. The deprecated function is scheduled for removal in Python 3.16.

  • Replaced all 11 occurrences of asyncio.iscoroutinefunction with inspect.iscoroutinefunction
  • Added import inspect to all affected files that didn't already have it
  • No functional changes to the logic - this is a direct drop-in replacement

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
sdk/python/packages/flet/src/flet/testing/flet_test_app.py Added inspect import and replaced deprecated function call when checking if __flet_app_main is a coroutine
sdk/python/packages/flet/src/flet/pubsub/pubsub_hub.py Added inspect import and replaced deprecated function call when determining handler type in __send method
sdk/python/packages/flet/src/flet/messaging/session.py Added inspect import and replaced deprecated function calls (2 occurrences) when checking hook setup/cleanup functions
sdk/python/packages/flet/src/flet/messaging/pyodide_connection.py Added inspect import and replaced deprecated function call when checking __before_main callback
sdk/python/packages/flet/src/flet/messaging/flet_socket_server.py Added inspect import and replaced deprecated function call when checking __before_main callback
sdk/python/packages/flet/src/flet/controls/page.py Added inspect import and replaced deprecated function calls (4 occurrences) for checking coroutine handlers in run_task, login, _authorize_callback, and logout methods
sdk/python/packages/flet/src/flet/controls/base_control.py Replaced deprecated function call when checking event handler type in _trigger_event method (already had inspect imported)
sdk/python/packages/flet/src/flet/app.py Replaced deprecated function call when checking main function type in on_session_created (already had inspect imported)
sdk/python/packages/flet-web/src/flet_web/fastapi/flet_fastapi.py Added inspect import and replaced deprecated function calls (2 occurrences) when checking startup/shutdown handlers
sdk/python/packages/flet-web/src/flet_web/fastapi/flet_app.py Replaced deprecated function calls (2 occurrences) when checking main and before_main functions (already had inspect imported)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

feature: replace asyncio.iscoroutinefunction with inspect.iscoroutinefunction

1 participant