-
Notifications
You must be signed in to change notification settings - Fork 607
v1: Remove _async suffix from all methods, remove fire-n-forget counterparts
#5537
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
Conversation
Removed all synchronous wrapper methods that used asyncio.create_task to call async methods for focus, scrolling, launching URLs, and other UI actions. Updated all example usages and documentation to use async/await directly, ensuring a consistent asynchronous API surface. This change simplifies the codebase, reduces confusion between sync and async methods, and prepares for future async-only usage patterns.
There was a problem hiding this 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
Deploying flet-docs with
|
| Latest commit: |
1b68f8c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://d1cc9968.flet-docs.pages.dev |
| Branch Preview URL: | https://v1-remove-method-async.flet-docs.pages.dev |
Replaces the FLET_TEST_USE_FVM environment variable with FLET_TEST_DISABLE_FVM to control whether Flutter tests are run directly or via fvm. Updates documentation, CI configuration, and test app logic to reflect this change, ensuring consistency and clarity in test execution across environments.
Replaces usage of asyncio.create_task with dedicated async handler functions for button clicks and link taps in several Flet Python example files. This improves code readability and aligns with best practices for async event handling.
Renamed environment variable FLET_TEST_SIMILARITY_THRESHOLD to FLET_TEST_SCREENSHOTS_SIMILARITY_THRESHOLD and updated related documentation and code. Replaced FletTestApp.pixel_ratio and similarity_threshold with screenshots_pixel_ratio and screenshots_similarity_threshold, respectively. Updated test code and internal logic to use new names and improved FletTestApp constructor with explicit arguments and documentation. Also made Page.can_launch_url asynchronous.
sdk/python/packages/flet/src/flet/controls/core/canvas/canvas.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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 standardizes asynchronous method naming across the Flet codebase by removing the "_async" suffix from all async methods and eliminating their non-awaitable fire-and-forget wrapper counterparts. The changes consolidate on single awaitable methods for controls, services, and APIs while updating documentation and examples to reflect the new naming convention.
Key changes:
- Renamed all methods from
method_async()tomethod()and removed non-async wrappers - Updated internal invocation from
_invoke_method_asyncto_invoke_method - Modified examples, tests, and documentation to use the new async method signatures
Reviewed Changes
Copilot reviewed 85 out of 85 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
sdk/python/packages/flet/src/flet/testing/tester.py |
Updated method calls from _invoke_method_async to _invoke_method |
sdk/python/packages/flet/src/flet/testing/flet_test_app.py |
Enhanced documentation and renamed method calls to use new naming convention |
sdk/python/packages/flet/src/flet/controls/services/ |
Removed _async suffix from all service methods and eliminated wrapper methods |
sdk/python/packages/flet/src/flet/controls/material/ |
Updated button and form controls to use new async method naming |
sdk/python/packages/flet/src/flet/controls/core/ |
Updated core controls like Window, View, Screenshot to use new method names |
sdk/python/packages/flet/src/flet/auth/ |
Renamed auth provider and service methods to remove _async suffix |
| Examples and documentation | Updated all code samples to use new async method names |
sdk/python/Taskfile.yml |
Renamed pytest task to tests and added control-tests target |
Changed the teardown method in Tester to be asynchronous and updated its implementation to use await. Also clarified docstrings in Canvas methods by removing references to asynchronous behavior.
Close #5531
Summary by Sourcery
Standardize asynchronous method naming by removing the “_async” suffix and eliminating fire-and-forget wrappers, consolidating on single awaitable methods across controls, services, and APIs.
Enhancements:
Build:
Documentation: