-
Notifications
You must be signed in to change notification settings - Fork 933
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow simple container literals as default values (#3703)
- Loading branch information
1 parent
0f95056
commit 7da06b9
Showing
7 changed files
with
461 additions
and
162 deletions.
There are no files selected for viewing
198 changes: 140 additions & 58 deletions
198
crates/ruff/resources/test/fixtures/flake8_pyi/PYI011.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,79 +1,161 @@ | ||
import math | ||
import os | ||
import sys | ||
from math import inf | ||
|
||
import numpy as np | ||
|
||
def f12( | ||
x, | ||
y: str = os.pathsep, # OK | ||
) -> None: | ||
... | ||
|
||
|
||
def f11(*, x: str = "x") -> None: # OK | ||
... | ||
|
||
|
||
) -> None: ... | ||
def f11(*, x: str = "x") -> None: ... # OK | ||
def f13( | ||
x: list[str] = [ | ||
x: list[str] = [ # OK | ||
"foo", | ||
"bar", | ||
"baz", | ||
] # OK | ||
) -> None: | ||
... | ||
|
||
|
||
] | ||
) -> None: ... | ||
def f14( | ||
x: tuple[str, ...] = ( | ||
x: tuple[str, ...] = ( # OK | ||
"foo", | ||
"bar", | ||
"baz", | ||
) # OK | ||
) -> None: | ||
... | ||
|
||
|
||
) | ||
) -> None: ... | ||
def f15( | ||
x: set[str] = { | ||
x: set[str] = { # OK | ||
"foo", | ||
"bar", | ||
"baz", | ||
} # OK | ||
) -> None: | ||
... | ||
|
||
|
||
def f16(x: frozenset[bytes] = frozenset({b"foo", b"bar", b"baz"})) -> None: # OK | ||
... | ||
|
||
|
||
} | ||
) -> None: ... | ||
def f151(x: dict[int, int] = {1: 2}) -> None: ... # Ok | ||
def f152( | ||
x: dict[ | ||
int, int | ||
] = { # OK | ||
1: 2, | ||
**{3: 4}, | ||
} | ||
) -> None: ... | ||
def f153( | ||
x: list[ | ||
int | ||
] = [ # OK | ||
1, | ||
2, | ||
3, | ||
4, | ||
5, | ||
6, | ||
7, | ||
8, | ||
9, | ||
10, | ||
11, | ||
] | ||
) -> None: ... | ||
def f154( | ||
x: tuple[ | ||
str, tuple[str, ...] | ||
] = ( # OK | ||
"foo", | ||
("bar", "baz"), | ||
) | ||
) -> None: ... | ||
def f141( | ||
x: list[ | ||
int | ||
] = [ # OK | ||
*range(10) | ||
], | ||
) -> None: ... | ||
def f142( | ||
x: list[ | ||
int | ||
] = list( # OK | ||
range(10) | ||
), | ||
) -> None: ... | ||
def f16( | ||
x: frozenset[ | ||
bytes | ||
] = frozenset( # OK | ||
{b"foo", b"bar", b"baz"} | ||
) | ||
) -> None: ... | ||
def f17( | ||
x: str = "foo" + "bar", # OK | ||
) -> None: | ||
... | ||
|
||
|
||
x: str = "foo" # OK | ||
+ "bar", | ||
) -> None: ... | ||
def f18( | ||
x: str = b"foo" + b"bar", # OK | ||
) -> None: | ||
... | ||
|
||
|
||
x: str = b"foo" # OK | ||
+ b"bar", | ||
) -> None: ... | ||
def f19( | ||
x: object = "foo" + 4, # OK | ||
) -> None: | ||
... | ||
|
||
|
||
x: object = "foo" # OK | ||
+ 4, | ||
) -> None: ... | ||
def f20( | ||
x: int = 5 + 5, # OK | ||
) -> None: | ||
... | ||
|
||
|
||
x: int = 5 | ||
+ 5, # OK | ||
) -> None: ... | ||
def f21( | ||
x: complex = 3j - 3j, # OK | ||
) -> None: | ||
... | ||
|
||
|
||
x: complex = 3j | ||
- 3j, # OK | ||
) -> None: ... | ||
def f22( | ||
x: complex = -42.5j + 4.3j, # OK | ||
) -> None: | ||
... | ||
x: complex = -42.5j # OK | ||
+ 4.3j, | ||
) -> None: ... | ||
def f23( | ||
x: bool = True, # OK | ||
) -> None: ... | ||
def f24( | ||
x: float = 3.14, # OK | ||
) -> None: ... | ||
def f25( | ||
x: float = -3.14, # OK | ||
) -> None: ... | ||
def f26( | ||
x: complex = -3.14j, # OK | ||
) -> None: ... | ||
def f27( | ||
x: complex = -3 - 3.14j, # OK | ||
) -> None: ... | ||
def f28( | ||
x: float = math.tau, # OK | ||
) -> None: ... | ||
def f29( | ||
x: float = math.inf, # OK | ||
) -> None: ... | ||
def f30( | ||
x: float = -math.inf, # OK | ||
) -> None: ... | ||
def f31( | ||
x: float = inf, # OK | ||
) -> None: ... | ||
def f32( | ||
x: float = np.inf, # OK | ||
) -> None: ... | ||
def f33( | ||
x: float = math.nan, # OK | ||
) -> None: ... | ||
def f34( | ||
x: float = -math.nan, # OK | ||
) -> None: ... | ||
def f35( | ||
x: complex = math.inf # OK | ||
+ 1j, | ||
) -> None: ... | ||
def f36( | ||
*, | ||
x: str = sys.version, # OK | ||
) -> None: ... | ||
def f37( | ||
*, | ||
x: str = "" # OK | ||
+ "", | ||
) -> 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
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
Oops, something went wrong.