Skip to content

Commit 85d3a9d

Browse files
committed
Merge branch 'build_tools' into build_tools_ruff
* build_tools: Add comments about pre-commit hooks and how to disable them temporarily Code feedback Do not use isort on init files Discard changes to __init__.py files Use correct docs target to build site (not preview) Restore missing target
2 parents f663011 + 6f84637 commit 85d3a9d

File tree

15 files changed

+109
-96
lines changed

15 files changed

+109
-96
lines changed

.github/workflows/build-docs.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929

3030
- name: Build site
3131
run: |
32-
make docs
32+
make docs-site
3333
3434
- name: Upload site artifact
3535
if: github.ref == 'refs/heads/main'

.pre-commit-config.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# For the rare case that you'd like to commit with no pre-commit hooks, you can use `--no-verify` in the commit call.
2+
# ```
3+
# git commit --no-verify -m "MSG"
4+
# ```
15
repos:
26
- repo: https://github.com/astral-sh/ruff-pre-commit
37
rev: v0.3.2

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# .PHONY: help clean% check% format% docs% lint test pyright playwright% install% testrail% coverage release
2-
31
# Depend on `FORCE` to ensure the target is always run
42
FORCE:
53

@@ -60,8 +58,10 @@ $(VENV):
6058
$(PYBIN)/pip install --upgrade pip
6159

6260
$(PYBIN): $(VENV)
61+
$(PYTHON): $(PYBIN)
6362
$(PIP): $(PYBIN)
6463

64+
6565
UV = $(SITE_PACKAGES)/uv
6666
$(UV):
6767
$(MAKE) $(PYBIN)
@@ -80,7 +80,7 @@ PYTEST = $(SITE_PACKAGES)/pytest
8080
COVERAGE = $(SITE_PACKAGES)/coverage
8181
PYRIGHT = $(SITE_PACKAGES)/pyright
8282
PLAYWRIGHT = $(SITE_PACKAGES)/playwright
83-
$(PYTEST) $(COVERAGE) $(PYRIGHT) $(PLAYWRIGHT):
83+
$(RUFF) $(PYTEST) $(COVERAGE) $(PYRIGHT) $(PLAYWRIGHT):
8484
@$(MAKE) install-deps
8585

