Skip to content

Conversation

@ndonkoHenri
Copy link
Contributor

@ndonkoHenri ndonkoHenri commented Oct 17, 2025

Summary by Sourcery

Replace assertion-based validations with explicit exception raises and refine documentation

Enhancements:

  • Replace assert statements with explicit if checks raising ValueError, RuntimeError, IndexError, FletUnsupportedPlatformException, or FileNotFoundError for invalid inputs in map, UI controls, video, audio, and other classes
  • Update docstrings to describe the correct exception types, remove outdated examples, and standardize cross-reference syntax using (c) anchors
  • Modify pip utility functions to raise RuntimeError on package version mismatches and use FileNotFoundError for missing application bundles

@ndonkoHenri ndonkoHenri requested a review from Copilot October 17, 2025 14:01
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 replaces internal assertions with explicit runtime checks that raise well-defined exceptions and updates related docstrings accordingly.

  • Swapped assert statements for conditional checks raising ValueError, RuntimeError, or FletUnsupportedPlatformException where appropriate.
  • Updated docstrings to reflect new exception types and improved phrasing/links.
  • Minor refactors and cleanup in example snippets and messages.

Reviewed Changes

Copilot reviewed 45 out of 45 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
sdk/python/packages/flet/src/flet/utils/pip.py Replace asserts with explicit version mismatch checks; still installs on exceptions.
sdk/python/packages/flet/src/flet/testing/flet_test_app.py Convert asserts to raises; adjust error messages for clarity; change screenshot comparison behavior.
sdk/python/packages/flet/src/flet/pubsub/pubsub_hub.py Replace assert with RuntimeError when event loop is missing.
sdk/python/packages/flet/src/flet/controls/services/shared_preferences.py Replace assert with ValueError for None values.
sdk/python/packages/flet/src/flet/controls/material/menu_bar.py Replace assert in before_update with ValueError; docstring updates.
sdk/python/packages/flet/src/flet/controls/material/expansion_panel.py Replace asserts with raises; docstrings simplified/updated.
sdk/python/packages/flet/src/flet/controls/material/dropdownm2.py Replace assert with ValueError; doc updated.
sdk/python/packages/flet/src/flet/controls/material/dropdown.py Doc updates for exception types and text.
sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_colors.py Replace assert with ValueError in with_opacity; doc updated.
sdk/python/packages/flet/src/flet/controls/control_event.py Replace assert with RuntimeError when control has no page.
sdk/python/packages/flet/src/flet/controls/context.py Docstring updated to reflect RuntimeError.
sdk/python/packages/flet/src/flet/controls/colors.py Replace assert with ValueError in with_opacity; doc updated.
sdk/python/packages/flet/src/flet/controls/box.py Replace asserts with ValueError in post_init validations.
sdk/python/packages/flet/src/flet/controls/border.py Docstring update for ValueError.
sdk/python/packages/flet/src/flet/controls/base_page.py Replace assert with RuntimeError when views are empty.
sdk/python/packages/flet/src/flet/controls/base_control.py Replace asserts with RuntimeError for missing page before update/invoke/trigger.
sdk/python/packages/flet-webview/src/flet_webview/webview.py Replace assert with RuntimeError for page presence.
sdk/python/packages/flet-web/src/flet_web/fastapi/flet_app.py Replace assert with RuntimeError for missing upload path.
sdk/python/packages/flet-video/src/flet_video/video.py Replace asserts with ValueError; tighten index checks and messages; doc updates.
sdk/python/packages/flet-video/src/flet_video/types.py Doc link updates.
sdk/python/packages/flet-permission-handler/src/flet_permission_handler/types.py Doc link updates.
sdk/python/packages/flet-map/src/flet_map/types.py Replace asserts with ValueError; doc updates; link cleanups.
sdk/python/packages/flet-map/src/flet_map/tile_layer.py Replace asserts with ValueError; per-field validation docs; link fixes.
sdk/python/packages/flet-map/src/flet_map/source_attribution.py Replace assert with ValueError for visibility; doc updates.
sdk/python/packages/flet-map/src/flet_map/simple_attribution.py Doc link update.
sdk/python/packages/flet-map/src/flet_map/polyline_layer.py Replace asserts with ValueError in validation; doc updates.
sdk/python/packages/flet-map/src/flet_map/polygon_layer.py Replace assert with ValueError; doc updates.
sdk/python/packages/flet-map/src/flet_map/marker_layer.py Replace asserts with ValueError; doc updates.
sdk/python/packages/flet-map/src/flet_map/map.py Replace asserts with ValueError; doc tweaks.
sdk/python/packages/flet-map/src/flet_map/circle_layer.py Replace assert with ValueError; doc updates.
sdk/python/packages/flet-lottie/src/flet_lottie/lottie.py Replace assert with ValueError for required src/src_base64; doc updates.
sdk/python/packages/flet-geolocator/src/flet_geolocator/geolocator.py Replace asserts with FletUnsupportedPlatformException; doc updates.
sdk/python/packages/flet-desktop/src/flet_desktop/init.py Replace assert with FileNotFoundError; minor import reordering.
sdk/python/packages/flet-datatable2/src/flet_datatable2/datacolumn2.py Doc link update.
sdk/python/packages/flet-charts/src/flet_charts/pie_chart_section.py Replace asserts with ValueError in validation; doc updates.
sdk/python/packages/flet-charts/src/flet_charts/line_chart_data_point.py Doc link update.
sdk/python/packages/flet-charts/src/flet_charts/line_chart_data.py Doc link update.
sdk/python/packages/flet-charts/src/flet_charts/chart_axis.py Doc link updates.
sdk/python/packages/flet-charts/src/flet_charts/bar_chart.py Doc link updates and text tweaks.
sdk/python/packages/flet-audio/src/flet_audio/audio.py Replace assert with ValueError; doc updates.
sdk/python/packages/flet-audio-recorder/src/flet_audio_recorder/audio_recorder.py Replace assert with ValueError; doc updates.
sdk/python/packages/flet-ads/src/flet_ads/native_ad.py Replace assert with ValueError; doc updates.
sdk/python/packages/flet-ads/src/flet_ads/interstitial_ad.py Doc update to FletUnsupportedPlatformException.
sdk/python/packages/flet-ads/src/flet_ads/base_ad.py Replace assert with FletUnsupportedPlatformException; doc updates.
sdk/python/packages/flet-ads/src/flet_ads/banner_ad.py Doc update to FletUnsupportedPlatformException.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Oct 17, 2025

Deploying flet-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0dc41d4
Status: ✅  Deploy successful!
Preview URL: https://6dc412c6.flet-docs.pages.dev
Branch Preview URL: https://replace-more-assertions.flet-docs.pages.dev

View logs

FeodorFitsner and others added 2 commits October 17, 2025 09:22
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@FeodorFitsner FeodorFitsner merged commit 64f7191 into main Oct 19, 2025
30 of 53 checks passed
@FeodorFitsner FeodorFitsner deleted the replace-more-assertions branch October 19, 2025 19:30
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.

3 participants