Skip to content

Commit eb95abc

Browse files
committed
feat: convert to uv and ruff
- Remove `requires-optional.txt` and `test_requirements/*` (no longer used). - Convert `commands.py` to use `argparse` instead of hand-rolled. - Rationalize imports in `codegen/__init__.py` (all at top level). - Divide dependencies in `pyproject.toml` into core and optional. - Update `pyproject.toml` to install `inflect` and `requests`. - Modify `uv.lock` file. - Modify code reformatting in `codegen/__init__.py` to use `ruff` instead of `black`. - Add new function to use `ruff` to reformat existing code (run `python commands.py format`). - Add new function to use `ruff` to check code (run `python commands.py lint`). - Regenerate code and reformat using `ruff` - Replace uses of `uv pip` with `uv sync` in `.circleci/config.yml`. - Clean up several hundred complaints from `ruff` about unused variables and imports. - Clean up cases in `tests/**/*.py` where the same function name was used for several tests (which meant that only the last one defined was actually run). Note: `uv.lock` reflects `dev_optional`, i.e., pins *all* dependencies.
1 parent 9dc08a1 commit eb95abc

File tree

1,227 files changed

+6434
-7448
lines changed

Some content is hidden

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

1,227 files changed

+6434
-7448
lines changed

.circleci/config.yml

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ commands:
2525
curl -LsSf https://astral.sh/uv/install.sh | sh
2626
uv venv
2727
source .venv/bin/activate
28-
uv pip install .
29-
uv pip install -r ./test_requirements/requirements_core.txt
28+
uv sync --extra dev_core
3029
- run:
3130
name: List installed packages and python version
3231
command: |
@@ -56,8 +55,7 @@ commands:
5655
curl -LsSf https://astral.sh/uv/install.sh | sh
5756
uv venv
5857
source .venv/bin/activate
59-
uv pip install .
60-
uv pip install -r ./test_requirements/requirements_optional.txt
58+
uv sync --extra dev_optional
6159
6260
- when:
6361
condition:
@@ -70,8 +68,7 @@ commands:
7068
name: Install pandas
7169
command: |
7270
source .venv/bin/activate
73-
uv pip install pip
74-
python -m pip install pandas==<<parameters.pandas_version>> numpy==<<parameters.numpy_version>>
71+
uv pip install pandas==<<parameters.pandas_version>> numpy==<<parameters.numpy_version>>
7572
7673
- run:
7774
name: Test core
@@ -125,8 +122,7 @@ commands:
125122
curl -LsSf https://astral.sh/uv/install.sh | sh
126123
uv venv
127124
source .venv/bin/activate
128-
uv pip install .
129-
uv pip install -r ./test_requirements/requirements_optional.txt
125+
uv pip install .[dev_optional]
130126
# Install Kaleido v0 instead of the v1 specified in requirements_optional.txt
131127
uv pip uninstall kaleido
132128
uv pip install kaleido==0.2.1
@@ -151,16 +147,16 @@ jobs:
151147
steps:
152148
- checkout
153149
- run:
154-
name: Install black
150+
name: Install ruff
155151
command: |
156-
python -m venv venv
157-
. venv/bin/activate
158-
pip install black==25.1.0
152+
uv venv
153+
source .venv/bin/activate
154+
uv sync --extra dev_core
159155
- run:
160-
name: Check formatting with black
156+
name: Check handwritten code with ruff
161157
command: |
162-
. venv/bin/activate
163-
black --check . --exclude venv
158+
source .venv/bin/activate
159+
ruff format .
164160
165161
test_core_py:
166162
parameters:
@@ -226,22 +222,20 @@ jobs:
226222
curl -LsSf https://astral.sh/uv/install.sh | sh
227223
uv venv
228224
source .venv/bin/activate
229-
uv pip install -e .
230-
uv pip install -r test_requirements/requirements_optional.txt
225+
uv sync --extra dev_optional
231226
232227
- run:
233-
name: Build html figures (Pandas 2)
228+
name: Build HTML figures (Pandas 2)
234229
command: |
235230
source .venv/bin/activate
236231
python tests/percy/plotly-express.py
237232
- run:
238-
name: Build html figures (Pandas 1) and compare
233+
name: Build HTML figures (Pandas 1) and compare
239234
command: |
240235
source .venv/bin/activate
241236
mkdir tests/percy/pandas2
242237
mv tests/percy/*.html tests/percy/pandas2/
243-
uv pip install pip
244-
python -m pip install pandas==1.5.3 numpy==1.26.4
238+
uv pip install pandas==1.5.3 numpy==1.26.4
245239
python tests/percy/plotly-express.py
246240
python tests/percy/compare-pandas.py
247241
rm -rf tests/percy/pandas2
@@ -273,8 +267,7 @@ jobs:
273267
curl -LsSf https://astral.sh/uv/install.sh | sh
274268
uv venv
275269
source .venv/bin/activate
276-
uv pip install -e .
277-
uv pip install -r ./test_requirements/requirements_core.txt black inflect jupyterlab
270+
uv sync --extra dev_optional
278271
- run:
279272
name: Update plotly.js to dev
280273
command: |
@@ -291,7 +284,7 @@ jobs:
291284
name: Build source distribution packages
292285
command: |
293286
source .venv/bin/activate
294-
uv pip install build
287+
uv sync --extra dev_build
295288
python -m build --sdist --wheel -o dist
296289
when: always
297290
- store_artifacts:
@@ -312,8 +305,7 @@ jobs:
312305
curl -LsSf https://astral.sh/uv/install.sh | sh
313306
uv venv
314307
source .venv/bin/activate
315-
uv pip install build
316-
uv pip install jupyter
308+
uv sync --extra dev_build
317309
cd js
318310
npm ci
319311
npm run build
@@ -439,6 +431,7 @@ jobs:
439431
- store_artifacts:
440432
path: doc/build
441433
destination: doc/build
434+
442435
workflows:
443436
code_formatting:
444437
jobs:
@@ -449,7 +442,6 @@ workflows:
449442
release_build:
450443
jobs:
451444
- full_build
452-
453445
build:
454446
jobs:
455447
- test_core_py:
@@ -483,4 +475,4 @@ workflows:
483475
python_version:
484476
- "3.12"
485477
- python_311_percy
486-
- build-doc
478+
- build-doc

.github/ISSUE_TEMPLATE.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
Thanks for your interest in Plotly.py!
1+
Thanks for your interest in Plotly.py.
2+
Before opening an issue, please:
23

3-
Before opening an issue, please search for existing and closed issues :)
4+
- Use the [latest version](https://github.com/plotly/plotly.py/blob/main/CHANGELOG.md) of plotly.py in your report unless not applicable.
5+
- Search for existing and closed issues.
6+
- Include a minimal reproducible example with bug reports.
47

5-
**Please** accompany bug reports with a reproducible example. Please use the [latest version](https://github.com/plotly/plotly.py/blob/main/CHANGELOG.md) of plotly.py in your report unless not applicable.
6-
7-
Note that GitHub Issues are meant to be used for bug reports and feature requests only. Implementation or usage questions should be asked on [community.plotly.com](https://community.plotly.com/c/graphing-libraries/python/10) or on Stack Overflow (tagged [`plotly`](https://stackoverflow.com/questions/tagged/plotly)).
8+
Note that GitHub Issues are meant to be used for bug reports and feature requests.
9+
Questions about usage should be asked on [community.plotly.com](https://community.plotly.com/c/graphing-libraries/python/10).

.github/pull_request_template.md

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
<!--
2-
Please uncomment this block and take a look at this checklist if your PR is making substantial changes to **documentation**/impacts files in the `doc` directory. Check all that apply to your PR, and leave the rest unchecked to discuss with your reviewer! Not all boxes must be checked for every PR :)
2+
Please uncomment this block and fill in this checklist if your PR makes substantial changes to documentation in the `doc` directory.
3+
Not all boxes must be checked for every PR:
4+
check those that apply to your PR and leave the rest unchecked to discuss with your reviewer.
35
4-
If your PR modifies code of the `plotly` package, we have a different checklist
5-
below :-).
6+
If your PR modifies code of the `plotly` package, we have a different checklist below.
67
7-
### Documentation PR
8+
## Documentation PR
89
9-
- [ ] I've [seen the `doc/README.md` file](https://github.com/plotly/plotly.py/blob/main/doc/README.md)
10-
- [ ] This change runs in the current version of Plotly on PyPI and targets the `doc-prod` branch OR it targets the `main` branch
11-
- [ ] If this PR modifies the first example in a page or adds a new one, it is a `px` example if at all possible
12-
- [ ] Every new/modified example has a descriptive title and motivating sentence or paragraph
13-
- [ ] Every new/modified example is independently runnable
14-
- [ ] Every new/modified example is optimized for short line count and focuses on the Plotly/visualization-related aspects of the example rather than the computation required to produce the data being visualized
15-
- [ ] Meaningful/relatable datasets are used for all new examples instead of randomly-generated data where possible
16-
- [ ] The random seed is set if using randomly-generated data in new/modified examples
17-
- [ ] New/modified remote datasets are loaded from https://plotly.github.io/datasets and added to https://github.com/plotly/datasets
18-
- [ ] Large computations are avoided in the new/modified examples in favour of loading remote datasets that represent the output of such computations
19-
- [ ] Imports are `plotly.graph_objects as go` / `plotly.express as px` / `plotly.io as pio`
20-
- [ ] Data frames are always called `df`
21-
- [ ] `fig = <something>` call is high up in each new/modified example (either `px.<something>` or `make_subplots` or `go.Figure`)
22-
- [ ] Liberal use is made of `fig.add_*` and `fig.update_*` rather than `go.Figure(data=..., layout=...)` in every new/modified example
23-
- [ ] Specific adders and updaters like `fig.add_shape` and `fig.update_xaxes` are used instead of big `fig.update_layout` calls in every new/modified example
24-
- [ ] `fig.show()` is at the end of each new/modified example
25-
- [ ] `plotly.plot()` and `plotly.iplot()` are not used in any new/modified example
26-
- [ ] Hex codes for colors are not used in any new/modified example in favour of [these nice ones](https://github.com/plotly/plotly.py/issues/2192)
10+
- [ ] I have seen the [`doc/README.md`](https://github.com/plotly/plotly.py/blob/main/doc/README.md) file.
11+
- [ ] This change runs in the current version of Plotly on PyPI and targets the `doc-prod` branch OR it targets the `main` branch.
12+
- [ ] If this PR modifies the first example in a page or adds a new one, it is a `px` example if at all possible.
13+
- [ ] Every new/modified example has a descriptive title and motivating sentence or paragraph.
14+
- [ ] Every new/modified example is independently runnable.
15+
- [ ] Every new/modified example is optimized for short line count and focuses on the Plotly/visualization-related aspects of the example rather than the computation required to produce the data being visualized.
16+
- [ ] Meaningful/relatable datasets are used for all new examples instead of randomly-generated data where possible.
17+
- [ ] The random seed is set if using randomly-generated data.
18+
- [ ] New/modified remote datasets are loaded from https://plotly.github.io/datasets and added to https://github.com/plotly/datasets.
19+
- [ ] Large computations are avoided in the new/modified examples in favour of loading remote datasets that represent the output of such computations.
20+
- [ ] Imports are `plotly.graph_objects as go`, `plotly.express as px`, and/or `plotly.io as pio`.
21+
- [ ] Data frames are always called `df`.
22+
- [ ] `fig = <something>` is called high up in each new/modified example (either `px.<something>` or `make_subplots` or `go.Figure`).
23+
- [ ] Liberal use is made of `fig.add_*` and `fig.update_*` rather than `go.Figure(data=..., layout=...)`.
24+
- [ ] Specific adders and updaters like `fig.add_shape` and `fig.update_xaxes` are used instead of big `fig.update_layout` calls.
25+
- [ ] `fig.show()` is at the end of each example.
26+
- [ ] `plotly.plot()` and `plotly.iplot()` are not used in any example.
27+
- [ ] Named colors are used instead of hex codes wherever possible.
28+
- [ ] Code blocks are marked with `&#96;&#96;&#96;python`.
2729
2830
## Code PR
2931
30-
- [ ] I have read through the [contributing notes](https://github.com/plotly/plotly.py/blob/main/CONTRIBUTING.md) and understand the structure of the package. In particular, if my PR modifies code of `plotly.graph_objects`, my modifications concern the `codegen` files and not generated files.
31-
- [ ] I have added tests (if submitting a new feature or correcting a bug) or
32-
modified existing tests.
33-
- [ ] For a new feature, I have added documentation examples in an existing or
34-
new tutorial notebook (please see the doc checklist as well).
35-
- [ ] I have added a CHANGELOG entry if fixing/changing/adding anything substantial.
36-
- [ ] For a new feature or a change in behaviour, I have updated the relevant docstrings in the code to describe the feature or behaviour (please see the doc checklist as well).
32+
- [ ] I have read through the [contributing notes](https://github.com/plotly/plotly.py/blob/main/CONTRIBUTING.md) and understand the structure of the package. In particular, if my PR modifies code of `plotly.graph_objects`, my modifications concern the code generator and *not* the generated files.
33+
- [ ] I have added tests or modified existing tests.
34+
- [ ] For a new feature, I have added documentation examples (please see the doc checklist as well).
35+
- [ ] I have added a CHANGELOG entry if changing anything substantial.
36+
- [ ] For a new feature or a change in behavior, I have updated the relevant docstrings in the code.
3737
3838
-->

0 commit comments

Comments
 (0)