Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/reflex-components-code/news/+py-typed.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ship a `py.typed` marker so type checkers such as mypy read the package's bundled `.pyi` stubs instead of treating it as untyped.
Empty file.
1 change: 1 addition & 0 deletions packages/reflex-components-core/news/+py-typed.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ship a `py.typed` marker so type checkers such as mypy read the package's bundled `.pyi` stubs instead of treating it as untyped.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ship a `py.typed` marker so type checkers such as mypy read the package's bundled `.pyi` stubs instead of treating it as untyped.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ship a `py.typed` marker so type checkers such as mypy read the package's bundled `.pyi` stubs instead of treating it as untyped, and mark the names the package root imports as re-exported.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Grid components."""

from .datatable import DataTable
from .datatable import DataTable as DataTable

data_table = DataTable.create
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ship a `py.typed` marker so type checkers such as mypy read the package's bundled `.pyi` stubs instead of treating it as untyped.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ship a `py.typed` marker so type checkers such as mypy read the package's bundled `.pyi` stubs instead of treating it as untyped, and mark the names the package root imports as re-exported.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Lucide Icon Component."""

from .icon import Icon
from .icon import Icon as Icon

icon = Icon.create
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ship a `py.typed` marker so type checkers such as mypy read the package's bundled `.pyi` stubs instead of treating it as untyped.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ship a `py.typed` marker so type checkers such as mypy read the package's bundled `.pyi` stubs instead of treating it as untyped, and mark the names the package root imports as re-exported.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Moment.js component."""

from .moment import Moment, MomentProvider
from .moment import Moment as Moment
from .moment import MomentDelta as MomentDelta
from .moment import MomentProvider as MomentProvider

moment = Moment.create
moment_provider = MomentProvider.create
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ship a `py.typed` marker so type checkers such as mypy read the package's bundled `.pyi` stubs instead of treating it as untyped, and mark the names the package root imports as re-exported.
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@

from reflex_base.components.component import ComponentNamespace

from .plotly import (
Plotly,
PlotlyBasic,
PlotlyCartesian,
PlotlyFinance,
PlotlyGeo,
PlotlyGl2d,
PlotlyGl3d,
PlotlyMapbox,
PlotlyStrict,
)
from .plotly import Plotly as Plotly
from .plotly import PlotlyBasic as PlotlyBasic
from .plotly import PlotlyCartesian as PlotlyCartesian
from .plotly import PlotlyFinance as PlotlyFinance
from .plotly import PlotlyGeo as PlotlyGeo
from .plotly import PlotlyGl2d as PlotlyGl2d
from .plotly import PlotlyGl3d as PlotlyGl3d
from .plotly import PlotlyMapbox as PlotlyMapbox
from .plotly import PlotlyStrict as PlotlyStrict


class PlotlyNamespace(ComponentNamespace):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ship a `py.typed` marker so type checkers such as mypy read the package's bundled `.pyi` stubs instead of treating it as untyped.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ship a `py.typed` marker so type checkers such as mypy read the package's bundled `.pyi` stubs instead of treating it as untyped, and mark the names the package root imports as re-exported.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""React Player component for audio and video."""

from . import react_player
from .audio import Audio
from .video import Video
from .audio import Audio as Audio
from .video import Video as Video

audio = Audio.create
video = Video.create
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ship a `py.typed` marker so type checkers such as mypy read the package's bundled `.pyi` stubs instead of treating it as untyped.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ship a `py.typed` marker so type checkers such as mypy read the package's bundled `.pyi` stubs instead of treating it as untyped, and mark the names the package root imports as re-exported.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Init file for the sonner component."""

from .toast import toast
from .toast import toast as toast
1 change: 1 addition & 0 deletions packages/reflex-site-shared/news/+py-typed.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ship a `py.typed` marker so type checkers such as mypy read the package's bundled `.pyi` stubs instead of treating it as untyped.
Empty file.
14 changes: 14 additions & 0 deletions tests/units/test_build_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,20 @@ def test_package_ships_only_its_own_stubs(
assert not config.include_path("tests/golden.pyi")


@pytest.mark.parametrize("package", stub_packages(), ids=lambda path: path.name)
def test_package_ships_py_typed(package: Path):
"""Type checkers ignore a package's stubs unless it ships a py.typed marker.

Args:
package: The workspace package directory.
"""
markers = sorted((package / "src").glob("*/py.typed"))
assert markers
config = WheelBuilder(str(package)).config
for marker in markers:
assert config.include_path(marker.relative_to(package).as_posix())


def build_hook(root: Path, directory: Path, target: str = "wheel"):
"""Load the stub-generating build hook and instantiate it against a root.

Expand Down
2 changes: 1 addition & 1 deletion tests/units/utils/test_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from typing import Any

import pytest
from reflex_base.constants.colors import Color
from reflex_base.utils.format import json_dumps
from reflex_base.vars.base import LiteralVar
from reflex_components_core.core.colors import Color

from reflex.utils import serializers

Expand Down