Compare commits
2 Commits
david/comp
...
preview-bi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d3e160dcb7 | ||
|
|
003851b54c |
@@ -1,8 +1,9 @@
|
||||
use crate::format_element::PrintMode;
|
||||
use crate::{GroupId, TextSize};
|
||||
use std::cell::Cell;
|
||||
use std::num::NonZeroU8;
|
||||
|
||||
use crate::format_element::PrintMode;
|
||||
use crate::{GroupId, TextSize};
|
||||
|
||||
/// A Tag marking the start and end of some content to which some special formatting should be applied.
|
||||
///
|
||||
/// Tags always come in pairs of a start and an end tag and the styling defined by this tag
|
||||
@@ -99,6 +100,10 @@ pub enum Tag {
|
||||
}
|
||||
|
||||
impl Tag {
|
||||
pub const fn align(count: NonZeroU8) -> Tag {
|
||||
Tag::StartAlign(Align(count))
|
||||
}
|
||||
|
||||
/// Returns `true` if `self` is any start tag.
|
||||
pub const fn is_start(&self) -> bool {
|
||||
matches!(
|
||||
|
||||
@@ -13,10 +13,11 @@ use ruff_text_size::{Ranged, TextRange};
|
||||
|
||||
use crate::comments::{leading_comments, trailing_comments, Comments, SourceComment};
|
||||
use crate::expression::parentheses::{
|
||||
in_parentheses_only_group, in_parentheses_only_if_group_breaks,
|
||||
in_parentheses_only_soft_line_break, in_parentheses_only_soft_line_break_or_space,
|
||||
is_expression_parenthesized, write_in_parentheses_only_group_end_tag,
|
||||
write_in_parentheses_only_group_start_tag, Parentheses,
|
||||
in_parentheses_only_group, in_parentheses_only_if_group_breaks, in_parentheses_only_indent_end,
|
||||
in_parentheses_only_indent_start, in_parentheses_only_soft_line_break,
|
||||
in_parentheses_only_soft_line_break_or_space, is_expression_parenthesized,
|
||||
write_in_parentheses_only_group_end_tag, write_in_parentheses_only_group_start_tag,
|
||||
Parentheses,
|
||||
};
|
||||
use crate::expression::OperatorPrecedence;
|
||||
use crate::prelude::*;
|
||||
@@ -287,7 +288,7 @@ impl Format<PyFormatContext<'_>> for BinaryLike<'_> {
|
||||
let flat_binary = self.flatten(&comments, f.context().source());
|
||||
|
||||
if self.is_bool_op() {
|
||||
return in_parentheses_only_group(&&*flat_binary).fmt(f);
|
||||
return in_parentheses_only_group(&flat_binary).fmt(f);
|
||||
}
|
||||
|
||||
let source = f.context().source();
|
||||
@@ -481,7 +482,7 @@ impl Format<PyFormatContext<'_>> for BinaryLike<'_> {
|
||||
// Finish the group that wraps all implicit concatenated strings
|
||||
write_in_parentheses_only_group_end_tag(f);
|
||||
} else {
|
||||
in_parentheses_only_group(&&*flat_binary).fmt(f)?;
|
||||
in_parentheses_only_group(&flat_binary).fmt(f)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -527,6 +528,12 @@ impl<'a> Deref for FlatBinaryExpression<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl Format<PyFormatContext<'_>> for FlatBinaryExpression<'_> {
|
||||
fn fmt(&self, f: &mut Formatter<PyFormatContext<'_>>) -> FormatResult<()> {
|
||||
Format::fmt(&**self, f)
|
||||
}
|
||||
}
|
||||
|
||||
/// Binary chain represented as a flat vector where operands are stored at even indices and operators
|
||||
/// add odd indices.
|
||||
///
|
||||
@@ -642,7 +649,7 @@ impl<'a> FlatBinaryExpressionSlice<'a> {
|
||||
}
|
||||
|
||||
/// Formats a binary chain slice by inserting soft line breaks before the lowest-precedence operators.
|
||||
/// In other words: It splits the line before by the lowest precedence operators (and it either splits
|
||||
/// In other words: It splits the line before the lowest precedence operators (and it either splits
|
||||
/// all of them or none). For example, the lowest precedence operator for `a + b * c + d` is the `+` operator.
|
||||
/// The expression either gets formatted as `a + b * c + d` if it fits on the line or as
|
||||
/// ```python
|
||||
@@ -678,59 +685,64 @@ impl Format<PyFormatContext<'_>> for FlatBinaryExpressionSlice<'_> {
|
||||
let mut last_operator: Option<OperatorIndex> = None;
|
||||
|
||||
let lowest_precedence = self.lowest_precedence();
|
||||
let lowest_precedence_operators = self
|
||||
.operators()
|
||||
.filter(|(_, operator)| operator.precedence() == lowest_precedence);
|
||||
|
||||
for (index, operator_part) in self.operators() {
|
||||
if operator_part.precedence() == lowest_precedence {
|
||||
let left = self.between_operators(last_operator, index);
|
||||
let right = self.after_operator(index);
|
||||
for (index, operator_part) in lowest_precedence_operators {
|
||||
let left = self.between_operators(last_operator, index);
|
||||
let right = self.after_operator(index);
|
||||
|
||||
let is_pow = operator_part.symbol.is_pow()
|
||||
&& is_simple_power_expression(
|
||||
left.last_operand().expression(),
|
||||
right.first_operand().expression(),
|
||||
f.context().comments().ranges(),
|
||||
f.context().source(),
|
||||
);
|
||||
let is_pow = operator_part.symbol.is_pow()
|
||||
&& is_simple_power_expression(
|
||||
left.last_operand().expression(),
|
||||
right.first_operand().expression(),
|
||||
f.context().comments().ranges(),
|
||||
f.context().source(),
|
||||
);
|
||||
|
||||
if let Some(leading) = left.first_operand().leading_binary_comments() {
|
||||
leading_comments(leading).fmt(f)?;
|
||||
}
|
||||
|
||||
match &left.0 {
|
||||
[OperandOrOperator::Operand(operand)] => operand.fmt(f)?,
|
||||
_ => in_parentheses_only_group(&left).fmt(f)?,
|
||||
}
|
||||
|
||||
if let Some(trailing) = left.last_operand().trailing_binary_comments() {
|
||||
trailing_comments(trailing).fmt(f)?;
|
||||
}
|
||||
|
||||
if is_pow {
|
||||
in_parentheses_only_soft_line_break().fmt(f)?;
|
||||
} else {
|
||||
in_parentheses_only_soft_line_break_or_space().fmt(f)?;
|
||||
}
|
||||
|
||||
operator_part.fmt(f)?;
|
||||
|
||||
// Format the operator on its own line if the right side has any leading comments.
|
||||
if operator_part.has_trailing_comments()
|
||||
|| right.first_operand().has_unparenthesized_leading_comments(
|
||||
f.context().comments(),
|
||||
f.context().source(),
|
||||
)
|
||||
{
|
||||
hard_line_break().fmt(f)?;
|
||||
} else if is_pow {
|
||||
if is_fix_power_op_line_length_enabled(f.context()) {
|
||||
in_parentheses_only_if_group_breaks(&space()).fmt(f)?;
|
||||
}
|
||||
} else {
|
||||
space().fmt(f)?;
|
||||
}
|
||||
|
||||
last_operator = Some(index);
|
||||
if let Some(leading) = left.first_operand().leading_binary_comments() {
|
||||
leading_comments(leading).fmt(f)?;
|
||||
}
|
||||
|
||||
match &left.0 {
|
||||
[OperandOrOperator::Operand(operand)] => operand.fmt(f)?,
|
||||
_ => in_parentheses_only_group(&left).fmt(f)?,
|
||||
}
|
||||
|
||||
if last_operator.is_none() {
|
||||
in_parentheses_only_indent_start().fmt(f)?;
|
||||
}
|
||||
|
||||
if let Some(trailing) = left.last_operand().trailing_binary_comments() {
|
||||
trailing_comments(trailing).fmt(f)?;
|
||||
}
|
||||
|
||||
if is_pow {
|
||||
in_parentheses_only_soft_line_break().fmt(f)?;
|
||||
} else {
|
||||
in_parentheses_only_soft_line_break_or_space().fmt(f)?;
|
||||
}
|
||||
|
||||
operator_part.fmt(f)?;
|
||||
|
||||
// Format the operator on its own line if the right side has any leading comments.
|
||||
if operator_part.has_trailing_comments()
|
||||
|| right.first_operand().has_unparenthesized_leading_comments(
|
||||
f.context().comments(),
|
||||
f.context().source(),
|
||||
)
|
||||
{
|
||||
hard_line_break().fmt(f)?;
|
||||
} else if is_pow {
|
||||
if is_fix_power_op_line_length_enabled(f.context()) {
|
||||
in_parentheses_only_if_group_breaks(&space()).fmt(f)?;
|
||||
}
|
||||
} else {
|
||||
space().fmt(f)?;
|
||||
}
|
||||
|
||||
last_operator = Some(index);
|
||||
}
|
||||
|
||||
// Format the last right side
|
||||
@@ -745,9 +757,11 @@ impl Format<PyFormatContext<'_>> for FlatBinaryExpressionSlice<'_> {
|
||||
}
|
||||
|
||||
match &right.0 {
|
||||
[OperandOrOperator::Operand(operand)] => operand.fmt(f),
|
||||
_ => in_parentheses_only_group(&right).fmt(f),
|
||||
[OperandOrOperator::Operand(operand)] => operand.fmt(f)?,
|
||||
_ => in_parentheses_only_group(&right).fmt(f)?,
|
||||
}
|
||||
|
||||
in_parentheses_only_indent_end().fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -379,6 +379,42 @@ where
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn in_parentheses_only_indent_start<'a>() -> impl Format<PyFormatContext<'a>> {
|
||||
format_with(|f: &mut PyFormatter| {
|
||||
match f.context().node_level() {
|
||||
NodeLevel::TopLevel(_) | NodeLevel::CompoundStatement | NodeLevel::Expression(None) => {
|
||||
// no-op, not parenthesized
|
||||
}
|
||||
NodeLevel::Expression(Some(parentheses_id)) => f.write_element(FormatElement::Tag(
|
||||
Tag::StartIndentIfGroupBreaks(parentheses_id),
|
||||
)),
|
||||
NodeLevel::ParenthesizedExpression => {
|
||||
f.write_element(FormatElement::Tag(Tag::StartIndent))
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn in_parentheses_only_indent_end<'a>() -> impl Format<PyFormatContext<'a>> {
|
||||
format_with(|f: &mut PyFormatter| {
|
||||
match f.context().node_level() {
|
||||
NodeLevel::TopLevel(_) | NodeLevel::CompoundStatement | NodeLevel::Expression(None) => {
|
||||
// no-op, not parenthesized
|
||||
}
|
||||
NodeLevel::Expression(Some(_)) => {
|
||||
f.write_element(FormatElement::Tag(Tag::EndIndentIfGroupBreaks))
|
||||
}
|
||||
NodeLevel::ParenthesizedExpression => {
|
||||
f.write_element(FormatElement::Tag(Tag::EndIndent))
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
/// Format comments inside empty parentheses, brackets or curly braces.
|
||||
///
|
||||
/// Empty `()`, `[]` and `{}` are special because there can be dangling comments, and they can be in
|
||||
|
||||
@@ -0,0 +1,314 @@
|
||||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/black/cases/collections.py
|
||||
---
|
||||
## Input
|
||||
|
||||
```python
|
||||
import core, time, a
|
||||
|
||||
from . import A, B, C
|
||||
|
||||
# keeps existing trailing comma
|
||||
from foo import (
|
||||
bar,
|
||||
)
|
||||
|
||||
# also keeps existing structure
|
||||
from foo import (
|
||||
baz,
|
||||
qux,
|
||||
)
|
||||
|
||||
# `as` works as well
|
||||
from foo import (
|
||||
xyzzy as magic,
|
||||
)
|
||||
|
||||
a = {1,2,3,}
|
||||
b = {
|
||||
1,2,
|
||||
3}
|
||||
c = {
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
}
|
||||
x = 1,
|
||||
y = narf(),
|
||||
nested = {(1,2,3),(4,5,6),}
|
||||
nested_no_trailing_comma = {(1,2,3),(4,5,6)}
|
||||
nested_long_lines = ["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "cccccccccccccccccccccccccccccccccccccccc", (1, 2, 3), "dddddddddddddddddddddddddddddddddddddddd"]
|
||||
{"oneple": (1,),}
|
||||
{"oneple": (1,)}
|
||||
['ls', 'lsoneple/%s' % (foo,)]
|
||||
x = {"oneple": (1,)}
|
||||
y = {"oneple": (1,),}
|
||||
assert False, ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa wraps %s" % bar)
|
||||
|
||||
# looping over a 1-tuple should also not get wrapped
|
||||
for x in (1,):
|
||||
pass
|
||||
for (x,) in (1,), (2,), (3,):
|
||||
pass
|
||||
|
||||
[1, 2, 3,]
|
||||
|
||||
division_result_tuple = (6/2,)
|
||||
print("foo %r", (foo.bar,))
|
||||
|
||||
if True:
|
||||
IGNORED_TYPES_FOR_ATTRIBUTE_CHECKING = (
|
||||
Config.IGNORED_TYPES_FOR_ATTRIBUTE_CHECKING
|
||||
| {pylons.controllers.WSGIController}
|
||||
)
|
||||
|
||||
if True:
|
||||
ec2client.get_waiter('instance_stopped').wait(
|
||||
InstanceIds=[instance.id],
|
||||
WaiterConfig={
|
||||
'Delay': 5,
|
||||
})
|
||||
ec2client.get_waiter("instance_stopped").wait(
|
||||
InstanceIds=[instance.id],
|
||||
WaiterConfig={"Delay": 5,},
|
||||
)
|
||||
ec2client.get_waiter("instance_stopped").wait(
|
||||
InstanceIds=[instance.id], WaiterConfig={"Delay": 5,},
|
||||
)
|
||||
```
|
||||
|
||||
## Black Differences
|
||||
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -54,7 +54,7 @@
|
||||
}
|
||||
assert False, (
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa wraps %s"
|
||||
- % bar
|
||||
+ % bar
|
||||
)
|
||||
|
||||
# looping over a 1-tuple should also not get wrapped
|
||||
@@ -75,7 +75,7 @@
|
||||
if True:
|
||||
IGNORED_TYPES_FOR_ATTRIBUTE_CHECKING = (
|
||||
Config.IGNORED_TYPES_FOR_ATTRIBUTE_CHECKING
|
||||
- | {pylons.controllers.WSGIController}
|
||||
+ | {pylons.controllers.WSGIController}
|
||||
)
|
||||
|
||||
if True:
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
|
||||
```python
|
||||
import core, time, a
|
||||
|
||||
from . import A, B, C
|
||||
|
||||
# keeps existing trailing comma
|
||||
from foo import (
|
||||
bar,
|
||||
)
|
||||
|
||||
# also keeps existing structure
|
||||
from foo import (
|
||||
baz,
|
||||
qux,
|
||||
)
|
||||
|
||||
# `as` works as well
|
||||
from foo import (
|
||||
xyzzy as magic,
|
||||
)
|
||||
|
||||
a = {
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
}
|
||||
b = {1, 2, 3}
|
||||
c = {
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
}
|
||||
x = (1,)
|
||||
y = (narf(),)
|
||||
nested = {
|
||||
(1, 2, 3),
|
||||
(4, 5, 6),
|
||||
}
|
||||
nested_no_trailing_comma = {(1, 2, 3), (4, 5, 6)}
|
||||
nested_long_lines = [
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"cccccccccccccccccccccccccccccccccccccccc",
|
||||
(1, 2, 3),
|
||||
"dddddddddddddddddddddddddddddddddddddddd",
|
||||
]
|
||||
{
|
||||
"oneple": (1,),
|
||||
}
|
||||
{"oneple": (1,)}
|
||||
["ls", "lsoneple/%s" % (foo,)]
|
||||
x = {"oneple": (1,)}
|
||||
y = {
|
||||
"oneple": (1,),
|
||||
}
|
||||
assert False, (
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa wraps %s"
|
||||
% bar
|
||||
)
|
||||
|
||||
# looping over a 1-tuple should also not get wrapped
|
||||
for x in (1,):
|
||||
pass
|
||||
for (x,) in (1,), (2,), (3,):
|
||||
pass
|
||||
|
||||
[
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
]
|
||||
|
||||
division_result_tuple = (6 / 2,)
|
||||
print("foo %r", (foo.bar,))
|
||||
|
||||
if True:
|
||||
IGNORED_TYPES_FOR_ATTRIBUTE_CHECKING = (
|
||||
Config.IGNORED_TYPES_FOR_ATTRIBUTE_CHECKING
|
||||
| {pylons.controllers.WSGIController}
|
||||
)
|
||||
|
||||
if True:
|
||||
ec2client.get_waiter("instance_stopped").wait(
|
||||
InstanceIds=[instance.id],
|
||||
WaiterConfig={
|
||||
"Delay": 5,
|
||||
},
|
||||
)
|
||||
ec2client.get_waiter("instance_stopped").wait(
|
||||
InstanceIds=[instance.id],
|
||||
WaiterConfig={
|
||||
"Delay": 5,
|
||||
},
|
||||
)
|
||||
ec2client.get_waiter("instance_stopped").wait(
|
||||
InstanceIds=[instance.id],
|
||||
WaiterConfig={
|
||||
"Delay": 5,
|
||||
},
|
||||
)
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
||||
```python
|
||||
import core, time, a
|
||||
|
||||
from . import A, B, C
|
||||
|
||||
# keeps existing trailing comma
|
||||
from foo import (
|
||||
bar,
|
||||
)
|
||||
|
||||
# also keeps existing structure
|
||||
from foo import (
|
||||
baz,
|
||||
qux,
|
||||
)
|
||||
|
||||
# `as` works as well
|
||||
from foo import (
|
||||
xyzzy as magic,
|
||||
)
|
||||
|
||||
a = {
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
}
|
||||
b = {1, 2, 3}
|
||||
c = {
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
}
|
||||
x = (1,)
|
||||
y = (narf(),)
|
||||
nested = {
|
||||
(1, 2, 3),
|
||||
(4, 5, 6),
|
||||
}
|
||||
nested_no_trailing_comma = {(1, 2, 3), (4, 5, 6)}
|
||||
nested_long_lines = [
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"cccccccccccccccccccccccccccccccccccccccc",
|
||||
(1, 2, 3),
|
||||
"dddddddddddddddddddddddddddddddddddddddd",
|
||||
]
|
||||
{
|
||||
"oneple": (1,),
|
||||
}
|
||||
{"oneple": (1,)}
|
||||
["ls", "lsoneple/%s" % (foo,)]
|
||||
x = {"oneple": (1,)}
|
||||
y = {
|
||||
"oneple": (1,),
|
||||
}
|
||||
assert False, (
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa wraps %s"
|
||||
% bar
|
||||
)
|
||||
|
||||
# looping over a 1-tuple should also not get wrapped
|
||||
for x in (1,):
|
||||
pass
|
||||
for (x,) in (1,), (2,), (3,):
|
||||
pass
|
||||
|
||||
[
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
]
|
||||
|
||||
division_result_tuple = (6 / 2,)
|
||||
print("foo %r", (foo.bar,))
|
||||
|
||||
if True:
|
||||
IGNORED_TYPES_FOR_ATTRIBUTE_CHECKING = (
|
||||
Config.IGNORED_TYPES_FOR_ATTRIBUTE_CHECKING
|
||||
| {pylons.controllers.WSGIController}
|
||||
)
|
||||
|
||||
if True:
|
||||
ec2client.get_waiter("instance_stopped").wait(
|
||||
InstanceIds=[instance.id],
|
||||
WaiterConfig={
|
||||
"Delay": 5,
|
||||
},
|
||||
)
|
||||
ec2client.get_waiter("instance_stopped").wait(
|
||||
InstanceIds=[instance.id],
|
||||
WaiterConfig={
|
||||
"Delay": 5,
|
||||
},
|
||||
)
|
||||
ec2client.get_waiter("instance_stopped").wait(
|
||||
InstanceIds=[instance.id],
|
||||
WaiterConfig={
|
||||
"Delay": 5,
|
||||
},
|
||||
)
|
||||
```
|
||||
|
||||
|
||||
@@ -192,7 +192,7 @@ instruction()#comment with bad spacing
|
||||
children[0],
|
||||
body,
|
||||
children[-1], # type: ignore
|
||||
@@ -72,7 +76,11 @@
|
||||
@@ -72,14 +76,18 @@
|
||||
body,
|
||||
parameters.children[-1], # )2
|
||||
]
|
||||
@@ -204,7 +204,19 @@ instruction()#comment with bad spacing
|
||||
+ ] # type: ignore
|
||||
if (
|
||||
self._proc is not None
|
||||
# has the child process finished?
|
||||
- # has the child process finished?
|
||||
- and self._returncode is None
|
||||
- # the child process has finished, but the
|
||||
- # transport hasn't been notified yet?
|
||||
- and self._proc.poll() is None
|
||||
+ # has the child process finished?
|
||||
+ and self._returncode is None
|
||||
+ # the child process has finished, but the
|
||||
+ # transport hasn't been notified yet?
|
||||
+ and self._proc.poll() is None
|
||||
):
|
||||
pass
|
||||
# no newline before or after
|
||||
@@ -115,7 +123,9 @@
|
||||
arg3=True,
|
||||
)
|
||||
@@ -228,14 +240,23 @@ instruction()#comment with bad spacing
|
||||
)
|
||||
|
||||
|
||||
@@ -158,7 +171,10 @@
|
||||
@@ -151,14 +164,17 @@
|
||||
[
|
||||
CONFIG_FILE,
|
||||
]
|
||||
- + SHARED_CONFIG_FILES
|
||||
- + USER_CONFIG_FILES
|
||||
+ + SHARED_CONFIG_FILES
|
||||
+ + USER_CONFIG_FILES
|
||||
) # type: Final
|
||||
|
||||
|
||||
class Test:
|
||||
def _init_host(self, parsed) -> None:
|
||||
- if parsed.hostname is None or not parsed.hostname.strip(): # type: ignore
|
||||
+ if (
|
||||
+ parsed.hostname is None # type: ignore
|
||||
+ or not parsed.hostname.strip()
|
||||
+ or not parsed.hostname.strip()
|
||||
+ ):
|
||||
pass
|
||||
|
||||
@@ -330,11 +351,11 @@ def inline_comments_in_brackets_ruin_everything():
|
||||
] # type: ignore
|
||||
if (
|
||||
self._proc is not None
|
||||
# has the child process finished?
|
||||
and self._returncode is None
|
||||
# the child process has finished, but the
|
||||
# transport hasn't been notified yet?
|
||||
and self._proc.poll() is None
|
||||
# has the child process finished?
|
||||
and self._returncode is None
|
||||
# the child process has finished, but the
|
||||
# transport hasn't been notified yet?
|
||||
and self._proc.poll() is None
|
||||
):
|
||||
pass
|
||||
# no newline before or after
|
||||
@@ -411,8 +432,8 @@ CONFIG_FILES = (
|
||||
[
|
||||
CONFIG_FILE,
|
||||
]
|
||||
+ SHARED_CONFIG_FILES
|
||||
+ USER_CONFIG_FILES
|
||||
+ SHARED_CONFIG_FILES
|
||||
+ USER_CONFIG_FILES
|
||||
) # type: Final
|
||||
|
||||
|
||||
@@ -420,7 +441,7 @@ class Test:
|
||||
def _init_host(self, parsed) -> None:
|
||||
if (
|
||||
parsed.hostname is None # type: ignore
|
||||
or not parsed.hostname.strip()
|
||||
or not parsed.hostname.strip()
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
@@ -141,6 +141,23 @@ aaaaaaaaaaaaa, bbbbbbbbb = map(list, map(itertools.chain.from_iterable, zip(*ite
|
||||
an_element_with_a_long_value = calls() or more_calls() and more() # type: bool
|
||||
|
||||
tup = (
|
||||
@@ -61,11 +59,11 @@
|
||||
|
||||
a = (
|
||||
element
|
||||
- + another_element
|
||||
- + another_element_with_long_name
|
||||
- + element
|
||||
- + another_element
|
||||
- + another_element_with_long_name
|
||||
+ + another_element
|
||||
+ + another_element_with_long_name
|
||||
+ + element
|
||||
+ + another_element
|
||||
+ + another_element_with_long_name
|
||||
) # type: int
|
||||
|
||||
|
||||
@@ -100,7 +98,13 @@
|
||||
)
|
||||
|
||||
@@ -243,11 +260,11 @@ def f(
|
||||
|
||||
a = (
|
||||
element
|
||||
+ another_element
|
||||
+ another_element_with_long_name
|
||||
+ element
|
||||
+ another_element
|
||||
+ another_element_with_long_name
|
||||
+ another_element
|
||||
+ another_element_with_long_name
|
||||
+ element
|
||||
+ another_element
|
||||
+ another_element_with_long_name
|
||||
) # type: int
|
||||
|
||||
|
||||
|
||||
@@ -146,6 +146,40 @@ if (
|
||||
# b comment
|
||||
None
|
||||
)
|
||||
@@ -92,20 +91,20 @@
|
||||
# comment1
|
||||
a
|
||||
# comment2
|
||||
- or (
|
||||
- # comment3
|
||||
- (
|
||||
- # comment4
|
||||
- b
|
||||
- )
|
||||
- # comment5
|
||||
- and
|
||||
- # comment6
|
||||
- c
|
||||
or (
|
||||
- # comment7
|
||||
- d
|
||||
+ # comment3
|
||||
+ (
|
||||
+ # comment4
|
||||
+ b
|
||||
+ )
|
||||
+ # comment5
|
||||
+ and
|
||||
+ # comment6
|
||||
+ c
|
||||
+ or (
|
||||
+ # comment7
|
||||
+ d
|
||||
+ )
|
||||
)
|
||||
- )
|
||||
):
|
||||
print("Foo")
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
@@ -244,21 +278,21 @@ if (
|
||||
# comment1
|
||||
a
|
||||
# comment2
|
||||
or (
|
||||
# comment3
|
||||
(
|
||||
# comment4
|
||||
b
|
||||
)
|
||||
# comment5
|
||||
and
|
||||
# comment6
|
||||
c
|
||||
or (
|
||||
# comment7
|
||||
d
|
||||
# comment3
|
||||
(
|
||||
# comment4
|
||||
b
|
||||
)
|
||||
# comment5
|
||||
and
|
||||
# comment6
|
||||
c
|
||||
or (
|
||||
# comment7
|
||||
d
|
||||
)
|
||||
)
|
||||
)
|
||||
):
|
||||
print("Foo")
|
||||
```
|
||||
|
||||
@@ -193,6 +193,26 @@ class C:
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -22,8 +22,8 @@
|
||||
if (
|
||||
# Rule 1
|
||||
i % 2 == 0
|
||||
- # Rule 2
|
||||
- and i % 3 == 0
|
||||
+ # Rule 2
|
||||
+ and i % 3 == 0
|
||||
):
|
||||
while (
|
||||
# Just a comment
|
||||
@@ -41,7 +41,7 @@
|
||||
)
|
||||
return (
|
||||
'Utterly failed doctest test for %s\n File "%s", line %s, in %s\n\n%s'
|
||||
- % (test.name, test.filename, lineno, lname, err)
|
||||
+ % (test.name, test.filename, lineno, lname, err)
|
||||
)
|
||||
|
||||
def omitting_trailers(self) -> None:
|
||||
@@ -110,19 +110,20 @@
|
||||
value, is_going_to_be="too long to fit in a single line", srsly=True
|
||||
), "Not what we expected"
|
||||
@@ -222,12 +242,12 @@ class C:
|
||||
+ key8: value8,
|
||||
+ key9: value9,
|
||||
+ }
|
||||
+ == expected
|
||||
+ == expected
|
||||
+ ), "Not what we expected and the message is too long to fit in one line"
|
||||
|
||||
assert expected(
|
||||
value, is_going_to_be="too long to fit in a single line", srsly=True
|
||||
@@ -161,9 +162,7 @@
|
||||
@@ -161,21 +162,19 @@
|
||||
8 STORE_ATTR 0 (x)
|
||||
10 LOAD_CONST 0 (None)
|
||||
12 RETURN_VALUE
|
||||
@@ -238,6 +258,29 @@ class C:
|
||||
|
||||
assert (
|
||||
expectedexpectedexpectedexpectedexpectedexpectedexpectedexpectedexpect
|
||||
- == {
|
||||
- key1: value1,
|
||||
- key2: value2,
|
||||
- key3: value3,
|
||||
- key4: value4,
|
||||
- key5: value5,
|
||||
- key6: value6,
|
||||
- key7: value7,
|
||||
- key8: value8,
|
||||
- key9: value9,
|
||||
- }
|
||||
+ == {
|
||||
+ key1: value1,
|
||||
+ key2: value2,
|
||||
+ key3: value3,
|
||||
+ key4: value4,
|
||||
+ key5: value5,
|
||||
+ key6: value6,
|
||||
+ key7: value7,
|
||||
+ key8: value8,
|
||||
+ key9: value9,
|
||||
+ }
|
||||
)
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
@@ -267,8 +310,8 @@ class C:
|
||||
if (
|
||||
# Rule 1
|
||||
i % 2 == 0
|
||||
# Rule 2
|
||||
and i % 3 == 0
|
||||
# Rule 2
|
||||
and i % 3 == 0
|
||||
):
|
||||
while (
|
||||
# Just a comment
|
||||
@@ -286,7 +329,7 @@ class C:
|
||||
)
|
||||
return (
|
||||
'Utterly failed doctest test for %s\n File "%s", line %s, in %s\n\n%s'
|
||||
% (test.name, test.filename, lineno, lname, err)
|
||||
% (test.name, test.filename, lineno, lname, err)
|
||||
)
|
||||
|
||||
def omitting_trailers(self) -> None:
|
||||
@@ -367,7 +410,7 @@ class C:
|
||||
key8: value8,
|
||||
key9: value9,
|
||||
}
|
||||
== expected
|
||||
== expected
|
||||
), "Not what we expected and the message is too long to fit in one line"
|
||||
|
||||
assert expected(
|
||||
@@ -411,17 +454,17 @@ class C:
|
||||
|
||||
assert (
|
||||
expectedexpectedexpectedexpectedexpectedexpectedexpectedexpectedexpect
|
||||
== {
|
||||
key1: value1,
|
||||
key2: value2,
|
||||
key3: value3,
|
||||
key4: value4,
|
||||
key5: value5,
|
||||
key6: value6,
|
||||
key7: value7,
|
||||
key8: value8,
|
||||
key9: value9,
|
||||
}
|
||||
== {
|
||||
key1: value1,
|
||||
key2: value2,
|
||||
key3: value3,
|
||||
key4: value4,
|
||||
key5: value5,
|
||||
key6: value6,
|
||||
key7: value7,
|
||||
key8: value8,
|
||||
key9: value9,
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
|
||||
@@ -193,6 +193,26 @@ class C:
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -22,8 +22,8 @@
|
||||
if (
|
||||
# Rule 1
|
||||
i % 2 == 0
|
||||
- # Rule 2
|
||||
- and i % 3 == 0
|
||||
+ # Rule 2
|
||||
+ and i % 3 == 0
|
||||
):
|
||||
while (
|
||||
# Just a comment
|
||||
@@ -41,7 +41,7 @@
|
||||
)
|
||||
return (
|
||||
'Utterly failed doctest test for %s\n File "%s", line %s, in %s\n\n%s'
|
||||
- % (test.name, test.filename, lineno, lname, err)
|
||||
+ % (test.name, test.filename, lineno, lname, err)
|
||||
)
|
||||
|
||||
def omitting_trailers(self) -> None:
|
||||
@@ -110,19 +110,20 @@
|
||||
value, is_going_to_be="too long to fit in a single line", srsly=True
|
||||
), "Not what we expected"
|
||||
@@ -222,12 +242,12 @@ class C:
|
||||
+ key8: value8,
|
||||
+ key9: value9,
|
||||
+ }
|
||||
+ == expected
|
||||
+ == expected
|
||||
+ ), "Not what we expected and the message is too long to fit in one line"
|
||||
|
||||
assert expected(
|
||||
value, is_going_to_be="too long to fit in a single line", srsly=True
|
||||
@@ -161,9 +162,7 @@
|
||||
@@ -161,21 +162,19 @@
|
||||
8 STORE_ATTR 0 (x)
|
||||
10 LOAD_CONST 0 (None)
|
||||
12 RETURN_VALUE
|
||||
@@ -238,6 +258,29 @@ class C:
|
||||
|
||||
assert (
|
||||
expectedexpectedexpectedexpectedexpectedexpectedexpectedexpectedexpect
|
||||
- == {
|
||||
- key1: value1,
|
||||
- key2: value2,
|
||||
- key3: value3,
|
||||
- key4: value4,
|
||||
- key5: value5,
|
||||
- key6: value6,
|
||||
- key7: value7,
|
||||
- key8: value8,
|
||||
- key9: value9,
|
||||
- }
|
||||
+ == {
|
||||
+ key1: value1,
|
||||
+ key2: value2,
|
||||
+ key3: value3,
|
||||
+ key4: value4,
|
||||
+ key5: value5,
|
||||
+ key6: value6,
|
||||
+ key7: value7,
|
||||
+ key8: value8,
|
||||
+ key9: value9,
|
||||
+ }
|
||||
)
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
@@ -267,8 +310,8 @@ class C:
|
||||
if (
|
||||
# Rule 1
|
||||
i % 2 == 0
|
||||
# Rule 2
|
||||
and i % 3 == 0
|
||||
# Rule 2
|
||||
and i % 3 == 0
|
||||
):
|
||||
while (
|
||||
# Just a comment
|
||||
@@ -286,7 +329,7 @@ class C:
|
||||
)
|
||||
return (
|
||||
'Utterly failed doctest test for %s\n File "%s", line %s, in %s\n\n%s'
|
||||
% (test.name, test.filename, lineno, lname, err)
|
||||
% (test.name, test.filename, lineno, lname, err)
|
||||
)
|
||||
|
||||
def omitting_trailers(self) -> None:
|
||||
@@ -367,7 +410,7 @@ class C:
|
||||
key8: value8,
|
||||
key9: value9,
|
||||
}
|
||||
== expected
|
||||
== expected
|
||||
), "Not what we expected and the message is too long to fit in one line"
|
||||
|
||||
assert expected(
|
||||
@@ -411,17 +454,17 @@ class C:
|
||||
|
||||
assert (
|
||||
expectedexpectedexpectedexpectedexpectedexpectedexpectedexpectedexpect
|
||||
== {
|
||||
key1: value1,
|
||||
key2: value2,
|
||||
key3: value3,
|
||||
key4: value4,
|
||||
key5: value5,
|
||||
key6: value6,
|
||||
key7: value7,
|
||||
key8: value8,
|
||||
key9: value9,
|
||||
}
|
||||
== {
|
||||
key1: value1,
|
||||
key2: value2,
|
||||
key3: value3,
|
||||
key4: value4,
|
||||
key5: value5,
|
||||
key6: value6,
|
||||
key7: value7,
|
||||
key8: value8,
|
||||
key9: value9,
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
|
||||
@@ -275,6 +275,131 @@ last_call()
|
||||
) # note: no trailing comma pre-3.6
|
||||
call(*gidgets[:2])
|
||||
call(a, *gidgets[:2])
|
||||
@@ -277,95 +277,95 @@
|
||||
pass
|
||||
a = (
|
||||
aaaa.bbbb.cccc.dddd.eeee.ffff.gggg.hhhh.iiii.jjjj.kkkk.llll.mmmm.nnnn.oooo.pppp
|
||||
- in qqqq.rrrr.ssss.tttt.uuuu.vvvv.xxxx.yyyy.zzzz
|
||||
+ in qqqq.rrrr.ssss.tttt.uuuu.vvvv.xxxx.yyyy.zzzz
|
||||
)
|
||||
a = (
|
||||
aaaa.bbbb.cccc.dddd.eeee.ffff.gggg.hhhh.iiii.jjjj.kkkk.llll.mmmm.nnnn.oooo.pppp
|
||||
- not in qqqq.rrrr.ssss.tttt.uuuu.vvvv.xxxx.yyyy.zzzz
|
||||
+ not in qqqq.rrrr.ssss.tttt.uuuu.vvvv.xxxx.yyyy.zzzz
|
||||
)
|
||||
a = (
|
||||
aaaa.bbbb.cccc.dddd.eeee.ffff.gggg.hhhh.iiii.jjjj.kkkk.llll.mmmm.nnnn.oooo.pppp
|
||||
- is qqqq.rrrr.ssss.tttt.uuuu.vvvv.xxxx.yyyy.zzzz
|
||||
+ is qqqq.rrrr.ssss.tttt.uuuu.vvvv.xxxx.yyyy.zzzz
|
||||
)
|
||||
a = (
|
||||
aaaa.bbbb.cccc.dddd.eeee.ffff.gggg.hhhh.iiii.jjjj.kkkk.llll.mmmm.nnnn.oooo.pppp
|
||||
- is not qqqq.rrrr.ssss.tttt.uuuu.vvvv.xxxx.yyyy.zzzz
|
||||
+ is not qqqq.rrrr.ssss.tttt.uuuu.vvvv.xxxx.yyyy.zzzz
|
||||
)
|
||||
if (
|
||||
threading.current_thread() != threading.main_thread()
|
||||
- and threading.current_thread() != threading.main_thread()
|
||||
- or signal.getsignal(signal.SIGINT) != signal.default_int_handler
|
||||
+ and threading.current_thread() != threading.main_thread()
|
||||
+ or signal.getsignal(signal.SIGINT) != signal.default_int_handler
|
||||
):
|
||||
return True
|
||||
if (
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
- | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
):
|
||||
return True
|
||||
if (
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
- & aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ & aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
):
|
||||
return True
|
||||
if (
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
- + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
):
|
||||
return True
|
||||
if (
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
- - aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ - aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
):
|
||||
return True
|
||||
if (
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
- * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
):
|
||||
return True
|
||||
if (
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
- / aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ / aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
):
|
||||
return True
|
||||
if (
|
||||
~aaaa.a + aaaa.b - aaaa.c * aaaa.d / aaaa.e
|
||||
- | aaaa.f & aaaa.g % aaaa.h ^ aaaa.i << aaaa.k >> aaaa.l**aaaa.m // aaaa.n
|
||||
+ | aaaa.f & aaaa.g % aaaa.h ^ aaaa.i << aaaa.k >> aaaa.l**aaaa.m // aaaa.n
|
||||
):
|
||||
return True
|
||||
if (
|
||||
~aaaaaaaa.a + aaaaaaaa.b - aaaaaaaa.c @ aaaaaaaa.d / aaaaaaaa.e
|
||||
- | aaaaaaaa.f & aaaaaaaa.g % aaaaaaaa.h
|
||||
- ^ aaaaaaaa.i << aaaaaaaa.k >> aaaaaaaa.l**aaaaaaaa.m // aaaaaaaa.n
|
||||
+ | aaaaaaaa.f & aaaaaaaa.g % aaaaaaaa.h
|
||||
+ ^ aaaaaaaa.i << aaaaaaaa.k >> aaaaaaaa.l**aaaaaaaa.m // aaaaaaaa.n
|
||||
):
|
||||
return True
|
||||
if (
|
||||
~aaaaaaaaaaaaaaaa.a
|
||||
- + aaaaaaaaaaaaaaaa.b
|
||||
- - aaaaaaaaaaaaaaaa.c * aaaaaaaaaaaaaaaa.d @ aaaaaaaaaaaaaaaa.e
|
||||
- | aaaaaaaaaaaaaaaa.f & aaaaaaaaaaaaaaaa.g % aaaaaaaaaaaaaaaa.h
|
||||
- ^ aaaaaaaaaaaaaaaa.i
|
||||
- << aaaaaaaaaaaaaaaa.k
|
||||
- >> aaaaaaaaaaaaaaaa.l**aaaaaaaaaaaaaaaa.m // aaaaaaaaaaaaaaaa.n
|
||||
+ + aaaaaaaaaaaaaaaa.b
|
||||
+ - aaaaaaaaaaaaaaaa.c * aaaaaaaaaaaaaaaa.d @ aaaaaaaaaaaaaaaa.e
|
||||
+ | aaaaaaaaaaaaaaaa.f & aaaaaaaaaaaaaaaa.g % aaaaaaaaaaaaaaaa.h
|
||||
+ ^ aaaaaaaaaaaaaaaa.i
|
||||
+ << aaaaaaaaaaaaaaaa.k
|
||||
+ >> aaaaaaaaaaaaaaaa.l**aaaaaaaaaaaaaaaa.m // aaaaaaaaaaaaaaaa.n
|
||||
):
|
||||
return True
|
||||
(
|
||||
aaaaaaaaaaaaaaaa
|
||||
- + aaaaaaaaaaaaaaaa
|
||||
- - aaaaaaaaaaaaaaaa
|
||||
- * (aaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaa)
|
||||
- / (aaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaa)
|
||||
+ + aaaaaaaaaaaaaaaa
|
||||
+ - aaaaaaaaaaaaaaaa
|
||||
+ * (aaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaa)
|
||||
+ / (aaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaa)
|
||||
)
|
||||
aaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaa
|
||||
(
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
- >> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
- << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ >> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
)
|
||||
bbbb >> bbbb * bbbb
|
||||
(
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
- ^ bbbb.a & aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
- ^ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ ^ bbbb.a & aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ ^ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
)
|
||||
last_call()
|
||||
# standalone comment at ENDMARKER
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
@@ -559,95 +684,95 @@ for (
|
||||
pass
|
||||
a = (
|
||||
aaaa.bbbb.cccc.dddd.eeee.ffff.gggg.hhhh.iiii.jjjj.kkkk.llll.mmmm.nnnn.oooo.pppp
|
||||
in qqqq.rrrr.ssss.tttt.uuuu.vvvv.xxxx.yyyy.zzzz
|
||||
in qqqq.rrrr.ssss.tttt.uuuu.vvvv.xxxx.yyyy.zzzz
|
||||
)
|
||||
a = (
|
||||
aaaa.bbbb.cccc.dddd.eeee.ffff.gggg.hhhh.iiii.jjjj.kkkk.llll.mmmm.nnnn.oooo.pppp
|
||||
not in qqqq.rrrr.ssss.tttt.uuuu.vvvv.xxxx.yyyy.zzzz
|
||||
not in qqqq.rrrr.ssss.tttt.uuuu.vvvv.xxxx.yyyy.zzzz
|
||||
)
|
||||
a = (
|
||||
aaaa.bbbb.cccc.dddd.eeee.ffff.gggg.hhhh.iiii.jjjj.kkkk.llll.mmmm.nnnn.oooo.pppp
|
||||
is qqqq.rrrr.ssss.tttt.uuuu.vvvv.xxxx.yyyy.zzzz
|
||||
is qqqq.rrrr.ssss.tttt.uuuu.vvvv.xxxx.yyyy.zzzz
|
||||
)
|
||||
a = (
|
||||
aaaa.bbbb.cccc.dddd.eeee.ffff.gggg.hhhh.iiii.jjjj.kkkk.llll.mmmm.nnnn.oooo.pppp
|
||||
is not qqqq.rrrr.ssss.tttt.uuuu.vvvv.xxxx.yyyy.zzzz
|
||||
is not qqqq.rrrr.ssss.tttt.uuuu.vvvv.xxxx.yyyy.zzzz
|
||||
)
|
||||
if (
|
||||
threading.current_thread() != threading.main_thread()
|
||||
and threading.current_thread() != threading.main_thread()
|
||||
or signal.getsignal(signal.SIGINT) != signal.default_int_handler
|
||||
and threading.current_thread() != threading.main_thread()
|
||||
or signal.getsignal(signal.SIGINT) != signal.default_int_handler
|
||||
):
|
||||
return True
|
||||
if (
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
| aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
| aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
):
|
||||
return True
|
||||
if (
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
& aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
& aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
):
|
||||
return True
|
||||
if (
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
):
|
||||
return True
|
||||
if (
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
):
|
||||
return True
|
||||
if (
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
):
|
||||
return True
|
||||
if (
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
/ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
/ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
):
|
||||
return True
|
||||
if (
|
||||
~aaaa.a + aaaa.b - aaaa.c * aaaa.d / aaaa.e
|
||||
| aaaa.f & aaaa.g % aaaa.h ^ aaaa.i << aaaa.k >> aaaa.l**aaaa.m // aaaa.n
|
||||
| aaaa.f & aaaa.g % aaaa.h ^ aaaa.i << aaaa.k >> aaaa.l**aaaa.m // aaaa.n
|
||||
):
|
||||
return True
|
||||
if (
|
||||
~aaaaaaaa.a + aaaaaaaa.b - aaaaaaaa.c @ aaaaaaaa.d / aaaaaaaa.e
|
||||
| aaaaaaaa.f & aaaaaaaa.g % aaaaaaaa.h
|
||||
^ aaaaaaaa.i << aaaaaaaa.k >> aaaaaaaa.l**aaaaaaaa.m // aaaaaaaa.n
|
||||
| aaaaaaaa.f & aaaaaaaa.g % aaaaaaaa.h
|
||||
^ aaaaaaaa.i << aaaaaaaa.k >> aaaaaaaa.l**aaaaaaaa.m // aaaaaaaa.n
|
||||
):
|
||||
return True
|
||||
if (
|
||||
~aaaaaaaaaaaaaaaa.a
|
||||
+ aaaaaaaaaaaaaaaa.b
|
||||
- aaaaaaaaaaaaaaaa.c * aaaaaaaaaaaaaaaa.d @ aaaaaaaaaaaaaaaa.e
|
||||
| aaaaaaaaaaaaaaaa.f & aaaaaaaaaaaaaaaa.g % aaaaaaaaaaaaaaaa.h
|
||||
^ aaaaaaaaaaaaaaaa.i
|
||||
<< aaaaaaaaaaaaaaaa.k
|
||||
>> aaaaaaaaaaaaaaaa.l**aaaaaaaaaaaaaaaa.m // aaaaaaaaaaaaaaaa.n
|
||||
+ aaaaaaaaaaaaaaaa.b
|
||||
- aaaaaaaaaaaaaaaa.c * aaaaaaaaaaaaaaaa.d @ aaaaaaaaaaaaaaaa.e
|
||||
| aaaaaaaaaaaaaaaa.f & aaaaaaaaaaaaaaaa.g % aaaaaaaaaaaaaaaa.h
|
||||
^ aaaaaaaaaaaaaaaa.i
|
||||
<< aaaaaaaaaaaaaaaa.k
|
||||
>> aaaaaaaaaaaaaaaa.l**aaaaaaaaaaaaaaaa.m // aaaaaaaaaaaaaaaa.n
|
||||
):
|
||||
return True
|
||||
(
|
||||
aaaaaaaaaaaaaaaa
|
||||
+ aaaaaaaaaaaaaaaa
|
||||
- aaaaaaaaaaaaaaaa
|
||||
* (aaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaa)
|
||||
/ (aaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaa)
|
||||
+ aaaaaaaaaaaaaaaa
|
||||
- aaaaaaaaaaaaaaaa
|
||||
* (aaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaa)
|
||||
/ (aaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaa)
|
||||
)
|
||||
aaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaa
|
||||
(
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
>> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
<< aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
>> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
<< aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
)
|
||||
bbbb >> bbbb * bbbb
|
||||
(
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
^ bbbb.a & aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
^ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
^ bbbb.a & aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
^ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
)
|
||||
last_call()
|
||||
# standalone comment at ENDMARKER
|
||||
|
||||
@@ -110,6 +110,15 @@ elif unformatted:
|
||||
},
|
||||
)
|
||||
|
||||
@@ -19,7 +18,7 @@
|
||||
"-la",
|
||||
]
|
||||
# fmt: on
|
||||
- + path,
|
||||
+ + path,
|
||||
check=True,
|
||||
)
|
||||
|
||||
@@ -82,6 +81,6 @@
|
||||
if x:
|
||||
return x
|
||||
@@ -143,7 +152,7 @@ run(
|
||||
"-la",
|
||||
]
|
||||
# fmt: on
|
||||
+ path,
|
||||
+ path,
|
||||
check=True,
|
||||
)
|
||||
|
||||
|
||||
@@ -21,15 +21,17 @@ else:
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -1,7 +1,7 @@
|
||||
@@ -1,8 +1,8 @@
|
||||
a, b, c = 3, 4, 5
|
||||
if (
|
||||
a == 3
|
||||
- and b != 9 # fmt: skip
|
||||
+ and b != 9 # fmt: skip
|
||||
and c is not None
|
||||
- and c is not None
|
||||
+ and b != 9 # fmt: skip
|
||||
+ and c is not None
|
||||
):
|
||||
print("I'm good!")
|
||||
else:
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
@@ -38,8 +40,8 @@ else:
|
||||
a, b, c = 3, 4, 5
|
||||
if (
|
||||
a == 3
|
||||
and b != 9 # fmt: skip
|
||||
and c is not None
|
||||
and b != 9 # fmt: skip
|
||||
and c is not None
|
||||
):
|
||||
print("I'm good!")
|
||||
else:
|
||||
|
||||
@@ -0,0 +1,343 @@
|
||||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/black/cases/function_trailing_comma.py
|
||||
---
|
||||
## Input
|
||||
|
||||
```python
|
||||
def f(a,):
|
||||
d = {'key': 'value',}
|
||||
tup = (1,)
|
||||
|
||||
def f2(a,b,):
|
||||
d = {'key': 'value', 'key2': 'value2',}
|
||||
tup = (1,2,)
|
||||
|
||||
def f(a:int=1,):
|
||||
call(arg={'explode': 'this',})
|
||||
call2(arg=[1,2,3],)
|
||||
x = {
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
}["a"]
|
||||
if a == {"a": 1,"b": 2,"c": 3,"d": 4,"e": 5,"f": 6,"g": 7,"h": 8,}["a"]:
|
||||
pass
|
||||
|
||||
def xxxxxxxxxxxxxxxxxxxxxxxxxxxx() -> Set[
|
||||
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||
]:
|
||||
json = {"k": {"k2": {"k3": [1,]}}}
|
||||
|
||||
|
||||
|
||||
# The type annotation shouldn't get a trailing comma since that would change its type.
|
||||
# Relevant bug report: https://github.com/psf/black/issues/2381.
|
||||
def some_function_with_a_really_long_name() -> (
|
||||
returning_a_deeply_nested_import_of_a_type_i_suppose
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
def some_method_with_a_really_long_name(very_long_parameter_so_yeah: str, another_long_parameter: int) -> (
|
||||
another_case_of_returning_a_deeply_nested_import_of_a_type_i_suppose_cause_why_not
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
def func() -> (
|
||||
also_super_long_type_annotation_that_may_cause_an_AST_related_crash_in_black(this_shouldn_t_get_a_trailing_comma_too)
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
def func() -> ((also_super_long_type_annotation_that_may_cause_an_AST_related_crash_in_black(
|
||||
this_shouldn_t_get_a_trailing_comma_too
|
||||
))
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
# Make sure inner one-element tuple won't explode
|
||||
some_module.some_function(
|
||||
argument1, (one_element_tuple,), argument4, argument5, argument6
|
||||
)
|
||||
|
||||
# Inner trailing comma causes outer to explode
|
||||
some_module.some_function(
|
||||
argument1, (one, two,), argument4, argument5, argument6
|
||||
)
|
||||
```
|
||||
|
||||
## Black Differences
|
||||
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -38,16 +38,16 @@
|
||||
}["a"]
|
||||
if (
|
||||
a
|
||||
- == {
|
||||
- "a": 1,
|
||||
- "b": 2,
|
||||
- "c": 3,
|
||||
- "d": 4,
|
||||
- "e": 5,
|
||||
- "f": 6,
|
||||
- "g": 7,
|
||||
- "h": 8,
|
||||
- }["a"]
|
||||
+ == {
|
||||
+ "a": 1,
|
||||
+ "b": 2,
|
||||
+ "c": 3,
|
||||
+ "d": 4,
|
||||
+ "e": 5,
|
||||
+ "f": 6,
|
||||
+ "g": 7,
|
||||
+ "h": 8,
|
||||
+ }["a"]
|
||||
):
|
||||
pass
|
||||
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
|
||||
```python
|
||||
def f(
|
||||
a,
|
||||
):
|
||||
d = {
|
||||
"key": "value",
|
||||
}
|
||||
tup = (1,)
|
||||
|
||||
|
||||
def f2(
|
||||
a,
|
||||
b,
|
||||
):
|
||||
d = {
|
||||
"key": "value",
|
||||
"key2": "value2",
|
||||
}
|
||||
tup = (
|
||||
1,
|
||||
2,
|
||||
)
|
||||
|
||||
|
||||
def f(
|
||||
a: int = 1,
|
||||
):
|
||||
call(
|
||||
arg={
|
||||
"explode": "this",
|
||||
}
|
||||
)
|
||||
call2(
|
||||
arg=[1, 2, 3],
|
||||
)
|
||||
x = {
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
}["a"]
|
||||
if (
|
||||
a
|
||||
== {
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3,
|
||||
"d": 4,
|
||||
"e": 5,
|
||||
"f": 6,
|
||||
"g": 7,
|
||||
"h": 8,
|
||||
}["a"]
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
def xxxxxxxxxxxxxxxxxxxxxxxxxxxx() -> (
|
||||
Set["xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"]
|
||||
):
|
||||
json = {
|
||||
"k": {
|
||||
"k2": {
|
||||
"k3": [
|
||||
1,
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# The type annotation shouldn't get a trailing comma since that would change its type.
|
||||
# Relevant bug report: https://github.com/psf/black/issues/2381.
|
||||
def some_function_with_a_really_long_name() -> (
|
||||
returning_a_deeply_nested_import_of_a_type_i_suppose
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
def some_method_with_a_really_long_name(
|
||||
very_long_parameter_so_yeah: str, another_long_parameter: int
|
||||
) -> another_case_of_returning_a_deeply_nested_import_of_a_type_i_suppose_cause_why_not:
|
||||
pass
|
||||
|
||||
|
||||
def func() -> (
|
||||
also_super_long_type_annotation_that_may_cause_an_AST_related_crash_in_black(
|
||||
this_shouldn_t_get_a_trailing_comma_too
|
||||
)
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
def func() -> (
|
||||
also_super_long_type_annotation_that_may_cause_an_AST_related_crash_in_black(
|
||||
this_shouldn_t_get_a_trailing_comma_too
|
||||
)
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
# Make sure inner one-element tuple won't explode
|
||||
some_module.some_function(
|
||||
argument1, (one_element_tuple,), argument4, argument5, argument6
|
||||
)
|
||||
|
||||
# Inner trailing comma causes outer to explode
|
||||
some_module.some_function(
|
||||
argument1,
|
||||
(
|
||||
one,
|
||||
two,
|
||||
),
|
||||
argument4,
|
||||
argument5,
|
||||
argument6,
|
||||
)
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
||||
```python
|
||||
def f(
|
||||
a,
|
||||
):
|
||||
d = {
|
||||
"key": "value",
|
||||
}
|
||||
tup = (1,)
|
||||
|
||||
|
||||
def f2(
|
||||
a,
|
||||
b,
|
||||
):
|
||||
d = {
|
||||
"key": "value",
|
||||
"key2": "value2",
|
||||
}
|
||||
tup = (
|
||||
1,
|
||||
2,
|
||||
)
|
||||
|
||||
|
||||
def f(
|
||||
a: int = 1,
|
||||
):
|
||||
call(
|
||||
arg={
|
||||
"explode": "this",
|
||||
}
|
||||
)
|
||||
call2(
|
||||
arg=[1, 2, 3],
|
||||
)
|
||||
x = {
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
}["a"]
|
||||
if (
|
||||
a
|
||||
== {
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3,
|
||||
"d": 4,
|
||||
"e": 5,
|
||||
"f": 6,
|
||||
"g": 7,
|
||||
"h": 8,
|
||||
}["a"]
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
def xxxxxxxxxxxxxxxxxxxxxxxxxxxx() -> (
|
||||
Set["xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"]
|
||||
):
|
||||
json = {
|
||||
"k": {
|
||||
"k2": {
|
||||
"k3": [
|
||||
1,
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# The type annotation shouldn't get a trailing comma since that would change its type.
|
||||
# Relevant bug report: https://github.com/psf/black/issues/2381.
|
||||
def some_function_with_a_really_long_name() -> (
|
||||
returning_a_deeply_nested_import_of_a_type_i_suppose
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
def some_method_with_a_really_long_name(
|
||||
very_long_parameter_so_yeah: str, another_long_parameter: int
|
||||
) -> another_case_of_returning_a_deeply_nested_import_of_a_type_i_suppose_cause_why_not:
|
||||
pass
|
||||
|
||||
|
||||
def func() -> (
|
||||
also_super_long_type_annotation_that_may_cause_an_AST_related_crash_in_black(
|
||||
this_shouldn_t_get_a_trailing_comma_too
|
||||
)
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
def func() -> (
|
||||
also_super_long_type_annotation_that_may_cause_an_AST_related_crash_in_black(
|
||||
this_shouldn_t_get_a_trailing_comma_too
|
||||
)
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
# Make sure inner one-element tuple won't explode
|
||||
some_module.some_function(
|
||||
argument1, (one_element_tuple,), argument4, argument5, argument6
|
||||
)
|
||||
|
||||
# Inner trailing comma causes outer to explode
|
||||
some_module.some_function(
|
||||
argument1,
|
||||
(
|
||||
one,
|
||||
two,
|
||||
),
|
||||
argument4,
|
||||
argument5,
|
||||
argument6,
|
||||
)
|
||||
```
|
||||
|
||||
|
||||
@@ -0,0 +1,227 @@
|
||||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/black/cases/import_spacing.py
|
||||
---
|
||||
## Input
|
||||
|
||||
```python
|
||||
"""The asyncio package, tracking PEP 3156."""
|
||||
|
||||
# flake8: noqa
|
||||
|
||||
from logging import (
|
||||
WARNING
|
||||
)
|
||||
from logging import (
|
||||
ERROR,
|
||||
)
|
||||
import sys
|
||||
|
||||
# This relies on each of the submodules having an __all__ variable.
|
||||
from .base_events import *
|
||||
from .coroutines import *
|
||||
from .events import * # comment here
|
||||
|
||||
from .futures import *
|
||||
from .locks import * # comment here
|
||||
from .protocols import *
|
||||
|
||||
from ..runners import * # comment here
|
||||
from ..queues import *
|
||||
from ..streams import *
|
||||
|
||||
from some_library import (
|
||||
Just, Enough, Libraries, To, Fit, In, This, Nice, Split, Which, We, No, Longer, Use
|
||||
)
|
||||
from name_of_a_company.extremely_long_project_name.component.ttypes import CuteLittleServiceHandlerFactoryyy
|
||||
from name_of_a_company.extremely_long_project_name.extremely_long_component_name.ttypes import *
|
||||
|
||||
from .a.b.c.subprocess import *
|
||||
from . import (tasks)
|
||||
from . import (A, B, C)
|
||||
from . import SomeVeryLongNameAndAllOfItsAdditionalLetters1, \
|
||||
SomeVeryLongNameAndAllOfItsAdditionalLetters2
|
||||
|
||||
__all__ = (
|
||||
base_events.__all__
|
||||
+ coroutines.__all__
|
||||
+ events.__all__
|
||||
+ futures.__all__
|
||||
+ locks.__all__
|
||||
+ protocols.__all__
|
||||
+ runners.__all__
|
||||
+ queues.__all__
|
||||
+ streams.__all__
|
||||
+ tasks.__all__
|
||||
)
|
||||
```
|
||||
|
||||
## Black Differences
|
||||
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -52,13 +52,13 @@
|
||||
|
||||
__all__ = (
|
||||
base_events.__all__
|
||||
- + coroutines.__all__
|
||||
- + events.__all__
|
||||
- + futures.__all__
|
||||
- + locks.__all__
|
||||
- + protocols.__all__
|
||||
- + runners.__all__
|
||||
- + queues.__all__
|
||||
- + streams.__all__
|
||||
- + tasks.__all__
|
||||
+ + coroutines.__all__
|
||||
+ + events.__all__
|
||||
+ + futures.__all__
|
||||
+ + locks.__all__
|
||||
+ + protocols.__all__
|
||||
+ + runners.__all__
|
||||
+ + queues.__all__
|
||||
+ + streams.__all__
|
||||
+ + tasks.__all__
|
||||
)
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
|
||||
```python
|
||||
"""The asyncio package, tracking PEP 3156."""
|
||||
|
||||
# flake8: noqa
|
||||
|
||||
from logging import WARNING
|
||||
from logging import (
|
||||
ERROR,
|
||||
)
|
||||
import sys
|
||||
|
||||
# This relies on each of the submodules having an __all__ variable.
|
||||
from .base_events import *
|
||||
from .coroutines import *
|
||||
from .events import * # comment here
|
||||
|
||||
from .futures import *
|
||||
from .locks import * # comment here
|
||||
from .protocols import *
|
||||
|
||||
from ..runners import * # comment here
|
||||
from ..queues import *
|
||||
from ..streams import *
|
||||
|
||||
from some_library import (
|
||||
Just,
|
||||
Enough,
|
||||
Libraries,
|
||||
To,
|
||||
Fit,
|
||||
In,
|
||||
This,
|
||||
Nice,
|
||||
Split,
|
||||
Which,
|
||||
We,
|
||||
No,
|
||||
Longer,
|
||||
Use,
|
||||
)
|
||||
from name_of_a_company.extremely_long_project_name.component.ttypes import (
|
||||
CuteLittleServiceHandlerFactoryyy,
|
||||
)
|
||||
from name_of_a_company.extremely_long_project_name.extremely_long_component_name.ttypes import *
|
||||
|
||||
from .a.b.c.subprocess import *
|
||||
from . import tasks
|
||||
from . import A, B, C
|
||||
from . import (
|
||||
SomeVeryLongNameAndAllOfItsAdditionalLetters1,
|
||||
SomeVeryLongNameAndAllOfItsAdditionalLetters2,
|
||||
)
|
||||
|
||||
__all__ = (
|
||||
base_events.__all__
|
||||
+ coroutines.__all__
|
||||
+ events.__all__
|
||||
+ futures.__all__
|
||||
+ locks.__all__
|
||||
+ protocols.__all__
|
||||
+ runners.__all__
|
||||
+ queues.__all__
|
||||
+ streams.__all__
|
||||
+ tasks.__all__
|
||||
)
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
||||
```python
|
||||
"""The asyncio package, tracking PEP 3156."""
|
||||
|
||||
# flake8: noqa
|
||||
|
||||
from logging import WARNING
|
||||
from logging import (
|
||||
ERROR,
|
||||
)
|
||||
import sys
|
||||
|
||||
# This relies on each of the submodules having an __all__ variable.
|
||||
from .base_events import *
|
||||
from .coroutines import *
|
||||
from .events import * # comment here
|
||||
|
||||
from .futures import *
|
||||
from .locks import * # comment here
|
||||
from .protocols import *
|
||||
|
||||
from ..runners import * # comment here
|
||||
from ..queues import *
|
||||
from ..streams import *
|
||||
|
||||
from some_library import (
|
||||
Just,
|
||||
Enough,
|
||||
Libraries,
|
||||
To,
|
||||
Fit,
|
||||
In,
|
||||
This,
|
||||
Nice,
|
||||
Split,
|
||||
Which,
|
||||
We,
|
||||
No,
|
||||
Longer,
|
||||
Use,
|
||||
)
|
||||
from name_of_a_company.extremely_long_project_name.component.ttypes import (
|
||||
CuteLittleServiceHandlerFactoryyy,
|
||||
)
|
||||
from name_of_a_company.extremely_long_project_name.extremely_long_component_name.ttypes import *
|
||||
|
||||
from .a.b.c.subprocess import *
|
||||
from . import tasks
|
||||
from . import A, B, C
|
||||
from . import (
|
||||
SomeVeryLongNameAndAllOfItsAdditionalLetters1,
|
||||
SomeVeryLongNameAndAllOfItsAdditionalLetters2,
|
||||
)
|
||||
|
||||
__all__ = (
|
||||
base_events.__all__
|
||||
+ coroutines.__all__
|
||||
+ events.__all__
|
||||
+ futures.__all__
|
||||
+ locks.__all__
|
||||
+ protocols.__all__
|
||||
+ runners.__all__
|
||||
+ queues.__all__
|
||||
+ streams.__all__
|
||||
+ tasks.__all__
|
||||
)
|
||||
```
|
||||
|
||||
|
||||
@@ -304,7 +304,52 @@ long_unmergable_string_with_pragma = (
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -165,13 +165,9 @@
|
||||
@@ -40,11 +40,11 @@
|
||||
sooo="soooo", x=2
|
||||
),
|
||||
"A %s %s"
|
||||
- % (
|
||||
- "formatted",
|
||||
- "string",
|
||||
- ): "This is a really really really long string that has to go inside of a dictionary. It is %s bad (#%d)."
|
||||
- % ("soooo", 2),
|
||||
+ % (
|
||||
+ "formatted",
|
||||
+ "string",
|
||||
+ ): "This is a really really really long string that has to go inside of a dictionary. It is %s bad (#%d)."
|
||||
+ % ("soooo", 2),
|
||||
}
|
||||
|
||||
func_with_keywords(
|
||||
@@ -123,7 +123,7 @@
|
||||
|
||||
old_fmt_string1 = (
|
||||
"While we are on the topic of %s, we should also note that old-style formatting must also be preserved, since some %s still uses it."
|
||||
- % ("formatting", "code")
|
||||
+ % ("formatting", "code")
|
||||
)
|
||||
|
||||
old_fmt_string2 = "This is a %s %s %s %s" % (
|
||||
@@ -135,12 +135,12 @@
|
||||
|
||||
old_fmt_string3 = (
|
||||
"Whereas only the strings after the percent sign were long in the last example, this example uses a long initial string as well. This is another %s %s %s %s"
|
||||
- % (
|
||||
- "really really really really really",
|
||||
- "old",
|
||||
- "way to format strings!",
|
||||
- "Use f-strings instead!",
|
||||
- )
|
||||
+ % (
|
||||
+ "really really really really really",
|
||||
+ "old",
|
||||
+ "way to format strings!",
|
||||
+ "Use f-strings instead!",
|
||||
+ )
|
||||
)
|
||||
|
||||
fstring = f"f-strings definitely make things more {difficult} than they need to be for {{black}}. But boy they sure are handy. The problem is that some lines will need to have the 'f' whereas others do not. This {line}, for example, needs one."
|
||||
@@ -165,36 +165,32 @@
|
||||
|
||||
triple_quote_string = """This is a really really really long triple quote string assignment and it should not be touched."""
|
||||
|
||||
@@ -320,6 +365,50 @@ long_unmergable_string_with_pragma = (
|
||||
"formatting"
|
||||
)
|
||||
|
||||
assert some_type_of_boolean_expression, (
|
||||
"Followed by a really really really long string that is used to provide context to the AssertionError exception, which uses dynamic string %s."
|
||||
- % "formatting"
|
||||
+ % "formatting"
|
||||
)
|
||||
|
||||
assert some_type_of_boolean_expression, (
|
||||
"Followed by a really really really long string that is used to provide context to the AssertionError exception, which uses dynamic %s %s."
|
||||
- % ("string", "formatting")
|
||||
+ % ("string", "formatting")
|
||||
)
|
||||
|
||||
some_function_call(
|
||||
"With a reallly generic name and with a really really long string that is, at some point down the line, "
|
||||
- + added
|
||||
- + " to a variable and then added to another string."
|
||||
+ + added
|
||||
+ + " to a variable and then added to another string."
|
||||
)
|
||||
|
||||
some_function_call(
|
||||
"With a reallly generic name and with a really really long string that is, at some point down the line, "
|
||||
- + added
|
||||
- + " to a variable and then added to another string. But then what happens when the final string is also supppppperrrrr long?! Well then that second (realllllllly long) string should be split too.",
|
||||
+ + added
|
||||
+ + " to a variable and then added to another string. But then what happens when the final string is also supppppperrrrr long?! Well then that second (realllllllly long) string should be split too.",
|
||||
"and a second argument",
|
||||
and_a_third,
|
||||
)
|
||||
@@ -249,10 +245,10 @@
|
||||
|
||||
annotated_variable: Final = (
|
||||
"This is a large "
|
||||
- + STRING
|
||||
- + " that has been "
|
||||
- + CONCATENATED
|
||||
- + "using the '+' operator."
|
||||
+ + STRING
|
||||
+ + " that has been "
|
||||
+ + CONCATENATED
|
||||
+ + "using the '+' operator."
|
||||
)
|
||||
annotated_variable: Final = "This is a large string that has a type annotation attached to it. A type annotation should NOT stop a long string from being wrapped."
|
||||
annotated_variable: Literal[
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
@@ -367,11 +456,11 @@ D4 = {
|
||||
sooo="soooo", x=2
|
||||
),
|
||||
"A %s %s"
|
||||
% (
|
||||
"formatted",
|
||||
"string",
|
||||
): "This is a really really really long string that has to go inside of a dictionary. It is %s bad (#%d)."
|
||||
% ("soooo", 2),
|
||||
% (
|
||||
"formatted",
|
||||
"string",
|
||||
): "This is a really really really long string that has to go inside of a dictionary. It is %s bad (#%d)."
|
||||
% ("soooo", 2),
|
||||
}
|
||||
|
||||
func_with_keywords(
|
||||
@@ -450,7 +539,7 @@ fmt_string2 = "But what about when the string is {} but {}".format(
|
||||
|
||||
old_fmt_string1 = (
|
||||
"While we are on the topic of %s, we should also note that old-style formatting must also be preserved, since some %s still uses it."
|
||||
% ("formatting", "code")
|
||||
% ("formatting", "code")
|
||||
)
|
||||
|
||||
old_fmt_string2 = "This is a %s %s %s %s" % (
|
||||
@@ -462,12 +551,12 @@ old_fmt_string2 = "This is a %s %s %s %s" % (
|
||||
|
||||
old_fmt_string3 = (
|
||||
"Whereas only the strings after the percent sign were long in the last example, this example uses a long initial string as well. This is another %s %s %s %s"
|
||||
% (
|
||||
"really really really really really",
|
||||
"old",
|
||||
"way to format strings!",
|
||||
"Use f-strings instead!",
|
||||
)
|
||||
% (
|
||||
"really really really really really",
|
||||
"old",
|
||||
"way to format strings!",
|
||||
"Use f-strings instead!",
|
||||
)
|
||||
)
|
||||
|
||||
fstring = f"f-strings definitely make things more {difficult} than they need to be for {{black}}. But boy they sure are handy. The problem is that some lines will need to have the 'f' whereas others do not. This {line}, for example, needs one."
|
||||
@@ -500,24 +589,24 @@ assert some_type_of_boolean_expression, "Followed by a really really really long
|
||||
|
||||
assert some_type_of_boolean_expression, (
|
||||
"Followed by a really really really long string that is used to provide context to the AssertionError exception, which uses dynamic string %s."
|
||||
% "formatting"
|
||||
% "formatting"
|
||||
)
|
||||
|
||||
assert some_type_of_boolean_expression, (
|
||||
"Followed by a really really really long string that is used to provide context to the AssertionError exception, which uses dynamic %s %s."
|
||||
% ("string", "formatting")
|
||||
% ("string", "formatting")
|
||||
)
|
||||
|
||||
some_function_call(
|
||||
"With a reallly generic name and with a really really long string that is, at some point down the line, "
|
||||
+ added
|
||||
+ " to a variable and then added to another string."
|
||||
+ added
|
||||
+ " to a variable and then added to another string."
|
||||
)
|
||||
|
||||
some_function_call(
|
||||
"With a reallly generic name and with a really really long string that is, at some point down the line, "
|
||||
+ added
|
||||
+ " to a variable and then added to another string. But then what happens when the final string is also supppppperrrrr long?! Well then that second (realllllllly long) string should be split too.",
|
||||
+ added
|
||||
+ " to a variable and then added to another string. But then what happens when the final string is also supppppperrrrr long?! Well then that second (realllllllly long) string should be split too.",
|
||||
"and a second argument",
|
||||
and_a_third,
|
||||
)
|
||||
@@ -572,10 +661,10 @@ func_with_bad_parens(
|
||||
|
||||
annotated_variable: Final = (
|
||||
"This is a large "
|
||||
+ STRING
|
||||
+ " that has been "
|
||||
+ CONCATENATED
|
||||
+ "using the '+' operator."
|
||||
+ STRING
|
||||
+ " that has been "
|
||||
+ CONCATENATED
|
||||
+ "using the '+' operator."
|
||||
)
|
||||
annotated_variable: Final = "This is a large string that has a type annotation attached to it. A type annotation should NOT stop a long string from being wrapped."
|
||||
annotated_variable: Literal[
|
||||
|
||||
@@ -95,7 +95,96 @@ def f(
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -63,7 +63,7 @@
|
||||
@@ -1,17 +1,17 @@
|
||||
# This has always worked
|
||||
z = (
|
||||
Loooooooooooooooooooooooong
|
||||
- | Loooooooooooooooooooooooong
|
||||
- | Loooooooooooooooooooooooong
|
||||
- | Loooooooooooooooooooooooong
|
||||
+ | Loooooooooooooooooooooooong
|
||||
+ | Loooooooooooooooooooooooong
|
||||
+ | Loooooooooooooooooooooooong
|
||||
)
|
||||
|
||||
# "AnnAssign"s now also work
|
||||
z: (
|
||||
Loooooooooooooooooooooooong
|
||||
- | Loooooooooooooooooooooooong
|
||||
- | Loooooooooooooooooooooooong
|
||||
- | Loooooooooooooooooooooooong
|
||||
+ | Loooooooooooooooooooooooong
|
||||
+ | Loooooooooooooooooooooooong
|
||||
+ | Loooooooooooooooooooooooong
|
||||
)
|
||||
z: Short | Short2 | Short3 | Short4
|
||||
z: int
|
||||
@@ -20,9 +20,9 @@
|
||||
|
||||
z: (
|
||||
Loooooooooooooooooooooooong
|
||||
- | Loooooooooooooooooooooooong
|
||||
- | Loooooooooooooooooooooooong
|
||||
- | Loooooooooooooooooooooooong
|
||||
+ | Loooooooooooooooooooooooong
|
||||
+ | Loooooooooooooooooooooooong
|
||||
+ | Loooooooooooooooooooooooong
|
||||
) = 7
|
||||
z: Short | Short2 | Short3 | Short4 = 8
|
||||
z: int = 2.3
|
||||
@@ -31,39 +31,39 @@
|
||||
# In case I go for not enforcing parantheses, this might get improved at the same time
|
||||
x = (
|
||||
z
|
||||
- == 9999999999999999999999999999999999999999
|
||||
- | 9999999999999999999999999999999999999999
|
||||
- | 9999999999999999999999999999999999999999
|
||||
- | 9999999999999999999999999999999999999999,
|
||||
+ == 9999999999999999999999999999999999999999
|
||||
+ | 9999999999999999999999999999999999999999
|
||||
+ | 9999999999999999999999999999999999999999
|
||||
+ | 9999999999999999999999999999999999999999,
|
||||
y
|
||||
- == 9999999999999999999999999999999999999999
|
||||
- + 9999999999999999999999999999999999999999
|
||||
- + 9999999999999999999999999999999999999999
|
||||
- + 9999999999999999999999999999999999999999,
|
||||
+ == 9999999999999999999999999999999999999999
|
||||
+ + 9999999999999999999999999999999999999999
|
||||
+ + 9999999999999999999999999999999999999999
|
||||
+ + 9999999999999999999999999999999999999999,
|
||||
)
|
||||
|
||||
x = (
|
||||
z
|
||||
- == (
|
||||
- 9999999999999999999999999999999999999999
|
||||
- | 9999999999999999999999999999999999999999
|
||||
- | 9999999999999999999999999999999999999999
|
||||
- | 9999999999999999999999999999999999999999
|
||||
- ),
|
||||
+ == (
|
||||
+ 9999999999999999999999999999999999999999
|
||||
+ | 9999999999999999999999999999999999999999
|
||||
+ | 9999999999999999999999999999999999999999
|
||||
+ | 9999999999999999999999999999999999999999
|
||||
+ ),
|
||||
y
|
||||
- == (
|
||||
- 9999999999999999999999999999999999999999
|
||||
- + 9999999999999999999999999999999999999999
|
||||
- + 9999999999999999999999999999999999999999
|
||||
- + 9999999999999999999999999999999999999999
|
||||
- ),
|
||||
+ == (
|
||||
+ 9999999999999999999999999999999999999999
|
||||
+ + 9999999999999999999999999999999999999999
|
||||
+ + 9999999999999999999999999999999999999999
|
||||
+ + 9999999999999999999999999999999999999999
|
||||
+ ),
|
||||
)
|
||||
|
||||
# handle formatting of "tname"s in parameter list
|
||||
|
||||
|
||||
# remove unnecessary paren
|
||||
@@ -110,14 +199,12 @@ def f(
|
||||
i: int,
|
||||
- x: (
|
||||
- Loooooooooooooooooooooooong
|
||||
- | Looooooooooooooooong
|
||||
- | Looooooooooooooooooooong
|
||||
+ x: Loooooooooooooooooooooooong
|
||||
| Looooooooooooooooong
|
||||
| Looooooooooooooooooooong
|
||||
- | Looooooong
|
||||
- ),
|
||||
+ x: Loooooooooooooooooooooooong
|
||||
+ | Looooooooooooooooong
|
||||
+ | Looooooooooooooooooooong
|
||||
+ | Looooooong,
|
||||
+ | Looooooong,
|
||||
*,
|
||||
s: str,
|
||||
) -> None:
|
||||
@@ -138,17 +225,17 @@ def f(
|
||||
# This has always worked
|
||||
z = (
|
||||
Loooooooooooooooooooooooong
|
||||
| Loooooooooooooooooooooooong
|
||||
| Loooooooooooooooooooooooong
|
||||
| Loooooooooooooooooooooooong
|
||||
| Loooooooooooooooooooooooong
|
||||
| Loooooooooooooooooooooooong
|
||||
| Loooooooooooooooooooooooong
|
||||
)
|
||||
|
||||
# "AnnAssign"s now also work
|
||||
z: (
|
||||
Loooooooooooooooooooooooong
|
||||
| Loooooooooooooooooooooooong
|
||||
| Loooooooooooooooooooooooong
|
||||
| Loooooooooooooooooooooooong
|
||||
| Loooooooooooooooooooooooong
|
||||
| Loooooooooooooooooooooooong
|
||||
| Loooooooooooooooooooooooong
|
||||
)
|
||||
z: Short | Short2 | Short3 | Short4
|
||||
z: int
|
||||
@@ -157,9 +244,9 @@ z: int
|
||||
|
||||
z: (
|
||||
Loooooooooooooooooooooooong
|
||||
| Loooooooooooooooooooooooong
|
||||
| Loooooooooooooooooooooooong
|
||||
| Loooooooooooooooooooooooong
|
||||
| Loooooooooooooooooooooooong
|
||||
| Loooooooooooooooooooooooong
|
||||
| Loooooooooooooooooooooooong
|
||||
) = 7
|
||||
z: Short | Short2 | Short3 | Short4 = 8
|
||||
z: int = 2.3
|
||||
@@ -168,32 +255,32 @@ z: int = foo()
|
||||
# In case I go for not enforcing parantheses, this might get improved at the same time
|
||||
x = (
|
||||
z
|
||||
== 9999999999999999999999999999999999999999
|
||||
| 9999999999999999999999999999999999999999
|
||||
| 9999999999999999999999999999999999999999
|
||||
| 9999999999999999999999999999999999999999,
|
||||
== 9999999999999999999999999999999999999999
|
||||
| 9999999999999999999999999999999999999999
|
||||
| 9999999999999999999999999999999999999999
|
||||
| 9999999999999999999999999999999999999999,
|
||||
y
|
||||
== 9999999999999999999999999999999999999999
|
||||
+ 9999999999999999999999999999999999999999
|
||||
+ 9999999999999999999999999999999999999999
|
||||
+ 9999999999999999999999999999999999999999,
|
||||
== 9999999999999999999999999999999999999999
|
||||
+ 9999999999999999999999999999999999999999
|
||||
+ 9999999999999999999999999999999999999999
|
||||
+ 9999999999999999999999999999999999999999,
|
||||
)
|
||||
|
||||
x = (
|
||||
z
|
||||
== (
|
||||
9999999999999999999999999999999999999999
|
||||
| 9999999999999999999999999999999999999999
|
||||
| 9999999999999999999999999999999999999999
|
||||
| 9999999999999999999999999999999999999999
|
||||
),
|
||||
== (
|
||||
9999999999999999999999999999999999999999
|
||||
| 9999999999999999999999999999999999999999
|
||||
| 9999999999999999999999999999999999999999
|
||||
| 9999999999999999999999999999999999999999
|
||||
),
|
||||
y
|
||||
== (
|
||||
9999999999999999999999999999999999999999
|
||||
+ 9999999999999999999999999999999999999999
|
||||
+ 9999999999999999999999999999999999999999
|
||||
+ 9999999999999999999999999999999999999999
|
||||
),
|
||||
== (
|
||||
9999999999999999999999999999999999999999
|
||||
+ 9999999999999999999999999999999999999999
|
||||
+ 9999999999999999999999999999999999999999
|
||||
+ 9999999999999999999999999999999999999999
|
||||
),
|
||||
)
|
||||
|
||||
# handle formatting of "tname"s in parameter list
|
||||
@@ -210,9 +297,9 @@ def foo(i: (int,)) -> None: ...
|
||||
def foo(
|
||||
i: int,
|
||||
x: Loooooooooooooooooooooooong
|
||||
| Looooooooooooooooong
|
||||
| Looooooooooooooooooooong
|
||||
| Looooooong,
|
||||
| Looooooooooooooooong
|
||||
| Looooooooooooooooooooong
|
||||
| Looooooong,
|
||||
*,
|
||||
s: str,
|
||||
) -> None:
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/black/cases/pep_604.py
|
||||
---
|
||||
## Input
|
||||
|
||||
```python
|
||||
def some_very_long_name_function() -> my_module.Asdf | my_module.AnotherType | my_module.YetAnotherType | None:
|
||||
pass
|
||||
|
||||
|
||||
def some_very_long_name_function() -> my_module.Asdf | my_module.AnotherType | my_module.YetAnotherType | my_module.EvenMoreType | None:
|
||||
pass
|
||||
```
|
||||
|
||||
## Black Differences
|
||||
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
def some_very_long_name_function() -> (
|
||||
my_module.Asdf
|
||||
- | my_module.AnotherType
|
||||
- | my_module.YetAnotherType
|
||||
- | my_module.EvenMoreType
|
||||
- | None
|
||||
+ | my_module.AnotherType
|
||||
+ | my_module.YetAnotherType
|
||||
+ | my_module.EvenMoreType
|
||||
+ | None
|
||||
):
|
||||
pass
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
|
||||
```python
|
||||
def some_very_long_name_function() -> (
|
||||
my_module.Asdf | my_module.AnotherType | my_module.YetAnotherType | None
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
def some_very_long_name_function() -> (
|
||||
my_module.Asdf
|
||||
| my_module.AnotherType
|
||||
| my_module.YetAnotherType
|
||||
| my_module.EvenMoreType
|
||||
| None
|
||||
):
|
||||
pass
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
||||
```python
|
||||
def some_very_long_name_function() -> (
|
||||
my_module.Asdf | my_module.AnotherType | my_module.YetAnotherType | None
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
def some_very_long_name_function() -> (
|
||||
my_module.Asdf
|
||||
| my_module.AnotherType
|
||||
| my_module.YetAnotherType
|
||||
| my_module.EvenMoreType
|
||||
| None
|
||||
):
|
||||
pass
|
||||
```
|
||||
|
||||
|
||||
@@ -13,12 +13,14 @@ importA;()<<0**0#
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -2,5 +2,5 @@
|
||||
@@ -1,6 +1,6 @@
|
||||
importA
|
||||
(
|
||||
()
|
||||
<< 0
|
||||
- << 0
|
||||
- ** 0
|
||||
+ **0
|
||||
+ << 0
|
||||
+ **0
|
||||
) #
|
||||
```
|
||||
|
||||
@@ -28,8 +30,8 @@ importA;()<<0**0#
|
||||
importA
|
||||
(
|
||||
()
|
||||
<< 0
|
||||
**0
|
||||
<< 0
|
||||
**0
|
||||
) #
|
||||
```
|
||||
|
||||
|
||||
@@ -85,21 +85,18 @@ class Random:
|
||||
- a_very_long_variable * and_a_very_long_function_call() / 100000.0
|
||||
- )
|
||||
+ "a key in my dict": a_very_long_variable
|
||||
+ * and_a_very_long_function_call()
|
||||
+ / 100000.0
|
||||
+ * and_a_very_long_function_call()
|
||||
+ / 100000.0
|
||||
}
|
||||
|
||||
my_dict = {
|
||||
- "a key in my dict": (
|
||||
- a_very_long_variable
|
||||
- * and_a_very_long_function_call()
|
||||
- * and_another_long_func()
|
||||
- / 100000.0
|
||||
- )
|
||||
+ "a key in my dict": a_very_long_variable
|
||||
+ * and_a_very_long_function_call()
|
||||
+ * and_another_long_func()
|
||||
+ / 100000.0
|
||||
* and_a_very_long_function_call()
|
||||
* and_another_long_func()
|
||||
/ 100000.0
|
||||
- )
|
||||
}
|
||||
|
||||
my_dict = {
|
||||
@@ -140,15 +137,15 @@ my_dict = {
|
||||
|
||||
my_dict = {
|
||||
"a key in my dict": a_very_long_variable
|
||||
* and_a_very_long_function_call()
|
||||
/ 100000.0
|
||||
* and_a_very_long_function_call()
|
||||
/ 100000.0
|
||||
}
|
||||
|
||||
my_dict = {
|
||||
"a key in my dict": a_very_long_variable
|
||||
* and_a_very_long_function_call()
|
||||
* and_another_long_func()
|
||||
/ 100000.0
|
||||
* and_a_very_long_function_call()
|
||||
* and_another_long_func()
|
||||
/ 100000.0
|
||||
}
|
||||
|
||||
my_dict = {
|
||||
|
||||
@@ -439,11 +439,11 @@ log.info(f"""Skipping: {'a' == 'b'} {desc['ms_name']} {money=} {dte=} {pos_share
|
||||
- "This is a really really really long string that has to go inside of a"
|
||||
- " dictionary. It is %s bad (#%d)." % ("soooo", 2)
|
||||
- ),
|
||||
+ % (
|
||||
+ "formatted",
|
||||
+ "string",
|
||||
+ ): "This is a really really really long string that has to go inside of a dictionary. It is %s bad (#%d)."
|
||||
+ % ("soooo", 2),
|
||||
+ % (
|
||||
+ "formatted",
|
||||
+ "string",
|
||||
+ ): "This is a really really really long string that has to go inside of a dictionary. It is %s bad (#%d)."
|
||||
+ % ("soooo", 2),
|
||||
}
|
||||
|
||||
D5 = { # Test for https://github.com/psf/black/issues/3261
|
||||
@@ -622,22 +622,29 @@ log.info(f"""Skipping: {'a' == 'b'} {desc['ms_name']} {money=} {dte=} {pos_share
|
||||
- "While we are on the topic of %s, we should also note that old-style formatting"
|
||||
- " must also be preserved, since some %s still uses it." % ("formatting", "code")
|
||||
+ "While we are on the topic of %s, we should also note that old-style formatting must also be preserved, since some %s still uses it."
|
||||
+ % ("formatting", "code")
|
||||
+ % ("formatting", "code")
|
||||
)
|
||||
|
||||
old_fmt_string2 = "This is a %s %s %s %s" % (
|
||||
@@ -271,8 +201,7 @@
|
||||
@@ -271,36 +201,23 @@
|
||||
)
|
||||
|
||||
old_fmt_string3 = (
|
||||
- "Whereas only the strings after the percent sign were long in the last example,"
|
||||
- " this example uses a long initial string as well. This is another %s %s %s %s"
|
||||
- % (
|
||||
- "really really really really really",
|
||||
- "old",
|
||||
- "way to format strings!",
|
||||
- "Use f-strings instead!",
|
||||
- )
|
||||
+ "Whereas only the strings after the percent sign were long in the last example, this example uses a long initial string as well. This is another %s %s %s %s"
|
||||
% (
|
||||
"really really really really really",
|
||||
"old",
|
||||
@@ -281,26 +210,14 @@
|
||||
)
|
||||
+ % (
|
||||
+ "really really really really really",
|
||||
+ "old",
|
||||
+ "way to format strings!",
|
||||
+ "Use f-strings instead!",
|
||||
+ )
|
||||
)
|
||||
|
||||
-fstring = (
|
||||
@@ -688,33 +695,37 @@ log.info(f"""Skipping: {'a' == 'b'} {desc['ms_name']} {money=} {dte=} {pos_share
|
||||
- "Followed by a really really really long string that is used to provide context to"
|
||||
- " the AssertionError exception, which uses dynamic string %s." % "formatting"
|
||||
+ "Followed by a really really really long string that is used to provide context to the AssertionError exception, which uses dynamic string %s."
|
||||
+ % "formatting"
|
||||
+ % "formatting"
|
||||
)
|
||||
|
||||
assert some_type_of_boolean_expression, (
|
||||
- "Followed by a really really really long string that is used to provide context to"
|
||||
- " the AssertionError exception, which uses dynamic %s %s."
|
||||
- % ("string", "formatting")
|
||||
+ "Followed by a really really really long string that is used to provide context to the AssertionError exception, which uses dynamic %s %s."
|
||||
% ("string", "formatting")
|
||||
+ % ("string", "formatting")
|
||||
)
|
||||
|
||||
some_function_call(
|
||||
- "With a reallly generic name and with a really really long string that is, at some"
|
||||
- " point down the line, "
|
||||
- + added
|
||||
- + " to a variable and then added to another string."
|
||||
+ "With a reallly generic name and with a really really long string that is, at some point down the line, "
|
||||
+ added
|
||||
+ " to a variable and then added to another string."
|
||||
+ + added
|
||||
+ + " to a variable and then added to another string."
|
||||
)
|
||||
|
||||
some_function_call(
|
||||
- "With a reallly generic name and with a really really long string that is, at some"
|
||||
- " point down the line, "
|
||||
+ "With a reallly generic name and with a really really long string that is, at some point down the line, "
|
||||
+ added
|
||||
- + added
|
||||
- + " to a variable and then added to another string. But then what happens when the"
|
||||
- " final string is also supppppperrrrr long?! Well then that second (realllllllly"
|
||||
- " long) string should be split too.",
|
||||
+ + " to a variable and then added to another string. But then what happens when the final string is also supppppperrrrr long?! Well then that second (realllllllly long) string should be split too.",
|
||||
+ "With a reallly generic name and with a really really long string that is, at some point down the line, "
|
||||
+ + added
|
||||
+ + " to a variable and then added to another string. But then what happens when the final string is also supppppperrrrr long?! Well then that second (realllllllly long) string should be split too.",
|
||||
"and a second argument",
|
||||
and_a_third,
|
||||
)
|
||||
@@ -772,7 +783,7 @@ log.info(f"""Skipping: {'a' == 'b'} {desc['ms_name']} {money=} {dte=} {pos_share
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
@@ -397,7 +306,7 @@
|
||||
@@ -397,61 +306,38 @@
|
||||
func_with_bad_parens(
|
||||
x,
|
||||
y,
|
||||
@@ -781,14 +792,21 @@ log.info(f"""Skipping: {'a' == 'b'} {desc['ms_name']} {money=} {dte=} {pos_share
|
||||
z,
|
||||
)
|
||||
|
||||
@@ -408,50 +317,27 @@
|
||||
+ CONCATENATED
|
||||
+ "using the '+' operator."
|
||||
)
|
||||
annotated_variable: Final = (
|
||||
"This is a large "
|
||||
- + STRING
|
||||
- + " that has been "
|
||||
- + CONCATENATED
|
||||
- + "using the '+' operator."
|
||||
-)
|
||||
-annotated_variable: Final = (
|
||||
- "This is a large string that has a type annotation attached to it. A type"
|
||||
- " annotation should NOT stop a long string from being wrapped."
|
||||
-)
|
||||
+ + STRING
|
||||
+ + " that has been "
|
||||
+ + CONCATENATED
|
||||
+ + "using the '+' operator."
|
||||
)
|
||||
+annotated_variable: Final = "This is a large string that has a type annotation attached to it. A type annotation should NOT stop a long string from being wrapped."
|
||||
annotated_variable: Literal["fakse_literal"] = (
|
||||
- "This is a large string that has a type annotation attached to it. A type"
|
||||
@@ -910,15 +928,16 @@ log.info(f"""Skipping: {'a' == 'b'} {desc['ms_name']} {money=} {dte=} {pos_share
|
||||
- + ", \n".join(
|
||||
- " (%r, self.%s, visitor.%s)" % (attrname, attrname, visit_name)
|
||||
- for attrname, visit_name in names
|
||||
+ (" return [\n")
|
||||
+ + (
|
||||
+ ", \n".join(
|
||||
+ " (%r, self.%s, visitor.%s)" % (attrname, attrname, visit_name)
|
||||
+ for attrname, visit_name in names
|
||||
+ )
|
||||
)
|
||||
- )
|
||||
- + "\n ]\n"
|
||||
+ + ("\n ]\n")
|
||||
+ (" return [\n")
|
||||
+ + (
|
||||
+ ", \n".join(
|
||||
+ " (%r, self.%s, visitor.%s)" % (attrname, attrname, visit_name)
|
||||
+ for attrname, visit_name in names
|
||||
+ )
|
||||
+ )
|
||||
+ + ("\n ]\n")
|
||||
)
|
||||
|
||||
|
||||
@@ -1028,11 +1047,11 @@ D4 = {
|
||||
sooo="soooo", x=2
|
||||
),
|
||||
"A %s %s"
|
||||
% (
|
||||
"formatted",
|
||||
"string",
|
||||
): "This is a really really really long string that has to go inside of a dictionary. It is %s bad (#%d)."
|
||||
% ("soooo", 2),
|
||||
% (
|
||||
"formatted",
|
||||
"string",
|
||||
): "This is a really really really long string that has to go inside of a dictionary. It is %s bad (#%d)."
|
||||
% ("soooo", 2),
|
||||
}
|
||||
|
||||
D5 = { # Test for https://github.com/psf/black/issues/3261
|
||||
@@ -1178,7 +1197,7 @@ fmt_string2 = "But what about when the string is {} but {}".format(
|
||||
|
||||
old_fmt_string1 = (
|
||||
"While we are on the topic of %s, we should also note that old-style formatting must also be preserved, since some %s still uses it."
|
||||
% ("formatting", "code")
|
||||
% ("formatting", "code")
|
||||
)
|
||||
|
||||
old_fmt_string2 = "This is a %s %s %s %s" % (
|
||||
@@ -1190,12 +1209,12 @@ old_fmt_string2 = "This is a %s %s %s %s" % (
|
||||
|
||||
old_fmt_string3 = (
|
||||
"Whereas only the strings after the percent sign were long in the last example, this example uses a long initial string as well. This is another %s %s %s %s"
|
||||
% (
|
||||
"really really really really really",
|
||||
"old",
|
||||
"way to format strings!",
|
||||
"Use f-strings instead!",
|
||||
)
|
||||
% (
|
||||
"really really really really really",
|
||||
"old",
|
||||
"way to format strings!",
|
||||
"Use f-strings instead!",
|
||||
)
|
||||
)
|
||||
|
||||
fstring = f"f-strings definitely make things more {difficult} than they need to be for {{black}}. But boy they sure are handy. The problem is that some lines will need to have the 'f' whereas others do not. This {line}, for example, needs one."
|
||||
@@ -1228,24 +1247,24 @@ assert some_type_of_boolean_expression, "Followed by a really really really long
|
||||
|
||||
assert some_type_of_boolean_expression, (
|
||||
"Followed by a really really really long string that is used to provide context to the AssertionError exception, which uses dynamic string %s."
|
||||
% "formatting"
|
||||
% "formatting"
|
||||
)
|
||||
|
||||
assert some_type_of_boolean_expression, (
|
||||
"Followed by a really really really long string that is used to provide context to the AssertionError exception, which uses dynamic %s %s."
|
||||
% ("string", "formatting")
|
||||
% ("string", "formatting")
|
||||
)
|
||||
|
||||
some_function_call(
|
||||
"With a reallly generic name and with a really really long string that is, at some point down the line, "
|
||||
+ added
|
||||
+ " to a variable and then added to another string."
|
||||
+ added
|
||||
+ " to a variable and then added to another string."
|
||||
)
|
||||
|
||||
some_function_call(
|
||||
"With a reallly generic name and with a really really long string that is, at some point down the line, "
|
||||
+ added
|
||||
+ " to a variable and then added to another string. But then what happens when the final string is also supppppperrrrr long?! Well then that second (realllllllly long) string should be split too.",
|
||||
+ added
|
||||
+ " to a variable and then added to another string. But then what happens when the final string is also supppppperrrrr long?! Well then that second (realllllllly long) string should be split too.",
|
||||
"and a second argument",
|
||||
and_a_third,
|
||||
)
|
||||
@@ -1300,10 +1319,10 @@ func_with_bad_parens(
|
||||
|
||||
annotated_variable: Final = (
|
||||
"This is a large "
|
||||
+ STRING
|
||||
+ " that has been "
|
||||
+ CONCATENATED
|
||||
+ "using the '+' operator."
|
||||
+ STRING
|
||||
+ " that has been "
|
||||
+ CONCATENATED
|
||||
+ "using the '+' operator."
|
||||
)
|
||||
annotated_variable: Final = "This is a large string that has a type annotation attached to it. A type annotation should NOT stop a long string from being wrapped."
|
||||
annotated_variable: Literal["fakse_literal"] = (
|
||||
@@ -1372,13 +1391,13 @@ dict_with_lambda_values = {
|
||||
# Complex string concatenations with a method call in the middle.
|
||||
code = (
|
||||
(" return [\n")
|
||||
+ (
|
||||
", \n".join(
|
||||
" (%r, self.%s, visitor.%s)" % (attrname, attrname, visit_name)
|
||||
for attrname, visit_name in names
|
||||
+ (
|
||||
", \n".join(
|
||||
" (%r, self.%s, visitor.%s)" % (attrname, attrname, visit_name)
|
||||
for attrname, visit_name in names
|
||||
)
|
||||
)
|
||||
)
|
||||
+ ("\n ]\n")
|
||||
+ ("\n ]\n")
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -99,18 +99,19 @@ msg += "This long string should not be split at any point ever since it is just
|
||||
some_string_inside_a_variable
|
||||
- + "Some string that is just long enough to cause a split to take"
|
||||
- " place.............",
|
||||
+ + "Some string that is just long enough to cause a split to take place.............",
|
||||
+ + "Some string that is just long enough to cause a split to take place.............",
|
||||
xyz,
|
||||
- "Some really long string that needs to get split eventually but I'm running out of"
|
||||
- " things to say"
|
||||
- + some_string_inside_a_variable,
|
||||
+ "Some really long string that needs to get split eventually but I'm running out of things to say"
|
||||
+ some_string_inside_a_variable,
|
||||
+ + some_string_inside_a_variable,
|
||||
)
|
||||
addition_inside_tuple = (
|
||||
some_string_inside_a_variable
|
||||
- + "Some string that is just long enough to cause a split to take"
|
||||
- " place.............."
|
||||
+ + "Some string that is just long enough to cause a split to take place.............."
|
||||
+ + "Some string that is just long enough to cause a split to take place.............."
|
||||
)
|
||||
return (
|
||||
"Hi there. This is areally really reallllly long string that needs to be split!!!"
|
||||
@@ -131,20 +132,21 @@ msg += "This long string should not be split at any point ever since it is just
|
||||
str(result)
|
||||
- == "This long string should be split at some point right close to or around"
|
||||
- " hereeeeeee"
|
||||
+ == "This long string should be split at some point right close to or around hereeeeeee"
|
||||
+ == "This long string should be split at some point right close to or around hereeeeeee"
|
||||
)
|
||||
assert (
|
||||
str(result)
|
||||
- < "This long string should be split at some point right close to or around"
|
||||
- " hereeeeee"
|
||||
+ < "This long string should be split at some point right close to or around hereeeeee"
|
||||
+ < "This long string should be split at some point right close to or around hereeeeee"
|
||||
)
|
||||
assert (
|
||||
"A format string: %s"
|
||||
- % "This long string should be split at some point right close to or around"
|
||||
- " hereeeeeee"
|
||||
+ % "This long string should be split at some point right close to or around hereeeeeee"
|
||||
!= result
|
||||
- != result
|
||||
+ % "This long string should be split at some point right close to or around hereeeeeee"
|
||||
+ != result
|
||||
)
|
||||
msg += (
|
||||
"This long string should be wrapped in parens at some point right around hereeeee"
|
||||
@@ -193,14 +195,14 @@ some_variable = (
|
||||
)
|
||||
addition_inside_tuple = (
|
||||
some_string_inside_a_variable
|
||||
+ "Some string that is just long enough to cause a split to take place.............",
|
||||
+ "Some string that is just long enough to cause a split to take place.............",
|
||||
xyz,
|
||||
"Some really long string that needs to get split eventually but I'm running out of things to say"
|
||||
+ some_string_inside_a_variable,
|
||||
+ some_string_inside_a_variable,
|
||||
)
|
||||
addition_inside_tuple = (
|
||||
some_string_inside_a_variable
|
||||
+ "Some string that is just long enough to cause a split to take place.............."
|
||||
+ "Some string that is just long enough to cause a split to take place.............."
|
||||
)
|
||||
return (
|
||||
"Hi there. This is areally really reallllly long string that needs to be split!!!"
|
||||
@@ -216,16 +218,16 @@ return (
|
||||
return f"{x}/b/c/d/d/d/dadfjsadjsaidoaisjdsfjaofjdfijaidfjaodfjaoifjodjafojdoajaaaaaaaaaaaa"
|
||||
assert (
|
||||
str(result)
|
||||
== "This long string should be split at some point right close to or around hereeeeeee"
|
||||
== "This long string should be split at some point right close to or around hereeeeeee"
|
||||
)
|
||||
assert (
|
||||
str(result)
|
||||
< "This long string should be split at some point right close to or around hereeeeee"
|
||||
< "This long string should be split at some point right close to or around hereeeeee"
|
||||
)
|
||||
assert (
|
||||
"A format string: %s"
|
||||
% "This long string should be split at some point right close to or around hereeeeeee"
|
||||
!= result
|
||||
% "This long string should be split at some point right close to or around hereeeeeee"
|
||||
!= result
|
||||
)
|
||||
msg += (
|
||||
"This long string should be wrapped in parens at some point right around hereeeee"
|
||||
|
||||
@@ -660,7 +660,7 @@ s = f'Lorem Ipsum is simply dummy text of the printing and typesetting industry:
|
||||
- " on one line at alllll." % "formatting",
|
||||
+ (
|
||||
+ "A long string with {}. This string is so long that it is ridiculous. It can't fit on one line at alllll."
|
||||
+ % "formatting"
|
||||
+ % "formatting"
|
||||
+ ),
|
||||
)
|
||||
|
||||
@@ -669,7 +669,7 @@ s = f'Lorem Ipsum is simply dummy text of the printing and typesetting industry:
|
||||
- " one line at alllll." % ("formatting", "string"),
|
||||
+ (
|
||||
+ "A long string with {}. This {} is so long that it is ridiculous. It can't fit on one line at alllll."
|
||||
+ % ("formatting", "string")
|
||||
+ % ("formatting", "string")
|
||||
+ ),
|
||||
)
|
||||
|
||||
@@ -688,17 +688,17 @@ s = f'Lorem Ipsum is simply dummy text of the printing and typesetting industry:
|
||||
- xxxx.xxxxxxxxxxxxxx(xx),
|
||||
+ (
|
||||
+ "xxxxxxxxxx xxxx xx xxxxxx(%x) xx %x xxxx xx xxx %x.xx"
|
||||
+ % (len(self) + 1, xxxx.xxxxxxxxxx, xxxx.xxxxxxxxxx)
|
||||
+ )
|
||||
+ + (
|
||||
+ " %.3f (%s) to %.3f (%s).\n"
|
||||
+ % (
|
||||
+ xxxx.xxxxxxxxx,
|
||||
+ xxxx.xxxxxxxxxxxxxx(xxxx.xxxxxxxxx),
|
||||
+ x,
|
||||
+ xxxx.xxxxxxxxxxxxxx(xx),
|
||||
+ )
|
||||
+ % (len(self) + 1, xxxx.xxxxxxxxxx, xxxx.xxxxxxxxxx)
|
||||
)
|
||||
+ + (
|
||||
+ " %.3f (%s) to %.3f (%s).\n"
|
||||
+ % (
|
||||
+ xxxx.xxxxxxxxx,
|
||||
+ xxxx.xxxxxxxxxxxxxx(xxxx.xxxxxxxxx),
|
||||
+ x,
|
||||
+ xxxx.xxxxxxxxxxxxxx(xx),
|
||||
+ )
|
||||
+ )
|
||||
)
|
||||
|
||||
|
||||
@@ -777,9 +777,9 @@ s = f'Lorem Ipsum is simply dummy text of the printing and typesetting industry:
|
||||
- + "xx xxxxxx xxxxxx xxxxxx xx xxxxxxx xxx xxx ${0} xx x xxxxxxxx xxxxx"
|
||||
- .xxxxxx(xxxxxx_xxxxxx_xxx)
|
||||
+ "xxx xxxxxx xxx xxxxxxxxx.xx xx xxxxxxxx. xxx xxxxxxxxxxxxx.xx xxxxxxx "
|
||||
+ + "xx xxxxxx xxxxxx xxxxxx xx xxxxxxx xxx xxx ${0} xx x xxxxxxxx xxxxx".xxxxxx(
|
||||
+ xxxxxx_xxxxxx_xxx
|
||||
+ )
|
||||
+ + "xx xxxxxx xxxxxx xxxxxx xx xxxxxxx xxx xxx ${0} xx x xxxxxxxx xxxxx".xxxxxx(
|
||||
+ xxxxxx_xxxxxx_xxx
|
||||
+ )
|
||||
)
|
||||
|
||||
|
||||
@@ -832,7 +832,7 @@ s = f'Lorem Ipsum is simply dummy text of the printing and typesetting industry:
|
||||
|
||||
some_commented_string = ( # This comment stays at the top.
|
||||
"This string is long but not so long that it needs hahahah toooooo be so greatttt"
|
||||
@@ -279,36 +280,25 @@
|
||||
@@ -279,37 +280,26 @@
|
||||
)
|
||||
|
||||
lpar_and_rpar_have_comments = func_call( # LPAR Comment
|
||||
@@ -852,32 +852,33 @@ s = f'Lorem Ipsum is simply dummy text of the printing and typesetting industry:
|
||||
- f" {'' if ID is None else ID} | perl -nE 'print if /^{field}:/'"
|
||||
-)
|
||||
+cmd_fstring = f"sudo -E deluge-console info --detailed --sort-reverse=time_added {'' if ID is None else ID} | perl -nE 'print if /^{field}:/'"
|
||||
+
|
||||
+cmd_fstring = f"sudo -E deluge-console info --detailed --sort-reverse=time_added {'{{}}' if ID is None else ID} | perl -nE 'print if /^{field}:/'"
|
||||
|
||||
-cmd_fstring = (
|
||||
- "sudo -E deluge-console info --detailed --sort-reverse=time_added"
|
||||
- f" {'{{}}' if ID is None else ID} | perl -nE 'print if /^{field}:/'"
|
||||
-)
|
||||
+cmd_fstring = f"sudo -E deluge-console info --detailed --sort-reverse=time_added {'{{}}' if ID is None else ID} | perl -nE 'print if /^{field}:/'"
|
||||
+cmd_fstring = f"sudo -E deluge-console info --detailed --sort-reverse=time_added {{'' if ID is None else ID}} | perl -nE 'print if /^{field}:/'"
|
||||
|
||||
-cmd_fstring = (
|
||||
- "sudo -E deluge-console info --detailed --sort-reverse=time_added {'' if ID is"
|
||||
- f" None else ID}} | perl -nE 'print if /^{field}:/'"
|
||||
-)
|
||||
+cmd_fstring = f"sudo -E deluge-console info --detailed --sort-reverse=time_added {{'' if ID is None else ID}} | perl -nE 'print if /^{field}:/'"
|
||||
|
||||
+fstring = f"This string really doesn't need to be an {{{{fstring}}}}, but this one most certainly, absolutely {does}."
|
||||
+
|
||||
|
||||
fstring = (
|
||||
- "This string really doesn't need to be an {{fstring}}, but this one most"
|
||||
- f" certainly, absolutely {does}."
|
||||
+ f"We have to remember to escape {braces}." " Like {these}." f" But not {this}."
|
||||
)
|
||||
-
|
||||
-fstring = f"We have to remember to escape {braces}. Like {{these}}. But not {this}."
|
||||
|
||||
-fstring = f"We have to remember to escape {braces}. Like {{these}}. But not {this}."
|
||||
-
|
||||
|
||||
class A:
|
||||
@@ -364,10 +354,7 @@
|
||||
class B:
|
||||
@@ -364,11 +354,8 @@
|
||||
def foo():
|
||||
if not hasattr(module, name):
|
||||
raise ValueError(
|
||||
@@ -885,10 +886,12 @@ s = f'Lorem Ipsum is simply dummy text of the printing and typesetting industry:
|
||||
- " serialize things like inner classes. Please move the object into"
|
||||
- " the main module body to use migrations.\nFor more information,"
|
||||
- " see https://docs.djangoproject.com/en/%s/topics/migrations/#serializing-values"
|
||||
- % (name, module_name, get_docs_version())
|
||||
+ "Could not find object %s in %s.\nPlease note that you cannot serialize things like inner classes. Please move the object into the main module body to use migrations.\nFor more information, see https://docs.djangoproject.com/en/%s/topics/migrations/#serializing-values"
|
||||
% (name, module_name, get_docs_version())
|
||||
+ % (name, module_name, get_docs_version())
|
||||
)
|
||||
|
||||
|
||||
@@ -382,23 +369,19 @@
|
||||
|
||||
class Step(StepBase):
|
||||
@@ -927,10 +930,19 @@ s = f'Lorem Ipsum is simply dummy text of the printing and typesetting industry:
|
||||
- r"for pid in $(ps aux | grep paster | grep -v grep | grep '\-%d' | awk"
|
||||
- r" '{print $2}'); do kill $pid; done" % (i)
|
||||
+ r"for pid in $(ps aux | grep paster | grep -v grep | grep '\-%d' | awk '{print $2}'); do kill $pid; done"
|
||||
+ % (i)
|
||||
+ % (i)
|
||||
)
|
||||
|
||||
|
||||
@@ -423,7 +406,7 @@
|
||||
def G():
|
||||
assert (
|
||||
c_float(val[0][0] / val[0][1]).value
|
||||
- == c_float(value[0][0] / value[0][1]).value
|
||||
+ == c_float(value[0][0] / value[0][1]).value
|
||||
), "%s didn't roundtrip" % tag
|
||||
|
||||
|
||||
@@ -432,9 +415,7 @@
|
||||
assert xxxxxxx_xxxx in [
|
||||
x.xxxxx.xxxxxx.xxxxx.xxxxxx,
|
||||
@@ -1036,14 +1048,14 @@ s = f'Lorem Ipsum is simply dummy text of the printing and typesetting industry:
|
||||
- in "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', 'grykangaroo$',"
|
||||
- " 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', 'o$', 'oo$', 'roo$', 'rykangaroo$',"
|
||||
- " 'ykangaroo$']"
|
||||
+ in "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', 'grykangaroo$', 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', 'o$', 'oo$', 'roo$', 'rykangaroo$', 'ykangaroo$']"
|
||||
+ in "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', 'grykangaroo$', 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', 'o$', 'oo$', 'roo$', 'rykangaroo$', 'ykangaroo$']"
|
||||
)
|
||||
assert (
|
||||
str(suffix_arr)
|
||||
- not in "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', 'grykangaroo$',"
|
||||
- " 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', 'o$', 'oo$', 'roo$',"
|
||||
- " 'rykangaroo$', 'ykangaroo$']"
|
||||
+ not in "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', 'grykangaroo$', 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', 'o$', 'oo$', 'roo$', 'rykangaroo$', 'ykangaroo$']"
|
||||
+ not in "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', 'grykangaroo$', 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', 'o$', 'oo$', 'roo$', 'rykangaroo$', 'ykangaroo$']"
|
||||
)
|
||||
message = (
|
||||
f"1. Go to Google Developers Console and log in with your Google account."
|
||||
@@ -1323,14 +1335,14 @@ func_call_where_string_arg_has_method_call_and_bad_parens(
|
||||
func_call_where_string_arg_has_old_fmt_and_bad_parens(
|
||||
(
|
||||
"A long string with {}. This string is so long that it is ridiculous. It can't fit on one line at alllll."
|
||||
% "formatting"
|
||||
% "formatting"
|
||||
),
|
||||
)
|
||||
|
||||
func_call_where_string_arg_has_old_fmt_and_bad_parens(
|
||||
(
|
||||
"A long string with {}. This {} is so long that it is ridiculous. It can't fit on one line at alllll."
|
||||
% ("formatting", "string")
|
||||
% ("formatting", "string")
|
||||
),
|
||||
)
|
||||
|
||||
@@ -1341,17 +1353,17 @@ class A:
|
||||
xxxx.xxxxxxx.xxxxx(
|
||||
(
|
||||
"xxxxxxxxxx xxxx xx xxxxxx(%x) xx %x xxxx xx xxx %x.xx"
|
||||
% (len(self) + 1, xxxx.xxxxxxxxxx, xxxx.xxxxxxxxxx)
|
||||
% (len(self) + 1, xxxx.xxxxxxxxxx, xxxx.xxxxxxxxxx)
|
||||
)
|
||||
+ (
|
||||
" %.3f (%s) to %.3f (%s).\n"
|
||||
% (
|
||||
xxxx.xxxxxxxxx,
|
||||
xxxx.xxxxxxxxxxxxxx(xxxx.xxxxxxxxx),
|
||||
x,
|
||||
xxxx.xxxxxxxxxxxxxx(xx),
|
||||
+ (
|
||||
" %.3f (%s) to %.3f (%s).\n"
|
||||
% (
|
||||
xxxx.xxxxxxxxx,
|
||||
xxxx.xxxxxxxxxxxxxx(xxxx.xxxxxxxxx),
|
||||
x,
|
||||
xxxx.xxxxxxxxxxxxxx(xx),
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -1401,9 +1413,9 @@ class A:
|
||||
if True:
|
||||
xxxxx_xxxxxxxxxxxx(
|
||||
"xxx xxxxxx xxx xxxxxxxxx.xx xx xxxxxxxx. xxx xxxxxxxxxxxxx.xx xxxxxxx "
|
||||
+ "xx xxxxxx xxxxxx xxxxxx xx xxxxxxx xxx xxx ${0} xx x xxxxxxxx xxxxx".xxxxxx(
|
||||
xxxxxx_xxxxxx_xxx
|
||||
)
|
||||
+ "xx xxxxxx xxxxxx xxxxxx xx xxxxxxx xxx xxx ${0} xx x xxxxxxxx xxxxx".xxxxxx(
|
||||
xxxxxx_xxxxxx_xxx
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -1554,7 +1566,7 @@ class A:
|
||||
if not hasattr(module, name):
|
||||
raise ValueError(
|
||||
"Could not find object %s in %s.\nPlease note that you cannot serialize things like inner classes. Please move the object into the main module body to use migrations.\nFor more information, see https://docs.djangoproject.com/en/%s/topics/migrations/#serializing-values"
|
||||
% (name, module_name, get_docs_version())
|
||||
% (name, module_name, get_docs_version())
|
||||
)
|
||||
|
||||
|
||||
@@ -1592,7 +1604,7 @@ if __name__ == "__main__":
|
||||
for i in range(4, 8):
|
||||
cmd = (
|
||||
r"for pid in $(ps aux | grep paster | grep -v grep | grep '\-%d' | awk '{print $2}'); do kill $pid; done"
|
||||
% (i)
|
||||
% (i)
|
||||
)
|
||||
|
||||
|
||||
@@ -1605,7 +1617,7 @@ def A():
|
||||
def G():
|
||||
assert (
|
||||
c_float(val[0][0] / val[0][1]).value
|
||||
== c_float(value[0][0] / value[0][1]).value
|
||||
== c_float(value[0][0] / value[0][1]).value
|
||||
), "%s didn't roundtrip" % tag
|
||||
|
||||
|
||||
@@ -1725,11 +1737,11 @@ assert str(suffix_arr) > (
|
||||
)
|
||||
assert (
|
||||
str(suffix_arr)
|
||||
in "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', 'grykangaroo$', 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', 'o$', 'oo$', 'roo$', 'rykangaroo$', 'ykangaroo$']"
|
||||
in "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', 'grykangaroo$', 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', 'o$', 'oo$', 'roo$', 'rykangaroo$', 'ykangaroo$']"
|
||||
)
|
||||
assert (
|
||||
str(suffix_arr)
|
||||
not in "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', 'grykangaroo$', 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', 'o$', 'oo$', 'roo$', 'rykangaroo$', 'ykangaroo$']"
|
||||
not in "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', 'grykangaroo$', 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', 'o$', 'oo$', 'roo$', 'rykangaroo$', 'ykangaroo$']"
|
||||
)
|
||||
message = (
|
||||
f"1. Go to Google Developers Console and log in with your Google account."
|
||||
|
||||
@@ -201,7 +201,7 @@ this_will_also_become_one_line = ( # comment
|
||||
+ textwrap.dedent(
|
||||
+ """dove
|
||||
+ coo"""
|
||||
+ % "cowabunga"
|
||||
+ % "cowabunga"
|
||||
+ ),
|
||||
)
|
||||
call(
|
||||
@@ -212,7 +212,7 @@ this_will_also_become_one_line = ( # comment
|
||||
+ textwrap.dedent(
|
||||
+ """dove
|
||||
+coo"""
|
||||
+ % "cowabunga"
|
||||
+ % "cowabunga"
|
||||
+ ),
|
||||
)
|
||||
call(
|
||||
@@ -222,7 +222,7 @@ this_will_also_become_one_line = ( # comment
|
||||
+ textwrap.dedent(
|
||||
+ """cow
|
||||
+ moo"""
|
||||
+ % "cowabunga"
|
||||
+ % "cowabunga"
|
||||
+ ),
|
||||
"dogsay",
|
||||
)
|
||||
@@ -234,7 +234,7 @@ this_will_also_become_one_line = ( # comment
|
||||
+ textwrap.dedent(
|
||||
+ """crow
|
||||
+ caw"""
|
||||
+ % "cowabunga"
|
||||
+ % "cowabunga"
|
||||
+ ),
|
||||
)
|
||||
call(
|
||||
@@ -244,7 +244,7 @@ this_will_also_become_one_line = ( # comment
|
||||
+ textwrap.dedent(
|
||||
+ """cat
|
||||
+ meow"""
|
||||
+ % "cowabunga"
|
||||
+ % "cowabunga"
|
||||
+ ),
|
||||
{"dog", "say"},
|
||||
)
|
||||
@@ -256,7 +256,7 @@ this_will_also_become_one_line = ( # comment
|
||||
+ textwrap.dedent(
|
||||
+ """horse
|
||||
+ neigh"""
|
||||
+ % "cowabunga"
|
||||
+ % "cowabunga"
|
||||
+ ),
|
||||
)
|
||||
call(
|
||||
@@ -267,7 +267,7 @@ this_will_also_become_one_line = ( # comment
|
||||
+ textwrap.dedent(
|
||||
+ """pig
|
||||
+ oink"""
|
||||
+ % "cowabunga"
|
||||
+ % "cowabunga"
|
||||
+ ),
|
||||
)
|
||||
textwrap.dedent("""A one-line triple-quoted string.""")
|
||||
@@ -391,7 +391,7 @@ call(
|
||||
textwrap.dedent(
|
||||
"""dove
|
||||
coo"""
|
||||
% "cowabunga"
|
||||
% "cowabunga"
|
||||
),
|
||||
)
|
||||
call(
|
||||
@@ -400,7 +400,7 @@ call(
|
||||
textwrap.dedent(
|
||||
"""dove
|
||||
coo"""
|
||||
% "cowabunga"
|
||||
% "cowabunga"
|
||||
),
|
||||
)
|
||||
call(
|
||||
@@ -408,7 +408,7 @@ call(
|
||||
textwrap.dedent(
|
||||
"""cow
|
||||
moo"""
|
||||
% "cowabunga"
|
||||
% "cowabunga"
|
||||
),
|
||||
"dogsay",
|
||||
)
|
||||
@@ -418,7 +418,7 @@ call(
|
||||
textwrap.dedent(
|
||||
"""crow
|
||||
caw"""
|
||||
% "cowabunga"
|
||||
% "cowabunga"
|
||||
),
|
||||
)
|
||||
call(
|
||||
@@ -426,7 +426,7 @@ call(
|
||||
textwrap.dedent(
|
||||
"""cat
|
||||
meow"""
|
||||
% "cowabunga"
|
||||
% "cowabunga"
|
||||
),
|
||||
{"dog", "say"},
|
||||
)
|
||||
@@ -436,7 +436,7 @@ call(
|
||||
textwrap.dedent(
|
||||
"""horse
|
||||
neigh"""
|
||||
% "cowabunga"
|
||||
% "cowabunga"
|
||||
),
|
||||
)
|
||||
call(
|
||||
@@ -445,7 +445,7 @@ call(
|
||||
textwrap.dedent(
|
||||
"""pig
|
||||
oink"""
|
||||
% "cowabunga"
|
||||
% "cowabunga"
|
||||
),
|
||||
)
|
||||
textwrap.dedent("""A one-line triple-quoted string.""")
|
||||
|
||||
@@ -0,0 +1,354 @@
|
||||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/black/cases/preview_power_op_spacing.py
|
||||
---
|
||||
## Input
|
||||
|
||||
```python
|
||||
a = 1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1
|
||||
b = 1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1
|
||||
c = 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1
|
||||
d = 1**1 ** 1**1 ** 1**1 ** 1**1 ** 1**1**1 ** 1 ** 1**1 ** 1**1**1**1**1 ** 1 ** 1**1**1 **1**1** 1 ** 1 ** 1
|
||||
e = 𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟
|
||||
f = 𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟
|
||||
|
||||
a = 1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0
|
||||
b = 1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0
|
||||
c = 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0
|
||||
d = 1.0**1.0 ** 1.0**1.0 ** 1.0**1.0 ** 1.0**1.0 ** 1.0**1.0**1.0 ** 1.0 ** 1.0**1.0 ** 1.0**1.0**1.0
|
||||
```
|
||||
|
||||
## Black Differences
|
||||
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -1,83 +1,83 @@
|
||||
a = 1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1
|
||||
b = (
|
||||
1
|
||||
- ** 1
|
||||
- ** 1
|
||||
- ** 1
|
||||
- ** 1
|
||||
- ** 1
|
||||
- ** 1
|
||||
- ** 1
|
||||
- ** 1
|
||||
- ** 1
|
||||
- ** 1
|
||||
- ** 1
|
||||
- ** 1
|
||||
- ** 1
|
||||
- ** 1
|
||||
- ** 1
|
||||
- ** 1
|
||||
- ** 1
|
||||
- ** 1
|
||||
- ** 1
|
||||
- ** 1
|
||||
- ** 1
|
||||
- ** 1
|
||||
- ** 1
|
||||
- ** 1
|
||||
- ** 1
|
||||
- ** 1
|
||||
- ** 1
|
||||
- ** 1
|
||||
+ ** 1
|
||||
+ ** 1
|
||||
+ ** 1
|
||||
+ ** 1
|
||||
+ ** 1
|
||||
+ ** 1
|
||||
+ ** 1
|
||||
+ ** 1
|
||||
+ ** 1
|
||||
+ ** 1
|
||||
+ ** 1
|
||||
+ ** 1
|
||||
+ ** 1
|
||||
+ ** 1
|
||||
+ ** 1
|
||||
+ ** 1
|
||||
+ ** 1
|
||||
+ ** 1
|
||||
+ ** 1
|
||||
+ ** 1
|
||||
+ ** 1
|
||||
+ ** 1
|
||||
+ ** 1
|
||||
+ ** 1
|
||||
+ ** 1
|
||||
+ ** 1
|
||||
+ ** 1
|
||||
+ ** 1
|
||||
)
|
||||
c = 1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1
|
||||
d = 1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1
|
||||
e = 𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟
|
||||
f = (
|
||||
𨉟
|
||||
- ** 𨉟
|
||||
- ** 𨉟
|
||||
- ** 𨉟
|
||||
- ** 𨉟
|
||||
- ** 𨉟
|
||||
- ** 𨉟
|
||||
- ** 𨉟
|
||||
- ** 𨉟
|
||||
- ** 𨉟
|
||||
- ** 𨉟
|
||||
- ** 𨉟
|
||||
- ** 𨉟
|
||||
- ** 𨉟
|
||||
- ** 𨉟
|
||||
- ** 𨉟
|
||||
- ** 𨉟
|
||||
- ** 𨉟
|
||||
- ** 𨉟
|
||||
- ** 𨉟
|
||||
- ** 𨉟
|
||||
- ** 𨉟
|
||||
+ ** 𨉟
|
||||
+ ** 𨉟
|
||||
+ ** 𨉟
|
||||
+ ** 𨉟
|
||||
+ ** 𨉟
|
||||
+ ** 𨉟
|
||||
+ ** 𨉟
|
||||
+ ** 𨉟
|
||||
+ ** 𨉟
|
||||
+ ** 𨉟
|
||||
+ ** 𨉟
|
||||
+ ** 𨉟
|
||||
+ ** 𨉟
|
||||
+ ** 𨉟
|
||||
+ ** 𨉟
|
||||
+ ** 𨉟
|
||||
+ ** 𨉟
|
||||
+ ** 𨉟
|
||||
+ ** 𨉟
|
||||
+ ** 𨉟
|
||||
+ ** 𨉟
|
||||
)
|
||||
|
||||
a = 1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0
|
||||
b = (
|
||||
1.0
|
||||
- ** 1.0
|
||||
- ** 1.0
|
||||
- ** 1.0
|
||||
- ** 1.0
|
||||
- ** 1.0
|
||||
- ** 1.0
|
||||
- ** 1.0
|
||||
- ** 1.0
|
||||
- ** 1.0
|
||||
- ** 1.0
|
||||
- ** 1.0
|
||||
- ** 1.0
|
||||
- ** 1.0
|
||||
- ** 1.0
|
||||
- ** 1.0
|
||||
- ** 1.0
|
||||
- ** 1.0
|
||||
+ ** 1.0
|
||||
+ ** 1.0
|
||||
+ ** 1.0
|
||||
+ ** 1.0
|
||||
+ ** 1.0
|
||||
+ ** 1.0
|
||||
+ ** 1.0
|
||||
+ ** 1.0
|
||||
+ ** 1.0
|
||||
+ ** 1.0
|
||||
+ ** 1.0
|
||||
+ ** 1.0
|
||||
+ ** 1.0
|
||||
+ ** 1.0
|
||||
+ ** 1.0
|
||||
+ ** 1.0
|
||||
+ ** 1.0
|
||||
)
|
||||
c = 1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0
|
||||
d = 1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
|
||||
```python
|
||||
a = 1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1
|
||||
b = (
|
||||
1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
)
|
||||
c = 1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1
|
||||
d = 1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1
|
||||
e = 𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟
|
||||
f = (
|
||||
𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
)
|
||||
|
||||
a = 1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0
|
||||
b = (
|
||||
1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
)
|
||||
c = 1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0
|
||||
d = 1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
||||
```python
|
||||
a = 1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1
|
||||
b = (
|
||||
1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
)
|
||||
c = 1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1
|
||||
d = 1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1
|
||||
e = 𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟
|
||||
f = (
|
||||
𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
)
|
||||
|
||||
a = 1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0
|
||||
b = (
|
||||
1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
)
|
||||
c = 1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0
|
||||
d = 1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0
|
||||
```
|
||||
|
||||
|
||||
@@ -129,6 +129,15 @@ a = (
|
||||
|
||||
some_kind_of_table[
|
||||
some_key # type: ignore # noqa: E501
|
||||
@@ -79,7 +77,7 @@
|
||||
# Right side of assignment contains un-nested pairs of inner parens.
|
||||
some_kind_of_instance.some_kind_of_map[a_key] = (
|
||||
isinstance(some_var, SomeClass)
|
||||
- and table.something_and_something != table.something_else
|
||||
+ and table.something_and_something != table.something_else
|
||||
) or (
|
||||
isinstance(some_other_var, BaseClass) and table.something != table.some_other_thing
|
||||
)
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
@@ -213,7 +222,7 @@ xxxxxxxxx_yyy_zzzzzzzz[
|
||||
# Right side of assignment contains un-nested pairs of inner parens.
|
||||
some_kind_of_instance.some_kind_of_map[a_key] = (
|
||||
isinstance(some_var, SomeClass)
|
||||
and table.something_and_something != table.something_else
|
||||
and table.something_and_something != table.something_else
|
||||
) or (
|
||||
isinstance(some_other_var, BaseClass) and table.something != table.some_other_thing
|
||||
)
|
||||
|
||||
@@ -127,6 +127,24 @@ def foo(a,b) -> tuple[int, int, int,]:
|
||||
return 2 * a
|
||||
|
||||
|
||||
@@ -45,7 +53,7 @@
|
||||
|
||||
def foo() -> (
|
||||
intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds
|
||||
- | intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds
|
||||
+ | intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds
|
||||
):
|
||||
return 2
|
||||
|
||||
@@ -64,7 +72,7 @@
|
||||
c: int,
|
||||
) -> (
|
||||
intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds
|
||||
- | intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds
|
||||
+ | intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds
|
||||
):
|
||||
return 2
|
||||
|
||||
@@ -124,5 +132,9 @@
|
||||
# this is broken - the trailing comma is transferred to the param list. Fixed in preview
|
||||
def foo(
|
||||
@@ -198,7 +216,7 @@ def foo() -> (
|
||||
|
||||
def foo() -> (
|
||||
intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds
|
||||
| intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds
|
||||
| intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds
|
||||
):
|
||||
return 2
|
||||
|
||||
@@ -217,7 +235,7 @@ def foo(
|
||||
c: int,
|
||||
) -> (
|
||||
intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds
|
||||
| intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds
|
||||
| intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds
|
||||
):
|
||||
return 2
|
||||
|
||||
|
||||
@@ -41,12 +41,14 @@ assert (
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -2,7 +2,7 @@
|
||||
@@ -1,8 +1,8 @@
|
||||
importA
|
||||
(
|
||||
()
|
||||
<< 0
|
||||
- << 0
|
||||
- ** 101234234242352525425252352352525234890264906820496920680926538059059209922523523525
|
||||
+ **101234234242352525425252352352525234890264906820496920680926538059059209922523523525
|
||||
+ << 0
|
||||
+ **101234234242352525425252352352525234890264906820496920680926538059059209922523523525
|
||||
) #
|
||||
|
||||
assert sort_by_dependency(
|
||||
@@ -70,8 +72,8 @@ assert (
|
||||
importA
|
||||
(
|
||||
()
|
||||
<< 0
|
||||
**101234234242352525425252352352525234890264906820496920680926538059059209922523523525
|
||||
<< 0
|
||||
**101234234242352525425252352352525234890264906820496920680926538059059209922523523525
|
||||
) #
|
||||
|
||||
assert sort_by_dependency(
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/black/cases/trailing_comma_optional_parens1.py
|
||||
---
|
||||
## Input
|
||||
|
||||
```python
|
||||
if e1234123412341234.winerror not in (_winapi.ERROR_SEM_TIMEOUT,
|
||||
_winapi.ERROR_PIPE_BUSY) or _check_timeout(t):
|
||||
pass
|
||||
|
||||
if x:
|
||||
if y:
|
||||
new_id = max(Vegetable.objects.order_by('-id')[0].id,
|
||||
Mineral.objects.order_by('-id')[0].id) + 1
|
||||
|
||||
class X:
|
||||
def get_help_text(self):
|
||||
return ngettext(
|
||||
"Your password must contain at least %(min_length)d character.",
|
||||
"Your password must contain at least %(min_length)d characters.",
|
||||
self.min_length,
|
||||
) % {'min_length': self.min_length}
|
||||
|
||||
class A:
|
||||
def b(self):
|
||||
if self.connection.mysql_is_mariadb and (
|
||||
10,
|
||||
4,
|
||||
3,
|
||||
) < self.connection.mysql_version < (10, 5, 2):
|
||||
pass
|
||||
```
|
||||
|
||||
## Black Differences
|
||||
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -11,7 +11,7 @@
|
||||
Vegetable.objects.order_by("-id")[0].id,
|
||||
Mineral.objects.order_by("-id")[0].id,
|
||||
)
|
||||
- + 1
|
||||
+ + 1
|
||||
)
|
||||
|
||||
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
|
||||
```python
|
||||
if e1234123412341234.winerror not in (
|
||||
_winapi.ERROR_SEM_TIMEOUT,
|
||||
_winapi.ERROR_PIPE_BUSY,
|
||||
) or _check_timeout(t):
|
||||
pass
|
||||
|
||||
if x:
|
||||
if y:
|
||||
new_id = (
|
||||
max(
|
||||
Vegetable.objects.order_by("-id")[0].id,
|
||||
Mineral.objects.order_by("-id")[0].id,
|
||||
)
|
||||
+ 1
|
||||
)
|
||||
|
||||
|
||||
class X:
|
||||
def get_help_text(self):
|
||||
return ngettext(
|
||||
"Your password must contain at least %(min_length)d character.",
|
||||
"Your password must contain at least %(min_length)d characters.",
|
||||
self.min_length,
|
||||
) % {"min_length": self.min_length}
|
||||
|
||||
|
||||
class A:
|
||||
def b(self):
|
||||
if self.connection.mysql_is_mariadb and (
|
||||
10,
|
||||
4,
|
||||
3,
|
||||
) < self.connection.mysql_version < (10, 5, 2):
|
||||
pass
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
||||
```python
|
||||
if e1234123412341234.winerror not in (
|
||||
_winapi.ERROR_SEM_TIMEOUT,
|
||||
_winapi.ERROR_PIPE_BUSY,
|
||||
) or _check_timeout(t):
|
||||
pass
|
||||
|
||||
if x:
|
||||
if y:
|
||||
new_id = (
|
||||
max(
|
||||
Vegetable.objects.order_by("-id")[0].id,
|
||||
Mineral.objects.order_by("-id")[0].id,
|
||||
)
|
||||
+ 1
|
||||
)
|
||||
|
||||
|
||||
class X:
|
||||
def get_help_text(self):
|
||||
return ngettext(
|
||||
"Your password must contain at least %(min_length)d character.",
|
||||
"Your password must contain at least %(min_length)d characters.",
|
||||
self.min_length,
|
||||
) % {"min_length": self.min_length}
|
||||
|
||||
|
||||
class A:
|
||||
def b(self):
|
||||
if self.connection.mysql_is_mariadb and (
|
||||
10,
|
||||
4,
|
||||
3,
|
||||
) < self.connection.mysql_version < (10, 5, 2):
|
||||
pass
|
||||
```
|
||||
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/black/cases/trailing_comma_optional_parens3.py
|
||||
---
|
||||
## Input
|
||||
|
||||
```python
|
||||
if True:
|
||||
if True:
|
||||
if True:
|
||||
return _(
|
||||
"qweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweas "
|
||||
+ "qweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqwegqweasdzxcqweasdzxc.",
|
||||
"qweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqwe",
|
||||
) % {"reported_username": reported_username, "report_reason": report_reason}
|
||||
```
|
||||
|
||||
## Black Differences
|
||||
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -3,6 +3,6 @@
|
||||
if True:
|
||||
return _(
|
||||
"qweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweas "
|
||||
- + "qweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqwegqweasdzxcqweasdzxc.",
|
||||
+ + "qweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqwegqweasdzxcqweasdzxc.",
|
||||
"qweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqwe",
|
||||
) % {"reported_username": reported_username, "report_reason": report_reason}
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
|
||||
```python
|
||||
if True:
|
||||
if True:
|
||||
if True:
|
||||
return _(
|
||||
"qweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweas "
|
||||
+ "qweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqwegqweasdzxcqweasdzxc.",
|
||||
"qweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqwe",
|
||||
) % {"reported_username": reported_username, "report_reason": report_reason}
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
||||
```python
|
||||
if True:
|
||||
if True:
|
||||
if True:
|
||||
return _(
|
||||
"qweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweas "
|
||||
+ "qweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqwegqweasdzxcqweasdzxc.",
|
||||
"qweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqwe",
|
||||
) % {"reported_username": reported_username, "report_reason": report_reason}
|
||||
```
|
||||
|
||||
|
||||
@@ -56,7 +56,12 @@ assert xxxxxxxxx.xxxxxxxxx.xxxxxxxxx(
|
||||
|
||||
|
||||
# Example from https://github.com/psf/black/issues/3229
|
||||
@@ -43,8 +41,6 @@
|
||||
@@ -39,12 +37,10 @@
|
||||
# https://github.com/psf/black/pull/3370 causes an infinite recursion.
|
||||
assert (
|
||||
long_module.long_class.long_func().another_func()
|
||||
- == long_module.long_class.long_func()["some_key"].another_func(arg1)
|
||||
+ == long_module.long_class.long_func()["some_key"].another_func(arg1)
|
||||
)
|
||||
|
||||
# Regression test for https://github.com/psf/black/issues/3414.
|
||||
@@ -112,7 +117,7 @@ def refresh_token(self, device_family, refresh_token, api_key):
|
||||
# https://github.com/psf/black/pull/3370 causes an infinite recursion.
|
||||
assert (
|
||||
long_module.long_class.long_func().another_func()
|
||||
== long_module.long_class.long_func()["some_key"].another_func(arg1)
|
||||
== long_module.long_class.long_func()["some_key"].another_func(arg1)
|
||||
)
|
||||
|
||||
# Regression test for https://github.com/psf/black/issues/3414.
|
||||
|
||||
@@ -292,7 +292,7 @@ x6 = (
|
||||
# Regression test for: https://github.com/astral-sh/ruff/issues/7370
|
||||
result = (
|
||||
f(111111111111111111111111111111111111111111111111111111111111111111111111111111111)
|
||||
+ 1
|
||||
+ 1
|
||||
).bit_length()
|
||||
```
|
||||
|
||||
|
||||
@@ -78,20 +78,20 @@ result = await self.request(
|
||||
|
||||
result = await (
|
||||
1
|
||||
+ f(
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
)
|
||||
+ f(
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
)
|
||||
)
|
||||
|
||||
result = await (
|
||||
1
|
||||
+ f(
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
)
|
||||
+ f(
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
)
|
||||
)
|
||||
|
||||
# Optional parentheses.
|
||||
|
||||
@@ -430,28 +430,28 @@ if True:
|
||||
```python
|
||||
(
|
||||
aaaaaaaa
|
||||
+ # trailing operator comment
|
||||
b # trailing right comment
|
||||
+ # trailing operator comment
|
||||
b # trailing right comment
|
||||
)
|
||||
|
||||
|
||||
(
|
||||
aaaaaaaa # trailing left comment
|
||||
+ # trailing operator comment
|
||||
# leading right comment
|
||||
b
|
||||
+ # trailing operator comment
|
||||
# leading right comment
|
||||
b
|
||||
)
|
||||
|
||||
(
|
||||
# leading left most comment
|
||||
aaaaaaaa
|
||||
+ # trailing operator comment
|
||||
# leading b comment
|
||||
b # trailing b comment
|
||||
# trailing b ownline comment
|
||||
+ # trailing second operator comment
|
||||
# leading c comment
|
||||
c # trailing c comment
|
||||
+ # trailing operator comment
|
||||
# leading b comment
|
||||
b # trailing b comment
|
||||
# trailing b ownline comment
|
||||
+ # trailing second operator comment
|
||||
# leading c comment
|
||||
c # trailing c comment
|
||||
# trailing own line comment
|
||||
)
|
||||
|
||||
@@ -497,21 +497,24 @@ aaaaaaaaaaaaaa + {
|
||||
# Wraps it in parentheses if it needs to break both left and right
|
||||
(
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ [bbbbbbbbbbbbbbbbbbbbbb, ccccccccccccccccccccc, dddddddddddddddd, eee]
|
||||
+ [bbbbbbbbbbbbbbbbbbbbbb, ccccccccccccccccccccc, dddddddddddddddd, eee]
|
||||
) # comment
|
||||
|
||||
|
||||
# But only for expressions that have a statement parent.
|
||||
not (
|
||||
aaaaaaaaaaaaaa
|
||||
+ {a for x in bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb}
|
||||
+ {
|
||||
a
|
||||
for x in bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
}
|
||||
)
|
||||
[
|
||||
a
|
||||
+ [
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
]
|
||||
in c
|
||||
+ [
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
]
|
||||
in c
|
||||
]
|
||||
|
||||
|
||||
@@ -524,13 +527,13 @@ not (
|
||||
|
||||
if (
|
||||
aaaaaaaaaaaaaaaaaa
|
||||
+
|
||||
# has the child process finished?
|
||||
bbbbbbbbbbbbbbb
|
||||
+
|
||||
# the child process has finished, but the
|
||||
# transport hasn't been notified yet?
|
||||
ccccccccccc
|
||||
+
|
||||
# has the child process finished?
|
||||
bbbbbbbbbbbbbbb
|
||||
+
|
||||
# the child process has finished, but the
|
||||
# transport hasn't been notified yet?
|
||||
ccccccccccc
|
||||
):
|
||||
pass
|
||||
|
||||
@@ -553,7 +556,7 @@ if (
|
||||
dddddddddddddddddddd,
|
||||
eeeeeeeeee,
|
||||
]
|
||||
& aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
& aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
):
|
||||
pass
|
||||
|
||||
@@ -569,13 +572,13 @@ if aaaaaaaaaaaaaaaaaaaaaaaaaa & [
|
||||
|
||||
if (
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
& [
|
||||
aaaaaaaaaaaaa,
|
||||
bbbbbbbbbbbbbbbbbbbb,
|
||||
cccccccccccccccccccc,
|
||||
dddddddddddddddddddd,
|
||||
eeeeeeeeee,
|
||||
]
|
||||
& [
|
||||
aaaaaaaaaaaaa,
|
||||
bbbbbbbbbbbbbbbbbbbb,
|
||||
cccccccccccccccccccc,
|
||||
dddddddddddddddddddd,
|
||||
eeeeeeeeee,
|
||||
]
|
||||
):
|
||||
pass
|
||||
|
||||
@@ -674,9 +677,9 @@ if (
|
||||
iiiiiiiiiiiiiiii,
|
||||
jjjjjjjjjjjjj,
|
||||
]
|
||||
&
|
||||
# comment
|
||||
a + b
|
||||
&
|
||||
# comment
|
||||
a + b
|
||||
):
|
||||
pass
|
||||
|
||||
@@ -693,14 +696,14 @@ for user_id in set(target_user_ids) - {u.user_id for u in updates}:
|
||||
# Keeps parenthesized left hand sides
|
||||
(
|
||||
log(self.price / self.strike)
|
||||
+ (self.risk_free - self.div_cont + 0.5 * (self.sigma**2)) * self.exp_time
|
||||
+ (self.risk_free - self.div_cont + 0.5 * (self.sigma**2)) * self.exp_time
|
||||
) / self.sigmaT
|
||||
|
||||
# Stability with end-of-line comments between empty tuples and bin op
|
||||
x = (
|
||||
()
|
||||
- ( #
|
||||
)
|
||||
- ( #
|
||||
)
|
||||
)
|
||||
x = (
|
||||
() - () #
|
||||
@@ -729,10 +732,10 @@ expected_content = (
|
||||
</sitemapindex>
|
||||
"""
|
||||
# Needs parentheses
|
||||
% (
|
||||
self.base_url,
|
||||
date.today(),
|
||||
)
|
||||
% (
|
||||
self.base_url,
|
||||
date.today(),
|
||||
)
|
||||
)
|
||||
|
||||
expected_content = (
|
||||
@@ -742,12 +745,12 @@ expected_content = (
|
||||
</sitemap>
|
||||
</sitemapindex>
|
||||
"""
|
||||
%
|
||||
# Needs parentheses
|
||||
(
|
||||
self.base_url,
|
||||
date.today(),
|
||||
)
|
||||
%
|
||||
# Needs parentheses
|
||||
(
|
||||
self.base_url,
|
||||
date.today(),
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -768,8 +771,8 @@ expected_content = (
|
||||
</sitemap>
|
||||
</sitemapindex>
|
||||
"""
|
||||
+ sssssssssssssssssssssssssssssssssssssssssooooo
|
||||
* looooooooooooooooooooooooooooooongggggggggggg
|
||||
+ sssssssssssssssssssssssssssssssssssssssssooooo
|
||||
* looooooooooooooooooooooooooooooongggggggggggg
|
||||
)
|
||||
|
||||
call(
|
||||
@@ -796,10 +799,10 @@ expected_content = (
|
||||
</sitemap>
|
||||
</sitemapindex>
|
||||
"""
|
||||
% (
|
||||
# Needs parentheses
|
||||
self.base_url
|
||||
)
|
||||
% (
|
||||
# Needs parentheses
|
||||
self.base_url
|
||||
)
|
||||
)
|
||||
|
||||
# Skip FString content when determining whether to omit optional parentheses or not.0
|
||||
@@ -807,7 +810,7 @@ expected_content = (
|
||||
# (Call expressions at the beginning don't count as parenthesized because they don't start with parens).
|
||||
assert (
|
||||
format.format_event(spec)
|
||||
== f'Event("_remove_cookie", {{key:`testkey`,options:{json.dumps(options)}}})'
|
||||
== f'Event("_remove_cookie", {{key:`testkey`,options:{json.dumps(options)}}})'
|
||||
)
|
||||
# Avoid parentheses for this example because it starts with a tuple expression.
|
||||
assert (
|
||||
@@ -817,62 +820,62 @@ assert (
|
||||
|
||||
rowuses = [
|
||||
(1 << j) # column ordinal
|
||||
| (1 << (n + i - j + n - 1)) # NW-SE ordinal
|
||||
| (1 << (n + 2 * n - 1 + i + j)) # NE-SW ordinal
|
||||
| (1 << (n + i - j + n - 1)) # NW-SE ordinal
|
||||
| (1 << (n + 2 * n - 1 + i + j)) # NE-SW ordinal
|
||||
for j in rangen
|
||||
]
|
||||
|
||||
rowuses = [
|
||||
(1 << j) # column ordinal
|
||||
|
|
||||
# comment
|
||||
(1 << (n + i - j + n - 1)) # NW-SE ordinal
|
||||
| (1 << (n + 2 * n - 1 + i + j)) # NE-SW ordinal
|
||||
|
|
||||
# comment
|
||||
(1 << (n + i - j + n - 1)) # NW-SE ordinal
|
||||
| (1 << (n + 2 * n - 1 + i + j)) # NE-SW ordinal
|
||||
for j in rangen
|
||||
]
|
||||
|
||||
skip_bytes = (
|
||||
header.timecnt * 5 # Transition times and types
|
||||
+ header.typecnt * 6 # Local time type records
|
||||
+ header.charcnt # Time zone designations
|
||||
+ header.leapcnt * 8 # Leap second records
|
||||
+ header.isstdcnt # Standard/wall indicators
|
||||
+ header.isutcnt # UT/local indicators
|
||||
+ header.typecnt * 6 # Local time type records
|
||||
+ header.charcnt # Time zone designations
|
||||
+ header.leapcnt * 8 # Leap second records
|
||||
+ header.isstdcnt # Standard/wall indicators
|
||||
+ header.isutcnt # UT/local indicators
|
||||
)
|
||||
|
||||
|
||||
if (
|
||||
(1 + 2) # test
|
||||
or (3 + 4) # other
|
||||
or (4 + 5) # more
|
||||
or (3 + 4) # other
|
||||
or (4 + 5) # more
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
if (
|
||||
(1 and 2) # test
|
||||
+ (3 and 4) # other
|
||||
+ (4 and 5) # more
|
||||
+ (3 and 4) # other
|
||||
+ (4 and 5) # more
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
if (
|
||||
(1 + 2) # test
|
||||
< (3 + 4) # other
|
||||
> (4 + 5) # more
|
||||
< (3 + 4) # other
|
||||
> (4 + 5) # more
|
||||
):
|
||||
pass
|
||||
|
||||
z = (
|
||||
a
|
||||
+
|
||||
# a: extracts this comment
|
||||
# b: and this comment
|
||||
(
|
||||
# c: formats it as part of the expression
|
||||
x and y
|
||||
)
|
||||
+
|
||||
# a: extracts this comment
|
||||
# b: and this comment
|
||||
(
|
||||
# c: formats it as part of the expression
|
||||
x and y
|
||||
)
|
||||
)
|
||||
|
||||
z = (
|
||||
@@ -882,7 +885,7 @@ z = (
|
||||
)
|
||||
# b: extracts this comment
|
||||
# c: and this comment
|
||||
+ a
|
||||
+ a
|
||||
)
|
||||
|
||||
# Test for https://github.com/astral-sh/ruff/issues/7431
|
||||
|
||||
@@ -252,8 +252,8 @@ def test():
|
||||
),
|
||||
"post_processed": (
|
||||
collected["post_processed"]
|
||||
and ", %s post-processed" % post_processed_count
|
||||
or ""
|
||||
and ", %s post-processed" % post_processed_count
|
||||
or ""
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
@@ -198,37 +198,37 @@ if (self._proc
|
||||
if (
|
||||
self._proc
|
||||
# has the child process finished?
|
||||
and self._returncode
|
||||
# the child process has finished, but the
|
||||
# transport hasn't been notified yet?
|
||||
and self._proc.poll()
|
||||
and self._returncode
|
||||
# the child process has finished, but the
|
||||
# transport hasn't been notified yet?
|
||||
and self._proc.poll()
|
||||
):
|
||||
pass
|
||||
|
||||
if (
|
||||
self._proc
|
||||
and self._returncode
|
||||
and self._proc.poll()
|
||||
and self._proc
|
||||
and self._returncode
|
||||
and self._proc.poll()
|
||||
and self._returncode
|
||||
and self._proc.poll()
|
||||
and self._proc
|
||||
and self._returncode
|
||||
and self._proc.poll()
|
||||
):
|
||||
pass
|
||||
|
||||
if (
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
and aaaaaaaaaaaaaaaaa
|
||||
and aaaaaaaaaaaaaaaaaaaaaa
|
||||
and aaaaaaaaaaaaaaaaaaaaaaaa
|
||||
and aaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
and aaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
and aaaaaaaaaaaaaaaaa
|
||||
and aaaaaaaaaaaaaaaaaaaaaa
|
||||
and aaaaaaaaaaaaaaaaaaaaaaaa
|
||||
and aaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
and aaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
if (
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaas
|
||||
and aaaaaaaaaaaaaaaaa
|
||||
and aaaaaaaaaaaaaaaaa
|
||||
):
|
||||
pass
|
||||
|
||||
@@ -254,61 +254,61 @@ if [
|
||||
# Break right only applies for boolean operations with a left and right side
|
||||
if (
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
and bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
and ccccccccccccccccc
|
||||
and [dddddddddddddd, eeeeeeeeee, fffffffffffffff]
|
||||
and bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
and ccccccccccccccccc
|
||||
and [dddddddddddddd, eeeeeeeeee, fffffffffffffff]
|
||||
):
|
||||
pass
|
||||
|
||||
# Regression test for https://github.com/astral-sh/ruff/issues/6068
|
||||
if not (
|
||||
isinstance(aaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbb)
|
||||
or numpy
|
||||
and isinstance(ccccccccccc, dddddd)
|
||||
or numpy
|
||||
and isinstance(ccccccccccc, dddddd)
|
||||
):
|
||||
pass
|
||||
|
||||
if not (
|
||||
isinstance(aaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbb)
|
||||
and numpy
|
||||
or isinstance(ccccccccccc, dddddd)
|
||||
and numpy
|
||||
or isinstance(ccccccccccc, dddddd)
|
||||
):
|
||||
pass
|
||||
|
||||
if not (
|
||||
isinstance(aaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbb)
|
||||
or xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
+ yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
|
||||
and isinstance(ccccccccccc, dddddd)
|
||||
or xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
+ yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
|
||||
and isinstance(ccccccccccc, dddddd)
|
||||
):
|
||||
pass
|
||||
|
||||
if not (
|
||||
isinstance(aaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbb)
|
||||
and xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
+ yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
|
||||
or isinstance(ccccccccccc, dddddd)
|
||||
and xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
+ yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
|
||||
or isinstance(ccccccccccc, dddddd)
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
if not (
|
||||
isinstance(aaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbb)
|
||||
or (
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
+ yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
|
||||
)
|
||||
and isinstance(ccccccccccc, dddddd)
|
||||
or (
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
+ yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
|
||||
)
|
||||
and isinstance(ccccccccccc, dddddd)
|
||||
):
|
||||
pass
|
||||
|
||||
if not (
|
||||
isinstance(aaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbb)
|
||||
and (
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
+ yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
|
||||
)
|
||||
or isinstance(ccccccccccc, dddddd)
|
||||
and (
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
+ yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
|
||||
)
|
||||
or isinstance(ccccccccccc, dddddd)
|
||||
):
|
||||
pass
|
||||
|
||||
@@ -322,8 +322,8 @@ def test():
|
||||
if "_continue" in request.POST or (
|
||||
# Redirecting after "Save as new".
|
||||
"_saveasnew" in request.POST
|
||||
and self.save_as_continue
|
||||
and self.has_change_permission(request, obj)
|
||||
and self.save_as_continue
|
||||
and self.has_change_permission(request, obj)
|
||||
):
|
||||
pass
|
||||
|
||||
@@ -333,7 +333,7 @@ if True:
|
||||
if True:
|
||||
if (
|
||||
self.validate_max
|
||||
and self.total_form_count() - len(self.deleted_forms) > self.max_num
|
||||
and self.total_form_count() - len(self.deleted_forms) > self.max_num
|
||||
) or self.management_form.cleaned_data[
|
||||
TOTAL_FORM_COUNT
|
||||
] > self.absolute_max:
|
||||
@@ -343,15 +343,18 @@ if True:
|
||||
if True:
|
||||
if (
|
||||
reference_field_name is None
|
||||
or
|
||||
# Unspecified to_field(s).
|
||||
to_fields is None
|
||||
or
|
||||
# Reference to primary key.
|
||||
(None in to_fields and (reference_field is None or reference_field.primary_key))
|
||||
or
|
||||
# Reference to field.
|
||||
reference_field_name in to_fields
|
||||
or
|
||||
# Unspecified to_field(s).
|
||||
to_fields is None
|
||||
or
|
||||
# Reference to primary key.
|
||||
(
|
||||
None in to_fields
|
||||
and (reference_field is None or reference_field.primary_key)
|
||||
)
|
||||
or
|
||||
# Reference to field.
|
||||
reference_field_name in to_fields
|
||||
):
|
||||
pass
|
||||
|
||||
@@ -359,9 +362,9 @@ if True:
|
||||
field = opts.get_field(name)
|
||||
if (
|
||||
field.is_relation
|
||||
and
|
||||
# Generic foreign keys OR reverse relations
|
||||
((field.many_to_one and not field.related_model) or field.one_to_many)
|
||||
and
|
||||
# Generic foreign keys OR reverse relations
|
||||
((field.many_to_one and not field.related_model) or field.one_to_many)
|
||||
):
|
||||
pass
|
||||
|
||||
@@ -369,35 +372,35 @@ if (
|
||||
if True:
|
||||
return (
|
||||
filtered.exists()
|
||||
and
|
||||
# It may happen that the object is deleted from the DB right after
|
||||
# this check, causing the subsequent UPDATE to return zero matching
|
||||
# rows. The same result can occur in some rare cases when the
|
||||
# database returns zero despite the UPDATE being executed
|
||||
# successfully (a row is matched and updated). In order to
|
||||
# distinguish these two cases, the object's existence in the
|
||||
# database is again checked for if the UPDATE query returns 0.
|
||||
(filtered._update(values) > 0 or filtered.exists())
|
||||
and
|
||||
# It may happen that the object is deleted from the DB right after
|
||||
# this check, causing the subsequent UPDATE to return zero matching
|
||||
# rows. The same result can occur in some rare cases when the
|
||||
# database returns zero despite the UPDATE being executed
|
||||
# successfully (a row is matched and updated). In order to
|
||||
# distinguish these two cases, the object's existence in the
|
||||
# database is again checked for if the UPDATE query returns 0.
|
||||
(filtered._update(values) > 0 or filtered.exists())
|
||||
)
|
||||
|
||||
|
||||
if (
|
||||
self._proc is not None
|
||||
# has the child process finished?
|
||||
and self._returncode is None
|
||||
# the child process has finished, but the
|
||||
# transport hasn't been notified yet?
|
||||
and self._proc.poll() is None
|
||||
# has the child process finished?
|
||||
and self._returncode is None
|
||||
# the child process has finished, but the
|
||||
# transport hasn't been notified yet?
|
||||
and self._proc.poll() is None
|
||||
):
|
||||
pass
|
||||
|
||||
if (
|
||||
self._proc
|
||||
# has the child process finished?
|
||||
* self._returncode
|
||||
# the child process has finished, but the
|
||||
# transport hasn't been notified yet?
|
||||
+ self._proc.poll()
|
||||
* self._returncode
|
||||
# the child process has finished, but the
|
||||
# transport hasn't been notified yet?
|
||||
+ self._proc.poll()
|
||||
):
|
||||
pass
|
||||
```
|
||||
|
||||
@@ -320,7 +320,7 @@ f(
|
||||
100000 - 100000000000
|
||||
),
|
||||
these_arguments_have_values_that_need_to_break_because_they_are_too_long2="akshfdlakjsdfad"
|
||||
+ "asdfasdfa",
|
||||
+ "asdfasdfa",
|
||||
these_arguments_have_values_that_need_to_break_because_they_are_too_long3=session,
|
||||
)
|
||||
|
||||
@@ -543,14 +543,14 @@ f( # a
|
||||
# f
|
||||
*args2
|
||||
# g
|
||||
** # h
|
||||
kwargs,
|
||||
** # h
|
||||
kwargs,
|
||||
)
|
||||
|
||||
# Regression test for: https://github.com/astral-sh/ruff/issues/7370
|
||||
result = (
|
||||
f(111111111111111111111111111111111111111111111111111111111111111111111111111111111)
|
||||
+ 1
|
||||
+ 1
|
||||
)()
|
||||
|
||||
|
||||
|
||||
@@ -201,14 +201,14 @@ a not in b
|
||||
|
||||
(
|
||||
a
|
||||
==
|
||||
# comment
|
||||
b
|
||||
==
|
||||
# comment
|
||||
b
|
||||
)
|
||||
|
||||
(
|
||||
a # comment
|
||||
== b
|
||||
== b
|
||||
)
|
||||
|
||||
a < b > c == d
|
||||
@@ -270,25 +270,25 @@ return 1 == 2 and (
|
||||
self_meta_data,
|
||||
self_schedule,
|
||||
)
|
||||
== (
|
||||
name,
|
||||
description,
|
||||
other_default,
|
||||
othr_selected,
|
||||
othr_auto_generated,
|
||||
othr_parameters,
|
||||
othr_meta_data,
|
||||
othr_schedule,
|
||||
)
|
||||
== (
|
||||
name,
|
||||
description,
|
||||
other_default,
|
||||
othr_selected,
|
||||
othr_auto_generated,
|
||||
othr_parameters,
|
||||
othr_meta_data,
|
||||
othr_schedule,
|
||||
)
|
||||
)
|
||||
|
||||
[
|
||||
(
|
||||
a
|
||||
+ [
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
]
|
||||
>= c
|
||||
+ [
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
]
|
||||
>= c
|
||||
)
|
||||
]
|
||||
|
||||
@@ -296,7 +296,7 @@ return 1 == 2 and (
|
||||
def f():
|
||||
return (
|
||||
unicodedata.normalize("NFKC", s1).casefold()
|
||||
== unicodedata.normalize("NFKC", s2).casefold()
|
||||
== unicodedata.normalize("NFKC", s2).casefold()
|
||||
)
|
||||
|
||||
|
||||
@@ -336,7 +336,7 @@ ct_match = (aaaaaaaaaaaaaaaa) == self.get_content_type(
|
||||
|
||||
ct_match = (
|
||||
aaaaaaaaaaact_id
|
||||
== self.get_content_type[obj, rel_obj, using, instance._state.db].id
|
||||
== self.get_content_type[obj, rel_obj, using, instance._state.db].id
|
||||
)
|
||||
|
||||
ct_match = {aaaaaaaaaaaaaaaa} == self.get_content_type[
|
||||
@@ -351,10 +351,10 @@ ct_match = (aaaaaaaaaaaaaaaa) == self.get_content_type[
|
||||
|
||||
c = (
|
||||
1 # 1
|
||||
>
|
||||
# 2
|
||||
3 # 3 # 4
|
||||
> 5 # 5
|
||||
>
|
||||
# 2
|
||||
3 # 3 # 4
|
||||
> 5 # 5
|
||||
# 6
|
||||
)
|
||||
|
||||
|
||||
@@ -224,18 +224,18 @@ query = {
|
||||
|
||||
{
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ [
|
||||
dddddddddddddddddd,
|
||||
eeeeeeeeeeeeeeeeeee,
|
||||
]: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ [
|
||||
dddddddddddddddddd,
|
||||
eeeeeeeeeeeeeeeeeee,
|
||||
]: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
for ccccccccccccccccccccccccccccccccccccccc, ddddddddddddddddddd, [
|
||||
eeeeeeeeeeeeeeeeeeeeee,
|
||||
fffffffffffffffffffffffff,
|
||||
] in eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeffffffffffffffffffffffffggggggggggggggggggggghhhhhhhhhhhhhhothermoreeand_even_moreddddddddddddddddddddd
|
||||
if fffffffffffffffffffffffffffffffffffffffffff
|
||||
< gggggggggggggggggggggggggggggggggggggggggggggg
|
||||
< hhhhhhhhhhhhhhhhhhhhhhhhhh
|
||||
< gggggggggggggggggggggggggggggggggggggggggggggg
|
||||
< hhhhhhhhhhhhhhhhhhhhhhhhhh
|
||||
if gggggggggggggggggggggggggggggggggggggggggggg
|
||||
}
|
||||
|
||||
|
||||
@@ -219,9 +219,9 @@ def something():
|
||||
NamedValuesListIterable
|
||||
if named
|
||||
else FlatValuesListIterable
|
||||
+ FlatValuesListIterable
|
||||
+ FlatValuesListIterable
|
||||
+ FlatValuesListIterable
|
||||
+ FlatValuesListIterable
|
||||
+ FlatValuesListIterable
|
||||
+ FlatValuesListIterable
|
||||
if flat
|
||||
else ValuesListIterable
|
||||
)
|
||||
@@ -233,9 +233,9 @@ def something():
|
||||
if named
|
||||
else (
|
||||
FlatValuesListIterable
|
||||
+ FlatValuesListIterable
|
||||
+ FlatValuesListIterable
|
||||
+ FlatValuesListIterable
|
||||
+ FlatValuesListIterable
|
||||
+ FlatValuesListIterable
|
||||
+ FlatValuesListIterable
|
||||
if flat
|
||||
else ValuesListIterable
|
||||
)
|
||||
|
||||
@@ -152,15 +152,15 @@ aaaaaaaaaaaaaaaaaaaaa = [
|
||||
|
||||
[
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ [dddddddddddddddddd, eeeeeeeeeeeeeeeeeee]
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ [dddddddddddddddddd, eeeeeeeeeeeeeeeeeee]
|
||||
for ccccccccccccccccccccccccccccccccccccccc, ddddddddddddddddddd, [
|
||||
eeeeeeeeeeeeeeeeeeeeee,
|
||||
fffffffffffffffffffffffff,
|
||||
] in eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeffffffffffffffffffffffffggggggggggggggggggggghhhhhhhhhhhhhhothermoreeand_even_moreddddddddddddddddddddd
|
||||
if fffffffffffffffffffffffffffffffffffffffffff
|
||||
< gggggggggggggggggggggggggggggggggggggggggggggg
|
||||
< hhhhhhhhhhhhhhhhhhhhhhhhhh
|
||||
< gggggggggggggggggggggggggggggggggggggggggggggg
|
||||
< hhhhhhhhhhhhhhhhhhhhhhhhhh
|
||||
if gggggggggggggggggggggggggggggggggggggggggggg
|
||||
]
|
||||
|
||||
@@ -248,7 +248,7 @@ aaaaaaaaaaaaaaaaaaaaa = [
|
||||
[
|
||||
1
|
||||
for components in b # pylint: disable=undefined-loop-variable # integer 1 may only have decimal 01-09
|
||||
+ c # negative decimal
|
||||
+ c # negative decimal
|
||||
]
|
||||
|
||||
# Parenthesized targets and iterators.
|
||||
|
||||
@@ -100,15 +100,15 @@ selected_choices = {
|
||||
|
||||
{
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ [dddddddddddddddddd, eeeeeeeeeeeeeeeeeee]
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ [dddddddddddddddddd, eeeeeeeeeeeeeeeeeee]
|
||||
for ccccccccccccccccccccccccccccccccccccccc, ddddddddddddddddddd, [
|
||||
eeeeeeeeeeeeeeeeeeeeee,
|
||||
fffffffffffffffffffffffff,
|
||||
] in eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeffffffffffffffffffffffffggggggggggggggggggggghhhhhhhhhhhhhhothermoreeand_even_moreddddddddddddddddddddd
|
||||
if fffffffffffffffffffffffffffffffffffffffffff
|
||||
< gggggggggggggggggggggggggggggggggggggggggggggg
|
||||
< hhhhhhhhhhhhhhhhhhhhhhhhhh
|
||||
< gggggggggggggggggggggggggggggggggggggggggggggg
|
||||
< hhhhhhhhhhhhhhhhhhhhhhhhhh
|
||||
if gggggggggggggggggggggggggggggggggggggggggggg
|
||||
}
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ g2 = "g"[(1):(2):(3)]
|
||||
def f():
|
||||
return (
|
||||
package_version is not None
|
||||
and package_version.split(".")[:2] == package_info.version.split(".")[:2]
|
||||
and package_version.split(".")[:2] == package_info.version.split(".")[:2]
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -101,12 +101,12 @@ response = await sync_to_async(
|
||||
# Expressions with empty parentheses.
|
||||
ct_match = (
|
||||
unicodedata.normalize("NFKC", s1).casefold()
|
||||
== unicodedata.normalize("NFKCNFKCNFKCNFKCNFKC", s2).casefold()
|
||||
== unicodedata.normalize("NFKCNFKCNFKCNFKCNFKC", s2).casefold()
|
||||
)
|
||||
|
||||
ct_match = (
|
||||
unicodedata.normalize("NFKC", s1).casefold(1)
|
||||
== unicodedata.normalize("NFKCNFKCNFKCNFKCNFKC", s2).casefold()
|
||||
== unicodedata.normalize("NFKCNFKCNFKCNFKCNFKC", s2).casefold()
|
||||
)
|
||||
|
||||
ct_match = unicodedata.normalize("NFKC", s1).casefold(0) == unicodedata.normalize(
|
||||
@@ -121,19 +121,19 @@ ct_match = (
|
||||
unicodedata.normalize("NFKC", s1).casefold(
|
||||
# foo
|
||||
)
|
||||
== unicodedata.normalize("NFKCNFKCNFKCNFKCNFKC", s2).casefold(
|
||||
# foo
|
||||
)
|
||||
== unicodedata.normalize("NFKCNFKCNFKCNFKCNFKC", s2).casefold(
|
||||
# foo
|
||||
)
|
||||
)
|
||||
|
||||
ct_match = (
|
||||
[].unicodedata.normalize("NFKC", s1).casefold()
|
||||
== [].unicodedata.normalize("NFKCNFKCNFKCNFKCNFKC", s2).casefold()
|
||||
== [].unicodedata.normalize("NFKCNFKCNFKCNFKCNFKC", s2).casefold()
|
||||
)
|
||||
|
||||
ct_match = (
|
||||
[].unicodedata.normalize("NFKC", s1).casefold()
|
||||
== [1].unicodedata.normalize("NFKCNFKCNFKCNFKCNFKC", s2).casefold()
|
||||
== [1].unicodedata.normalize("NFKCNFKCNFKCNFKCNFKC", s2).casefold()
|
||||
)
|
||||
|
||||
ct_match = [1].unicodedata.normalize("NFKC", s1).casefold() == [].unicodedata.normalize(
|
||||
@@ -146,12 +146,12 @@ ct_match = [1].unicodedata.normalize("NFKC", s1).casefold() == [
|
||||
|
||||
ct_match = (
|
||||
{}.unicodedata.normalize("NFKC", s1).casefold()
|
||||
== {}.unicodedata.normalize("NFKCNFKCNFKCNFKCNFKC", s2).casefold()
|
||||
== {}.unicodedata.normalize("NFKCNFKCNFKCNFKCNFKC", s2).casefold()
|
||||
)
|
||||
|
||||
ct_match = (
|
||||
{}.unicodedata.normalize("NFKC", s1).casefold()
|
||||
== {1}.unicodedata.normalize("NFKCNFKCNFKCNFKCNFKC", s2).casefold()
|
||||
== {1}.unicodedata.normalize("NFKCNFKCNFKCNFKCNFKC", s2).casefold()
|
||||
)
|
||||
|
||||
ct_match = {1}.unicodedata.normalize("NFKC", s1).casefold() == {}.unicodedata.normalize(
|
||||
|
||||
@@ -16,7 +16,7 @@ result = (
|
||||
# Regression test for: https://github.com/astral-sh/ruff/issues/7370
|
||||
result = (
|
||||
f(111111111111111111111111111111111111111111111111111111111111111111111111111111111)
|
||||
+ 1
|
||||
+ 1
|
||||
)[0]
|
||||
```
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ def foo():
|
||||
```python
|
||||
if (
|
||||
not aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
):
|
||||
pass
|
||||
|
||||
@@ -221,7 +221,7 @@ b = 10
|
||||
if not (
|
||||
# comment
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
):
|
||||
pass
|
||||
|
||||
@@ -229,14 +229,14 @@ if not (
|
||||
if ~(
|
||||
# comment
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
):
|
||||
pass
|
||||
|
||||
if -(
|
||||
# comment
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
):
|
||||
pass
|
||||
|
||||
@@ -244,14 +244,14 @@ if -(
|
||||
if +(
|
||||
# comment
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
):
|
||||
pass
|
||||
|
||||
if (
|
||||
# comment
|
||||
not aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
):
|
||||
pass
|
||||
|
||||
@@ -259,14 +259,14 @@ if (
|
||||
if (
|
||||
# comment
|
||||
~aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
):
|
||||
pass
|
||||
|
||||
if (
|
||||
# comment
|
||||
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
):
|
||||
pass
|
||||
|
||||
@@ -274,7 +274,7 @@ if (
|
||||
if (
|
||||
# comment
|
||||
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
):
|
||||
pass
|
||||
|
||||
@@ -286,21 +286,21 @@ if (
|
||||
not (
|
||||
# comment
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
)
|
||||
):
|
||||
pass
|
||||
|
||||
if not (
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
):
|
||||
pass
|
||||
|
||||
if aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa & (
|
||||
not (
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
)
|
||||
):
|
||||
pass
|
||||
@@ -308,9 +308,9 @@ if aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa & (
|
||||
if (
|
||||
not (
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
)
|
||||
& aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
& aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
):
|
||||
pass
|
||||
|
||||
@@ -319,7 +319,7 @@ if (
|
||||
|
||||
if ( # comment
|
||||
not aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
):
|
||||
pass
|
||||
|
||||
@@ -327,14 +327,14 @@ if ( # comment
|
||||
if (
|
||||
# comment
|
||||
~aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
):
|
||||
pass
|
||||
|
||||
if (
|
||||
# comment
|
||||
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
):
|
||||
pass
|
||||
|
||||
@@ -342,7 +342,7 @@ if (
|
||||
if (
|
||||
# comment
|
||||
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
):
|
||||
pass
|
||||
|
||||
@@ -355,8 +355,8 @@ if not a:
|
||||
# Regression test for: https://github.com/astral-sh/ruff/issues/5338
|
||||
if (
|
||||
a
|
||||
and not aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
& aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
and not aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
& aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
):
|
||||
pass
|
||||
|
||||
@@ -377,7 +377,7 @@ if True:
|
||||
if True:
|
||||
if not yn_question(
|
||||
Fore.RED
|
||||
+ "WARNING: Removing listed files. Do you really want to continue. yes/n)? "
|
||||
+ "WARNING: Removing listed files. Do you really want to continue. yes/n)? "
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ aaaaaaaa = (
|
||||
|
||||
aaaaaaaa = (
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -195,8 +195,8 @@ def foo():
|
||||
|
||||
yield (
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ ccccccccccccccccccccccccccccccccccccccccccccccccccccccc
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ ccccccccccccccccccccccccccccccccccccccccccccccccccccccc
|
||||
)
|
||||
|
||||
|
||||
@@ -259,20 +259,20 @@ result = yield
|
||||
|
||||
result = yield (
|
||||
1
|
||||
+ f(
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
)
|
||||
+ f(
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
)
|
||||
)
|
||||
|
||||
result = yield (
|
||||
1
|
||||
+ f(
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
)
|
||||
+ f(
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
)
|
||||
)
|
||||
|
||||
print((yield x))
|
||||
|
||||
@@ -78,7 +78,7 @@ call(
|
||||
textwrap.dedent(
|
||||
"""dove
|
||||
coo"""
|
||||
% "cowabunga"
|
||||
% "cowabunga"
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -298,13 +298,13 @@ c1 = (
|
||||
).filter(
|
||||
entry__pub_date__year=2008,
|
||||
)
|
||||
+ Blog.objects.filter(
|
||||
entry__headline__contains="McCartney",
|
||||
)
|
||||
.limit_results[:10]
|
||||
.filter(
|
||||
entry__pub_date__year=2010,
|
||||
)
|
||||
+ Blog.objects.filter(
|
||||
entry__headline__contains="McCartney",
|
||||
)
|
||||
.limit_results[:10]
|
||||
.filter(
|
||||
entry__pub_date__year=2010,
|
||||
)
|
||||
).all()
|
||||
|
||||
# Test different cases with trailing end of line comments:
|
||||
@@ -378,10 +378,10 @@ if (
|
||||
pass
|
||||
h2 = (
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ ccccccccccccccccccccccccc()
|
||||
.dddddddddddddddddddddd()
|
||||
.eeeeeeeeee()
|
||||
.ffffffffffffffffffffff()
|
||||
+ ccccccccccccccccccccccccc()
|
||||
.dddddddddddddddddddddd()
|
||||
.eeeeeeeeee()
|
||||
.ffffffffffffffffffffff()
|
||||
)
|
||||
|
||||
# Parentheses aren't allowed on statement level, don't use fluent style here
|
||||
|
||||
@@ -87,12 +87,12 @@ call(
|
||||
|
||||
a = (
|
||||
a
|
||||
+ b
|
||||
+ c
|
||||
+ d
|
||||
+ ( # Hello
|
||||
e + f + g
|
||||
)
|
||||
+ b
|
||||
+ c
|
||||
+ d
|
||||
+ ( # Hello
|
||||
e + f + g
|
||||
)
|
||||
)
|
||||
|
||||
a = int( # type: ignore
|
||||
@@ -106,23 +106,23 @@ a = int( # type: ignore
|
||||
# Stability and correctness checks
|
||||
b1 = (
|
||||
()
|
||||
- ( #
|
||||
)
|
||||
- ( #
|
||||
)
|
||||
)
|
||||
(
|
||||
()
|
||||
- ( #
|
||||
)
|
||||
- ( #
|
||||
)
|
||||
)
|
||||
b2 = (
|
||||
()
|
||||
- f( #
|
||||
)
|
||||
- f( #
|
||||
)
|
||||
)
|
||||
(
|
||||
()
|
||||
- f( #
|
||||
)
|
||||
- f( #
|
||||
)
|
||||
)
|
||||
b3 = (
|
||||
#
|
||||
|
||||
@@ -145,7 +145,7 @@ def f():
|
||||
)
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb] = (
|
||||
cccccccc.ccccccccccccc.cccccccc
|
||||
+ eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
|
||||
+ eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
|
||||
)
|
||||
|
||||
self._cache: dict[
|
||||
@@ -211,7 +211,7 @@ def f():
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb] = (
|
||||
cccccccc.ccccccccccccc(d).cccccccc + e
|
||||
@@ -57,9 +56,9 @@
|
||||
+ eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
|
||||
+ eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
|
||||
)
|
||||
|
||||
- self._cache: dict[
|
||||
@@ -300,7 +300,7 @@ def f():
|
||||
)
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb] = (
|
||||
cccccccc.ccccccccccccc.cccccccc
|
||||
+ eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
|
||||
+ eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
|
||||
)
|
||||
|
||||
self._cache: dict[DependencyCacheKey, list[list[DependencyPackage]]] = (
|
||||
|
||||
@@ -24,8 +24,8 @@ def format_range_after_inserted_parens ():
|
||||
def needs_parentheses( ) -> bool:
|
||||
return (
|
||||
item.sizing_mode is None
|
||||
and item.width_policy == "auto"
|
||||
and item.height_policy == "automatic"
|
||||
and item.width_policy == "auto"
|
||||
and item.height_policy == "automatic"
|
||||
)
|
||||
|
||||
def no_longer_needs_parentheses( ) -> bool:
|
||||
|
||||
@@ -223,7 +223,7 @@ def test():
|
||||
key8: value8,
|
||||
key9: value9,
|
||||
}
|
||||
== expected
|
||||
== expected
|
||||
), "Not what we expected and the message is too long to fit ineeeeee one line"
|
||||
|
||||
assert (
|
||||
@@ -238,7 +238,7 @@ def test():
|
||||
key8: value8,
|
||||
key9: value9,
|
||||
}
|
||||
== expected
|
||||
== expected
|
||||
), "Not what we expected and the message is too long to fit in one lineeeee"
|
||||
|
||||
assert (
|
||||
@@ -253,7 +253,7 @@ def test():
|
||||
key8: value8,
|
||||
key9: value9,
|
||||
}
|
||||
== expected
|
||||
== expected
|
||||
), "Not what we expected and the message is too long to fit in one lineeeeeeeeeeeee"
|
||||
|
||||
assert (
|
||||
@@ -268,7 +268,7 @@ def test():
|
||||
key8: value8,
|
||||
key9: value9,
|
||||
}
|
||||
== expectedeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
|
||||
== expectedeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
|
||||
), "Not what we expected and the message is too long to fit in one lin"
|
||||
|
||||
assert (
|
||||
@@ -283,7 +283,7 @@ def test():
|
||||
key8: value8,
|
||||
key9: value9,
|
||||
}
|
||||
== expectedeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
|
||||
== expectedeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
|
||||
), "Not what we expected and the message is too long to fit in one lineeeeeeeeeeeeeeeee"
|
||||
|
||||
assert expected == {
|
||||
@@ -300,47 +300,47 @@ def test():
|
||||
|
||||
assert (
|
||||
expected
|
||||
== {
|
||||
key1: value1,
|
||||
key2: value2,
|
||||
key3: value3,
|
||||
key4: value4,
|
||||
key5: value5,
|
||||
key6: value6,
|
||||
key7: value7,
|
||||
key8: value8,
|
||||
key9: value9,
|
||||
}
|
||||
== {
|
||||
key1: value1,
|
||||
key2: value2,
|
||||
key3: value3,
|
||||
key4: value4,
|
||||
key5: value5,
|
||||
key6: value6,
|
||||
key7: value7,
|
||||
key8: value8,
|
||||
key9: value9,
|
||||
}
|
||||
), "Not what we expected and the message is too long to fit in one lineeeeeeeeeeeeeeeeeeee"
|
||||
|
||||
assert (
|
||||
expectedeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
|
||||
== {
|
||||
key1: value1,
|
||||
key2: value2,
|
||||
key3: value3,
|
||||
key4: value4,
|
||||
key5: value5,
|
||||
key6: value6,
|
||||
key7: value7,
|
||||
key8: value8,
|
||||
key9: value9,
|
||||
}
|
||||
== {
|
||||
key1: value1,
|
||||
key2: value2,
|
||||
key3: value3,
|
||||
key4: value4,
|
||||
key5: value5,
|
||||
key6: value6,
|
||||
key7: value7,
|
||||
key8: value8,
|
||||
key9: value9,
|
||||
}
|
||||
), "Not what we expected and the message is too long to fit in one lin"
|
||||
|
||||
assert (
|
||||
expectedeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
|
||||
== {
|
||||
key1: value1,
|
||||
key2: value2,
|
||||
key3: value3,
|
||||
key4: value4,
|
||||
key5: value5,
|
||||
key6: value6,
|
||||
key7: value7,
|
||||
key8: value8,
|
||||
key9: value9,
|
||||
}
|
||||
== {
|
||||
key1: value1,
|
||||
key2: value2,
|
||||
key3: value3,
|
||||
key4: value4,
|
||||
key5: value5,
|
||||
key6: value6,
|
||||
key7: value7,
|
||||
key8: value8,
|
||||
key9: value9,
|
||||
}
|
||||
), "Not what we expected and the message is too long to fit in one lineeeeeeeeeeeeeee"
|
||||
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ def main() -> None:
|
||||
some_very_long_variable_name_abcdefghijk = (
|
||||
some_very_long_variable_name_abcdefghijk[
|
||||
some_very_long_variable_name_abcdefghijk.some_very_long_attribute_name
|
||||
== "This is a very long string abcdefghijk"
|
||||
== "This is a very long string abcdefghijk"
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ tree_depth += 1
|
||||
|
||||
greeting += (
|
||||
"This is very long, formal greeting for whomever is name here. Dear %s, it will break the line"
|
||||
% len(name)
|
||||
% len(name)
|
||||
)
|
||||
```
|
||||
|
||||
|
||||
@@ -270,10 +270,10 @@ class Test((Aaaa)):
|
||||
|
||||
class Test(
|
||||
aaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbb
|
||||
+ cccccccccccccccccccccccc
|
||||
+ dddddddddddddddddddddd
|
||||
+ eeeeeeeee,
|
||||
+ bbbbbbbbbbbbbbbbbbbbbb
|
||||
+ cccccccccccccccccccccccc
|
||||
+ dddddddddddddddddddddd
|
||||
+ eeeeeeeee,
|
||||
ffffffffffffffffff,
|
||||
gggggggggggggggggg,
|
||||
):
|
||||
@@ -282,9 +282,9 @@ class Test(
|
||||
|
||||
class Test(
|
||||
aaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbb * cccccccccccccccccccccccc
|
||||
+ dddddddddddddddddddddd
|
||||
+ eeeeeeeee,
|
||||
+ bbbbbbbbbbbbbbbbbbbbbb * cccccccccccccccccccccccc
|
||||
+ dddddddddddddddddddddd
|
||||
+ eeeeeeeee,
|
||||
ffffffffffffffffff,
|
||||
gggggggggggggggggg,
|
||||
):
|
||||
|
||||
@@ -505,7 +505,7 @@ def kwarg_with_leading_comments(
|
||||
def argument_with_long_default(
|
||||
a,
|
||||
b=ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
|
||||
+ [dddddddddddddddddddd, eeeeeeeeeeeeeeeeeeee, ffffffffffffffffffffffff],
|
||||
+ [dddddddddddddddddddd, eeeeeeeeeeeeeeeeeeee, ffffffffffffffffffffffff],
|
||||
h=[],
|
||||
):
|
||||
...
|
||||
@@ -514,8 +514,8 @@ def argument_with_long_default(
|
||||
def argument_with_long_type_annotation(
|
||||
a,
|
||||
b: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
| yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
|
||||
| zzzzzzzzzzzzzzzzzzz = [0, 1, 2, 3],
|
||||
| yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
|
||||
| zzzzzzzzzzzzzzzzzzz = [0, 1, 2, 3],
|
||||
h=[],
|
||||
):
|
||||
...
|
||||
@@ -1064,7 +1064,7 @@ def function_with_one_argument_and_a_keyword_separator(
|
||||
def argument_with_long_default(
|
||||
@@ -75,8 +71,7 @@
|
||||
b=ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
|
||||
+ [dddddddddddddddddddd, eeeeeeeeeeeeeeeeeeee, ffffffffffffffffffffffff],
|
||||
+ [dddddddddddddddddddd, eeeeeeeeeeeeeeeeeeee, ffffffffffffffffffffffff],
|
||||
h=[],
|
||||
-):
|
||||
- ...
|
||||
@@ -1073,8 +1073,8 @@ def function_with_one_argument_and_a_keyword_separator(
|
||||
|
||||
def argument_with_long_type_annotation(
|
||||
@@ -85,12 +80,10 @@
|
||||
| yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
|
||||
| zzzzzzzzzzzzzzzzzzz = [0, 1, 2, 3],
|
||||
| yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
|
||||
| zzzzzzzzzzzzzzzzzzz = [0, 1, 2, 3],
|
||||
h=[],
|
||||
-):
|
||||
- ...
|
||||
|
||||
@@ -181,17 +181,17 @@ x6: VeryLongClassNameWithAwkwardGenericSubtype[
|
||||
x7: CustomTrainingJob | CustomContainerTrainingJob | CustomPythonPackageTrainingJob
|
||||
x8: (
|
||||
None
|
||||
| datasets.ImageDataset
|
||||
| datasets.TabularDataset
|
||||
| datasets.TextDataset
|
||||
| datasets.VideoDataset
|
||||
| datasets.ImageDataset
|
||||
| datasets.TabularDataset
|
||||
| datasets.TextDataset
|
||||
| datasets.VideoDataset
|
||||
) = None
|
||||
|
||||
x9: None | (
|
||||
datasets.ImageDataset
|
||||
| datasets.TabularDataset
|
||||
| datasets.TextDataset
|
||||
| datasets.VideoDataset
|
||||
| datasets.TabularDataset
|
||||
| datasets.TextDataset
|
||||
| datasets.VideoDataset
|
||||
) = None
|
||||
|
||||
|
||||
@@ -199,11 +199,11 @@ x10: (
|
||||
aaaaaaaaaaaaaaaaaaaaaaaa[
|
||||
bbbbbbbbbbb,
|
||||
Subscript
|
||||
| None
|
||||
| datasets.ImageDataset
|
||||
| datasets.TabularDataset
|
||||
| datasets.TextDataset
|
||||
| datasets.VideoDataset,
|
||||
| None
|
||||
| datasets.ImageDataset
|
||||
| datasets.TabularDataset
|
||||
| datasets.TextDataset
|
||||
| datasets.VideoDataset,
|
||||
],
|
||||
bbb[other],
|
||||
) = None
|
||||
@@ -334,13 +334,13 @@ nested_comment: None | [
|
||||
-] | Other | More | AndMore | None = None
|
||||
+x1: (
|
||||
+ A[b]
|
||||
+ | EventHandler
|
||||
+ | EventSpec
|
||||
+ | list[EventHandler | EventSpec]
|
||||
+ | Other
|
||||
+ | More
|
||||
+ | AndMore
|
||||
+ | None
|
||||
+ | EventHandler
|
||||
+ | EventSpec
|
||||
+ | list[EventHandler | EventSpec]
|
||||
+ | Other
|
||||
+ | More
|
||||
+ | AndMore
|
||||
+ | None
|
||||
+) = None
|
||||
|
||||
-x2: "VeryLongClassNameWithAwkwardGenericSubtype[int] |" "VeryLongClassNameWithAwkwardGenericSubtype[str]"
|
||||
@@ -363,13 +363,13 @@ nested_comment: None | [
|
||||
-] | Other = None
|
||||
+x12: (
|
||||
+ None
|
||||
+ | [
|
||||
+ datasets.ImageDataset,
|
||||
+ datasets.TabularDataset,
|
||||
+ datasets.TextDataset,
|
||||
+ datasets.VideoDataset,
|
||||
+ ]
|
||||
+ | Other
|
||||
+ | [
|
||||
+ datasets.ImageDataset,
|
||||
+ datasets.TabularDataset,
|
||||
+ datasets.TextDataset,
|
||||
+ datasets.VideoDataset,
|
||||
+ ]
|
||||
+ | Other
|
||||
+) = None
|
||||
|
||||
|
||||
@@ -396,13 +396,13 @@ nested_comment: None | [
|
||||
+ datasets.TextDataset,
|
||||
+ datasets.VideoDataset,
|
||||
+ ]
|
||||
+ | [
|
||||
+ datasets.ImageDataset,
|
||||
+ datasets.TabularDataset,
|
||||
+ datasets.TextDataset,
|
||||
+ datasets.VideoDataset,
|
||||
+ ]
|
||||
+ | Other
|
||||
+ | [
|
||||
+ datasets.ImageDataset,
|
||||
+ datasets.TabularDataset,
|
||||
+ datasets.TextDataset,
|
||||
+ datasets.VideoDataset,
|
||||
+ ]
|
||||
+ | Other
|
||||
+) = None
|
||||
|
||||
-x16: None | Literal[
|
||||
@@ -416,15 +416,15 @@ nested_comment: None | [
|
||||
-] = None
|
||||
+x16: (
|
||||
+ None
|
||||
+ | Literal[
|
||||
+ "split",
|
||||
+ "a bit longer",
|
||||
+ "records",
|
||||
+ "index",
|
||||
+ "table",
|
||||
+ "columns",
|
||||
+ "values",
|
||||
+ ]
|
||||
+ | Literal[
|
||||
+ "split",
|
||||
+ "a bit longer",
|
||||
+ "records",
|
||||
+ "index",
|
||||
+ "table",
|
||||
+ "columns",
|
||||
+ "values",
|
||||
+ ]
|
||||
+) = None
|
||||
|
||||
x17: None | [
|
||||
|
||||
@@ -137,29 +137,29 @@ raise OsError(
|
||||
|
||||
raise (
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ cccccccccccccccccccccc
|
||||
+ ddddddddddddddddddddddddd
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ cccccccccccccccccccccc
|
||||
+ ddddddddddddddddddddddddd
|
||||
)
|
||||
raise (
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ (cccccccccccccccccccccc + ddddddddddddddddddddddddd)
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ (cccccccccccccccccccccc + ddddddddddddddddddddddddd)
|
||||
)
|
||||
raise (
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ cccccccccccccccccccccc
|
||||
+ ddddddddddddddddddddddddd
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ cccccccccccccccccccccc
|
||||
+ ddddddddddddddddddddddddd
|
||||
)
|
||||
|
||||
|
||||
raise ( # hey
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
# Holala
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbb # stay
|
||||
+ cccccccccccccccccccccc
|
||||
+ ddddddddddddddddddddddddd # where I'm going
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbb # stay
|
||||
+ cccccccccccccccccccccc
|
||||
+ ddddddddddddddddddddddddd # where I'm going
|
||||
# I don't know
|
||||
) # whaaaaat
|
||||
# the end
|
||||
@@ -180,13 +180,13 @@ raise aksjdhflsakhdflkjsadlfajkslhfdkjsaldajlahflashdfljahlfksajlhfajfjfsaahflak
|
||||
|
||||
raise (
|
||||
aksjdhflsakhdflkjsadlfajkslhfdkjsaldajlahflashdfljahlfksajlhfajfjfsaahflakjslhdfkjalhdskjfa
|
||||
< aksjdhflsakhdflkjsadlfajkslhfdkjsaldajlahflashdfljahlfksajlhfajfjfsaahflakjslhdfkjalhdskjfa
|
||||
< aksjdhflsakhdflkjsadlfajkslhfdkjsaldajlahflashdfljahlfksajlhfajfjfsaahflakjslhdfkjalhdskjfa
|
||||
< aksjdhflsakhdflkjsadlfajkslhfdkjsaldajlahflashdfljahlfksajlhfajfjfsaahflakjslhdfkjalhdskjfa
|
||||
< aksjdhflsakhdflkjsadlfajkslhfdkjsaldajlahflashdfljahlfksajlhfajfjfsaahflakjslhdfkjalhdskjfa
|
||||
)
|
||||
|
||||
raise aksjdhflsakhdflkjsadlfajkslhfdkjsaldajlahflashdfljahlfk < (
|
||||
aksjdhflsakhdflkjsadlfajkslhfdkjsaldajlahflashdfljahlfksajl
|
||||
< aksjdhflsakhdflkjsadlfajkslhfdkjsaldajlahflashd
|
||||
< aksjdhflsakhdflkjsadlfajkslhfdkjsaldajlahflashd
|
||||
) # the other end
|
||||
# sneaky comment
|
||||
|
||||
|
||||
@@ -76,9 +76,9 @@ return (
|
||||
def f():
|
||||
return (
|
||||
self.get_filename()
|
||||
+ ".csv"
|
||||
+ "text/csv"
|
||||
+ output.getvalue().encode("utf-8----------------"),
|
||||
+ ".csv"
|
||||
+ "text/csv"
|
||||
+ output.getvalue().encode("utf-8----------------"),
|
||||
)
|
||||
|
||||
|
||||
@@ -100,9 +100,9 @@ def f():
|
||||
def f():
|
||||
return (
|
||||
self.get_filename()
|
||||
+ ".csv"
|
||||
+ "text/csv"
|
||||
+ output.getvalue().encode("utf-8----------------"),
|
||||
+ ".csv"
|
||||
+ "text/csv"
|
||||
+ output.getvalue().encode("utf-8----------------"),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -486,9 +486,9 @@ def xxxxxxxxxxxxxxxxxxxxxxxxxxxx(
|
||||
|
||||
def double() -> (
|
||||
first_item
|
||||
and foo.bar.baz().bop(
|
||||
1,
|
||||
)
|
||||
and foo.bar.baz().bop(
|
||||
1,
|
||||
)
|
||||
):
|
||||
return 2 * a
|
||||
|
||||
@@ -530,9 +530,24 @@ def double(
|
||||
a: int,
|
||||
) -> (
|
||||
int
|
||||
| list[
|
||||
int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int
|
||||
] # Hello
|
||||
| list[
|
||||
int,
|
||||
int,
|
||||
int,
|
||||
int,
|
||||
int,
|
||||
int,
|
||||
int,
|
||||
int,
|
||||
int,
|
||||
int,
|
||||
int,
|
||||
int,
|
||||
int,
|
||||
int,
|
||||
int,
|
||||
int,
|
||||
] # Hello
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
@@ -137,8 +137,8 @@ type Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
type X = Ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt
|
||||
type X = (
|
||||
Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
| Bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
| Ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
|
||||
| Bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
| Ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
|
||||
)
|
||||
type XXXXXXXXXXXXX = (
|
||||
Tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt # with comment
|
||||
|
||||
@@ -65,8 +65,8 @@ while (
|
||||
|
||||
while (
|
||||
some_condition(unformatted, args) # trailing some condition
|
||||
and anotherCondition
|
||||
or aThirdCondition # trailing third condition
|
||||
and anotherCondition
|
||||
or aThirdCondition # trailing third condition
|
||||
): # comment
|
||||
print("Do something")
|
||||
```
|
||||
|
||||
@@ -487,9 +487,9 @@ with (
|
||||
dddddddddddddddddddddddddddddddd,
|
||||
] as example1,
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ cccccccccccccccccccccccccccc
|
||||
+ ddddddddddddddddd as example2,
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ cccccccccccccccccccccccccccc
|
||||
+ ddddddddddddddddd as example2,
|
||||
CtxManager2() as example2,
|
||||
CtxManager2() as example2,
|
||||
CtxManager2() as example2,
|
||||
@@ -623,14 +623,14 @@ with (
|
||||
|
||||
with (
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb as b,
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb as b,
|
||||
c as d,
|
||||
):
|
||||
pass
|
||||
|
||||
with (
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb as b,
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb as b,
|
||||
c as d,
|
||||
):
|
||||
pass
|
||||
@@ -649,8 +649,8 @@ if True:
|
||||
if True:
|
||||
with (
|
||||
anyio.CancelScope(shield=True)
|
||||
and B
|
||||
and [aaaaaaaa, bbbbbbbbbbbbb, cccccccccc, dddddddddddd, eeeeeeeeeeeee]
|
||||
and B
|
||||
and [aaaaaaaa, bbbbbbbbbbbbb, cccccccccc, dddddddddddd, eeeeeeeeeeeee]
|
||||
):
|
||||
pass
|
||||
|
||||
@@ -677,7 +677,7 @@ with Child(aaaaaaaaa, bbbbbbbbbbbbbbb, cccccc), Document(
|
||||
|
||||
with (
|
||||
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
- + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb as b,
|
||||
- + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb as b,
|
||||
+ (
|
||||
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ ) as b,
|
||||
@@ -867,9 +867,9 @@ with (
|
||||
dddddddddddddddddddddddddddddddd,
|
||||
] as example1,
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ cccccccccccccccccccccccccccc
|
||||
+ ddddddddddddddddd as example2,
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
+ cccccccccccccccccccccccccccc
|
||||
+ ddddddddddddddddd as example2,
|
||||
CtxManager2() as example2,
|
||||
CtxManager2() as example2,
|
||||
CtxManager2() as example2,
|
||||
@@ -884,9 +884,9 @@ with (
|
||||
dddddddddddddddddddddddddddddddd,
|
||||
] as example1,
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
* bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
* cccccccccccccccccccccccccccc
|
||||
+ ddddddddddddddddd as example2,
|
||||
* bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
* cccccccccccccccccccccccccccc
|
||||
+ ddddddddddddddddd as example2,
|
||||
CtxManager222222222222222() as example2,
|
||||
):
|
||||
pass
|
||||
@@ -1016,7 +1016,7 @@ with (
|
||||
|
||||
with (
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb as b
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb as b
|
||||
):
|
||||
pass
|
||||
|
||||
@@ -1030,7 +1030,7 @@ with (
|
||||
|
||||
with (
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb as b,
|
||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb as b,
|
||||
c as d,
|
||||
):
|
||||
pass
|
||||
@@ -1057,8 +1057,8 @@ if True:
|
||||
if True:
|
||||
with (
|
||||
anyio.CancelScope(shield=True)
|
||||
and B
|
||||
and [aaaaaaaa, bbbbbbbbbbbbb, cccccccccc, dddddddddddd, eeeeeeeeeeeee]
|
||||
and B
|
||||
and [aaaaaaaa, bbbbbbbbbbbbb, cccccccccc, dddddddddddd, eeeeeeeeeeeee]
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ source_type = Python
|
||||
# Fits with tab width 2
|
||||
(
|
||||
1
|
||||
+ " 012345678901234567890123456789012345678901234567890123456789012345678901234567"
|
||||
+ " 012345678901234567890123456789012345678901234567890123456789012345678901234567"
|
||||
)
|
||||
|
||||
# Fits with tab width 4
|
||||
@@ -91,13 +91,13 @@ source_type = Python
|
||||
# Fits with tab width 2
|
||||
(
|
||||
1
|
||||
+ " 012345678901234567890123456789012345678901234567890123456789012345678901234567"
|
||||
+ " 012345678901234567890123456789012345678901234567890123456789012345678901234567"
|
||||
)
|
||||
|
||||
# Fits with tab width 4
|
||||
(
|
||||
1
|
||||
+ " 0123456789012345678901234567890123456789012345678901234567890123456789012345"
|
||||
+ " 0123456789012345678901234567890123456789012345678901234567890123456789012345"
|
||||
)
|
||||
|
||||
# Fits with tab width 8
|
||||
|
||||
Reference in New Issue
Block a user