Ship py.typed in the stub-generating component packages
All Submissions:
- Have you followed the guidelines stated in CONTRIBUTING.md file?
- Have you checked to ensure there aren't any other open Pull Requests for the desired changed?
Type of change
- Bug fix (non-breaking change which fixes an issue)
Description
Every workspace package that generates .pyi stubs at build time (the ones stub_packages() in tests/units/test_build_config.py picks up: the twelve reflex-components-* packages from the issue plus reflex-components-internal and reflex-site-shared) now ships an empty py.typed. Hatchling picks it up without config changes; the built reflex_components_radix wheel contains reflex_components_radix/py.typed next to themes/layout/box.pyi.
Once the packages are marked typed, pyright applies its library re-export rules to them, which flagged two in-repo imports:
reflex_components_radix.themes.components.icon_buttonimportsIconfrom thereflex_components_lucideroot. That root, and the other package roots that import names from their submodules (gridjs,moment,plotly,react-player,sonner), now re-export them explicitly withfrom .x import Name as Name, the formreflex_components_markdownandMomentDeltaalready use. Without this, code likefrom reflex_components_sonner import toastwould start failing pyright (reportPrivateImportUsage) and mypy--no-implicit-reexportonce the markers land; a probe importing all of these names from the roots reports 9 such errors on the first commit and none now.tests/units/utils/test_serializers.pyimportedColorthroughreflex_components_core.core.colors; it now imports it fromreflex_base.constants.colors, where it is defined.
A new parametrized test, test_package_ships_py_typed, asserts that each stub-generating package has a py.typed and that its wheel config includes it, so a newly split package can't drop the marker silently again. News fragments are added per package.
Testing
- The repro from the issue (
mypy --strict, mypy 2.4.1) against the workspace install: before,import-untypedonreflex_components_radix.themes.layout.box,no-any-return, andrx.box/Boxrevealed asAny. After:Success: no issues found, withrx.boxrevealed as the generatedBox.createsignature. uv run pytest tests/units/test_build_config.py: the new test fails for all 14 packages without the markers and passes with them (78 passed).uv run pytest tests/units: 15290 passed. The 6 failures intests/units/reflex_cli/...andtest_event.py::test_arg_mismatch_warning_renders_brackets_verbatimfail the same way onmainin my environment (terminal-width dependent output).uv run pre-commit run --all-filespasses, including pyright and ty.reflex-release changelog-checkpasses.pyrightandmypy --stricton a probe that importsDataTable,Icon,Moment,MomentProvider,Plotly*,Audio,Videoandtoastfrom the package roots: no errors.
Closes #7708