-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Detect automagic-like assignments in notebooks
- Loading branch information
1 parent
b61b0ed
commit e1b7b00
Showing
6 changed files
with
113 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__undefined_name.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
source: crates/ruff_linter/src/linter.rs | ||
--- | ||
undefined_name.ipynb:cell 3:1:7: F821 Undefined name `undefined` | ||
| | ||
1 | print(undefined) | ||
| ^^^^^^^^^ F821 | ||
| | ||
|
||
|
8 changes: 8 additions & 0 deletions
8
crates/ruff_notebook/resources/test/fixtures/jupyter/cell/automagic_assignment.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"execution_count": null, | ||
"cell_type": "code", | ||
"id": "1", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": ["colors = 6\n", "print(colors)"] | ||
} |
59 changes: 59 additions & 0 deletions
59
crates/ruff_notebook/resources/test/fixtures/jupyter/undefined_name.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "a0efffbc-85f1-4513-bf49-5387ec3a2a4e", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"colors = 6" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "6e0b2b50-43f2-4f59-951d-9404dd560ae4", | ||
"metadata": { | ||
"is_executing": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"print(colors)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"outputs": [], | ||
"source": [ | ||
"print(undefined)" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "884e0e4e686fd56" | ||
} | ||
], | ||
"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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters