Skip to content

Commit a97b75b

Browse files
authored
chore: explicitly re-export components (#951)
Helps typing and linting tools know the structure of the package. Fixes #950 Fixes #465
1 parent 5b7e2d7 commit a97b75b

File tree

6 files changed

+265
-64
lines changed

6 files changed

+265
-64
lines changed

solara/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ def _using_solara_server():
4040
use_state,
4141
use_state_widget,
4242
)
43-
from reacton.core import Element
44-
from .core import component
43+
from reacton.core import Element as Element
44+
from .core import component as component
4545

4646
try:
4747
import ipyvuetify.components as v # type: ignore
@@ -57,9 +57,7 @@ def _using_solara_server():
5757
from .cache import memoize
5858
from . import cache
5959

60-
# TODO: components re-exports v, we should use __all__ in components/misc.py
6160
from .components import * # type: ignore
62-
from .components import _component_vue
6361

6462
from .routing import use_route, use_router, use_route_level, find_route, use_pathname, resolve_path
6563
from .autorouting import generate_routes, generate_routes_directory, RenderPage, RoutingProvider, DefaultLayout

solara/components/__init__.py

Lines changed: 163 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,82 @@
11
# isort: skip_file
2-
from .button import Button # noqa: F401
3-
from .style import Style # noqa: F401 F403
4-
from .misc import * # noqa: F401 F403
5-
from .alert import Warning, Info, Error, Success # noqa: F401 F403
6-
from .checkbox import Checkbox # noqa: F401 F403
7-
from .cross_filter import ( # noqa: F401
2+
from .button import Button
3+
from .style import Style
4+
from .misc import (
5+
Navigator,
6+
GridDraggable,
7+
GridLayout,
8+
ListItem,
9+
ui_dropdown,
10+
ui_text,
11+
ui_checkbox,
12+
ui_slider,
13+
Text,
14+
Div,
15+
Preformatted,
16+
IconButton,
17+
HTML,
18+
VBox,
19+
HBox,
20+
Row,
21+
Column,
22+
GridFixed,
23+
Padding,
24+
FigurePlotly,
25+
Code,
26+
)
27+
from .alert import Warning, Info, Error, Success
28+
from .checkbox import Checkbox
29+
from .cross_filter import (
830
CrossFilterDataFrame,
931
CrossFilterReport,
1032
CrossFilterSelect,
1133
CrossFilterSlider,
1234
)
13-
from .datatable import DataTable, DataFrame # noqa: F401 F403
14-
from .details import Details # noqa: F401 F403
15-
from .file_browser import FileBrowser # noqa: F401 F403
16-
from .image import Image # noqa: F401 F403
17-
from .markdown import Markdown, MarkdownIt # noqa: F401 F403
18-
from .slider import ( # noqa: F401 F403
19-
DateSlider, # noqa: F401 F403
20-
FloatSlider, # noqa: F401 F403
21-
IntSlider, # noqa: F401 F403
22-
ValueSlider, # noqa: F401 F403
23-
SliderDate, # noqa: F401 F403
24-
SliderFloat, # noqa: F401 F403
25-
SliderInt, # noqa: F401 F403
26-
SliderValue, # noqa: F401 F403
27-
SliderRangeInt, # noqa: F401 F403
28-
SliderRangeFloat, # noqa: F401 F403
29-
) # noqa: F401 F403
30-
from .sql_code import SqlCode # noqa: F401 F403
31-
from .togglebuttons import ( # noqa: F401 F403
35+
from .datatable import DataTable, DataFrame
36+
from .details import Details
37+
from .file_browser import FileBrowser
38+
from .image import Image
39+
from .markdown import Markdown, MarkdownIt
40+
from .slider import (
41+
DateSlider,
42+
FloatSlider,
43+
IntSlider,
44+
ValueSlider,
45+
SliderDate,
46+
SliderFloat,
47+
SliderInt,
48+
SliderValue,
49+
SliderRangeInt,
50+
SliderRangeFloat,
51+
)
52+
from .sql_code import SqlCode
53+
from .togglebuttons import (
3254
ToggleButtonsMultiple,
3355
ToggleButtonsSingle,
3456
)
35-
from .input import InputText, InputFloat, InputInt # noqa: F401 F403
36-
from .input_text_area import InputTextArea # noqa: F401 F403
37-
from .pivot_table import PivotTableView, PivotTable, PivotTableCard # noqa: F401 F403
38-
from .head import Head # noqa: F401 F403
39-
from .title import Title # noqa: F401 F403
40-
from .link import Link # noqa: F401 F403
41-
from .applayout import AppLayout, Sidebar, AppBar, AppBarTitle # noqa: F401 F403
42-
from .tab_navigation import TabNavigation # noqa: F401 F403
43-
from .markdown_editor import MarkdownEditor # noqa: F401 F403
44-
from .select import Select, SelectMultiple # noqa: F401 F403
45-
from .matplotlib import FigureMatplotlib # noqa: F401 F403
46-
from .echarts import FigureEcharts # noqa: F401 F403
47-
from .figure_altair import FigureAltair, AltairChart # noqa: F401 F403
48-
from .meta import Meta # noqa: F401 F403
49-
from .columns import Columns, ColumnsResponsive # noqa: F401 F403
50-
from .file_drop import FileDrop, FileDropMultiple # noqa: F401 F403
51-
from .file_download import FileDownload # noqa: F401 F403
52-
from .tooltip import Tooltip # noqa: F401 F403
53-
from .card import Card, CardActions # noqa: F401 F403
54-
from .spinner import SpinnerSolara # noqa: F401 F403
55-
from .switch import Switch # noqa: F401 F403
56-
from .progress import ProgressLinear # noqa: F401 F403
57-
from .component_vue import _component_vue, component_vue # noqa: F401 F403
57+
from .input import InputText, InputFloat, InputInt
58+
from .input_text_area import InputTextArea
59+
from .pivot_table import PivotTableView, PivotTable, PivotTableCard
60+
from .head import Head
61+
from .title import Title
62+
from .link import Link
63+
from .applayout import AppLayout, Sidebar, AppBar, AppBarTitle
64+
from .tab_navigation import TabNavigation
65+
from .markdown_editor import MarkdownEditor
66+
from .select import Select, SelectMultiple
67+
from .matplotlib import FigureMatplotlib
68+
from .echarts import FigureEcharts
69+
from .figure_altair import FigureAltair, AltairChart
70+
from .meta import Meta
71+
from .columns import Columns, ColumnsResponsive
72+
from .file_drop import FileDrop, FileDropMultiple
73+
from .file_download import FileDownload
74+
from .tooltip import Tooltip
75+
from .card import Card, CardActions
76+
from .spinner import SpinnerSolara
77+
from .switch import Switch
78+
from .progress import ProgressLinear
79+
from .component_vue import _component_vue, component_vue
5880
import reacton.core
5981

6082
try:
@@ -65,6 +87,99 @@
6587
import logging
6688
from ..settings import main
6789

90+
91+
__all__ = [
92+
"Button",
93+
"Style",
94+
"Navigator",
95+
"GridDraggable",
96+
"GridLayout",
97+
"ListItem",
98+
"ui_dropdown",
99+
"ui_text",
100+
"ui_checkbox",
101+
"ui_slider",
102+
"Text",
103+
"Div",
104+
"Preformatted",
105+
"IconButton",
106+
"HTML",
107+
"VBox",
108+
"HBox",
109+
"Row",
110+
"Column",
111+
"GridFixed",
112+
"Padding",
113+
"FigurePlotly",
114+
"Code",
115+
"Warning",
116+
"Info",
117+
"Error",
118+
"Success",
119+
"Checkbox",
120+
"CrossFilterDataFrame",
121+
"CrossFilterReport",
122+
"CrossFilterSelect",
123+
"CrossFilterSlider",
124+
"DataTable",
125+
"DataFrame",
126+
"Details",
127+
"FileBrowser",
128+
"Image",
129+
"Markdown",
130+
"MarkdownIt",
131+
"DateSlider",
132+
"FloatSlider",
133+
"IntSlider",
134+
"ValueSlider",
135+
"SliderDate",
136+
"SliderFloat",
137+
"SliderInt",
138+
"SliderValue",
139+
"SliderRangeInt",
140+
"SliderRangeFloat",
141+
"SqlCode",
142+
"ToggleButtonsMultiple",
143+
"ToggleButtonsSingle",
144+
"InputText",
145+
"InputFloat",
146+
"InputInt",
147+
"InputTextArea",
148+
"PivotTableView",
149+
"PivotTable",
150+
"PivotTableCard",
151+
"Head",
152+
"Title",
153+
"Link",
154+
"AppLayout",
155+
"Sidebar",
156+
"AppBar",
157+
"AppBarTitle",
158+
"TabNavigation",
159+
"MarkdownEditor",
160+
"Select",
161+
"SelectMultiple",
162+
"FigureMatplotlib",
163+
"FigureEcharts",
164+
"FigureAltair",
165+
"AltairChart",
166+
"Meta",
167+
"Columns",
168+
"ColumnsResponsive",
169+
"FileDrop",
170+
"FileDropMultiple",
171+
"FileDownload",
172+
"Tooltip",
173+
"Card",
174+
"CardActions",
175+
"SpinnerSolara",
176+
"Switch",
177+
"ProgressLinear",
178+
"_component_vue",
179+
"component_vue",
180+
]
181+
182+
68183
_container = None
69184

70185
if main.default_container in globals():

solara/components/misc.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,32 @@
1313
GridLayout = GridDraggable
1414

1515

16+
# re-export components for typing to pick them up correctly
17+
__all__ = [
18+
"Navigator",
19+
"GridDraggable",
20+
"GridLayout",
21+
"ListItem",
22+
"ui_dropdown",
23+
"ui_text",
24+
"ui_checkbox",
25+
"ui_slider",
26+
"Text",
27+
"Div",
28+
"Preformatted",
29+
"IconButton",
30+
"HTML",
31+
"VBox",
32+
"HBox",
33+
"Row",
34+
"Column",
35+
"GridFixed",
36+
"Padding",
37+
"FigurePlotly",
38+
"Code",
39+
]
40+
41+
1642
@solara.component
1743
def ListItem(title, icon_name: str = None, children=[], value=None):
1844
if value is None:

solara/lab/__init__.py

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,52 @@
11
# isort: skip_file
2-
from .components import * # noqa: F401, F403
3-
from .utils import cookies, headers # noqa: F401, F403
4-
from ..lifecycle import on_kernel_start # noqa: F401
5-
from ..tasks import task, use_task, Task, TaskResult # noqa: F401, F403
6-
from ..toestand import computed # noqa: F401
2+
from .components import (
3+
ChatBox,
4+
ChatInput,
5+
ChatMessage,
6+
ConfirmationDialog,
7+
InputDate,
8+
InputDateRange,
9+
InputTime,
10+
ClickMenu,
11+
ContextMenu,
12+
Menu,
13+
Tab,
14+
Tabs,
15+
ThemeToggle,
16+
theme,
17+
use_dark_effective,
18+
)
19+
from .utils import cookies, headers
20+
from ..lifecycle import on_kernel_start
21+
from ..tasks import task, use_task, Task, TaskResult
22+
from ..toestand import computed
23+
24+
25+
__all__ = [
26+
"ChatBox",
27+
"ChatInput",
28+
"ChatMessage",
29+
"ConfirmationDialog",
30+
"InputDate",
31+
"InputDateRange",
32+
"InputTime",
33+
"ClickMenu",
34+
"ContextMenu",
35+
"Menu",
36+
"Tab",
37+
"Tabs",
38+
"ThemeToggle",
39+
"theme",
40+
"use_dark_effective",
41+
"cookies",
42+
"headers",
43+
"on_kernel_start",
44+
"task",
45+
"use_task",
46+
"Task",
47+
"TaskResult",
48+
"computed",
49+
]
750

851

952
def __getattr__(name):

solara/lab/components/__init__.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
1-
from .chat import ChatBox, ChatInput, ChatMessage # noqa: F401
2-
from .confirmation_dialog import ConfirmationDialog # noqa: F401
3-
from .input_date import InputDate, InputDateRange # noqa: F401
1+
from .chat import ChatBox, ChatInput, ChatMessage
2+
from .confirmation_dialog import ConfirmationDialog
3+
from .input_date import InputDate, InputDateRange
44
from .input_time import InputTime as InputTime
5-
from .menu import ClickMenu, ContextMenu, Menu # noqa: F401 F403
6-
from .tabs import Tab, Tabs # noqa: F401
7-
from .theming import ThemeToggle, theme, use_dark_effective # noqa: F401
5+
from .menu import ClickMenu, ContextMenu, Menu
6+
from .tabs import Tab, Tabs
7+
from .theming import ThemeToggle, theme, use_dark_effective
8+
9+
10+
__all__ = [
11+
"ChatBox",
12+
"ChatInput",
13+
"ChatMessage",
14+
"ConfirmationDialog",
15+
"InputDate",
16+
"InputDateRange",
17+
"InputTime",
18+
"ClickMenu",
19+
"ContextMenu",
20+
"Menu",
21+
"Tab",
22+
"Tabs",
23+
"ThemeToggle",
24+
"theme",
25+
"use_dark_effective",
26+
]

solara/website/pages/documentation/examples/utilities/countdown_timer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def run_timer():
4949
if seconds:
5050
solara.Markdown(f"# {seconds} seconds left")
5151
else:
52-
solara.solara.Markdown("# Time's up!")
52+
solara.Markdown("# Time's up!")
5353

5454
solara.v.TextField(type="number", v_model=duration, on_v_model=on_duration, disabled=running)
5555
with solara.Row():

0 commit comments

Comments
 (0)