Skip to content

Commit

Permalink
add new test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
diceroll123 committed Jan 15, 2024
1 parent 69f71d2 commit b387a6e
Show file tree
Hide file tree
Showing 4 changed files with 205 additions and 131 deletions.
4 changes: 4 additions & 0 deletions crates/ruff_linter/resources/test/fixtures/pycodestyle/E40.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#: E401
import os, sys
import re as regex, string # also with a comment!
import re as regex, string; x = 1

x = 1; import re as regex, string


def blah():
import datetime as dt, copy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ E40.py:2:1: E401 Multiple imports on one line
2 | import os, sys
| ^^^^^^^^^^^^^^ E401
3 | import re as regex, string # also with a comment!
4 | import re as regex, string; x = 1
|
= help: Split imports onto multiple lines

Expand All @@ -16,29 +17,48 @@ E40.py:3:1: E401 Multiple imports on one line
2 | import os, sys
3 | import re as regex, string # also with a comment!
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ E401
4 |
5 | def blah():
4 | import re as regex, string; x = 1
|
= help: Split imports onto multiple lines

E40.py:6:5: E401 Multiple imports on one line
E40.py:4:1: E401 Multiple imports on one line
|
5 | def blah():
6 | import datetime as dt, copy
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E401
7 | def nested_and_tested():
8 | import builtins, textwrap as tw
2 | import os, sys
3 | import re as regex, string # also with a comment!
4 | import re as regex, string; x = 1
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ E401
5 |
6 | x = 1; import re as regex, string
|
= help: Split imports onto multiple lines

E40.py:8:9: E401 Multiple imports on one line
E40.py:6:8: E401 Multiple imports on one line
|
4 | import re as regex, string; x = 1
5 |
6 | x = 1; import re as regex, string
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ E401
|
= help: Split imports onto multiple lines

E40.py:10:5: E401 Multiple imports on one line
|
9 | def blah():
10 | import datetime as dt, copy
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E401
11 | def nested_and_tested():
12 | import builtins, textwrap as tw
|
= help: Split imports onto multiple lines

E40.py:12:9: E401 Multiple imports on one line
|
6 | import datetime as dt, copy
7 | def nested_and_tested():
8 | import builtins, textwrap as tw
10 | import datetime as dt, copy
11 | def nested_and_tested():
12 | import builtins, textwrap as tw
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E401
9 |
10 | #: Okay
13 |
14 | #: Okay
|
= help: Split imports onto multiple lines

Expand Down
Original file line number Diff line number Diff line change
@@ -1,156 +1,164 @@
---
source: crates/ruff_linter/src/rules/pycodestyle/mod.rs
---
E40.py:11:1: E402 Module level import not at top of file
|
10 | #: Okay
11 | import os
E40.py:6:8: E402 Module level import not at top of file
|
4 | import re as regex, string; x = 1
5 |
6 | x = 1; import re as regex, string
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ E402
|

E40.py:15:1: E402 Module level import not at top of file
|
14 | #: Okay
15 | import os
| ^^^^^^^^^ E402
12 | import sys
16 | import sys
|

E40.py:12:1: E402 Module level import not at top of file
E40.py:16:1: E402 Module level import not at top of file
|
10 | #: Okay
11 | import os
12 | import sys
14 | #: Okay
15 | import os
16 | import sys
| ^^^^^^^^^^ E402
13 |
14 | from subprocess import Popen, PIPE
17 |
18 | from subprocess import Popen, PIPE
|

E40.py:14:1: E402 Module level import not at top of file
E40.py:18:1: E402 Module level import not at top of file
|
12 | import sys
13 |
14 | from subprocess import Popen, PIPE
16 | import sys
17 |
18 | from subprocess import Popen, PIPE
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E402
15 |
16 | from myclass import MyClass
19 |
20 | from myclass import MyClass
|

E40.py:16:1: E402 Module level import not at top of file
E40.py:20:1: E402 Module level import not at top of file
|
14 | from subprocess import Popen, PIPE
15 |
16 | from myclass import MyClass
18 | from subprocess import Popen, PIPE
19 |
20 | from myclass import MyClass
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E402
17 | from foo.bar.yourclass import YourClass
21 | from foo.bar.yourclass import YourClass
|

