Skip to content

Commit

Permalink
add E303 notebook test case
Browse files Browse the repository at this point in the history
  • Loading branch information
hoel-bagard committed Mar 22, 2024
1 parent d543e72 commit bce6989
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 26 deletions.
24 changes: 24 additions & 0 deletions crates/ruff_linter/resources/test/fixtures/pycodestyle/E30.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,30 @@
"# end"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# E303"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"\n",
"\n",
"\n",
"\n",
"def fn():\n",
"\tpass\n",
"# end"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,22 @@ E30.ipynb:29:5: E303 [*] Too many blank lines (2)
29 28 | # arbitrary comment
30 29 |
31 30 | def inner(): # E306 not expected (pycodestyle detects E306)

E30.ipynb:39:1: E303 [*] Too many blank lines (4)
|
39 | def fn():
| ^^^ E303
40 | pass
41 | # end
|
= help: Remove extraneous blank line(s)

Safe fix
34 34 | # E303
35 35 |
36 36 |
37 |-
38 |-
39 37 | def fn():
40 38 | pass
41 39 | # end
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
---
source: crates/ruff_linter/src/rules/pycodestyle/mod.rs
---
E30.ipynb:37:1: E304 [*] Blank lines found after function decorator (1)
E30.ipynb:45:1: E304 [*] Blank lines found after function decorator (1)
|
35 | @decorator
36 |
37 | def function():
43 | @decorator
44 |
45 | def function():
| ^^^ E304
38 | pass
39 | # end
46 | pass
47 | # end
|
= help: Remove extraneous blank line(s)

ℹ Safe fix
33 33 | # end
34 34 | # E304
35 35 | @decorator
36 |-
37 36 | def function():
38 37 | pass
39 38 | # end
41 41 | # end
42 42 | # E304
43 43 | @decorator
44 |-
45 44 | def function():
46 45 | pass
47 46 | # end
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
---
source: crates/ruff_linter/src/rules/pycodestyle/mod.rs
---
E30.ipynb:52:5: E306 [*] Expected 1 blank line before a nested definition, found 0
E30.ipynb:60:5: E306 [*] Expected 1 blank line before a nested definition, found 0
|
50 | def a():
51 | x = 1
52 | def b():
58 | def a():
59 | x = 1
60 | def b():
| ^^^ E306
53 | pass
54 | # end
61 | pass
62 | # end
|
= help: Add missing blank line

Safe fix
49 49 | # E306:3:5
50 50 | def a():
51 51 | x = 1
52 |+
52 53 | def b():
53 54 | pass
54 55 | # end
57 57 | # E306:3:5
58 58 | def a():
59 59 | x = 1
60 |+
60 61 | def b():
61 62 | pass
62 63 | # end

0 comments on commit bce6989

Please sign in to comment.