mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 02:13:08 +00:00

## Summary This PR moves `ruff/jupyter` into its own `ruff_notebook` crate. Beyond the move itself, there were a few challenges: 1. `ruff_notebook` relies on the source map abstraction. I've moved the source map into `ruff_diagnostics`, since it doesn't have any dependencies on its own and is used alongside diagnostics. 2. `ruff_notebook` has a couple tests for end-to-end linting and autofixing. I had to leave these tests in `ruff` itself. 3. We had code in `ruff/jupyter` that relied on Python lexing, in order to provide a more targeted error message in the event that a user saves a `.py` file with a `.ipynb` extension. I removed this in order to avoid a dependency on the parser, it felt like it wasn't worth retaining just for that dependency. ## Test Plan `cargo test`
49 lines
952 B
Text
49 lines
952 B
Text
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "a0efffbc-85f1-4513-bf49-5387ec3a2a4e",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"def f():\n",
|
|
" foo1 = %matplotlib --list\n",
|
|
" foo2: list[str] = %matplotlib --list"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "6e0b2b50-43f2-4f59-951d-9404dd560ae4",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"def f():\n",
|
|
" bar1 = !pwd\n",
|
|
" bar2: str = !pwd"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python (ruff)",
|
|
"language": "python",
|
|
"name": "ruff"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.11.3"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|