8686

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,5 @@ pre-commit install
5757
# To disable:
5858
# pre-commit uninstall
5959
```
60+
61+
If you absolutely need to skip the pre-commit hooks, you can use the [`--no-verify` flag when you commit](https://git-scm.com/docs/githooks#_pre_commit) (`git commit --no-verify -m "MSG"`).

examples/model-score/app.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@
1616
THRESHOLD_LOW = 0.5
1717
THRESHOLD_LOW_COLOR = "rgb(193, 0, 0)"
1818

19+
20+
def value_box_theme(score):
21+
if score > THRESHOLD_MID:
22+
return "text-success"
23+
elif score < THRESHOLD_LOW:
24+
return "bg-danger"
25+
else:
26+
return "text-warning"
27+
28+
1929
# Start a background thread that writes fake data to the SQLite database every second
2030
scoredata.begin()
2131

@@ -192,13 +202,7 @@ def value_boxes():
192202
ui.value_box(
193203
model,
194204
ui.h2(score),
195-
theme=(
196-
"text-success"
197-
if score > THRESHOLD_MID
198-
else "text-warning"
199-
if score > THRESHOLD_LOW
200-
else "bg-danger"
201-
),
205+
theme=value_box_theme(score),
202206
)
203207
for model, score in scores_by_model.items()
204208
],

ruff.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ extend-select = [
8888
]
8989

9090
[lint.extend-per-file-ignores]
91+
# I: isort; Do not reformat imports in `__init__.py` files.
92+
"**/__init__.py" = ["I"]
9193
# F403: 'from module import *' used; unable to detect undefined names
9294
# Also ignore `F403` in all `__init__.py` files.
9395
"shiny/__init__.py" = ["F403"]
@@ -102,8 +104,6 @@ extend-select = [
102104
"shiny/templates/**" = ["T20"]
103105
"shiny/api-examples/**" = ["T20"]
104106
"tests/**" = ["T20"]
105-
# I: isort
106-
"shiny/experimental/ui/__init__.py" = ["I"]
107107
# PT019: pytest
108108
"tests/pytest/test_output_transformer.py" = ["PT019"]
109109

shiny/express/__init__.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,14 @@
11
from __future__ import annotations
22

3-
from .. import render
4-
53
# Import these with underscore names so they won't show in autocomplete from the Python
64
# console.
75
from ..session import (
86
Inputs as _Inputs,
9-
)
10-
from ..session import (
117
Outputs as _Outputs,
12-
)
13-
from ..session import (
148
Session as _Session,
15-
)
16-
from ..session import (
179
get_current_session as _get_current_session,
1810
)
11+
from .. import render
1912
from . import ui
2013
from ._is_express import is_express_app
2114
from ._output import ( # noqa: F401
@@ -25,6 +18,7 @@
2518
from ._run import app_opts, wrap_express_app
2619
from .expressify_decorator import expressify
2720

21+
2822
__all__ = (
2923
"render",
3024
"input",

shiny/express/ui/__init__.py

+49-42
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
from __future__ import annotations
22

3+
34
from htmltools import (
4-
HTML,
5+
TagList,
56
Tag,
7+
TagChild,
68
TagAttrs,
79
TagAttrValue,
8-
TagChild,
9-
TagList,
10+
tags,
11+
HTML,
12+
head_content,
1013
a,
1114
br,
1215
code,
@@ -18,31 +21,30 @@
1821
h4,
1922
h5,
2023
h6,
21-
head_content,
2224
hr,
2325
img,
2426
p,
2527
pre,
2628
span,
2729
strong,
28-
tags,
30+
)
31+
32+
from ...ui import (
33+
fill,
2934
)
3035

3136
from ...ui import (
3237
AccordionPanel,
3338
AnimationOptions,
3439
CardItem,
35-
Progress,
3640
ShowcaseLayout,
3741
Sidebar,
3842
SliderStepArg,
3943
SliderValueArg,
4044
ValueBoxTheme,
41-
bind_task_button,
4245
brush_opts,
4346
click_opts,
4447
dblclick_opts,
45-
fill,
4648
help_text,
4749
hover_opts,
4850
include_css,
@@ -51,70 +53,74 @@
5153
input_action_link,
5254
input_checkbox,
5355
input_checkbox_group,
56+
input_switch,
57+
input_radio_buttons,
5458
input_dark_mode,
5559
input_date,
5660
input_date_range,
5761
input_file,
5862
input_numeric,
5963
input_password,
60-
input_radio_buttons,
6164
input_select,
6265
input_selectize,
6366
input_slider,
64-
input_switch,
67+
bind_task_button,
6568
input_task_button,
6669
input_text,
6770
input_text_area,
68-
insert_accordion_panel,
69-
insert_ui,
70-
js_eval,
71-
markdown,
72-
modal,
73-
modal_button,
74-
modal_remove,
75-
modal_show,
76-
nav_spacer,
77-
notification_remove,
78-
notification_show,
7971
panel_title,
72+
insert_accordion_panel,
8073
remove_accordion_panel,
81-
remove_ui,
8274
update_accordion,
8375
update_accordion_panel,
76+
update_sidebar,
8477
update_action_button,
8578
update_action_link,
8679
update_checkbox,
80+
update_switch,
8781
update_checkbox_group,
82+
update_radio_buttons,
8883
update_dark_mode,
8984
update_date,
9085
update_date_range,
91-
update_navs,
9286
update_numeric,
93-
update_popover,
94-
update_radio_buttons,
9587
update_select,
9688
update_selectize,
97-
update_sidebar,
9889
update_slider,
99-
update_switch,
10090
update_task_button,
10191
update_text,
10292
update_text_area,
93+
update_navs,
10394
update_tooltip,
95+
update_popover,
96+
insert_ui,
97+
remove_ui,
98+
markdown,
99+
modal_button,
100+
modal,
101+
modal_show,
102+
modal_remove,
103+
notification_show,
104+
notification_remove,
105+
nav_spacer,
106+
Progress,
104107
value_box_theme,
108+
js_eval,
105109
)
110+
106111
from ._cm_components import (
107-
accordion,
108-
accordion_panel,
109-
card,
110-
card_footer,
111-
card_header,
112+
sidebar,
113+
layout_sidebar,
112114
layout_column_wrap,
113115
layout_columns,
114-
layout_sidebar,
116+
card,
117+
card_header,
118+
card_footer,
119+
accordion,
120+
accordion_panel,
121+
nav_panel,
115122
nav_control,
116123
nav_menu,
117-
nav_panel,
118124
navset_bar,
119125
navset_card_pill,
120126
navset_card_tab,
@@ -124,22 +130,23 @@
124130
navset_pill_list,
125131
navset_tab,
126132
navset_underline,
127-
panel_absolute,
133+
value_box,
134+
panel_well,
128135
panel_conditional,
129136
panel_fixed,
130-
panel_well,
131-
popover,
132-
sidebar,
137+
panel_absolute,
133138
tooltip,
134-
value_box,
135-
)
136-
from ._hold import (
137-
hold,
139+
popover,
138140
)
141+
139142
from ._page import (
140143
page_opts,
141144
)
142145

146+
from ._hold import (
147+
hold,
148+
)
149+
143150
__all__ = (
144151
# Imports from htmltools
145152
"TagList",

shiny/reactive/__init__.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
from ._core import ( # noqa: F401
22
Context,
3-
flush,
4-
get_current_context, # pyright: ignore[reportUnusedImport]
5-
invalidate_later,
63
isolate,
4+
invalidate_later,
5+
flush,
76
lock,
87
on_flushed,
8+
get_current_context, # pyright: ignore[reportUnusedImport]
99
)
10-
from ._extended_task import ExtendedTask, extended_task
11-
from ._poll import file_reader, poll
10+
from ._poll import poll, file_reader
1211
from ._reactives import ( # noqa: F401
12+
value,
13+
Value,
14+
calc,
1315
Calc,
1416
Calc_, # pyright: ignore[reportUnusedImport]
1517
CalcAsync_, # pyright: ignore[reportUnusedImport]
18+
effect,
1619
Effect,
1720
Effect_, # pyright: ignore[reportUnusedImport]
18-
Value,
19-
calc,
20-
effect,
2121
event,
22-
value,
2322
)
23+
from ._extended_task import ExtendedTask, extended_task
24+
2425

2526
__all__ = (
2627
"Context",

shiny/render/__init__.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@
1010
DataTable,
1111
data_frame,
1212
)
13-
from ._deprecated import ( # noqa: F401
14-
RenderFunction, # pyright: ignore[reportUnusedImport]
15-
RenderFunctionAsync, # pyright: ignore[reportUnusedImport]
16-
)
1713
from ._express import (
1814
express,
1915
)
2016
from ._render import (
2117
code,
22-
download,
2318
image,
2419
plot,
2520
table,
2621
text,
2722
ui,
23+
download,
24+
)
25+
from ._deprecated import ( # noqa: F401
26+
RenderFunction, # pyright: ignore[reportUnusedImport]
27+
RenderFunctionAsync, # pyright: ignore[reportUnusedImport]
2828
)
2929

3030
__all__ = (

shiny/render/renderer/__init__.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
from ._renderer import (
2-
AsyncValueFn,
3-
Jsonifiable,
42
Renderer,
5-
RendererT,
63
ValueFn,
4+
Jsonifiable,
5+
RendererT,
6+
AsyncValueFn,
7+
# IT, # pyright: ignore[reportUnusedImport]
78
)
89

910
__all__ = (

0 commit comments

Comments
 (0)