Skip to content

Conversation

@FeodorFitsner
Copy link
Contributor

@FeodorFitsner FeodorFitsner commented Aug 10, 2025

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:

  • Rename all _async functions to and drop their non-awaiting wrappers that used asyncio.create_task
  • Switch internal invocation helpers from _invoke_method_async to _invoke_method
  • Update Taskfile and CI commands: rename pytest task to tests and add a control-tests target with FLET_TEST_USE_FVM
  • Refactor examples, integration tests, and documentation to call and await the renamed async methods

Build:

  • Update Taskfile.yml with renamed tasks and new control-tests entry

Documentation:

  • Adjust cookbook and documentation examples to reflect the new awaitable method names and remove legacy suffixes

FeodorFitsner and others added 4 commits August 10, 2025 15:55
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.
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

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Aug 10, 2025

Deploying flet-docs with  Cloudflare Pages  Cloudflare Pages

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

View logs

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.
@ndonkoHenri ndonkoHenri requested a review from Copilot August 11, 2025 05:36

This comment was marked as outdated.

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.
@ndonkoHenri ndonkoHenri requested a review from Copilot August 12, 2025 12:38
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 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() to method() and removed non-async wrappers
  • Updated internal invocation from _invoke_method_async to _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.
@FeodorFitsner FeodorFitsner merged commit daa7eb9 into main Aug 12, 2025
3 checks passed
@FeodorFitsner FeodorFitsner deleted the v1-remove-method-async branch August 12, 2025 18:27
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.

v1: Remove _async suffix from all methods, remove fire-n-forget counterparts

3 participants