Skip to content

Conversation

@nimaxin
Copy link

@nimaxin nimaxin commented Nov 24, 2025

Description

This PR adds PEP 561 type information support for the flet package.

Fixes #5854

Test Code

# After installing this branch, Pylance/mypy should recognize inline types without errors.

import flet

Type of change

  • New feature (non-breaking change which adds functionality)

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

(Not applicable)

Additional details

PEP 561 requires a py.typed marker file for typed packages. The file is intentionally empty. This change does not modify runtime behavior

@CLAassistant
Copy link

CLAassistant commented Nov 24, 2025

CLA assistant check
All committers have signed the CLA.

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 adds PEP 561 compliance to the flet package by introducing a py.typed marker file and configuring setuptools to include it in distributions, enabling type checkers like mypy and Pylance to recognize inline type annotations.

  • Added empty py.typed marker file in the flet package
  • Configured setuptools to include the py.typed file in package distributions
  • Explicitly configured package discovery for the src layout

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.

File Description
sdk/python/packages/flet/src/flet/py.typed Empty marker file required by PEP 561 for typed packages
sdk/python/packages/flet/pyproject.toml Added setuptools configuration for package discovery and to include py.typed in package data

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

@ndonkoHenri
Copy link
Contributor

Thanks for your contribution.

Can you please have a look at failing CI ?

@nimaxin
Copy link
Author

nimaxin commented Nov 24, 2025

Hi, thanks for reviewing!

Sorry, I haven't been working with setuptools recently, so I'm not sure which version Flet uses to build. Since setuptools v69.0.0, py.typed can be included automatically:
https://setuptools.pypa.io/en/latest/userguide/miscellaneous.html#controlling-files-in-the-distribution

Added in version v69.0.0: setuptools will attempt to include type information files by default in the distribution (.pyi and py.typed, as specified in PEP 561), as long as they are contained inside of a package directory (for the time being there is no automatic support for top-level .pyi files).

Please note however that this feature is EXPERIMENTAL and may change in the future.

If that's the case, we might not need to include these options in pyproject.toml at all. But for now, I think the changes I made will fix the CI issue.

@ndonkoHenri
Copy link
Contributor

I'm not sure which version Flet uses to build. Since setuptools v69.0.0, py.typed can be included automatically:
https://setuptools.pypa.io/en/latest/userguide/miscellaneous.html#controlling-files-in-the-distribution

I built the flet wheel locally to see which version of setuptools is being used, and it is latest one (80.9.0):

Building wheel from source distribution...
DEBUG Found workspace root: `/Users/ndonkohenri/PycharmProjects/flet-dev/flet/sdk/python`
DEBUG Using base executable for virtual environment: /Library/Frameworks/Python.framework/Versions/3.12/bin/python3.12
DEBUG Resolving build requirements
DEBUG Solving with installed Python version: 3.12.7
DEBUG Solving with target Python version: >=3.12.7
DEBUG Adding direct dependency: setuptools*
DEBUG Searching for a compatible version of setuptools (*)
DEBUG Selecting: setuptools==80.9.0 [compatible] (setuptools-80.9.0-py3-none-any.whl)
DEBUG Tried 1 versions: setuptools 1
DEBUG marker environment resolution took 0.000s
DEBUG Installing in setuptools==80.9.0 in /Users/ndonkohenri/.cache/uv/builds-v0/.tmpMLvmWG
DEBUG Registry requirement already cached: setuptools==80.9.0
DEBUG Installing build requirement: setuptools==80.9.0
DEBUG Creating PEP 517 build environment
DEBUG Calling `setuptools.build_meta.get_requires_for_build_wheel()`

pretty obvious, since we don't constrain it anywhere.

If that's the case, we might not need to include these options in pyproject.toml at all.

I guess, yh.

@nimaxin
Copy link
Author

nimaxin commented Nov 25, 2025

Hi @ndonkoHenri

I have cleaned up the PR to include only the py.typed file. All pyproject.toml changes including packages.find were removed since they are unrelated

@ndonkoHenri
Copy link
Contributor

I personally dont see the issue you are trying to solve on my vscode. can you share a screenshot of how it appears from your IDE?

I will suggest you give it a try to see if it fixes your issue:

  • open your Flet fork from your IDE, navigate to sdk/python/packages/flet and create new venv with uv venv
  • build the package : uv build
  • install the package: uv pip install dist/*.whl
  • then create a simple app to see if the issue is fixed.

@nimaxin
Copy link
Author

nimaxin commented Nov 26, 2025

I tested the PR as you suggested. Screenshots are attached:
before
before
after
after

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: Add type stubs or py.typed marker for Pylance support

3 participants