E40.py:17:1: E402 Module level import not at top of file
E40.py:21:1: E402 Module level import not at top of file
|
16 | from myclass import MyClass
17 | from foo.bar.yourclass import YourClass
20 | from myclass import MyClass
21 | from foo.bar.yourclass import YourClass
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E402
18 |
19 | import myclass
22 |
23 | import myclass
|

E40.py:19:1: E402 Module level import not at top of file
E40.py:23:1: E402 Module level import not at top of file
|
17 | from foo.bar.yourclass import YourClass
18 |
19 | import myclass
21 | from foo.bar.yourclass import YourClass
22 |
23 | import myclass
| ^^^^^^^^^^^^^^ E402
20 | import foo.bar.yourclass
21 | #: Okay
|

E40.py:20:1: E402 Module level import not at top of file
|
19 | import myclass
20 | import foo.bar.yourclass
| ^^^^^^^^^^^^^^^^^^^^^^^^ E402
21 | #: Okay
22 | __all__ = ['abc']
24 | import foo.bar.yourclass
25 | #: Okay
|

E40.py:24:1: E402 Module level import not at top of file
|
22 | __all__ = ['abc']
23 |
24 | import foo
| ^^^^^^^^^^ E402
23 | import myclass
24 | import foo.bar.yourclass
| ^^^^^^^^^^^^^^^^^^^^^^^^ E402
25 | #: Okay
26 | __version__ = "42"
26 | __all__ = ['abc']
|

E40.py:28:1: E402 Module level import not at top of file
|
26 | __version__ = "42"
26 | __all__ = ['abc']
27 |
28 | import foo
| ^^^^^^^^^^ E402
29 | #: Okay
30 | __author__ = "Simon Gomizelj"
30 | __version__ = "42"
|

E40.py:32:1: E402 Module level import not at top of file
|
30 | __author__ = "Simon Gomizelj"
30 | __version__ = "42"
31 |
32 | import foo
| ^^^^^^^^^^ E402
33 | #: Okay
34 | try:
34 | __author__ = "Simon Gomizelj"
|

E40.py:43:1: E402 Module level import not at top of file
E40.py:36:1: E402 Module level import not at top of file
|
41 | print('made attempt to import foo')
42 |
43 | import bar
34 | __author__ = "Simon Gomizelj"
35 |
36 | import foo
| ^^^^^^^^^^ E402
44 | #: Okay
45 | with warnings.catch_warnings():
37 | #: Okay
38 | try:
|

E40.py:49:1: E402 Module level import not at top of file
E40.py:47:1: E402 Module level import not at top of file
|
47 | import foo
48 |
49 | import bar
45 | print('made attempt to import foo')
46 |
47 | import bar
| ^^^^^^^^^^ E402
50 | #: Okay
51 | if False:
48 | #: Okay
49 | with warnings.catch_warnings():
|

E40.py:58:1: E402 Module level import not at top of file
E40.py:53:1: E402 Module level import not at top of file
|
56 | import mwahaha
57 |
58 | import bar
51 | import foo
52 |
53 | import bar
| ^^^^^^^^^^ E402
59 | #: E402
60 | VERSION = '1.2.3'
54 | #: Okay
55 | if False:
|

E40.py:62:1: E402 Module level import not at top of file
|
60 | VERSION = '1.2.3'
60 | import mwahaha
61 |
62 | import foo
62 | import bar
| ^^^^^^^^^^ E402
63 | #: E402
64 | import foo
64 | VERSION = '1.2.3'
|

E40.py:64:1: E402 Module level import not at top of file
E40.py:66:1: E402 Module level import not at top of file
|
62 | import foo
63 | #: E402
64 | import foo
| ^^^^^^^^^^ E402
64 | VERSION = '1.2.3'
65 |
66 | a = 1
66 | import foo
| ^^^^^^^^^^ E402
67 | #: E402
68 | import foo
|

E40.py:68:1: E402 Module level import not at top of file
|
66 | a = 1
67 |
68 | import bar
66 | import foo
67 | #: E402
68 | import foo
| ^^^^^^^^^^ E402
69 |
70 | a = 1
|

E40.py:72:1: E402 Module level import not at top of file
|
70 | a = 1
71 |
72 | import bar
| ^^^^^^^^^^ E402
|

Expand Down
Loading

0 comments on commit b387a6e

Please sign in to comment.