mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-20 04:29:47 +00:00
move unstable tests to preview file, finish preview gating
This commit is contained in:
parent
087387d40c
commit
cc84b4f056
6 changed files with 118 additions and 114 deletions
|
|
@ -142,17 +142,6 @@ lambda a, /, c: a
|
|||
x
|
||||
)
|
||||
|
||||
(
|
||||
lambda
|
||||
# comment 1
|
||||
*
|
||||
# comment 2
|
||||
x,
|
||||
**y:
|
||||
# comment 3
|
||||
x
|
||||
)
|
||||
|
||||
(
|
||||
lambda # comment 1
|
||||
* # comment 2
|
||||
|
|
@ -160,14 +149,6 @@ lambda a, /, c: a
|
|||
x
|
||||
)
|
||||
|
||||
(
|
||||
lambda # comment 1
|
||||
* # comment 2
|
||||
x,
|
||||
y: # comment 3
|
||||
x
|
||||
)
|
||||
|
||||
lambda *x\
|
||||
:x
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
[
|
||||
{
|
||||
"preview": "enabled"
|
||||
}
|
||||
]
|
||||
24
crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/lambda_preview.py
vendored
Normal file
24
crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/lambda_preview.py
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
"""
|
||||
Test cases from lambda.py that cause an instability in the stable
|
||||
implementation but that are handled by the preview `indent_lambda_parameters`
|
||||
version.
|
||||
"""
|
||||
|
||||
(
|
||||
lambda
|
||||
# comment 1
|
||||
*
|
||||
# comment 2
|
||||
x,
|
||||
**y:
|
||||
# comment 3
|
||||
x
|
||||
)
|
||||
|
||||
(
|
||||
lambda # comment 1
|
||||
* # comment 2
|
||||
x,
|
||||
y: # comment 3
|
||||
x
|
||||
)
|
||||
|
|
@ -10,6 +10,7 @@ use crate::comments::{
|
|||
use crate::context::{NodeLevel, WithNodeLevel};
|
||||
use crate::expression::parentheses::empty_parenthesized;
|
||||
use crate::prelude::*;
|
||||
use crate::preview::is_indent_lambda_parameters_enabled;
|
||||
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Default)]
|
||||
pub enum ParametersParentheses {
|
||||
|
|
@ -241,7 +242,11 @@ impl FormatNodeRule<Parameters> for FormatParameters {
|
|||
let num_parameters = item.len();
|
||||
|
||||
if self.parentheses == ParametersParentheses::Never {
|
||||
write!(f, [format_inner, dangling_comments(dangling)])
|
||||
if is_indent_lambda_parameters_enabled(f.context()) {
|
||||
write!(f, [format_inner, dangling_comments(dangling)])
|
||||
} else {
|
||||
write!(f, [group(&format_inner), dangling_comments(dangling)])
|
||||
}
|
||||
} else if num_parameters == 0 {
|
||||
let mut f = WithNodeLevel::new(NodeLevel::ParenthesizedExpression, f);
|
||||
// No parameters, format any dangling comments between `()`
|
||||
|
|
|
|||
|
|
@ -148,17 +148,6 @@ lambda a, /, c: a
|
|||
x
|
||||
)
|
||||
|
||||
(
|
||||
lambda
|
||||
# comment 1
|
||||
*
|
||||
# comment 2
|
||||
x,
|
||||
**y:
|
||||
# comment 3
|
||||
x
|
||||
)
|
||||
|
||||
(
|
||||
lambda # comment 1
|
||||
* # comment 2
|
||||
|
|
@ -166,14 +155,6 @@ lambda a, /, c: a
|
|||
x
|
||||
)
|
||||
|
||||
(
|
||||
lambda # comment 1
|
||||
* # comment 2
|
||||
x,
|
||||
y: # comment 3
|
||||
x
|
||||
)
|
||||
|
||||
lambda *x\
|
||||
:x
|
||||
|
||||
|
|
@ -486,8 +467,7 @@ lambda a, /, c: a
|
|||
(
|
||||
lambda
|
||||
# comment
|
||||
*x,
|
||||
**y: x
|
||||
*x, **y: x
|
||||
)
|
||||
|
||||
(
|
||||
|
|
@ -499,16 +479,6 @@ lambda a, /, c: a
|
|||
x
|
||||
)
|
||||
|
||||
(
|
||||
lambda
|
||||
# comment 1
|
||||
# comment 2
|
||||
*x,
|
||||
**y:
|
||||
# comment 3
|
||||
x
|
||||
)
|
||||
|
||||
(
|
||||
lambda # comment 1
|
||||
# comment 2
|
||||
|
|
@ -516,14 +486,6 @@ lambda a, /, c: a
|
|||
x
|
||||
)
|
||||
|
||||
(
|
||||
lambda # comment 1
|
||||
# comment 2
|
||||
*x,
|
||||
y: # comment 3
|
||||
x
|
||||
)
|
||||
|
||||
lambda *x: x
|
||||
|
||||
(
|
||||
|
|
@ -755,7 +717,7 @@ def a():
|
|||
):
|
||||
pass
|
||||
|
||||
@@ -122,48 +106,54 @@
|
||||
@@ -122,29 +106,34 @@
|
||||
|
||||
(
|
||||
lambda
|
||||
|
|
@ -769,8 +731,7 @@ def a():
|
|||
(
|
||||
lambda
|
||||
- # comment
|
||||
- *x,
|
||||
- **y: x
|
||||
- *x, **y: x
|
||||
+ # comment
|
||||
+ *x,
|
||||
+ **y
|
||||
|
|
@ -790,21 +751,6 @@ def a():
|
|||
x
|
||||
)
|
||||
|
||||
(
|
||||
lambda
|
||||
- # comment 1
|
||||
- # comment 2
|
||||
- *x,
|
||||
- **y:
|
||||
+ # comment 1
|
||||
+ # comment 2
|
||||
+ *x,
|
||||
+ **y
|
||||
+ :
|
||||
# comment 3
|
||||
x
|
||||
)
|
||||
|
||||
(
|
||||
lambda # comment 1
|
||||
- # comment 2
|
||||
|
|
@ -815,19 +761,7 @@ def a():
|
|||
x
|
||||
)
|
||||
|
||||
(
|
||||
lambda # comment 1
|
||||
- # comment 2
|
||||
- *x,
|
||||
- y: # comment 3
|
||||
+ # comment 2
|
||||
+ *x,
|
||||
+ y
|
||||
+ : # comment 3
|
||||
x
|
||||
)
|
||||
|
||||
@@ -171,8 +161,9 @@
|
||||
@@ -152,8 +141,9 @@
|
||||
|
||||
(
|
||||
lambda
|
||||
|
|
@ -839,7 +773,7 @@ def a():
|
|||
)
|
||||
|
||||
lambda: ( # comment
|
||||
@@ -210,8 +201,9 @@
|
||||
@@ -191,8 +181,9 @@
|
||||
|
||||
(
|
||||
lambda # 1
|
||||
|
|
@ -851,7 +785,7 @@ def a():
|
|||
# 4
|
||||
# 5
|
||||
# 6
|
||||
@@ -220,83 +212,94 @@
|
||||
@@ -201,83 +192,94 @@
|
||||
|
||||
(
|
||||
lambda # 1
|
||||
|
|
@ -1009,7 +943,7 @@ def a():
|
|||
# Trailing
|
||||
|
||||
lambda self, araa, kkkwargs=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
|
||||
@@ -310,9 +313,11 @@
|
||||
@@ -291,9 +293,11 @@
|
||||
c,
|
||||
d,
|
||||
e,
|
||||
|
|
@ -1024,7 +958,7 @@ def a():
|
|||
)
|
||||
|
||||
|
||||
@@ -321,14 +326,16 @@
|
||||
@@ -302,14 +306,16 @@
|
||||
c,
|
||||
d,
|
||||
e,
|
||||
|
|
@ -1200,17 +1134,6 @@ lambda a, /, c: a
|
|||
x
|
||||
)
|
||||
|
||||
(
|
||||
lambda
|
||||
# comment 1
|
||||
# comment 2
|
||||
*x,
|
||||
**y
|
||||
:
|
||||
# comment 3
|
||||
x
|
||||
)
|
||||
|
||||
(
|
||||
lambda # comment 1
|
||||
# comment 2
|
||||
|
|
@ -1219,15 +1142,6 @@ lambda a, /, c: a
|
|||
x
|
||||
)
|
||||
|
||||
(
|
||||
lambda # comment 1
|
||||
# comment 2
|
||||
*x,
|
||||
y
|
||||
: # comment 3
|
||||
x
|
||||
)
|
||||
|
||||
lambda *x: x
|
||||
|
||||
(
|
||||
|
|
|
|||
|
|
@ -0,0 +1,75 @@
|
|||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/lambda_preview.py
|
||||
---
|
||||
## Input
|
||||
```python
|
||||
"""
|
||||
Test cases from lambda.py that cause an instability in the stable
|
||||
implementation but that are handled by the preview `indent_lambda_parameters`
|
||||
version.
|
||||
"""
|
||||
|
||||
(
|
||||
lambda
|
||||
# comment 1
|
||||
*
|
||||
# comment 2
|
||||
x,
|
||||
**y:
|
||||
# comment 3
|
||||
x
|
||||
)
|
||||
|
||||
(
|
||||
lambda # comment 1
|
||||
* # comment 2
|
||||
x,
|
||||
y: # comment 3
|
||||
x
|
||||
)
|
||||
```
|
||||
|
||||
## Outputs
|
||||
### Output 1
|
||||
```
|
||||
indent-style = space
|
||||
line-width = 88
|
||||
indent-width = 4
|
||||
quote-style = Double
|
||||
line-ending = LineFeed
|
||||
magic-trailing-comma = Respect
|
||||
docstring-code = Disabled
|
||||
docstring-code-line-width = "dynamic"
|
||||
preview = Enabled
|
||||
target_version = 3.10
|
||||
source_type = Python
|
||||
```
|
||||
|
||||
```python
|
||||
"""
|
||||
Test cases from lambda.py that cause an instability in the stable
|
||||
implementation but that are handled by the preview `indent_lambda_parameters`
|
||||
version.
|
||||
"""
|
||||
|
||||
(
|
||||
lambda
|
||||
# comment 1
|
||||
# comment 2
|
||||
*x,
|
||||
**y
|
||||
:
|
||||
# comment 3
|
||||
x
|
||||
)
|
||||
|
||||
(
|
||||
lambda # comment 1
|
||||
# comment 2
|
||||
*x,
|
||||
y
|
||||
: # comment 3
|
||||
x
|
||||
)
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue