-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stabilize support for Jupyter Notebooks #12878
Conversation
docs/configuration.md
Outdated
`ruff format /path/to/notebook.ipynb` will always format `notebook.ipynb`. | ||
Alternatively, passing the notebook file(s) to `ruff` on the command-line will always lint or format | ||
the notebook. For example, `ruff check /path/to/notebook.ipynb` will always lint `notebook.ipynb`. | ||
Similarly, `ruff format /path/to/notebook.ipynb` will always format `notebook.ipynb`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we won't need this section anymore. we can move this section to another place that applies for all file types not just .ipynb
e0128be
to
80fb8e5
Compare
To lint or format files with additional file extensions, use the [`extend-include`](settings.md#extend-include) setting. | ||
|
||
=== "pyproject.toml" | ||
|
||
```toml | ||
[tool.ruff] | ||
extend-include = ["*.ipynb"] | ||
``` | ||
|
||
=== "ruff.toml" | ||
|
||
```toml | ||
extend-include = ["*.ipynb"] | ||
``` | ||
|
||
You can also change the default selection using the [`include`](settings.md#include) setting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any suggestion on what can be use for this example? I'm worried that it might signal to the users that we support that file extension. Using *.ipynb
was ok because we do support it. This is the reason I've removed this example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extend-include
has an example with .pyw
files. Although I think the example isn't needed because we already link to extend-include
which has an example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think not having an example here is fine.
There are couple more references in the docs that require updating which I'm doing right now. |
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
Q000 | 539 | 539 | 0 | 0 | 0 |
T201 | 151 | 151 | 0 | 0 | 0 |
E501 |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 1 | 0 | 0 | 0 |
BLE001 | 1 | 1 | 0 | 0 | 0 |
RUF010 | 1 | 1 | 0 | 0 | 0 |
PD008 | 1 | 1 | 0 | 0 | 0 |
S113 | 1 | 1 | 0 | 0 | 0 |
PTH111 | 1 | 1 | 0 | 0 | 0 |
PTH202 | 1 | 1 | 0 | 0 | 0 |
PTH102 | 1 | 1 | 0 | 0 | 0 |
FBT001 | 1 | 1 | 0 | 0 | 0 |
D400 | 1 | 1 | 0 | 0 | 0 |
D415 | 1 | 1 | 0 | 0 | 0 |
PTH107 | 1 | 1 | 0 | 0 | 0 |
C405 | 1 | 1 | 0 | 0 | 0 |
B018 | 1 | 1 | 0 | 0 | 0 |
N803 | 1 | 1 | 0 | 0 | 0 |
C901 | 1 | 1 | 0 | 0 | 0 |
SIM910 | 1 | 1 | 0 | 0 | 0 |
E711 | 1 | 1 | 0 | 0 | 0 |
RUF005 | 1 | 1 | 0 | 0 | 0 |
D205 | 1 | 1 | 0 | 0 | 0 |
D212 | 1 | 1 | 0 | 0 | 0 |
F841 | 1 | 1 | 0 | 0 | 0 |
SIM108 | 1 | 1 | 0 | 0 | 0 |
UP030 | 1 | 1 | 0 | 0 | 0 |
UP032 | 1 | 1 | 0 | 0 | 0 |
S506 | 1 | 1 | 0 | 0 | 0 |
PLW0127 | 1 | 1 | 0 | 0 | 0 |
PLW0128 | 1 | 1 | 0 | 0 | 0 |
F811 | 1 | 1 | 0 | 0 | 0 |
Linter (preview)
✅ ecosystem check detected no linter changes.
e1f238f
to
2915388
Compare
2915388
to
1d5be1c
Compare
Can you rebase/re-run the ecosystem checks. The augmented assignment adds a lot of noise. |
To lint or format files with additional file extensions, use the [`extend-include`](settings.md#extend-include) setting. | ||
|
||
=== "pyproject.toml" | ||
|
||
```toml | ||
[tool.ruff] | ||
extend-include = ["*.ipynb"] | ||
``` | ||
|
||
=== "ruff.toml" | ||
|
||
```toml | ||
extend-include = ["*.ipynb"] | ||
``` | ||
|
||
You can also change the default selection using the [`include`](settings.md#include) setting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extend-include
has an example with .pyw
files. Although I think the example isn't needed because we already link to extend-include
which has an example.
There are quiet a large number of violations and some violations seem less appropriate for notebooks (e.g. denying the use of |
It it up-to date with |
Let's see if re-triggering the ecosystem checks help |
Oh, I see what the problem is. The |
@MichaReiser I've made some edits as per your suggestions. Thanks. I've also updated some rule documentation to reflect the different behavior for Jupyter Notebooks. |
5421453
to
600dcc7
Compare
0369ce8
to
051d8bd
Compare
@MichaReiser, I pushed a few small updates. Would you mind having another quick look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good except the options documentation is a bit of a stretch ;)
051d8bd
to
b53746c
Compare
b53746c
to
5a5a709
Compare
Co-authored-by: Alex Waygood <alex.waygood@gmail.com> Closes: #12456 Closes: astral-sh/ruff-vscode#546
Co-authored-by: Alex Waygood <alex.waygood@gmail.com> Closes: #12456 Closes: astral-sh/ruff-vscode#546
Summary
This PR stabilizes the support for Jupyter Notebooks and adds them to Ruff's default inclusion set.
Closes: #12456
Closes: astral-sh/ruff-vscode#546
Test Plan