-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Typing stub file support for blank line rules
- Loading branch information
1 parent
46ab9de
commit 6bf8c21
Showing
12 changed files
with
418 additions
and
5 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
crates/ruff_linter/resources/test/fixtures/pycodestyle/E30.pyi
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,50 @@ | ||
import json | ||
|
||
from typing import Any, Sequence | ||
|
||
class MissingCommand(TypeError): ... | ||
class AnoherClass: ... | ||
|
||
def a(): ... | ||
|
||
@overload | ||
def a(arg: int): ... | ||
|
||
@overload | ||
def a(arg: int, name: str): ... | ||
|
||
|
||
def grouped1(): ... | ||
def grouped2(): ... | ||
def grouped3( ): ... | ||
|
||
|
||
class BackendProxy: | ||
backend_module: str | ||
backend_object: str | None | ||
backend: Any | ||
|
||
def grouped1(): ... | ||
def grouped2(): ... | ||
def grouped3( ): ... | ||
@decorated | ||
|
||
def with_blank_line(): ... | ||
|
||
|
||
def ungrouped(): ... | ||
a = "test" | ||
|
||
def function_def(): | ||
pass | ||
b = "test" | ||
|
||
|
||
def outer(): | ||
def inner(): | ||
pass | ||
def inner2(): | ||
pass | ||
|
||
class Foo: ... | ||
class Bar: ... |
62 changes: 62 additions & 0 deletions
62
crates/ruff_linter/resources/test/fixtures/pycodestyle/E30_isort.pyi
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,62 @@ | ||
import json | ||
|
||
|
||
|
||
from typing import Any, Sequence | ||
|
||
|
||
class MissingCommand(TypeError): ... # noqa: N818 | ||
|
||
|
||
class BackendProxy: | ||
backend_module: str | ||
backend_object: str | None | ||
backend: Any | ||
|
||
|
||
if __name__ == "__main__": | ||
import abcd | ||
|
||
|
||
abcd.foo() | ||
|
||
def __init__(self, backend_module: str, backend_obj: str | None) -> None: ... | ||
|
||
if TYPE_CHECKING: | ||
import os | ||
|
||
|
||
|
||
from typing_extensions import TypeAlias | ||
|
||
|
||
abcd.foo() | ||
|
||
def __call__(self, name: str, *args: Any, **kwargs: Any) -> Any: | ||
... | ||
|
||
if TYPE_CHECKING: | ||
from typing_extensions import TypeAlias | ||
|
||
def __call__2(self, name: str, *args: Any, **kwargs: Any) -> Any: | ||
... | ||
|
||
|
||
def _exit(self) -> None: ... | ||
|
||
|
||
def _optional_commands(self) -> dict[str, bool]: ... | ||
|
||
|
||
def run(argv: Sequence[str]) -> int: ... | ||
|
||
|
||
def read_line(fd: int = 0) -> bytearray: ... | ||
|
||
|
||
def flush() -> None: ... | ||
|
||
|
||
from typing import Any, Sequence | ||
|
||
class MissingCommand(TypeError): ... # noqa: N818 |
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
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
4 changes: 4 additions & 0 deletions
4
...style/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E301_typing_stub.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,4 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/pycodestyle/mod.rs | ||
--- | ||
|
4 changes: 4 additions & 0 deletions
4
...style/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E302_typing_stub.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,4 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/pycodestyle/mod.rs | ||
--- | ||
|
73 changes: 73 additions & 0 deletions
73
...style/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E303_typing_stub.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,73 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/pycodestyle/mod.rs | ||
--- | ||
E30.pyi:17:1: E303 [*] Too many blank lines (2) | ||
| | ||
17 | def grouped1(): ... | ||
| ^^^ E303 | ||
18 | def grouped2(): ... | ||
19 | def grouped3( ): ... | ||
| | ||
= help: Remove extraneous blank line(s) | ||
|
||
ℹ Safe fix | ||
13 13 | @overload | ||
14 14 | def a(arg: int, name: str): ... | ||
15 15 | | ||
16 |- | ||
17 16 | def grouped1(): ... | ||
18 17 | def grouped2(): ... | ||
19 18 | def grouped3( ): ... | ||
|
||
E30.pyi:22:1: E303 [*] Too many blank lines (2) | ||
| | ||
22 | class BackendProxy: | ||
| ^^^^^ E303 | ||
23 | backend_module: str | ||
24 | backend_object: str | None | ||
| | ||
= help: Remove extraneous blank line(s) | ||
|
||
ℹ Safe fix | ||
18 18 | def grouped2(): ... | ||
19 19 | def grouped3( ): ... | ||
20 20 | | ||
21 |- | ||
22 21 | class BackendProxy: | ||
23 22 | backend_module: str | ||
24 23 | backend_object: str | None | ||
|
||
E30.pyi:35:5: E303 [*] Too many blank lines (2) | ||
| | ||
35 | def ungrouped(): ... | ||
| ^^^ E303 | ||
36 | a = "test" | ||
| | ||
= help: Remove extraneous blank line(s) | ||
|
||
ℹ Safe fix | ||
31 31 | | ||
32 32 | def with_blank_line(): ... | ||
33 33 | | ||
34 |- | ||
35 34 | def ungrouped(): ... | ||
36 35 | a = "test" | ||
37 36 | | ||
|
||
E30.pyi:43:1: E303 [*] Too many blank lines (2) | ||
| | ||
43 | def outer(): | ||
| ^^^ E303 | ||
44 | def inner(): | ||
45 | pass | ||
| | ||
= help: Remove extraneous blank line(s) | ||
|
||
ℹ Safe fix | ||
39 39 | pass | ||
40 40 | b = "test" | ||
41 41 | | ||
42 |- | ||
43 42 | def outer(): | ||
44 43 | def inner(): | ||
45 44 | pass |
Oops, something went wrong.