Skip to content

Commit d4e8b79

Browse files
Merge branch 'master' into fix_batch_update_from_event_handler
2 parents 754a6d1 + 037c96a commit d4e8b79

23 files changed

+156
-187
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 1.8.3
2+
current_version = 1.9.0
33
commit = True
44
tag = True
55

.github/workflows/codequality.yaml

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,26 @@
11
name: Code quality
2-
32
on:
4-
- push
5-
- pull_request
6-
- workflow_dispatch
3+
workflow_call:
4+
workflow_dispatch:
75

86
jobs:
9-
build:
7+
code-quality:
108
runs-on: ubuntu-20.04
119
strategy:
1210
fail-fast: false
1311
matrix:
14-
python-version: [3.7, 3.8, 3.9, "3.10", "3.11"]
12+
python-version: [3.8, 3.9, "3.10", "3.11", "3.12", "3.13"] # pre-commit does not support Python < 3.8
1513

1614
steps:
17-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v4
1816
- name: Set up Python ${{ matrix.python-version }}
19-
uses: actions/setup-python@v2
17+
uses: actions/setup-python@v5
2018
with:
2119
python-version: ${{ matrix.python-version }}
22-
- name: Downgrade pip
23-
run: pip install "pip<22"
2420
- name: Install dependencies
2521
run: |
26-
pip install ".[dev]" "mypy<1" "black<23"
27-
mypy --install-types --non-interactive reacton
28-
- name: Run black
29-
run: black reacton
30-
- name: Run flake
31-
run: flake8 reacton
32-
- name: mypy
33-
run: mypy reacton
22+
pip install ".[dev]"
23+
- name: Install pre-commit
24+
run: pre-commit install
25+
- name: Run pre-commit
26+
run: pre-commit run --all-files

.github/workflows/installation.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
11
name: Test installation
22

33
on:
4-
- push
5-
- pull_request
6-
- workflow_dispatch
4+
workflow_call:
5+
workflow_dispatch:
76

87
jobs:
9-
build:
10-
runs-on: ubuntu-latest
8+
test-installation:
9+
runs-on: ubuntu-22.04
1110

