mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-26 20:10:09 +00:00
Fix unstable set comprehension formatting (#5327)
This commit is contained in:
parent
930f03de98
commit
2dfa6ff58d
4 changed files with 35 additions and 13 deletions
|
@ -187,3 +187,8 @@ if (
|
||||||
a + b
|
a + b
|
||||||
):
|
):
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
|
# Unstable formatting in https://github.com/realtyem/synapse-unraid/blob/unraid_develop/synapse/handlers/presence.py
|
||||||
|
for user_id in set(target_user_ids) - {u.user_id for u in updates}:
|
||||||
|
updates.append(UserPresenceState.default(user_id))
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::comments::Comments;
|
||||||
use crate::expression::parentheses::{
|
use crate::expression::parentheses::{
|
||||||
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
||||||
};
|
};
|
||||||
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented_custom_text, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::ExprSetComp;
|
use rustpython_parser::ast::ExprSetComp;
|
||||||
|
|
||||||
|
@ -10,8 +10,13 @@ use rustpython_parser::ast::ExprSetComp;
|
||||||
pub struct FormatExprSetComp;
|
pub struct FormatExprSetComp;
|
||||||
|
|
||||||
impl FormatNodeRule<ExprSetComp> for FormatExprSetComp {
|
impl FormatNodeRule<ExprSetComp> for FormatExprSetComp {
|
||||||
fn fmt_fields(&self, item: &ExprSetComp, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, _item: &ExprSetComp, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [not_yet_implemented(item)])
|
write!(
|
||||||
|
f,
|
||||||
|
[not_yet_implemented_custom_text(
|
||||||
|
"{NOT_IMPLEMENTED_set_value for value in NOT_IMPLEMENTED_set}"
|
||||||
|
)]
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -386,10 +386,10 @@ last_call()
|
||||||
- k: v
|
- k: v
|
||||||
- for k, v in this_is_a_very_long_variable_which_will_cause_a_trailing_comma_which_breaks_the_comprehension
|
- for k, v in this_is_a_very_long_variable_which_will_cause_a_trailing_comma_which_breaks_the_comprehension
|
||||||
-}
|
-}
|
||||||
+NOT_YET_IMPLEMENTED_ExprSetComp
|
+{NOT_IMPLEMENTED_set_value for value in NOT_IMPLEMENTED_set}
|
||||||
+NOT_YET_IMPLEMENTED_ExprSetComp
|
+{NOT_IMPLEMENTED_set_value for value in NOT_IMPLEMENTED_set}
|
||||||
+NOT_YET_IMPLEMENTED_ExprSetComp
|
+{NOT_IMPLEMENTED_set_value for value in NOT_IMPLEMENTED_set}
|
||||||
+NOT_YET_IMPLEMENTED_ExprSetComp
|
+{NOT_IMPLEMENTED_set_value for value in NOT_IMPLEMENTED_set}
|
||||||
+[i for i in []]
|
+[i for i in []]
|
||||||
+[i for i in []]
|
+[i for i in []]
|
||||||
+[i for i in []]
|
+[i for i in []]
|
||||||
|
@ -767,10 +767,10 @@ NOT_IMPLEMENTED_true if NOT_IMPLEMENTED_cond else NOT_IMPLEMENTED_false
|
||||||
another,
|
another,
|
||||||
NOT_YET_IMPLEMENTED_ExprStarred,
|
NOT_YET_IMPLEMENTED_ExprStarred,
|
||||||
]
|
]
|
||||||
NOT_YET_IMPLEMENTED_ExprSetComp
|
{NOT_IMPLEMENTED_set_value for value in NOT_IMPLEMENTED_set}
|
||||||
NOT_YET_IMPLEMENTED_ExprSetComp
|
{NOT_IMPLEMENTED_set_value for value in NOT_IMPLEMENTED_set}
|
||||||
NOT_YET_IMPLEMENTED_ExprSetComp
|
{NOT_IMPLEMENTED_set_value for value in NOT_IMPLEMENTED_set}
|
||||||
NOT_YET_IMPLEMENTED_ExprSetComp
|
{NOT_IMPLEMENTED_set_value for value in NOT_IMPLEMENTED_set}
|
||||||
[i for i in []]
|
[i for i in []]
|
||||||
[i for i in []]
|
[i for i in []]
|
||||||
[i for i in []]
|
[i for i in []]
|
||||||
|
|
|
@ -193,6 +193,11 @@ if (
|
||||||
a + b
|
a + b
|
||||||
):
|
):
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
|
# Unstable formatting in https://github.com/realtyem/synapse-unraid/blob/unraid_develop/synapse/handlers/presence.py
|
||||||
|
for user_id in set(target_user_ids) - {u.user_id for u in updates}:
|
||||||
|
updates.append(UserPresenceState.default(user_id))
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -241,7 +246,7 @@ aaaaaaaaaaaaaa + {
|
||||||
}
|
}
|
||||||
aaaaaaaaaaaaaa + [i for i in []]
|
aaaaaaaaaaaaaa + [i for i in []]
|
||||||
aaaaaaaaaaaaaa + (i for i in [])
|
aaaaaaaaaaaaaa + (i for i in [])
|
||||||
aaaaaaaaaaaaaa + NOT_YET_IMPLEMENTED_ExprSetComp
|
aaaaaaaaaaaaaa + {NOT_IMPLEMENTED_set_value for value in NOT_IMPLEMENTED_set}
|
||||||
|
|
||||||
# Wraps it in parentheses if it needs to break both left and right
|
# Wraps it in parentheses if it needs to break both left and right
|
||||||
(
|
(
|
||||||
|
@ -251,7 +256,7 @@ aaaaaaaaaaaaaa + NOT_YET_IMPLEMENTED_ExprSetComp
|
||||||
|
|
||||||
|
|
||||||
# But only for expressions that have a statement parent.
|
# But only for expressions that have a statement parent.
|
||||||
not (aaaaaaaaaaaaaa + NOT_YET_IMPLEMENTED_ExprSetComp)
|
not (aaaaaaaaaaaaaa + {NOT_IMPLEMENTED_set_value for value in NOT_IMPLEMENTED_set})
|
||||||
[
|
[
|
||||||
a
|
a
|
||||||
+ [
|
+ [
|
||||||
|
@ -432,6 +437,13 @@ if (
|
||||||
+ b
|
+ b
|
||||||
):
|
):
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
|
# Unstable formatting in https://github.com/realtyem/synapse-unraid/blob/unraid_develop/synapse/handlers/presence.py
|
||||||
|
for (
|
||||||
|
user_id
|
||||||
|
) in NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg) - {NOT_IMPLEMENTED_set_value for value in NOT_IMPLEMENTED_set}:
|
||||||
|
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue