-
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.
[
ruff
] Do not report when Optional
has no type arguments (`RUF013…
…`) (#14181) ## Summary Resolves #13833. ## Test Plan `cargo nextest run` and `cargo insta test`. --------- Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
- Loading branch information
1 parent
d3f1c8e
commit c9b84e2
Showing
4 changed files
with
102 additions
and
44 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
crates/ruff_linter/resources/test/fixtures/ruff/RUF013_4.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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# https://github.com/astral-sh/ruff/issues/13833 | ||
|
||
from typing import Optional | ||
|
||
|
||
def no_default(arg: Optional): ... | ||
|
||
|
||
def has_default(arg: Optional = None): ... | ||
|
||
|
||
def multiple_1(arg1: Optional, arg2: Optional = None): ... | ||
|
||
|
||
def multiple_2(arg1: Optional, arg2: Optional = None, arg3: int = None): ... | ||
|
||
|
||
def return_type(arg: Optional = None) -> Optional: ... | ||
|
||
|
||
def has_type_argument(arg: Optional[int] = None): ... |
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
20 changes: 20 additions & 0 deletions
20
..._linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_4.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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/ruff/mod.rs | ||
snapshot_kind: text | ||
--- | ||
RUF013_4.py:15:61: RUF013 [*] PEP 484 prohibits implicit `Optional` | ||
| | ||
15 | def multiple_2(arg1: Optional, arg2: Optional = None, arg3: int = None): ... | ||
| ^^^ RUF013 | ||
| | ||
= help: Convert to `T | None` | ||
|
||
ℹ Unsafe fix | ||
12 12 | def multiple_1(arg1: Optional, arg2: Optional = None): ... | ||
13 13 | | ||
14 14 | | ||
15 |-def multiple_2(arg1: Optional, arg2: Optional = None, arg3: int = None): ... | ||
15 |+def multiple_2(arg1: Optional, arg2: Optional = None, arg3: int | None = None): ... | ||
16 16 | | ||
17 17 | | ||
18 18 | def return_type(arg: Optional = None) -> Optional: ... |
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