Skip to content

Commit 5128d21

Browse files
authored
Modernise tooling (#1055)
* Switch to uv + ruff + just * Configure ruff * Format * Migrate nox and invoke tasks to just * Landing page typos * Update actions * Update prettier config * Format JS * Install just in workflow * Uv run dash-generate-components * Update prettier * Update contribution guide
1 parent d47183f commit 5128d21

File tree

106 files changed

+1850
-1030
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+1850
-1030
lines changed

.github/CONTRIBUTING.md

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -127,74 +127,60 @@ license your work under the terms of the [Apache 2.0 License](../LICENSE).
127127

128128
## Code guidelines
129129

130-
### Python
130+
We use [`uv`](https://docs.astral.sh/uv/) to manage the Python project, and [`just`](https://github.com/casey/just) as a task runner. See their resepctive documentation for details on how to install. To manage the JavaScript package you will also need to install [NodeJS](https://nodejs.org/)
131131

132-
We use [`nox`](https://nox.thea.codes/en/stable/) to test and lint Python code.
132+
Python code is linted using `ruff`, JavaScript code is linted using `prettier`. Run the linters with
133133

134134
```sh
135-
pip install nox
135+
just lint
136136
```
137137

138-
Code is linted using `black`, `flake8`, and `isort`. Run the linters with
138+
You can alternatively lint just the Python or JavaScript source with
139139

140140
```sh
141-
nox -s lint
141+
just lint-py
142+
just lint-js
142143
```
143144

144-
Many formatting issues can be fixed automatically by `black` and `isort`. Run
145-
them with
145+
Many formatting issues can be fixed automatically by `ruff` or `prettier` respectively. Run them with
146146

147147
```sh
148-
nox -s format
148+
just format
149149
```
150150

151151
Finally you can run the Python tests locally for a particular version of Python
152152
with
153153

154154
```sh
155-
nox -s test-3.8
155+
just python_version=3.10 test-py
156156
```
157157

158-
and similarly for other versions.
158+
and similarly for other versions. Run the JavaScript unit tests with
159159

160-
### JS
161-
162-
Prettier to format JavaScript code as configured in `.prettierrc`. You can lint
163-
your code with
164-
165-
```bash
166-
npm run lint
160+
```sh
161+
npm test
162+
# or
163+
just test-js
167164
```
168165

169-
and format it automatically with
166+
Run all tests with
170167

171-
```bash
172-
npm run format
168+
```sh
169+
just test
173170
```
174171

175-
### Run tests
176-
177-
Run `npm run test` before committing to ensure your changes pass our tests.
178-
179172
## Building dash-bootstrap-components locally
180173

181-
To build _dash-bootstrap-components_ locally, first install the Python
182-
development dependencies
183-
184-
```sh
185-
python -m pip install -r requirements-dev.txt
186-
```
187-
188-
Then install JavaScript dependencies
174+
First install JavaScript dependencies
189175

190176
```sh
191177
npm install
192178
```
193179

194-
You can now build Python, R and Julia packages with
180+
Then build with
195181

196182
```sh
197-
npm run build
183+
just build
198184
```
199185

200186
## License

.github/workflows/release.yml

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,32 @@ jobs:
1818
- id: get-version
1919
run: echo "version=$(echo ${{ github.head_ref }} | sed 's|release/||')" >> "$GITHUB_OUTPUT"
2020

21-
- name: Use Node 16
21+
- name: Use Node 22
2222
uses: actions/setup-node@v3
2323
with:
24-
node-version: 16
24+
node-version: 22
2525

26-
- name: Install dependencies
27-
run: npm ci
28-
- name: Set up Python 3.12
29-
uses: actions/setup-python@v5
26+
- name: Install the latest version of uv
27+
uses: astral-sh/setup-uv@v3
3028
with:
31-
python-version: '3.12'
29+
version: 'latest'
30+
31+
- name: Install just
32+
uses: extractions/setup-just@v2
3233

33-
- name: Install Python dependencies
34-
run: python -m pip install -r requirements-dev.txt
34+
- name: Install JS dependencies
35+
run: npm ci
3536

3637
- name: Update docs requirements
37-
run: invoke set-documentation-version ${{ steps.get-version.outputs.version }}
38+
run: just _set-docs-version ${{ steps.get-version.outputs.version }}
39+
40+
- name: Build dash-bootstrap-components
41+
run: just build
3842

3943
- uses: JS-DevTools/npm-publish@v1
4044
with:
4145
token: ${{ secrets.NPM_TOKEN }}
4246

43-
- name: Clean dist/
44-
run: rm -rf dist/dash_bootstrap_components.min.js
45-
46-
- name: Build dash-bootstrap-components
47-
run: python -m build --sdist --wheel --outdir dist/
48-
4947
- name: Publish to PyPI
5048
uses: pypa/gh-action-pypi-publish@v1.4.2
5149
with:
@@ -71,7 +69,7 @@ jobs:
7169
prerelease: false
7270

7371
- name: Post-release cleanup
74-
run: invoke postrelease ${{ steps.get-version.outputs.version }}
72+
run: just postrelease ${{ steps.get-version.outputs.version }}
7573

7674
- uses: stefanzweifel/git-auto-commit-action@v4
7775
with:
@@ -92,32 +90,29 @@ jobs:
9290
- id: get-version
9391
run: echo "version=$(echo ${{ github.head_ref }} | sed 's|prerelease/||')" >> "$GITHUB_OUTPUT"
9492

95-
- name: Use Node 16
93+
- name: Use Node 22
9694
uses: actions/setup-node@v3
9795
with:
98-
node-version: 16
96+
node-version: 22
9997

100-
- name: Install dependencies
101-
run: npm ci
102-
103-
- name: Set up Python 3.12
104-
uses: actions/setup-python@v5
98+
- name: Install the latest version of uv
99+
uses: astral-sh/setup-uv@v3
105100
with:
106-
python-version: '3.12'
101+
version: 'latest'
102+
103+
- name: Install just
104+
uses: extractions/setup-just@v2
105+
106+
- name: Install JS dependencies
107+
run: npm ci
107108

108-
- name: Install Python dependencies
109-
run: python -m pip install -r requirements-dev.txt
109+
- name: Build dash-bootstrap-components
110+
run: just build
110111

111112
- uses: JS-DevTools/npm-publish@v1
112113
with:
113114
token: ${{ secrets.NPM_TOKEN }}
114115

115-
- name: Clean dist/
116-
run: rm -rf dist/dash_bootstrap_components.min.js
117-
118-
- name: Build dash-bootstrap-components
119-
run: python -m build --sdist --wheel --outdir dist/
120-
121116
- name: Publish to PyPI
122117
uses: pypa/gh-action-pypi-publish@v1.4.2
123118
with:
@@ -143,7 +138,7 @@ jobs:
143138
prerelease: true
144139

145140
- name: Post-release cleanup
146-
run: invoke postrelease ${{ steps.get-version.outputs.version }}
141+
run: just postrelease ${{ steps.get-version.outputs.version }}
147142

148143
- uses: stefanzweifel/git-auto-commit-action@v4
149144
with:

.github/workflows/tests.yml

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,37 @@ jobs:
88
runs-on: 'ubuntu-latest'
99
steps:
1010
- uses: actions/checkout@v1
11-
- name: Use Node 16
11+
- name: Install just
12+
uses: extractions/setup-just@v2
13+
- name: Use Node 22
1214
uses: actions/setup-node@v3
1315
with:
14-
node-version: 16
16+
node-version: 22
1517
- name: Install dependencies
1618
run: npm ci
1719
- name: Lint source
18-
run: npm run lint
20+
run: just lint-js
1921
- name: Run tests
20-
run: npm run test
21-
- name: Run demo test
22-
run: npm run test:demo
22+
run: just test-js
2323
build:
2424
name: Build package
2525
runs-on: 'ubuntu-latest'
2626
steps:
2727
- uses: actions/checkout@v1
28-
- name: Use Node 16
28+
- name: Install just
29+
uses: extractions/setup-just@v2
30+
- name: Use Node 22
2931
uses: actions/setup-node@v3
3032
with:
31-
node-version: 16
33+
node-version: 22
3234
- name: Install dependencies
3335
run: npm ci
34-
- name: Set up Python 3.12
35-
uses: actions/setup-python@v5
36+
- name: Install the latest version of uv
37+
uses: astral-sh/setup-uv@v3
3638
with:
37-
python-version: '3.12'
38-
- name: Install Dash
39-
run: python -m pip install -r requirements-dev.txt
39+
version: 'latest'
4040
- name: Build dash-bootstrap-components
41-
run: npm run build
41+
run: just build
4242
- name: Upload generated files
4343
uses: actions/upload-artifact@v4
4444
with:
@@ -62,23 +62,18 @@ jobs:
6262
HUB_PORT: 4444
6363
steps:
6464
- uses: actions/checkout@v1
65-
- name: Set up Python 3.12
66-
uses: actions/setup-python@v5
65+
- name: Install the latest version of uv
66+
uses: astral-sh/setup-uv@v3
6767
with:
68-
python-version: '3.12'
69-
- name: Set up Python ${{ matrix.python-version }}
70-
if: matrix.python-version != '3.12'
71-
uses: actions/setup-python@v5
72-
with:
73-
python-version: ${{ matrix.python-version }}
74-
- name: Install nox
75-
run: python3.12 -m pip install -U nox
68+
version: 'latest'
69+
- name: Install just
70+
uses: extractions/setup-just@v2
7671
- name: Lint Python source
7772
if: matrix.python-version == '3.12'
78-
run: nox -s lint
73+
run: just lint-py
7974
- uses: actions/download-artifact@v4
8075
with:
8176
name: dash-bootstrap-components
8277
path: dash_bootstrap_components/_components
8378
- name: Test Python module
84-
run: nox -s test-${{ matrix.python-version }}
79+
run: just python_version=${{ matrix.python-version }} test-py

.prettierrc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"tabWidth": 2,
33
"singleQuote": true,
4-
"bracketSpacing": false
5-
}
4+
"bracketSpacing": false,
5+
"arrowParens": "avoid",
6+
"trailingComma": "none"
7+
}

MANIFEST.in

Lines changed: 0 additions & 3 deletions
This file was deleted.

dash_bootstrap_components/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515

1616
_js_dist = [
1717
{
18-
"relative_package_path": (
19-
"_components/dash_bootstrap_components.min.js"
20-
),
18+
"relative_package_path": ("_components/dash_bootstrap_components.min.js"),
2119
"external_url": (
2220
f"https://unpkg.com/dash-bootstrap-components@{__version__}"
2321
"/dist/dash_bootstrap_components.min.js"

dash_bootstrap_components/_table.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def _generate_table_from_df(
1414
index=False,
1515
index_label=None,
1616
date_format=None,
17-
**table_kwargs
17+
**table_kwargs,
1818
):
1919
"""
2020
Generate a Table component from a dataframe.
@@ -78,8 +78,7 @@ def _generate_table_from_df(
7878
# Get the actual headers
7979
n_levels = df.columns.nlevels
8080
header_values = [
81-
list(df.columns.get_level_values(level))
82-
for level in range(n_levels)
81+
list(df.columns.get_level_values(level)) for level in range(n_levels)
8382
]
8483

8584
# The sizes of consecutive header groups at each level
@@ -134,9 +133,7 @@ def _generate_table_from_df(
134133
table.append(
135134
html.Tbody(
136135
[
137-
html.Tr(
138-
[html.Td(df.iloc[i, j]) for j in range(len(df.columns))]
139-
)
136+
html.Tr([html.Td(df.iloc[i, j]) for j in range(len(df.columns))])
140137
for i in range(len(df))
141138
]
142139
)

dash_bootstrap_components/icons.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
BOOTSTRAP = (
2-
"https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.3/"
3-
"font/bootstrap-icons.css"
2+
"https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.3/" "font/bootstrap-icons.css"
43
)
54
FONT_AWESOME = "https://use.fontawesome.com/releases/v6.3.0/css/all.css"

dash_bootstrap_components/themes.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
BOOTSTRAP = (
2-
"https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
3-
)
1+
BOOTSTRAP = "https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
42

53
GRID = "https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap-grid.min.css" # noqa
64

docs/components_page/__init__.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,7 @@ def register_apps():
143143

144144
for slug, kwargs in component_bodies.items():
145145
requests_pathname_prefix = (
146-
f"/docs/components/{slug}/"
147-
if slug != "index"
148-
else "/docs/components/"
146+
f"/docs/components/{slug}/" if slug != "index" else "/docs/components/"
149147
)
150148
app = dash.Dash(
151149
external_stylesheets=["/static/loading.css"],
@@ -162,13 +160,9 @@ def register_apps():
162160
app.title = f"{_get_label(slug)} - dbc docs"
163161

164162
if slug == "layout":
165-
app.layout = html.Div(
166-
parse(app, **kwargs), className="layout-demo"
167-
)
163+
app.layout = html.Div(parse(app, **kwargs), className="layout-demo")
168164
elif slug == "button_group":
169-
app.layout = html.Div(
170-
parse(app, **kwargs), className="button-group-demo"
171-
)
165+
app.layout = html.Div(parse(app, **kwargs), className="button-group-demo")
172166
else:
173167
app.layout = parse(app, **kwargs)
174168
if slug == "index":

0 commit comments

Comments
 (0)