-
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.
[
pylint
] Omit stubs from invalid-bool
and `invalid-str-return-typ…
- Loading branch information
1 parent
9f01ac3
commit 4d8890e
Showing
5 changed files
with
65 additions
and
34 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
crates/ruff_linter/resources/test/fixtures/pylint/invalid_return_type_str.py
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 |
---|---|---|
@@ -1,36 +1,49 @@ | ||
# These testcases should raise errors | ||
|
||
|
||
class Float: | ||
def __str__(self): | ||
return 3.05 | ||
|
||
|
||
class Int: | ||
def __str__(self): | ||
return 1 | ||
|
||
|
||
class Int2: | ||
def __str__(self): | ||
return 0 | ||
|
||
|
||
class Bool: | ||
def __str__(self): | ||
return False | ||
|
||
|
||
# TODO: Once Ruff has better type checking | ||
def return_int(): | ||
return 3 | ||
|
||
|
||
class ComplexReturn: | ||
def __str__(self): | ||
return return_int() | ||
|
||
|
||
# These testcases should NOT raise errors | ||
|
||
|
||
class Str: | ||
def __str__(self): | ||
return "ruff" | ||
|
||
|
||
class Str2: | ||
def __str__(self): | ||
x = "ruff" | ||
return x | ||
|
||
|
||
class Str3: | ||
def __str__(self): ... |
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
40 changes: 16 additions & 24 deletions
40
...lint/snapshots/ruff_linter__rules__pylint__tests__PLE0307_invalid_return_type_str.py.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 |
---|---|---|
@@ -1,42 +1,34 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/pylint/mod.rs | ||
--- | ||
invalid_return_type_str.py:5:16: PLE0307 `__str__` does not return `str` | ||
invalid_return_type_str.py:6:16: PLE0307 `__str__` does not return `str` | ||
| | ||
3 | class Float: | ||
4 | def __str__(self): | ||
5 | return 3.05 | ||
4 | class Float: | ||
5 | def __str__(self): | ||
6 | return 3.05 | ||
| ^^^^ PLE0307 | ||
6 | | ||
7 | class Int: | ||
| | ||
|
||
invalid_return_type_str.py:9:16: PLE0307 `__str__` does not return `str` | ||
invalid_return_type_str.py:11:16: PLE0307 `__str__` does not return `str` | ||
| | ||
7 | class Int: | ||
8 | def __str__(self): | ||
9 | return 1 | ||
9 | class Int: | ||
10 | def __str__(self): | ||
11 | return 1 | ||
| ^ PLE0307 | ||
10 | | ||
11 | class Int2: | ||
| | ||
|
||
invalid_return_type_str.py:13:16: PLE0307 `__str__` does not return `str` | ||
invalid_return_type_str.py:16:16: PLE0307 `__str__` does not return `str` | ||
| | ||
11 | class Int2: | ||
12 | def __str__(self): | ||
13 | return 0 | ||
14 | class Int2: | ||
15 | def __str__(self): | ||
16 | return 0 | ||
| ^ PLE0307 | ||
14 | | ||
15 | class Bool: | ||
| | ||
|
||
invalid_return_type_str.py:17:16: PLE0307 `__str__` does not return `str` | ||
invalid_return_type_str.py:21:16: PLE0307 `__str__` does not return `str` | ||
| | ||
15 | class Bool: | ||
16 | def __str__(self): | ||
17 | return False | ||
19 | class Bool: | ||
20 | def __str__(self): | ||
21 | return False | ||
| ^^^^^ PLE0307 | ||
18 | | ||
19 | # TODO: Once Ruff has better type checking | ||
| |