1211
steps:
13-
- uses: actions/checkout@v2
12+
- uses: actions/checkout@v4
1413
- name: Set up Python 3.7
15-
uses: actions/setup-python@v2
14+
uses: actions/setup-python@v5
1615
with:
1716
python-version: 3.7
1817
- name: Install hatch
19-
run: pip install hatch "pip<22"
18+
run: pip install hatch
2019
- name: Build
2120
run: hatch build
2221
- name: Install
2322
run: pip install dist/*.whl
2423
- name: Test import
2524
run: python -c "import react_ipywidgets; import reacton"
25+
- uses: actions/upload-artifact@v4
26+
with:
27+
name: reacton-build-${{ github.run_number }}
28+
path: ./dist

.github/workflows/release.yaml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@ on:
66
- "*"
77

88
jobs:
9-
build:
9+
test:
10+
uses: ./.github/workflows/unittest.yml
11+
12+
release:
13+
needs: test
1014
runs-on: ubuntu-latest
1115
steps:
12-
- uses: actions/checkout@v2
13-
- name: Set up Python 3.7
14-
uses: actions/setup-python@v2
16+
- uses: actions/checkout@v4
17+
- name: Set up Python 3.12
18+
uses: actions/setup-python@v5
1519
with:
16-
python-version: 3.7
20+
python-version: "3.12"
1721
- name: Install hatch
1822
run: pip install hatch
1923
- name: Build
@@ -29,7 +33,7 @@ jobs:
2933
run: |
3034
openssl sha256 dist/*
3135
hatch publish
32-
- uses: actions/upload-artifact@v1
36+
- uses: actions/upload-artifact@v4
3337
with:
3438
name: distributions
3539
path: ./dist

.github/workflows/unittest.yml

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,40 @@
11
name: Unit testing
22

33
on:
4-
- push
5-
- pull_request
6-
- workflow_dispatch
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
workflow_dispatch:
9+
workflow_call:
710

811
jobs:
912
build:
13+
uses: ./.github/workflows/installation.yml
14+
15+
code-quality:
16+
uses: ./.github/workflows/codequality.yaml
17+
18+
unit-test:
19+
needs: [build, code-quality]
1020
runs-on: ubuntu-20.04
1121
strategy:
1222
fail-fast: false
1323
matrix:
14-
python-version: [3.6, 3.7, 3.8, 3.9, "3.10", "3.11"]
24+
python-version: [3.6, 3.7, 3.8, 3.9, "3.10", "3.11", "3.12", "3.13"]
1525

1626
steps:
17-
- uses: actions/checkout@v2
27+
- uses: actions/checkout@v4
1828
- name: Set up Python ${{ matrix.python-version }}
19-
uses: actions/setup-python@v2
29+
uses: actions/setup-python@v5
2030
with:
2131
python-version: ${{ matrix.python-version }}
22-
- name: Downgrade pip
23-
run: pip install "pip<22"
32+
- uses: actions/download-artifact@v4
33+
with:
34+
name: reacton-build-${{ github.run_number }}
35+
path: ./dist
2436
- name: Install
25-
run: pip install ".[dev]" "black<23"
37+
run: |
38+
pip install `echo dist/*.whl`[dev]
2639
- name: test
2740
run: pytest --cov=reacton reacton

.pre-commit-config.yaml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v2.3.0
3+
rev: v5.0.0
44
hooks:
55
- id: check-yaml
66
args: [--unsafe]
77
- id: end-of-file-fixer
88
- id: trailing-whitespace
9-
- repo: https://github.com/psf/black
10-
rev: 22.3.0
9+
- repo: https://github.com/astral-sh/ruff-pre-commit
10+
rev: v0.8.3
1111
hooks:
12-
- id: black
13-
- repo: https://github.com/PyCQA/flake8
14-
rev: 3.9.2
15-
hooks:
16-
- id: flake8
17-
- repo: https://github.com/PyCQA/isort
18-
rev: 5.11.5
19-
hooks:
20-
- id: isort
21-
files: \.py$
22-
args: [--profile=black]
12+
- id: ruff
13+
stages: [pre-commit]
14+
- id: ruff-format
15+
stages: [pre-commit]
2316
- repo: https://github.com/pre-commit/mirrors-mypy
24-
rev: "v0.942" # Use the sha / tag you want to point at
17+
rev: "v1.13.0" # Use the sha / tag you want to point at
2518
hooks:
2619
- id: mypy

notebooks/calculator.ipynb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@
137137
" with w.VBox():\n",
138138
" w.Label(value=state.error or state.output or \"0\")\n",
139139
"\n",
140-
" \n",
141140
" with w.HBox():\n",
142141
" if state.input:\n",
143142
" w.Button(description=\"C\", on_click=lambda: dispatch((\"clear\", None)))\n",
@@ -157,6 +156,7 @@
157156
" op = operator_map[op_symbol]\n",
158157
" w.Button(description=op_symbol, on_click=lambda op=op: dispatch((\"operator\", op)))\n",
159158
" with w.HBox():\n",
159+
"\n",
160160
" def boom():\n",
161161
" print(\"boom\")\n",
162162
" raise ValueError(\"boom\")\n",
@@ -170,7 +170,8 @@
170170
"\n",
171171
" return main\n",
172172
"\n",
173-
"Calculator()\n"
173+
"\n",
174+
"Calculator()"
174175
]
175176
},
176177
{
@@ -225,6 +226,7 @@
225226
" op = operator_map[op_symbol]\n",
226227
" v.BtnWithClick(children=op_symbol, color=\"primary\", on_click=lambda op=op: dispatch((\"operator\", op)), class_=class_)\n",
227228
" with w.HBox():\n",
229+
"\n",
228230
" def boom():\n",
229231
" print(\"boom\")\n",
230232
" raise ValueError(\"boom\")\n",
@@ -237,7 +239,9 @@
237239
" v.BtnWithClick(children=\"=\", color=\"primary\", on_click=lambda: dispatch((\"calculate\", None)), class_=class_)\n",
238240
"\n",
239241
" return main\n",
240-
"CalculatorVuetify()\n"
242+
"\n",
243+
"\n",
244+
"CalculatorVuetify()"
241245
]
242246
},
243247
{

notebooks/click-button.ipynb

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,15 @@
2626
"\n",
2727
"\n",
2828
"clicks = 0 # issue 3\n",
29+
"\n",
30+
"\n",
2931
"def on_click(button):\n",
3032
" global clicks # issue 3\n",
3133
" clicks += 1\n",
32-
" button.description = f\"Clicked {clicks} times\" # issue 1\n",
33-
"button = widgets.Button(description=\"Clicked 0 times\") # issue 1\n",
34+
" button.description = f\"Clicked {clicks} times\" # issue 1\n",
35+
"\n",
36+
"\n",
37+
"button = widgets.Button(description=\"Clicked 0 times\") # issue 1\n",
3438
"button.on_click(on_click) # issue 2\n",
3539
"display(button)"
3640
]
@@ -64,15 +68,15 @@
6468
" # first render, this return 0, after that, the last argument\n",
6569
" # of set_clicks\n",
6670
" clicks, set_clicks = reacton.use_state(0)\n",
67-
" \n",
71+
"\n",
6872
" def my_click_handler():\n",
6973
" # trigger a new render with a new value for clicks\n",
70-
" set_clicks(clicks+1)\n",
74+
" set_clicks(clicks + 1)\n",
7175
"\n",
72-
" button = w.Button(description=f\"Clicked {clicks} times\",\n",
73-
" on_click=my_click_handler)\n",
76+
" button = w.Button(description=f\"Clicked {clicks} times\", on_click=my_click_handler)\n",
7477
" return button\n",
7578
"\n",
79+
"\n",
7680
"ButtonClick()"
7781
]
7882
},
@@ -89,6 +93,8 @@
8993
" slider = w.IntSlider(min=0, max=20, value=count, on_value=set_count)\n",
9094
" buttons = [ButtonClick() for i in range(count)]\n",
9195
" return w.VBox(children=[slider, *buttons])\n",
96+
"\n",
97+
"\n",
9298
"display(ManyButtons())"
9399
]
94100
},
@@ -116,12 +122,16 @@
116122
" # first render, this return 0, after that, the last argument\n",
117123
" # of set_clicks\n",
118124
" clicks, set_clicks = reacton.use_state(0)\n",
125+
"\n",
119126
" def my_click_handler(*ignore_args):\n",
120127
" # trigger a new render with a new value for clicks\n",
121-
" set_clicks(clicks+1)\n",
128+
" set_clicks(clicks + 1)\n",
129+
"\n",
122130
" button = rv.Btn(children=[f\"Clicked {clicks} times\"])\n",
123-
" rv.use_event(button, 'click', my_click_handler)\n",
131+
" rv.use_event(button, \"click\", my_click_handler)\n",
124132
" return button\n",
133+
"\n",
134+
"\n",
125135
"ButtonClick()"
126136
]
127137
},

notebooks/markdown.ipynb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
" html = markdown.markdown(md)\n",
2929
" return w.HTML(value=html)\n",
3030
"\n",
31+
"\n",
3132
"Markdown(\"# Reacton rocks\\nSeriously **bold** idea!\")"
3233
]
3334
},
@@ -49,17 +50,17 @@
4950
"outputs": [],
5051
"source": [
5152
"@reacton.component\n",
52-
"def MarkdownEditor(md : str):\n",
53+
"def MarkdownEditor(md: str):\n",
5354
" md, set_md = reacton.use_state(md)\n",
5455
" edit, set_edit = reacton.use_state(True)\n",
5556
" with w.VBox() as main:\n",
5657
" Markdown(md)\n",
57-
" w.ToggleButton(description=\"Edit\",\n",
58-
" value=edit,\n",
59-
" on_value=set_edit)\n",
58+
" w.ToggleButton(description=\"Edit\", value=edit, on_value=set_edit)\n",
6059
" if edit:\n",
6160
" w.Textarea(value=md, on_value=set_md, rows=10)\n",
6261
" return main\n",
62+
"\n",
63+
"\n",
6364
"MarkdownEditor(\"# Reacton rocks\\nSeriously **bold** idea!\")"
6465
]
6566
},

0 commit comments

Comments
 (0)