mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-23 04:55:09 +00:00
Add basic Constant formatting (#4954)
This commit is contained in:
parent
83cf6d6e2f
commit
c1cc6f3be1
47 changed files with 549 additions and 624 deletions
|
@ -191,16 +191,16 @@ no_leading_newline = 30
|
|||
|
||||
assert_eq!(
|
||||
&printed,
|
||||
r#"a = 0x42
|
||||
r#"a = 10
|
||||
|
||||
|
||||
three_leading_newlines = 0x42
|
||||
three_leading_newlines = 80
|
||||
|
||||
|
||||
two_leading_newlines = 0x42
|
||||
two_leading_newlines = 20
|
||||
|
||||
one_leading_newline = 0x42
|
||||
no_leading_newline = 0x42"#
|
||||
one_leading_newline = 10
|
||||
no_leading_newline = 30"#
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -211,14 +211,14 @@ no_leading_newline = 0x42"#
|
|||
|
||||
assert_eq!(
|
||||
&printed,
|
||||
r#"a = 0x42
|
||||
r#"a = 10
|
||||
|
||||
three_leading_newlines = 0x42
|
||||
three_leading_newlines = 80
|
||||
|
||||
two_leading_newlines = 0x42
|
||||
two_leading_newlines = 20
|
||||
|
||||
one_leading_newline = 0x42
|
||||
no_leading_newline = 0x42"#
|
||||
one_leading_newline = 10
|
||||
no_leading_newline = 30"#
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -229,11 +229,11 @@ no_leading_newline = 0x42"#
|
|||
|
||||
assert_eq!(
|
||||
&printed,
|
||||
r#"a = 0x42
|
||||
three_leading_newlines = 0x42
|
||||
two_leading_newlines = 0x42
|
||||
one_leading_newline = 0x42
|
||||
no_leading_newline = 0x42"#
|
||||
r#"a = 10
|
||||
three_leading_newlines = 80
|
||||
two_leading_newlines = 20
|
||||
one_leading_newline = 10
|
||||
no_leading_newline = 30"#
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +1,38 @@
|
|||
use crate::expression::parentheses::{
|
||||
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
||||
};
|
||||
use crate::{not_yet_implemented_custom_text, AsFormat, FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::prelude::text;
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use rustpython_parser::ast::ExprAttribute;
|
||||
use crate::prelude::*;
|
||||
use crate::{not_yet_implemented_custom_text, FormatNodeRule};
|
||||
use ruff_formatter::write;
|
||||
use rustpython_parser::ast::{Constant, Expr, ExprAttribute, ExprConstant};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatExprAttribute;
|
||||
|
||||
impl FormatNodeRule<ExprAttribute> for FormatExprAttribute {
|
||||
fn fmt_fields(&self, item: &ExprAttribute, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
// We need to write the value - which is also a dummy - already because power op spacing
|
||||
// depends on it
|
||||
let ExprAttribute {
|
||||
value,
|
||||
range: _,
|
||||
attr: _,
|
||||
ctx: _,
|
||||
} = item;
|
||||
|
||||
let requires_space = matches!(
|
||||
value.as_ref(),
|
||||
Expr::Constant(ExprConstant {
|
||||
value: Constant::Int(_) | Constant::Float(_),
|
||||
..
|
||||
})
|
||||
);
|
||||
|
||||
write!(
|
||||
f,
|
||||
[
|
||||
item.value.format(),
|
||||
requires_space.then_some(space()),
|
||||
text("."),
|
||||
not_yet_implemented_custom_text(item, "NOT_IMPLEMENTED_attr")
|
||||
not_yet_implemented_custom_text("NOT_IMPLEMENTED_attr")
|
||||
]
|
||||
)
|
||||
}
|
||||
|
|
|
@ -9,11 +9,10 @@ use rustpython_parser::ast::ExprBoolOp;
|
|||
pub struct FormatExprBoolOp;
|
||||
|
||||
impl FormatNodeRule<ExprBoolOp> for FormatExprBoolOp {
|
||||
fn fmt_fields(&self, item: &ExprBoolOp, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
fn fmt_fields(&self, _item: &ExprBoolOp, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
write!(
|
||||
f,
|
||||
[not_yet_implemented_custom_text(
|
||||
item,
|
||||
"NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2"
|
||||
)]
|
||||
)
|
||||
|
|
|
@ -9,13 +9,10 @@ use rustpython_parser::ast::ExprCall;
|
|||
pub struct FormatExprCall;
|
||||
|
||||
impl FormatNodeRule<ExprCall> for FormatExprCall {
|
||||
fn fmt_fields(&self, item: &ExprCall, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
fn fmt_fields(&self, _item: &ExprCall, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
write!(
|
||||
f,
|
||||
[not_yet_implemented_custom_text(
|
||||
item,
|
||||
"NOT_IMPLEMENTED_call()"
|
||||
)]
|
||||
[not_yet_implemented_custom_text("NOT_IMPLEMENTED_call()")]
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,11 +10,10 @@ use rustpython_parser::ast::ExprCompare;
|
|||
pub struct FormatExprCompare;
|
||||
|
||||
impl FormatNodeRule<ExprCompare> for FormatExprCompare {
|
||||
fn fmt_fields(&self, item: &ExprCompare, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
fn fmt_fields(&self, _item: &ExprCompare, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
write!(
|
||||
f,
|
||||
[not_yet_implemented_custom_text(
|
||||
item,
|
||||
"NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right"
|
||||
)]
|
||||
)
|
||||
|
|
|
@ -1,16 +1,42 @@
|
|||
use crate::expression::parentheses::{
|
||||
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
||||
};
|
||||
use crate::{not_yet_implemented_custom_text, FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use rustpython_parser::ast::ExprConstant;
|
||||
use crate::prelude::*;
|
||||
use crate::{not_yet_implemented_custom_text, verbatim_text, FormatNodeRule};
|
||||
use ruff_formatter::write;
|
||||
use rustpython_parser::ast::{Constant, ExprConstant};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatExprConstant;
|
||||
|
||||
impl FormatNodeRule<ExprConstant> for FormatExprConstant {
|
||||
fn fmt_fields(&self, item: &ExprConstant, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
write!(f, [not_yet_implemented_custom_text(item, "0x42")])
|
||||
let ExprConstant {
|
||||
range: _,
|
||||
value,
|
||||
kind: _,
|
||||
} = item;
|
||||
|
||||
match value {
|
||||
Constant::Ellipsis => text("...").fmt(f),
|
||||
Constant::None => text("None").fmt(f),
|
||||
Constant::Bool(value) => match value {
|
||||
true => text("True").fmt(f),
|
||||
false => text("False").fmt(f),
|
||||
},
|
||||
Constant::Int(_) | Constant::Float(_) | Constant::Complex { .. } => {
|
||||
write!(f, [verbatim_text(item)])
|
||||
}
|
||||
Constant::Str(_) => {
|
||||
not_yet_implemented_custom_text(r#""NOT_YET_IMPLEMENTED_STRING""#).fmt(f)
|
||||
}
|
||||
Constant::Bytes(_) => {
|
||||
not_yet_implemented_custom_text(r#"b"NOT_YET_IMPLEMENTED_BYTE_STRING""#).fmt(f)
|
||||
}
|
||||
Constant::Tuple(_) => {
|
||||
not_yet_implemented_custom_text("(NOT_YET_IMPLEMENTED_TUPLE,)").fmt(f)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,11 +9,10 @@ use rustpython_parser::ast::ExprDict;
|
|||
pub struct FormatExprDict;
|
||||
|
||||
impl FormatNodeRule<ExprDict> for FormatExprDict {
|
||||
fn fmt_fields(&self, item: &ExprDict, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
fn fmt_fields(&self, _item: &ExprDict, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
write!(
|
||||
f,
|
||||
[not_yet_implemented_custom_text(
|
||||
item,
|
||||
"{NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value}"
|
||||
)]
|
||||
)
|
||||
|
|
|
@ -9,11 +9,10 @@ use rustpython_parser::ast::ExprDictComp;
|
|||
pub struct FormatExprDictComp;
|
||||
|
||||
impl FormatNodeRule<ExprDictComp> for FormatExprDictComp {
|
||||
fn fmt_fields(&self, item: &ExprDictComp, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
fn fmt_fields(&self, _item: &ExprDictComp, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
write!(
|
||||
f,
|
||||
[not_yet_implemented_custom_text(
|
||||
item,
|
||||
"{NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value for key, value in NOT_IMPLEMENTED_dict}"
|
||||
)]
|
||||
)
|
||||
|
|
|
@ -9,11 +9,8 @@ use rustpython_parser::ast::ExprGeneratorExp;
|
|||
pub struct FormatExprGeneratorExp;
|
||||
|
||||
impl FormatNodeRule<ExprGeneratorExp> for FormatExprGeneratorExp {
|
||||
fn fmt_fields(&self, item: &ExprGeneratorExp, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
write!(
|
||||
f,
|
||||
[not_yet_implemented_custom_text(item, "(i for i in [])")]
|
||||
)
|
||||
fn fmt_fields(&self, _item: &ExprGeneratorExp, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
write!(f, [not_yet_implemented_custom_text("(i for i in [])")])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,11 +9,10 @@ use rustpython_parser::ast::ExprIfExp;
|
|||
pub struct FormatExprIfExp;
|
||||
|
||||
impl FormatNodeRule<ExprIfExp> for FormatExprIfExp {
|
||||
fn fmt_fields(&self, item: &ExprIfExp, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
fn fmt_fields(&self, _item: &ExprIfExp, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
write!(
|
||||
f,
|
||||
[not_yet_implemented_custom_text(
|
||||
item,
|
||||
"NOT_IMPLEMENTED_true if NOT_IMPLEMENTED_cond else NOT_IMPLEMENTED_false"
|
||||
)]
|
||||
)
|
||||
|
|
|
@ -9,8 +9,8 @@ use rustpython_parser::ast::ExprLambda;
|
|||
pub struct FormatExprLambda;
|
||||
|
||||
impl FormatNodeRule<ExprLambda> for FormatExprLambda {
|
||||
fn fmt_fields(&self, item: &ExprLambda, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
write!(f, [not_yet_implemented_custom_text(item, "lambda x: True")])
|
||||
fn fmt_fields(&self, _item: &ExprLambda, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
write!(f, [not_yet_implemented_custom_text("lambda x: True")])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,11 +9,8 @@ use rustpython_parser::ast::ExprListComp;
|
|||
pub struct FormatExprListComp;
|
||||
|
||||
impl FormatNodeRule<ExprListComp> for FormatExprListComp {
|
||||
fn fmt_fields(&self, item: &ExprListComp, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
write!(
|
||||
f,
|
||||
[not_yet_implemented_custom_text(item, "[i for i in []]")]
|
||||
)
|
||||
fn fmt_fields(&self, _item: &ExprListComp, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
write!(f, [not_yet_implemented_custom_text("[i for i in []]")])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,11 +10,10 @@ use rustpython_parser::ast::ExprSlice;
|
|||
pub struct FormatExprSlice;
|
||||
|
||||
impl FormatNodeRule<ExprSlice> for FormatExprSlice {
|
||||
fn fmt_fields(&self, item: &ExprSlice, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
fn fmt_fields(&self, _item: &ExprSlice, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
write!(
|
||||
f,
|
||||
[not_yet_implemented_custom_text(
|
||||
item,
|
||||
"NOT_IMPLEMENTED_start:NOT_IMPLEMENTED_end"
|
||||
)]
|
||||
)
|
||||
|
|
|
@ -10,11 +10,10 @@ use rustpython_parser::ast::ExprSubscript;
|
|||
pub struct FormatExprSubscript;
|
||||
|
||||
impl FormatNodeRule<ExprSubscript> for FormatExprSubscript {
|
||||
fn fmt_fields(&self, item: &ExprSubscript, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
fn fmt_fields(&self, _item: &ExprSubscript, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
write!(
|
||||
f,
|
||||
[not_yet_implemented_custom_text(
|
||||
item,
|
||||
"NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key]"
|
||||
)]
|
||||
)
|
||||
|
|
|
@ -9,8 +9,8 @@ use rustpython_parser::ast::ExprTuple;
|
|||
pub struct FormatExprTuple;
|
||||
|
||||
impl FormatNodeRule<ExprTuple> for FormatExprTuple {
|
||||
fn fmt_fields(&self, item: &ExprTuple, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
write!(f, [not_yet_implemented_custom_text(item, "(1, 2)")])
|
||||
fn fmt_fields(&self, _item: &ExprTuple, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
write!(f, [not_yet_implemented_custom_text("(1, 2)")])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,19 +39,17 @@ where
|
|||
N: AstNode,
|
||||
{
|
||||
fn fmt(&self, node: &N, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
write!(f, [source_position(node.start())])?;
|
||||
self.fmt_leading_comments(node, f)?;
|
||||
self.fmt_node(node, f)?;
|
||||
self.fmt_dangling_comments(node, f)?;
|
||||
self.fmt_trailing_comments(node, f)?;
|
||||
write!(f, [source_position(node.end())])
|
||||
self.fmt_trailing_comments(node, f)
|
||||
}
|
||||
|
||||
/// Formats the node without comments. Ignores any suppression comments.
|
||||
fn fmt_node(&self, node: &N, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
write!(f, [source_position(node.start())])?;
|
||||
self.fmt_fields(node, f)?;
|
||||
|
||||
Ok(())
|
||||
write!(f, [source_position(node.end())])
|
||||
}
|
||||
|
||||
/// Formats the node's fields.
|
||||
|
@ -164,33 +162,26 @@ impl Format<PyFormatContext<'_>> for NotYetImplemented {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) struct NotYetImplementedCustomText(NodeKind, String);
|
||||
pub(crate) struct NotYetImplementedCustomText(&'static str);
|
||||
|
||||
/// Formats a placeholder for nodes that have not yet been implemented
|
||||
pub(crate) fn not_yet_implemented_custom_text<'a, T>(
|
||||
node: T,
|
||||
text: impl AsRef<str>,
|
||||
) -> NotYetImplementedCustomText
|
||||
where
|
||||
T: Into<AnyNodeRef<'a>>,
|
||||
{
|
||||
NotYetImplementedCustomText(node.into().kind(), text.as_ref().to_string())
|
||||
pub(crate) const fn not_yet_implemented_custom_text(
|
||||
text: &'static str,
|
||||
) -> NotYetImplementedCustomText {
|
||||
NotYetImplementedCustomText(text)
|
||||
}
|
||||
|
||||
impl Format<PyFormatContext<'_>> for NotYetImplementedCustomText {
|
||||
fn fmt(&self, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
f.write_element(FormatElement::Tag(Tag::StartVerbatim(
|
||||
tag::VerbatimKind::Verbatim {
|
||||
length: self.1.text_len(),
|
||||
length: self.0.text_len(),
|
||||
},
|
||||
)))?;
|
||||
|
||||
f.write_element(FormatElement::DynamicText {
|
||||
text: Box::from(self.1.clone()),
|
||||
})?;
|
||||
text(self.0).fmt(f)?;
|
||||
|
||||
f.write_element(FormatElement::Tag(Tag::EndVerbatim))?;
|
||||
Ok(())
|
||||
f.write_element(FormatElement::Tag(Tag::EndVerbatim))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -417,12 +408,11 @@ Formatted twice:
|
|||
#[ignore]
|
||||
#[test]
|
||||
fn quick_test() {
|
||||
let src = r#"AAAAAAAAAAAAA = AAAAAAAAAAAAA # type: ignore
|
||||
let src = r#"
|
||||
def test(): ...
|
||||
|
||||
call_to_some_function_asdf(
|
||||
foo,
|
||||
[AAAAAAAAAAAAAAAAAAAAAAA, AAAAAAAAAAAAAAAAAAAAAAA, AAAAAAAAAAAAAAAAAAAAAAA, BBBBBBBBBBBB], # type: ignore
|
||||
)
|
||||
# Comment
|
||||
def with_leading_comment(): ...
|
||||
"#;
|
||||
// Tokenize once
|
||||
let mut tokens = Vec::new();
|
||||
|
|
|
@ -55,17 +55,17 @@ y = 100(no)
|
|||
+x = NOT_IMPLEMENTED_call()
|
||||
+x = NOT_IMPLEMENTED_call()
|
||||
+x = NOT_IMPLEMENTED_call()
|
||||
+x = 0x42.NOT_IMPLEMENTED_attr
|
||||
+x = 0x42.NOT_IMPLEMENTED_attr
|
||||
+x = 0x42.NOT_IMPLEMENTED_attr
|
||||
+x = 1. .NOT_IMPLEMENTED_attr
|
||||
+x = 1E+1 .NOT_IMPLEMENTED_attr
|
||||
+x = 1E-1 .NOT_IMPLEMENTED_attr
|
||||
+x = NOT_IMPLEMENTED_call()
|
||||
+x = 0x42.NOT_IMPLEMENTED_attr
|
||||
+x = 123456789.123456789E123456789 .NOT_IMPLEMENTED_attr
|
||||
+x = NOT_IMPLEMENTED_call()
|
||||
+x = 0x42.NOT_IMPLEMENTED_attr
|
||||
+x = 123456789J.NOT_IMPLEMENTED_attr
|
||||
+x = NOT_IMPLEMENTED_call()
|
||||
+x = NOT_IMPLEMENTED_call()
|
||||
+x = NOT_IMPLEMENTED_call()
|
||||
+x = 0x42.NOT_IMPLEMENTED_attr
|
||||
+x = 0O777 .NOT_IMPLEMENTED_attr
|
||||
+x = NOT_IMPLEMENTED_call()
|
||||
+x = NOT_YET_IMPLEMENTED_ExprUnaryOp
|
||||
|
||||
|
@ -85,17 +85,17 @@ y = 100(no)
|
|||
x = NOT_IMPLEMENTED_call()
|
||||
x = NOT_IMPLEMENTED_call()
|
||||
x = NOT_IMPLEMENTED_call()
|
||||
x = 0x42.NOT_IMPLEMENTED_attr
|
||||
x = 0x42.NOT_IMPLEMENTED_attr
|
||||
x = 0x42.NOT_IMPLEMENTED_attr
|
||||
x = 1. .NOT_IMPLEMENTED_attr
|
||||
x = 1E+1 .NOT_IMPLEMENTED_attr
|
||||
x = 1E-1 .NOT_IMPLEMENTED_attr
|
||||
x = NOT_IMPLEMENTED_call()
|
||||
x = 0x42.NOT_IMPLEMENTED_attr
|
||||
x = 123456789.123456789E123456789 .NOT_IMPLEMENTED_attr
|
||||
x = NOT_IMPLEMENTED_call()
|
||||
x = 0x42.NOT_IMPLEMENTED_attr
|
||||
x = 123456789J.NOT_IMPLEMENTED_attr
|
||||
x = NOT_IMPLEMENTED_call()
|
||||
x = NOT_IMPLEMENTED_call()
|
||||
x = NOT_IMPLEMENTED_call()
|
||||
x = 0x42.NOT_IMPLEMENTED_attr
|
||||
x = 0O777 .NOT_IMPLEMENTED_attr
|
||||
x = NOT_IMPLEMENTED_call()
|
||||
x = NOT_YET_IMPLEMENTED_ExprUnaryOp
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ if True:
|
|||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -1,99 +1,40 @@
|
||||
@@ -1,99 +1,46 @@
|
||||
-import core, time, a
|
||||
+NOT_YET_IMPLEMENTED_StmtImport
|
||||
|
||||
|
@ -115,7 +115,8 @@ if True:
|
|||
- 2,
|
||||
- 3,
|
||||
-}
|
||||
-b = {1, 2, 3}
|
||||
+a = {1, 2, 3}
|
||||
b = {1, 2, 3}
|
||||
-c = {
|
||||
- 1,
|
||||
- 2,
|
||||
|
@ -128,13 +129,23 @@ if True:
|
|||
- (4, 5, 6),
|
||||
-}
|
||||
-nested_no_trailing_comma = {(1, 2, 3), (4, 5, 6)}
|
||||
-nested_long_lines = [
|
||||
+c = {1, 2, 3}
|
||||
+x = (1, 2)
|
||||
+y = (1, 2)
|
||||
+nested = {(1, 2), (1, 2)}
|
||||
+nested_no_trailing_comma = {(1, 2), (1, 2)}
|
||||
nested_long_lines = [
|
||||
- "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
- "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
- "cccccccccccccccccccccccccccccccccccccccc",
|
||||
- (1, 2, 3),
|
||||
- "dddddddddddddddddddddddddddddddddddddddd",
|
||||
-]
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
+ (1, 2),
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
]
|
||||
-{
|
||||
- "oneple": (1,),
|
||||
-}
|
||||
|
@ -148,17 +159,9 @@ if True:
|
|||
- "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa wraps %s"
|
||||
- % bar
|
||||
-)
|
||||
+a = {0x42, 0x42, 0x42}
|
||||
+b = {0x42, 0x42, 0x42}
|
||||
+c = {0x42, 0x42, 0x42}
|
||||
+x = (1, 2)
|
||||
+y = (1, 2)
|
||||
+nested = {(1, 2), (1, 2)}
|
||||
+nested_no_trailing_comma = {(1, 2), (1, 2)}
|
||||
+nested_long_lines = [0x42, 0x42, 0x42, (1, 2), 0x42]
|
||||
+{NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value}
|
||||
+{NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value}
|
||||
+[0x42, 0x42 % (1, 2)]
|
||||
+["NOT_YET_IMPLEMENTED_STRING", "NOT_YET_IMPLEMENTED_STRING" % (1, 2)]
|
||||
+x = {NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value}
|
||||
+y = {NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value}
|
||||
+NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
@ -176,7 +179,7 @@ if True:
|
|||
- 2,
|
||||
- 3,
|
||||
-]
|
||||
+[0x42, 0x42, 0x42]
|
||||
+[1, 2, 3]
|
||||
|
||||
-division_result_tuple = (6 / 2,)
|
||||
-print("foo %r", (foo.bar,))
|
||||
|
@ -228,17 +231,23 @@ NOT_YET_IMPLEMENTED_StmtImportFrom
|
|||
# `as` works as well
|
||||
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||
|
||||
a = {0x42, 0x42, 0x42}
|
||||
b = {0x42, 0x42, 0x42}
|
||||
c = {0x42, 0x42, 0x42}
|
||||
a = {1, 2, 3}
|
||||
b = {1, 2, 3}
|
||||
c = {1, 2, 3}
|
||||
x = (1, 2)
|
||||
y = (1, 2)
|
||||
nested = {(1, 2), (1, 2)}
|
||||
nested_no_trailing_comma = {(1, 2), (1, 2)}
|
||||
nested_long_lines = [0x42, 0x42, 0x42, (1, 2), 0x42]
|
||||
nested_long_lines = [
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
(1, 2),
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
]
|
||||
{NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value}
|
||||
{NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value}
|
||||
[0x42, 0x42 % (1, 2)]
|
||||
["NOT_YET_IMPLEMENTED_STRING", "NOT_YET_IMPLEMENTED_STRING" % (1, 2)]
|
||||
x = {NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value}
|
||||
y = {NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value}
|
||||
NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
@ -247,7 +256,7 @@ NOT_YET_IMPLEMENTED_StmtAssert
|
|||
NOT_YET_IMPLEMENTED_StmtFor
|
||||
NOT_YET_IMPLEMENTED_StmtFor
|
||||
|
||||
[0x42, 0x42, 0x42]
|
||||
[1, 2, 3]
|
||||
|
||||
division_result_tuple = (1, 2)
|
||||
NOT_IMPLEMENTED_call()
|
||||
|
|
|
@ -178,7 +178,7 @@ instruction()#comment with bad spacing
|
|||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -1,173 +1,68 @@
|
||||
@@ -1,31 +1,27 @@
|
||||
-from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
|
||||
- MyLovelyCompanyTeamProjectComponent, # NOT DRY
|
||||
-)
|
||||
|
@ -195,16 +195,16 @@ instruction()#comment with bad spacing
|
|||
- "Any",
|
||||
- "Callable",
|
||||
- "ClassVar",
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
# ABCs (from collections.abc).
|
||||
- "AbstractSet", # collections.abc.Set.
|
||||
- "ByteString",
|
||||
- "Container",
|
||||
+ 0x42, # collections.abc.Set.
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ "NOT_YET_IMPLEMENTED_STRING", # collections.abc.Set.
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
# Concrete collection types.
|
||||
- "Counter",
|
||||
- "Deque",
|
||||
|
@ -215,39 +215,30 @@ instruction()#comment with bad spacing
|
|||
- "FrozenSet",
|
||||
- "NamedTuple", # Not really a type.
|
||||
- "Generator",
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ 0x42, # Not really a type.
|
||||
+ 0x42,
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
+ "NOT_YET_IMPLEMENTED_STRING", # Not really a type.
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
]
|
||||
|
||||
not_shareables = [
|
||||
# singletons
|
||||
- True,
|
||||
- False,
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
NotImplemented,
|
||||
- ...,
|
||||
+ 0x42,
|
||||
@@ -37,129 +33,28 @@
|
||||
# builtin types and objects
|
||||
type,
|
||||
object,
|
||||
- object(),
|
||||
- Exception(),
|
||||
- 42,
|
||||
- 100.0,
|
||||
+ NOT_IMPLEMENTED_call(),
|
||||
+ NOT_IMPLEMENTED_call(),
|
||||
42,
|
||||
100.0,
|
||||
- "spam",
|
||||
+ NOT_IMPLEMENTED_call(),
|
||||
+ NOT_IMPLEMENTED_call(),
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
# user-defined types and objects
|
||||
Cheese,
|
||||
- Cheese("Wensleydale"),
|
||||
|
@ -308,10 +299,9 @@ instruction()#comment with bad spacing
|
|||
-""",
|
||||
- arg3=True,
|
||||
- )
|
||||
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||
|
||||
-
|
||||
- ############################################################################
|
||||
|
||||
-
|
||||
- call2(
|
||||
- # short
|
||||
- arg1,
|
||||
|
@ -346,17 +336,16 @@ instruction()#comment with bad spacing
|
|||
- while True:
|
||||
- if False:
|
||||
- continue
|
||||
+CONFIG_FILES = [CONFIG_FILE] + SHARED_CONFIG_FILES + USER_CONFIG_FILES # type: Final
|
||||
|
||||
-
|
||||
- # and round and round we go
|
||||
- # and round and round we go
|
||||
|
||||
-
|
||||
- # let's return
|
||||
- return Node(
|
||||
- syms.simple_stmt,
|
||||
- [Node(statement, result), Leaf(token.NEWLINE, "\n")], # FIXME: \r\n?
|
||||
- )
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||
|
||||
|
||||
-CONFIG_FILES = (
|
||||
|
@ -366,16 +355,18 @@ instruction()#comment with bad spacing
|
|||
- + SHARED_CONFIG_FILES
|
||||
- + USER_CONFIG_FILES
|
||||
-) # type: Final
|
||||
-
|
||||
-
|
||||
+CONFIG_FILES = [CONFIG_FILE] + 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
|
||||
- pass
|
||||
-
|
||||
-
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
|
||||
|
||||
#######################
|
||||
### SECTION COMMENT ###
|
||||
@@ -167,7 +62,7 @@
|
||||
#######################
|
||||
|
||||
|
||||
|
@ -396,39 +387,39 @@ NOT_YET_IMPLEMENTED_StmtImportFrom
|
|||
|
||||
__all__ = [
|
||||
# Super-special typing primitives.
|
||||
0x42,
|
||||
0x42,
|
||||
0x42,
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
# ABCs (from collections.abc).
|
||||
0x42, # collections.abc.Set.
|
||||
0x42,
|
||||
0x42,
|
||||
"NOT_YET_IMPLEMENTED_STRING", # collections.abc.Set.
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
# Concrete collection types.
|
||||
0x42,
|
||||
0x42,
|
||||
0x42,
|
||||
0x42,
|
||||
0x42,
|
||||
0x42,
|
||||
0x42,
|
||||
0x42, # Not really a type.
|
||||
0x42,
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
"NOT_YET_IMPLEMENTED_STRING", # Not really a type.
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
]
|
||||
|
||||
not_shareables = [
|
||||
# singletons
|
||||
0x42,
|
||||
0x42,
|
||||
True,
|
||||
False,
|
||||
NotImplemented,
|
||||
0x42,
|
||||
...,
|
||||
# builtin types and objects
|
||||
type,
|
||||
object,
|
||||
NOT_IMPLEMENTED_call(),
|
||||
NOT_IMPLEMENTED_call(),
|
||||
0x42,
|
||||
0x42,
|
||||
0x42,
|
||||
42,
|
||||
100.0,
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
# user-defined types and objects
|
||||
Cheese,
|
||||
NOT_IMPLEMENTED_call(),
|
||||
|
|
|
@ -87,40 +87,39 @@ if __name__ == "__main__":
|
|||
--- Black
|
||||
+++ Ruff
|
||||
@@ -1,61 +1,33 @@
|
||||
-while True:
|
||||
while True:
|
||||
- if something.changed:
|
||||
- do.stuff() # trailing comment
|
||||
- # Comment belongs to the `if` block.
|
||||
+while 0x42:
|
||||
+ NOT_YET_IMPLEMENTED_StmtIf
|
||||
# This one belongs to the `while` block.
|
||||
|
||||
# Should this one, too? I guess so.
|
||||
|
||||
# This one is properly standalone now.
|
||||
|
||||
-
|
||||
-for i in range(100):
|
||||
- # first we do this
|
||||
- if i % 33 == 0:
|
||||
- break
|
||||
+NOT_YET_IMPLEMENTED_StmtFor
|
||||
|
||||
-
|
||||
- # then we do this
|
||||
- print(i)
|
||||
- # and finally we loop around
|
||||
+NOT_YET_IMPLEMENTED_StmtWith
|
||||
|
||||
-with open(some_temp_file) as f:
|
||||
- data = f.read()
|
||||
-
|
||||
+NOT_YET_IMPLEMENTED_StmtFor
|
||||
|
||||
-try:
|
||||
- with open(some_other_file) as w:
|
||||
- w.write(data)
|
||||
+NOT_YET_IMPLEMENTED_StmtTry
|
||||
+NOT_YET_IMPLEMENTED_StmtWith
|
||||
|
||||
-except OSError:
|
||||
- print("problems")
|
||||
-
|
||||
+NOT_YET_IMPLEMENTED_StmtTry
|
||||
|
||||
-import sys
|
||||
+NOT_YET_IMPLEMENTED_StmtImport
|
||||
|
||||
|
@ -174,7 +173,7 @@ if __name__ == "__main__":
|
|||
## Ruff Output
|
||||
|
||||
```py
|
||||
while 0x42:
|
||||
while True:
|
||||
NOT_YET_IMPLEMENTED_StmtIf
|
||||
# This one belongs to the `while` block.
|
||||
|
||||
|
|
|
@ -246,7 +246,7 @@ aaaaaaaaaaaaa, bbbbbbbbb = map(list, map(itertools.chain.from_iterable, zip(*ite
|
|||
- "aaaaaaaa", "aaaaaaaa", "aaaaaaaa", "aaaaaaaa", "aaaaaaaa", "aaaaaaaa", "aaaaaaaa" # type: ignore
|
||||
- )
|
||||
|
||||
+result = 0x42 # aaa
|
||||
+result = "NOT_YET_IMPLEMENTED_STRING" # aaa
|
||||
|
||||
-result = ( # aaa
|
||||
- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||
|
@ -301,7 +301,7 @@ NOT_YET_IMPLEMENTED_StmtFunctionDef
|
|||
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||
|
||||
|
||||
result = 0x42 # aaa
|
||||
result = "NOT_YET_IMPLEMENTED_STRING" # aaa
|
||||
|
||||
AAAAAAAAAAAAA = (
|
||||
[AAAAAAAAAAAAA]
|
||||
|
|
|
@ -41,16 +41,13 @@ def function(a:int=42):
|
|||
-)
|
||||
+NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||
|
||||
-result = 1 # A simple comment
|
||||
result = 1 # A simple comment
|
||||
-result = (1,) # Another one
|
||||
+result = 0x42 # A simple comment
|
||||
+result = (1, 2) # Another one
|
||||
|
||||
-result = 1 # type: ignore
|
||||
-result = 1 # This comment is talking about type: ignore
|
||||
result = 1 # type: ignore
|
||||
result = 1 # This comment is talking about type: ignore
|
||||
-square = Square(4) # type: Optional[Square]
|
||||
+result = 0x42 # type: ignore
|
||||
+result = 0x42 # This comment is talking about type: ignore
|
||||
+square = NOT_IMPLEMENTED_call() # type: Optional[Square]
|
||||
|
||||
|
||||
|
@ -70,11 +67,11 @@ def function(a:int=42):
|
|||
```py
|
||||
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||
|
||||
result = 0x42 # A simple comment
|
||||
result = 1 # A simple comment
|
||||
result = (1, 2) # Another one
|
||||
|
||||
result = 0x42 # type: ignore
|
||||
result = 0x42 # This comment is talking about type: ignore
|
||||
result = 1 # type: ignore
|
||||
result = 1 # This comment is talking about type: ignore
|
||||
square = NOT_IMPLEMENTED_call() # type: Optional[Square]
|
||||
|
||||
|
||||
|
|
|
@ -114,51 +114,50 @@ async def wat():
|
|||
# Has many lines. Many, many lines.
|
||||
# Many, many, many lines.
|
||||
-"""Module docstring.
|
||||
+0x42
|
||||
|
||||
-
|
||||
-Possibly also many, many lines.
|
||||
-"""
|
||||
+NOT_YET_IMPLEMENTED_StmtImport
|
||||
+NOT_YET_IMPLEMENTED_StmtImport
|
||||
|
||||
-
|
||||
-import os.path
|
||||
-import sys
|
||||
-
|
||||
-import a
|
||||
-from b.c import X # some noqa comment
|
||||
+NOT_YET_IMPLEMENTED_StmtImport
|
||||
+NOT_YET_IMPLEMENTED_StmtImportFrom # some noqa comment
|
||||
+"NOT_YET_IMPLEMENTED_STRING"
|
||||
|
||||
-try:
|
||||
- import fast
|
||||
-except ImportError:
|
||||
- import slow as fast
|
||||
-
|
||||
-
|
||||
+NOT_YET_IMPLEMENTED_StmtImport
|
||||
+NOT_YET_IMPLEMENTED_StmtImport
|
||||
|
||||
+NOT_YET_IMPLEMENTED_StmtImport
|
||||
+NOT_YET_IMPLEMENTED_StmtImportFrom # some noqa comment
|
||||
|
||||
-# Some comment before a function.
|
||||
-y = 1
|
||||
+NOT_YET_IMPLEMENTED_StmtTry
|
||||
+y = 0x42
|
||||
y = 1
|
||||
(
|
||||
# some strings
|
||||
y # type: ignore
|
||||
)
|
||||
-
|
||||
|
||||
-
|
||||
-def function(default=None):
|
||||
- """Docstring comes first.
|
||||
|
||||
-
|
||||
- Possibly many lines.
|
||||
- """
|
||||
- # FIXME: Some comment about why this function is crap but still in production.
|
||||
- import inner_imports
|
||||
-
|
||||
|
||||
- if inner_imports.are_evil():
|
||||
- # Explains why we have this if.
|
||||
- # In great detail indeed.
|
||||
- x = X()
|
||||
- return x.method1() # type: ignore
|
||||
-
|
||||
|
||||
- # This return is also commented for some reason.
|
||||
- return default
|
||||
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||
|
@ -171,11 +170,11 @@ async def wat():
|
|||
|
||||
# Another comment!
|
||||
# This time two lines.
|
||||
-
|
||||
|
||||
|
||||
-class Foo:
|
||||
- """Docstring for class Foo. Example from Sphinx docs."""
|
||||
|
||||
-
|
||||
- #: Doc comment for class attribute Foo.bar.
|
||||
- #: It can have multiple lines.
|
||||
- bar = 1
|
||||
|
@ -188,12 +187,12 @@ async def wat():
|
|||
- def __init__(self):
|
||||
- #: Doc comment for instance attribute qux.
|
||||
- self.qux = 3
|
||||
-
|
||||
- self.spam = 4
|
||||
- """Docstring for instance attribute spam."""
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
|
||||
- self.spam = 4
|
||||
- """Docstring for instance attribute spam."""
|
||||
|
||||
-
|
||||
#' <h1>This is pweave!</h1>
|
||||
|
||||
|
||||
|
@ -227,7 +226,7 @@ async def wat():
|
|||
#
|
||||
# Has many lines. Many, many lines.
|
||||
# Many, many, many lines.
|
||||
0x42
|
||||
"NOT_YET_IMPLEMENTED_STRING"
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtImport
|
||||
NOT_YET_IMPLEMENTED_StmtImport
|
||||
|
@ -236,7 +235,7 @@ NOT_YET_IMPLEMENTED_StmtImport
|
|||
NOT_YET_IMPLEMENTED_StmtImportFrom # some noqa comment
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtTry
|
||||
y = 0x42
|
||||
y = 1
|
||||
(
|
||||
# some strings
|
||||
y # type: ignore
|
||||
|
|
|
@ -107,7 +107,7 @@ def g():
|
|||
+++ Ruff
|
||||
@@ -1,89 +1,12 @@
|
||||
-"""Docstring."""
|
||||
+0x42
|
||||
+"NOT_YET_IMPLEMENTED_STRING"
|
||||
|
||||
|
||||
# leading comment
|
||||
|
@ -203,7 +203,7 @@ def g():
|
|||
## Ruff Output
|
||||
|
||||
```py
|
||||
0x42
|
||||
"NOT_YET_IMPLEMENTED_STRING"
|
||||
|
||||
|
||||
# leading comment
|
||||
|
|
|
@ -267,19 +267,19 @@ last_call()
|
|||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -1,352 +1,247 @@
|
||||
@@ -1,5 +1,6 @@
|
||||
-"some_string"
|
||||
-b"\\xa3"
|
||||
+0x42
|
||||
+0x42
|
||||
+0x42
|
||||
+...
|
||||
+"NOT_YET_IMPLEMENTED_STRING"
|
||||
+b"NOT_YET_IMPLEMENTED_BYTE_STRING"
|
||||
Name
|
||||
-None
|
||||
-True
|
||||
-False
|
||||
-1
|
||||
-1.0
|
||||
-1j
|
||||
None
|
||||
True
|
||||
@@ -7,346 +8,240 @@
|
||||
1
|
||||
1.0
|
||||
1j
|
||||
-True or False
|
||||
-True or False or None
|
||||
-True and False
|
||||
|
@ -292,11 +292,23 @@ last_call()
|
|||
-Name1 and Name2 or Name3 and Name4
|
||||
-Name1 or (Name2 and Name3) or Name4
|
||||
-Name1 or Name2 and Name3 or Name4
|
||||
-v1 << 2
|
||||
-1 >> v2
|
||||
-1 % finished
|
||||
-1 + v2 - v3 * 4 ^ 5**v6 / 7 // 8
|
||||
-((1 + v2) - (v3 * 4)) ^ (((5**v6) / 7) // 8)
|
||||
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
||||
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
||||
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
||||
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
||||
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
||||
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
||||
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
||||
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
||||
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
||||
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
||||
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
||||
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
||||
v1 << 2
|
||||
1 >> v2
|
||||
1 % finished
|
||||
1 + v2 - v3 * 4 ^ 5**v6 / 7 // 8
|
||||
((1 + v2) - (v3 * 4)) ^ (((5**v6) / 7) // 8)
|
||||
-not great
|
||||
-~great
|
||||
-+value
|
||||
|
@ -332,29 +344,6 @@ last_call()
|
|||
-({"a": "b"}, (True or False), (+value), "string", b"bytes") or None
|
||||
-()
|
||||
-(1,)
|
||||
+0x42
|
||||
+0x42
|
||||
+0x42
|
||||
+0x42
|
||||
+0x42
|
||||
+0x42
|
||||
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
||||
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
||||
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
||||
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
||||
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
||||
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
||||
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
||||
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
||||
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
||||
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
||||
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
||||
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
||||
+v1 << 0x42
|
||||
+0x42 >> v2
|
||||
+0x42 % finished
|
||||
+0x42 + v2 - v3 * 0x42 ^ 0x42**v6 / 0x42 // 0x42
|
||||
+((0x42 + v2) - (v3 * 0x42)) ^ (((0x42**v6) / 0x42) // 0x42)
|
||||
+NOT_YET_IMPLEMENTED_ExprUnaryOp
|
||||
+NOT_YET_IMPLEMENTED_ExprUnaryOp
|
||||
+NOT_YET_IMPLEMENTED_ExprUnaryOp
|
||||
|
@ -380,11 +369,11 @@ last_call()
|
|||
+{NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value}
|
||||
+{NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value}
|
||||
+{
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
+ (NOT_IMPLEMENTED_true if NOT_IMPLEMENTED_cond else NOT_IMPLEMENTED_false),
|
||||
+}
|
||||
+NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
||||
|
@ -396,39 +385,34 @@ last_call()
|
|||
[]
|
||||
-[1, 2, 3, 4, 5, 6, 7, 8, 9, (10 or A), (11 or B), (12 or C)]
|
||||
[
|
||||
- 1,
|
||||
- 2,
|
||||
- 3,
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ (NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2),
|
||||
+ (NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2),
|
||||
+ (NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2),
|
||||
]
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
-]
|
||||
-[*a]
|
||||
-[*range(10)]
|
||||
-[
|
||||
- *a,
|
||||
- 4,
|
||||
- 5,
|
||||
-]
|
||||
4,
|
||||
5,
|
||||
+ 6,
|
||||
+ 7,
|
||||
+ 8,
|
||||
+ 9,
|
||||
+ (NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2),
|
||||
+ (NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2),
|
||||
+ (NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2),
|
||||
]
|
||||
-[
|
||||
- 4,
|
||||
- *a,
|
||||
- 5,
|
||||
-]
|
||||
+[0x42, 0x42, 0x42]
|
||||
+[1, 2, 3]
|
||||
+[NOT_YET_IMPLEMENTED_ExprStarred]
|
||||
+[NOT_YET_IMPLEMENTED_ExprStarred]
|
||||
+[NOT_YET_IMPLEMENTED_ExprStarred, 0x42, 0x42]
|
||||
+[0x42, NOT_YET_IMPLEMENTED_ExprStarred, 0x42]
|
||||
+[NOT_YET_IMPLEMENTED_ExprStarred, 4, 5]
|
||||
+[4, NOT_YET_IMPLEMENTED_ExprStarred, 5]
|
||||
[
|
||||
this_is_a_very_long_variable_which_will_force_a_delimiter_split,
|
||||
element,
|
||||
|
@ -475,9 +459,9 @@ last_call()
|
|||
+NOT_IMPLEMENTED_call()
|
||||
+lukasz.NOT_IMPLEMENTED_attr.NOT_IMPLEMENTED_attr
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+0x42.NOT_IMPLEMENTED_attr
|
||||
+0x42.NOT_IMPLEMENTED_attr
|
||||
+0x42.NOT_IMPLEMENTED_attr
|
||||
+1 .NOT_IMPLEMENTED_attr
|
||||
+1.0 .NOT_IMPLEMENTED_attr
|
||||
+....NOT_IMPLEMENTED_attr
|
||||
+NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key]
|
||||
+NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key]
|
||||
+NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key]
|
||||
|
@ -518,11 +502,11 @@ last_call()
|
|||
{
|
||||
- k: v
|
||||
- for k, v in this_is_a_very_long_variable_which_will_cause_a_trailing_comma_which_breaks_the_comprehension
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
+ NOT_IMPLEMENTED_true if NOT_IMPLEMENTED_cond else NOT_IMPLEMENTED_false,
|
||||
}
|
||||
-Python3 > Python2 > COBOL
|
||||
|
@ -558,15 +542,15 @@ last_call()
|
|||
- float,
|
||||
- dict[str, int],
|
||||
+[
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ 0x42,
|
||||
+ 1,
|
||||
+ 2,
|
||||
+ 3,
|
||||
+ 4,
|
||||
+ 5,
|
||||
+ 6,
|
||||
+ 7,
|
||||
+ 8,
|
||||
+ 9,
|
||||
+ NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2,
|
||||
+ NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2,
|
||||
+ NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2,
|
||||
|
@ -632,24 +616,6 @@ last_call()
|
|||
-}
|
||||
-a = (1,)
|
||||
-b = (1,)
|
||||
-c = 1
|
||||
-d = (1,) + a + (2,)
|
||||
-e = (1,).count(1)
|
||||
-f = 1, *range(10)
|
||||
-g = 1, *"ten"
|
||||
-what_is_up_with_those_new_coord_names = (coord_names + set(vars_to_create)) + set(
|
||||
- vars_to_remove
|
||||
-)
|
||||
-what_is_up_with_those_new_coord_names = (coord_names | set(vars_to_create)) - set(
|
||||
- vars_to_remove
|
||||
-)
|
||||
-result = (
|
||||
- session.query(models.Customer.id)
|
||||
- .filter(
|
||||
- models.Customer.account_id == account_id, models.Customer.email == email_address
|
||||
- )
|
||||
- .order_by(models.Customer.id.asc())
|
||||
- .all()
|
||||
+(1, 2)
|
||||
+(i for i in [])
|
||||
+(i for i in [])
|
||||
|
@ -659,7 +625,13 @@ last_call()
|
|||
+{NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value}
|
||||
+a = (1, 2)
|
||||
+b = (1, 2)
|
||||
+c = 0x42
|
||||
c = 1
|
||||
-d = (1,) + a + (2,)
|
||||
-e = (1,).count(1)
|
||||
-f = 1, *range(10)
|
||||
-g = 1, *"ten"
|
||||
-what_is_up_with_those_new_coord_names = (coord_names + set(vars_to_create)) + set(
|
||||
- vars_to_remove
|
||||
+d = (1, 2) + a + (1, 2)
|
||||
+e = NOT_IMPLEMENTED_call()
|
||||
+f = (1, 2)
|
||||
|
@ -668,6 +640,20 @@ last_call()
|
|||
+ (coord_names + NOT_IMPLEMENTED_call())
|
||||
+ + NOT_IMPLEMENTED_call()
|
||||
)
|
||||
-what_is_up_with_those_new_coord_names = (coord_names | set(vars_to_create)) - set(
|
||||
- vars_to_remove
|
||||
+what_is_up_with_those_new_coord_names = (
|
||||
+ (coord_names | NOT_IMPLEMENTED_call())
|
||||
+ - NOT_IMPLEMENTED_call()
|
||||
)
|
||||
-result = (
|
||||
- session.query(models.Customer.id)
|
||||
- .filter(
|
||||
- models.Customer.account_id == account_id, models.Customer.email == email_address
|
||||
- )
|
||||
- .order_by(models.Customer.id.asc())
|
||||
- .all()
|
||||
-)
|
||||
-result = (
|
||||
- session.query(models.Customer.id)
|
||||
- .filter(
|
||||
|
@ -677,10 +663,7 @@ last_call()
|
|||
- models.Customer.id.asc(),
|
||||
- )
|
||||
- .all()
|
||||
+what_is_up_with_those_new_coord_names = (
|
||||
+ (coord_names | NOT_IMPLEMENTED_call())
|
||||
+ - NOT_IMPLEMENTED_call()
|
||||
)
|
||||
-)
|
||||
-Ø = set()
|
||||
-authors.łukasz.say_thanks()
|
||||
-mapping = {
|
||||
|
@ -728,7 +711,19 @@ last_call()
|
|||
-for j in 1 + (2 + 3):
|
||||
- ...
|
||||
-while this and that:
|
||||
- ...
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_YET_IMPLEMENTED_StmtAssert
|
||||
+NOT_YET_IMPLEMENTED_StmtAssert
|
||||
+NOT_YET_IMPLEMENTED_StmtAssert
|
||||
+NOT_YET_IMPLEMENTED_StmtFor
|
||||
+NOT_YET_IMPLEMENTED_StmtFor
|
||||
+NOT_YET_IMPLEMENTED_StmtFor
|
||||
+NOT_YET_IMPLEMENTED_StmtFor
|
||||
+NOT_YET_IMPLEMENTED_StmtFor
|
||||
+while NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2:
|
||||
...
|
||||
-for (
|
||||
- addr_family,
|
||||
- addr_type,
|
||||
|
@ -810,19 +805,6 @@ last_call()
|
|||
- >> aaaaaaaaaaaaaaaa.l**aaaaaaaaaaaaaaaa.m // aaaaaaaaaaaaaaaa.n
|
||||
-):
|
||||
- return True
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_YET_IMPLEMENTED_StmtAssert
|
||||
+NOT_YET_IMPLEMENTED_StmtAssert
|
||||
+NOT_YET_IMPLEMENTED_StmtAssert
|
||||
+NOT_YET_IMPLEMENTED_StmtFor
|
||||
+NOT_YET_IMPLEMENTED_StmtFor
|
||||
+NOT_YET_IMPLEMENTED_StmtFor
|
||||
+NOT_YET_IMPLEMENTED_StmtFor
|
||||
+NOT_YET_IMPLEMENTED_StmtFor
|
||||
+while NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2:
|
||||
+ 0x42
|
||||
+NOT_YET_IMPLEMENTED_StmtFor
|
||||
+a = NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
|
||||
+a = NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
|
||||
|
@ -858,16 +840,16 @@ last_call()
|
|||
## Ruff Output
|
||||
|
||||
```py
|
||||
0x42
|
||||
0x42
|
||||
0x42
|
||||
...
|
||||
"NOT_YET_IMPLEMENTED_STRING"
|
||||
b"NOT_YET_IMPLEMENTED_BYTE_STRING"
|
||||
Name
|
||||
0x42
|
||||
0x42
|
||||
0x42
|
||||
0x42
|
||||
0x42
|
||||
0x42
|
||||
None
|
||||
True
|
||||
False
|
||||
1
|
||||
1.0
|
||||
1j
|
||||
NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
||||
NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
||||
NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
||||
|
@ -880,11 +862,11 @@ NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
|||
NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
||||
NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
||||
NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
||||
v1 << 0x42
|
||||
0x42 >> v2
|
||||
0x42 % finished
|
||||
0x42 + v2 - v3 * 0x42 ^ 0x42**v6 / 0x42 // 0x42
|
||||
((0x42 + v2) - (v3 * 0x42)) ^ (((0x42**v6) / 0x42) // 0x42)
|
||||
v1 << 2
|
||||
1 >> v2
|
||||
1 % finished
|
||||
1 + v2 - v3 * 4 ^ 5**v6 / 7 // 8
|
||||
((1 + v2) - (v3 * 4)) ^ (((5**v6) / 7) // 8)
|
||||
NOT_YET_IMPLEMENTED_ExprUnaryOp
|
||||
NOT_YET_IMPLEMENTED_ExprUnaryOp
|
||||
NOT_YET_IMPLEMENTED_ExprUnaryOp
|
||||
|
@ -910,11 +892,11 @@ NOT_IMPLEMENTED_true if NOT_IMPLEMENTED_cond else NOT_IMPLEMENTED_false
|
|||
{NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value}
|
||||
{NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value}
|
||||
{
|
||||
0x42,
|
||||
0x42,
|
||||
0x42,
|
||||
0x42,
|
||||
0x42,
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
(NOT_IMPLEMENTED_true if NOT_IMPLEMENTED_cond else NOT_IMPLEMENTED_false),
|
||||
}
|
||||
NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
||||
|
@ -924,24 +906,24 @@ NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2
|
|||
(1, 2)
|
||||
[]
|
||||
[
|
||||
0x42,
|
||||
0x42,
|
||||
0x42,
|
||||
0x42,
|
||||
0x42,
|
||||
0x42,
|
||||
0x42,
|
||||
0x42,
|
||||
0x42,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
(NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2),
|
||||
(NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2),
|
||||
(NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2),
|
||||
]
|
||||
[0x42, 0x42, 0x42]
|
||||
[1, 2, 3]
|
||||
[NOT_YET_IMPLEMENTED_ExprStarred]
|
||||
[NOT_YET_IMPLEMENTED_ExprStarred]
|
||||
[NOT_YET_IMPLEMENTED_ExprStarred, 0x42, 0x42]
|
||||
[0x42, NOT_YET_IMPLEMENTED_ExprStarred, 0x42]
|
||||
[NOT_YET_IMPLEMENTED_ExprStarred, 4, 5]
|
||||
[4, NOT_YET_IMPLEMENTED_ExprStarred, 5]
|
||||
[
|
||||
this_is_a_very_long_variable_which_will_force_a_delimiter_split,
|
||||
element,
|
||||
|
@ -975,9 +957,9 @@ NOT_IMPLEMENTED_call()
|
|||
NOT_IMPLEMENTED_call()
|
||||
lukasz.NOT_IMPLEMENTED_attr.NOT_IMPLEMENTED_attr
|
||||
NOT_IMPLEMENTED_call()
|
||||
0x42.NOT_IMPLEMENTED_attr
|
||||
0x42.NOT_IMPLEMENTED_attr
|
||||
0x42.NOT_IMPLEMENTED_attr
|
||||
1 .NOT_IMPLEMENTED_attr
|
||||
1.0 .NOT_IMPLEMENTED_attr
|
||||
....NOT_IMPLEMENTED_attr
|
||||
NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key]
|
||||
NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key]
|
||||
NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key]
|
||||
|
@ -1016,23 +998,23 @@ NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key]
|
|||
NOT_IMPLEMENTED_true if NOT_IMPLEMENTED_cond else NOT_IMPLEMENTED_false
|
||||
{NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value}
|
||||
{
|
||||
0x42,
|
||||
0x42,
|
||||
0x42,
|
||||
0x42,
|
||||
0x42,
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
NOT_IMPLEMENTED_true if NOT_IMPLEMENTED_cond else NOT_IMPLEMENTED_false,
|
||||
}
|
||||
[
|
||||
0x42,
|
||||
0x42,
|
||||
0x42,
|
||||
0x42,
|
||||
0x42,
|
||||
0x42,
|
||||
0x42,
|
||||
0x42,
|
||||
0x42,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2,
|
||||
NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2,
|
||||
NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2,
|
||||
|
@ -1048,7 +1030,7 @@ SomeName
|
|||
{NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value}
|
||||
a = (1, 2)
|
||||
b = (1, 2)
|
||||
c = 0x42
|
||||
c = 1
|
||||
d = (1, 2) + a + (1, 2)
|
||||
e = NOT_IMPLEMENTED_call()
|
||||
f = (1, 2)
|
||||
|
@ -1086,7 +1068,7 @@ NOT_YET_IMPLEMENTED_StmtFor
|
|||
NOT_YET_IMPLEMENTED_StmtFor
|
||||
NOT_YET_IMPLEMENTED_StmtFor
|
||||
while NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2:
|
||||
0x42
|
||||
...
|
||||
NOT_YET_IMPLEMENTED_StmtFor
|
||||
a = NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
|
||||
a = NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
|
||||
|
|
|
@ -57,12 +57,10 @@ def test_calculate_fades():
|
|||
-import pytest
|
||||
+NOT_YET_IMPLEMENTED_StmtImport
|
||||
|
||||
-TmSt = 1
|
||||
-TmEx = 2
|
||||
+TmSt = 0x42
|
||||
+TmEx = 0x42
|
||||
+
|
||||
TmSt = 1
|
||||
TmEx = 2
|
||||
|
||||
+
|
||||
# fmt: off
|
||||
|
||||
# Test data:
|
||||
|
@ -112,8 +110,8 @@ def test_calculate_fades():
|
|||
```py
|
||||
NOT_YET_IMPLEMENTED_StmtImport
|
||||
|
||||
TmSt = 0x42
|
||||
TmEx = 0x42
|
||||
TmSt = 1
|
||||
TmEx = 2
|
||||
|
||||
|
||||
# fmt: off
|
||||
|
|
|
@ -36,7 +36,7 @@ x = [
|
|||
- 1, 2,
|
||||
- 3, 4,
|
||||
-]
|
||||
+x = [0x42, 0x42, 0x42, 0x42]
|
||||
+x = [1, 2, 3, 4]
|
||||
# fmt: on
|
||||
|
||||
# fmt: off
|
||||
|
@ -44,25 +44,24 @@ x = [
|
|||
- 1, 2,
|
||||
- 3, 4,
|
||||
-]
|
||||
+x = [0x42, 0x42, 0x42, 0x42]
|
||||
+x = [1, 2, 3, 4]
|
||||
# fmt: on
|
||||
|
||||
-x = [1, 2, 3, 4]
|
||||
+x = [0x42, 0x42, 0x42, 0x42]
|
||||
x = [1, 2, 3, 4]
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
# fmt: off
|
||||
x = [0x42, 0x42, 0x42, 0x42]
|
||||
x = [1, 2, 3, 4]
|
||||
# fmt: on
|
||||
|
||||
# fmt: off
|
||||
x = [0x42, 0x42, 0x42, 0x42]
|
||||
x = [1, 2, 3, 4]
|
||||
# fmt: on
|
||||
|
||||
x = [0x42, 0x42, 0x42, 0x42]
|
||||
x = [1, 2, 3, 4]
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
|
|
@ -454,7 +454,7 @@ d={'a':1,
|
|||
-l=[1,2,3]
|
||||
-d={'a':1,
|
||||
- 'b':2}
|
||||
+l = [0x42, 0x42, 0x42]
|
||||
+l = [1, 2, 3]
|
||||
+d = {NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value}
|
||||
```
|
||||
|
||||
|
@ -532,7 +532,7 @@ NOT_IMPLEMENTED_call()
|
|||
# fmt: off
|
||||
NOT_YET_IMPLEMENTED_ExprYield
|
||||
# No formatting to the end of the file
|
||||
l = [0x42, 0x42, 0x42]
|
||||
l = [1, 2, 3]
|
||||
d = {NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value}
|
||||
```
|
||||
|
||||
|
|
|
@ -16,29 +16,49 @@ l3 = ["I have", "trailing comma", "so I should be braked",]
|
|||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -1,11 +1,3 @@
|
||||
-l1 = [
|
||||
@@ -1,11 +1,15 @@
|
||||
l1 = [
|
||||
- "This list should be broken up",
|
||||
- "into multiple lines",
|
||||
- "because it is way too long",
|
||||
-]
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
]
|
||||
-l2 = ["But this list shouldn't", "even though it also has", "way too many characters in it"] # fmt: skip
|
||||
-l3 = [
|
||||
+l2 = [
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
+] # fmt: skip
|
||||
l3 = [
|
||||
- "I have",
|
||||
- "trailing comma",
|
||||
- "so I should be braked",
|
||||
-]
|
||||
+l1 = [0x42, 0x42, 0x42]
|
||||
+l2 = [0x42, 0x42, 0x42] # fmt: skip
|
||||
+l3 = [0x42, 0x42, 0x42]
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
+ "NOT_YET_IMPLEMENTED_STRING",
|
||||
]
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
l1 = [0x42, 0x42, 0x42]
|
||||
l2 = [0x42, 0x42, 0x42] # fmt: skip
|
||||
l3 = [0x42, 0x42, 0x42]
|
||||
l1 = [
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
]
|
||||
l2 = [
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
] # fmt: skip
|
||||
l3 = [
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
]
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
|
|
@ -21,33 +21,31 @@ f = ["This is a very long line that should be formatted into a clearer line ", "
|
|||
--- Black
|
||||
+++ Ruff
|
||||
@@ -1,10 +1,7 @@
|
||||
-a = 3
|
||||
+a = 0x42
|
||||
a = 3
|
||||
# fmt: off
|
||||
-b, c = 1, 2
|
||||
-d = 6 # fmt: skip
|
||||
-e = 5
|
||||
+(1, 2) = (1, 2)
|
||||
+d = 0x42 # fmt: skip
|
||||
+e = 0x42
|
||||
+d = 6 # fmt: skip
|
||||
e = 5
|
||||
# fmt: on
|
||||
-f = [
|
||||
- "This is a very long line that should be formatted into a clearer line ",
|
||||
- "by rearranging.",
|
||||
-]
|
||||
+f = [0x42, 0x42]
|
||||
+f = ["NOT_YET_IMPLEMENTED_STRING", "NOT_YET_IMPLEMENTED_STRING"]
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
a = 0x42
|
||||
a = 3
|
||||
# fmt: off
|
||||
(1, 2) = (1, 2)
|
||||
d = 0x42 # fmt: skip
|
||||
e = 0x42
|
||||
d = 6 # fmt: skip
|
||||
e = 5
|
||||
# fmt: on
|
||||
f = [0x42, 0x42]
|
||||
f = ["NOT_YET_IMPLEMENTED_STRING", "NOT_YET_IMPLEMENTED_STRING"]
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
|
|
@ -17,23 +17,22 @@ l = [1, 2, 3,]
|
|||
--- Black
|
||||
+++ Ruff
|
||||
@@ -1,7 +1,3 @@
|
||||
-a = 2
|
||||
+a = 0x42
|
||||
a = 2
|
||||
# fmt: skip
|
||||
-l = [
|
||||
- 1,
|
||||
- 2,
|
||||
- 3,
|
||||
-]
|
||||
+l = [0x42, 0x42, 0x42]
|
||||
+l = [1, 2, 3]
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
a = 0x42
|
||||
a = 2
|
||||
# fmt: skip
|
||||
l = [0x42, 0x42, 0x42]
|
||||
l = [1, 2, 3]
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
|
|
@ -20,21 +20,20 @@ d = "thisisasuperlongstringthisisasuperlongstringthisisasuperlongstringthisisasu
|
|||
@@ -1,4 +1,4 @@
|
||||
-a = "this is some code"
|
||||
-b = 5 # fmt:skip
|
||||
-c = 9 # fmt: skip
|
||||
+a = "NOT_YET_IMPLEMENTED_STRING"
|
||||
+b = 5 # fmt:skip
|
||||
c = 9 # fmt: skip
|
||||
-d = "thisisasuperlongstringthisisasuperlongstringthisisasuperlongstringthisisasuperlongstring" # fmt:skip
|
||||
+a = 0x42
|
||||
+b = 0x42 # fmt:skip
|
||||
+c = 0x42 # fmt: skip
|
||||
+d = 0x42 # fmt:skip
|
||||
+d = "NOT_YET_IMPLEMENTED_STRING" # fmt:skip
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
a = 0x42
|
||||
b = 0x42 # fmt:skip
|
||||
c = 0x42 # fmt: skip
|
||||
d = 0x42 # fmt:skip
|
||||
a = "NOT_YET_IMPLEMENTED_STRING"
|
||||
b = 5 # fmt:skip
|
||||
c = 9 # fmt: skip
|
||||
d = "NOT_YET_IMPLEMENTED_STRING" # fmt:skip
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
|
|
@ -19,18 +19,17 @@ d = 5
|
|||
@@ -1,3 +1,3 @@
|
||||
-a, b = 1, 2
|
||||
-c = 6 # fmt: skip
|
||||
-d = 5
|
||||
+(1, 2) = (1, 2)
|
||||
+c = 0x42 # fmt: skip
|
||||
+d = 0x42
|
||||
+c = 6 # fmt: skip
|
||||
d = 5
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
(1, 2) = (1, 2)
|
||||
c = 0x42 # fmt: skip
|
||||
d = 0x42
|
||||
c = 6 # fmt: skip
|
||||
d = 5
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
|
|
@ -64,7 +64,7 @@ __all__ = (
|
|||
+++ Ruff
|
||||
@@ -1,64 +1,42 @@
|
||||
-"""The asyncio package, tracking PEP 3156."""
|
||||
+0x42
|
||||
+"NOT_YET_IMPLEMENTED_STRING"
|
||||
|
||||
# flake8: noqa
|
||||
|
||||
|
@ -162,7 +162,7 @@ __all__ = (
|
|||
## Ruff Output
|
||||
|
||||
```py
|
||||
0x42
|
||||
"NOT_YET_IMPLEMENTED_STRING"
|
||||
|
||||
# flake8: noqa
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ list_of_types = [tuple[int,],]
|
|||
-list_of_types = [
|
||||
- tuple[int,],
|
||||
-]
|
||||
+small_list = [0x42]
|
||||
+small_list = [1]
|
||||
+list_of_types = [NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key]]
|
||||
```
|
||||
|
||||
|
@ -69,7 +69,7 @@ NOT_YET_IMPLEMENTED_StmtAnnAssign
|
|||
d = NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key]
|
||||
|
||||
# Magic commas still work as expected for non-subscripts.
|
||||
small_list = [0x42]
|
||||
small_list = [1]
|
||||
list_of_types = [NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key]]
|
||||
```
|
||||
|
||||
|
|
|
@ -110,16 +110,16 @@ return np.divide(
|
|||
-o = settings(max_examples=10**6)
|
||||
-p = {(k, k**2): v**2 for k, v in pairs}
|
||||
-q = [10**i for i in range(6)]
|
||||
+a = 0x42**NOT_YET_IMPLEMENTED_ExprUnaryOp
|
||||
+b = 0x42 ** NOT_IMPLEMENTED_call()
|
||||
+a = 5**NOT_YET_IMPLEMENTED_ExprUnaryOp
|
||||
+b = 5 ** NOT_IMPLEMENTED_call()
|
||||
+c = NOT_YET_IMPLEMENTED_ExprUnaryOp
|
||||
+d = 0x42 ** NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key]
|
||||
+d = 5 ** NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key]
|
||||
+e = NOT_IMPLEMENTED_call()
|
||||
+f = NOT_IMPLEMENTED_call() ** 0x42
|
||||
+f = NOT_IMPLEMENTED_call() ** 5
|
||||
+g = a.NOT_IMPLEMENTED_attr**c.NOT_IMPLEMENTED_attr
|
||||
+h = 0x42 ** NOT_IMPLEMENTED_call()
|
||||
+i = NOT_IMPLEMENTED_call() ** 0x42
|
||||
+j = NOT_IMPLEMENTED_call().NOT_IMPLEMENTED_attr ** 0x42
|
||||
+h = 5 ** NOT_IMPLEMENTED_call()
|
||||
+i = NOT_IMPLEMENTED_call() ** 5
|
||||
+j = NOT_IMPLEMENTED_call().NOT_IMPLEMENTED_attr ** 5
|
||||
+k = [i for i in []]
|
||||
+l = NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
|
||||
+m = [(1, 2)]
|
||||
|
@ -146,16 +146,16 @@ return np.divide(
|
|||
-o = settings(max_examples=10**6.0)
|
||||
-p = {(k, k**2): v**2.0 for k, v in pairs}
|
||||
-q = [10.5**i for i in range(6)]
|
||||
+a = 0x42**NOT_YET_IMPLEMENTED_ExprUnaryOp
|
||||
+b = 0x42 ** NOT_IMPLEMENTED_call()
|
||||
+a = 5.0**NOT_YET_IMPLEMENTED_ExprUnaryOp
|
||||
+b = 5.0 ** NOT_IMPLEMENTED_call()
|
||||
+c = NOT_YET_IMPLEMENTED_ExprUnaryOp
|
||||
+d = 0x42 ** NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key]
|
||||
+d = 5.0 ** NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key]
|
||||
+e = NOT_IMPLEMENTED_call()
|
||||
+f = NOT_IMPLEMENTED_call() ** 0x42
|
||||
+f = NOT_IMPLEMENTED_call() ** 5.0
|
||||
+g = a.NOT_IMPLEMENTED_attr**c.NOT_IMPLEMENTED_attr
|
||||
+h = 0x42 ** NOT_IMPLEMENTED_call()
|
||||
+i = NOT_IMPLEMENTED_call() ** 0x42
|
||||
+j = NOT_IMPLEMENTED_call().NOT_IMPLEMENTED_attr ** 0x42
|
||||
+h = 5.0 ** NOT_IMPLEMENTED_call()
|
||||
+i = NOT_IMPLEMENTED_call() ** 5.0
|
||||
+j = NOT_IMPLEMENTED_call().NOT_IMPLEMENTED_attr ** 5.0
|
||||
+k = [i for i in []]
|
||||
+l = NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
|
||||
+m = [(1, 2)]
|
||||
|
@ -193,16 +193,16 @@ NOT_YET_IMPLEMENTED_StmtFunctionDef
|
|||
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||
|
||||
|
||||
a = 0x42**NOT_YET_IMPLEMENTED_ExprUnaryOp
|
||||
b = 0x42 ** NOT_IMPLEMENTED_call()
|
||||
a = 5**NOT_YET_IMPLEMENTED_ExprUnaryOp
|
||||
b = 5 ** NOT_IMPLEMENTED_call()
|
||||
c = NOT_YET_IMPLEMENTED_ExprUnaryOp
|
||||
d = 0x42 ** NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key]
|
||||
d = 5 ** NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key]
|
||||
e = NOT_IMPLEMENTED_call()
|
||||
f = NOT_IMPLEMENTED_call() ** 0x42
|
||||
f = NOT_IMPLEMENTED_call() ** 5
|
||||
g = a.NOT_IMPLEMENTED_attr**c.NOT_IMPLEMENTED_attr
|
||||
h = 0x42 ** NOT_IMPLEMENTED_call()
|
||||
i = NOT_IMPLEMENTED_call() ** 0x42
|
||||
j = NOT_IMPLEMENTED_call().NOT_IMPLEMENTED_attr ** 0x42
|
||||
h = 5 ** NOT_IMPLEMENTED_call()
|
||||
i = NOT_IMPLEMENTED_call() ** 5
|
||||
j = NOT_IMPLEMENTED_call().NOT_IMPLEMENTED_attr ** 5
|
||||
k = [i for i in []]
|
||||
l = NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
|
||||
m = [(1, 2)]
|
||||
|
@ -212,16 +212,16 @@ p = {NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value for key, value in NOT_
|
|||
q = [i for i in []]
|
||||
r = x**y
|
||||
|
||||
a = 0x42**NOT_YET_IMPLEMENTED_ExprUnaryOp
|
||||
b = 0x42 ** NOT_IMPLEMENTED_call()
|
||||
a = 5.0**NOT_YET_IMPLEMENTED_ExprUnaryOp
|
||||
b = 5.0 ** NOT_IMPLEMENTED_call()
|
||||
c = NOT_YET_IMPLEMENTED_ExprUnaryOp
|
||||
d = 0x42 ** NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key]
|
||||
d = 5.0 ** NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key]
|
||||
e = NOT_IMPLEMENTED_call()
|
||||
f = NOT_IMPLEMENTED_call() ** 0x42
|
||||
f = NOT_IMPLEMENTED_call() ** 5.0
|
||||
g = a.NOT_IMPLEMENTED_attr**c.NOT_IMPLEMENTED_attr
|
||||
h = 0x42 ** NOT_IMPLEMENTED_call()
|
||||
i = NOT_IMPLEMENTED_call() ** 0x42
|
||||
j = NOT_IMPLEMENTED_call().NOT_IMPLEMENTED_attr ** 0x42
|
||||
h = 5.0 ** NOT_IMPLEMENTED_call()
|
||||
i = NOT_IMPLEMENTED_call() ** 5.0
|
||||
j = NOT_IMPLEMENTED_call().NOT_IMPLEMENTED_attr ** 5.0
|
||||
k = [i for i in []]
|
||||
l = NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
|
||||
m = [(1, 2)]
|
||||
|
|
|
@ -47,7 +47,7 @@ xxxxxxxxx_yyy_zzzzzzzz[xx.xxxxxx(x_yyy_zzzzzz.xxxxx[0]), x_yyy_zzzzzz.xxxxxx(xxx
|
|||
-xxxxxxxxx_yyy_zzzzzzzz[
|
||||
- xx.xxxxxx(x_yyy_zzzzzz.xxxxx[0]), x_yyy_zzzzzz.xxxxxx(xxxx=1)
|
||||
-] = 1
|
||||
+NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key] = 0x42
|
||||
+NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key] = 1
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
|
@ -61,7 +61,7 @@ xxxxxxxxx_yyy_zzzzzzzz[xx.xxxxxx(x_yyy_zzzzzz.xxxxx[0]), x_yyy_zzzzzz.xxxxxx(xxx
|
|||
|
||||
# Make when when the left side of assignment plus the opening paren "... = (" is
|
||||
# exactly line length limit + 1, it won't be split like that.
|
||||
NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key] = 0x42
|
||||
NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key] = 1
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
|
|
@ -170,13 +170,13 @@ with open("/path/to/file.txt", mode="r") as read_file:
|
|||
-for i in range(5):
|
||||
- for j in range(7):
|
||||
- print(f"{i}) The lines above me should be removed!")
|
||||
-
|
||||
-
|
||||
-if random.randint(0, 3) == 0:
|
||||
- print("The new line above me is about to be removed!")
|
||||
+NOT_YET_IMPLEMENTED_StmtIf
|
||||
|
||||
|
||||
-if random.randint(0, 3) == 0:
|
||||
- print("The new line above me is about to be removed!")
|
||||
-
|
||||
-
|
||||
-if random.randint(0, 3) == 0:
|
||||
- print("The new lines above me is about to be removed!")
|
||||
+NOT_YET_IMPLEMENTED_StmtIf
|
||||
|
@ -188,23 +188,19 @@ with open("/path/to/file.txt", mode="r") as read_file:
|
|||
+NOT_YET_IMPLEMENTED_StmtIf
|
||||
|
||||
|
||||
-while True:
|
||||
while True:
|
||||
- print("The newline above me should be deleted!")
|
||||
+while 0x42:
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
|
||||
|
||||
-while True:
|
||||
while True:
|
||||
- print("The newlines above me should be deleted!")
|
||||
+while 0x42:
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
|
||||
|
||||
-while True:
|
||||
- while False:
|
||||
while True:
|
||||
while False:
|
||||
- print("The newlines above me should be deleted!")
|
||||
+while 0x42:
|
||||
+ while 0x42:
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
|
||||
|
||||
|
@ -263,16 +259,16 @@ NOT_YET_IMPLEMENTED_StmtIf
|
|||
NOT_YET_IMPLEMENTED_StmtIf
|
||||
|
||||
|
||||
while 0x42:
|
||||
while True:
|
||||
NOT_IMPLEMENTED_call()
|
||||
|
||||
|
||||
while 0x42:
|
||||
while True:
|
||||
NOT_IMPLEMENTED_call()
|
||||
|
||||
|
||||
while 0x42:
|
||||
while 0x42:
|
||||
while True:
|
||||
while False:
|
||||
NOT_IMPLEMENTED_call()
|
||||
|
||||
|
||||
|
|
|
@ -69,10 +69,8 @@ def example8():
|
|||
--- Black
|
||||
+++ Ruff
|
||||
@@ -1,85 +1,37 @@
|
||||
-x = 1
|
||||
-x = 1.2
|
||||
+x = 0x42
|
||||
+x = 0x42
|
||||
x = 1
|
||||
x = 1.2
|
||||
|
||||
-data = (
|
||||
- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||
|
@ -173,8 +171,8 @@ def example8():
|
|||
## Ruff Output
|
||||
|
||||
```py
|
||||
x = 0x42
|
||||
x = 0x42
|
||||
x = 1
|
||||
x = 1.2
|
||||
|
||||
data = NOT_IMPLEMENTED_call()
|
||||
|
||||
|
|
|
@ -74,13 +74,11 @@ func(
|
|||
+d = NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key]
|
||||
|
||||
# Remove commas for non-subscripts.
|
||||
-small_list = [1]
|
||||
small_list = [1]
|
||||
-list_of_types = [tuple[int,]]
|
||||
-small_set = {1}
|
||||
-set_of_types = {tuple[int,]}
|
||||
+small_list = [0x42]
|
||||
+list_of_types = [NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key]]
|
||||
+small_set = {0x42}
|
||||
small_set = {1}
|
||||
-set_of_types = {tuple[int,]}
|
||||
+set_of_types = {NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key]}
|
||||
|
||||
# Except single element tuples
|
||||
|
@ -113,9 +111,9 @@ NOT_YET_IMPLEMENTED_StmtAnnAssign
|
|||
d = NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key]
|
||||
|
||||
# Remove commas for non-subscripts.
|
||||
small_list = [0x42]
|
||||
small_list = [1]
|
||||
list_of_types = [NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key]]
|
||||
small_set = {0x42}
|
||||
small_set = {1}
|
||||
set_of_types = {NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key]}
|
||||
|
||||
# Except single element tuples
|
||||
|
|
|
@ -41,7 +41,7 @@ def docstring_multiline():
|
|||
-(b"", b"")
|
||||
-("", "")
|
||||
-(r"", R"")
|
||||
+name = 0x42
|
||||
+name = "NOT_YET_IMPLEMENTED_STRING"
|
||||
+(1, 2)
|
||||
+(1, 2)
|
||||
+(1, 2)
|
||||
|
@ -70,7 +70,7 @@ def docstring_multiline():
|
|||
```py
|
||||
#!/usr/bin/env python3
|
||||
|
||||
name = 0x42
|
||||
name = "NOT_YET_IMPLEMENTED_STRING"
|
||||
(1, 2)
|
||||
(1, 2)
|
||||
(1, 2)
|
||||
|
|
|
@ -42,14 +42,15 @@ assert (
|
|||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -1,58 +1,17 @@
|
||||
@@ -1,58 +1,21 @@
|
||||
importA
|
||||
-(
|
||||
(
|
||||
- ()
|
||||
- << 0
|
||||
+ (1, 2)
|
||||
<< 0
|
||||
- ** 101234234242352525425252352352525234890264906820496920680926538059059209922523523525
|
||||
-) #
|
||||
+(1, 2) << 0x42**0x42 #
|
||||
+ **101234234242352525425252352352525234890264906820496920680926538059059209922523523525
|
||||
) #
|
||||
|
||||
-assert sort_by_dependency(
|
||||
- {
|
||||
|
@ -65,10 +66,8 @@ assert (
|
|||
+NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
importA
|
||||
-0
|
||||
-0 ^ 0 #
|
||||
+0x42
|
||||
+0x42 ^ 0x42 #
|
||||
0
|
||||
0 ^ 0 #
|
||||
|
||||
|
||||
-class A:
|
||||
|
@ -114,13 +113,17 @@ assert (
|
|||
|
||||
```py
|
||||
importA
|
||||
(1, 2) << 0x42**0x42 #
|
||||
(
|
||||
(1, 2)
|
||||
<< 0
|
||||
**101234234242352525425252352352525234890264906820496920680926538059059209922523523525
|
||||
) #
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
importA
|
||||
0x42
|
||||
0x42 ^ 0x42 #
|
||||
0
|
||||
0 ^ 0 #
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
|
|
|
@ -1,73 +0,0 @@
|
|||
---
|
||||
source: crates/ruff_python_formatter/src/lib.rs
|
||||
expression: snapshot
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_cases/tricky_unicode_symbols.py
|
||||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
ä = 1
|
||||
µ = 2
|
||||
蟒 = 3
|
||||
x󠄀 = 4
|
||||
មុ = 1
|
||||
Q̇_per_meter = 4
|
||||
|
||||
A᧚ = 3
|
||||
A፩ = 8
|
||||
```
|
||||
|
||||
## Black Differences
|
||||
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -1,9 +1,9 @@
|
||||
-ä = 1
|
||||
-µ = 2
|
||||
-蟒 = 3
|
||||
-x󠄀 = 4
|
||||
-មុ = 1
|
||||
-Q̇_per_meter = 4
|
||||
+ä = 0x42
|
||||
+µ = 0x42
|
||||
+蟒 = 0x42
|
||||
+x󠄀 = 0x42
|
||||
+មុ = 0x42
|
||||
+Q̇_per_meter = 0x42
|
||||
|
||||
-A᧚ = 3
|
||||
-A፩ = 8
|
||||
+A᧚ = 0x42
|
||||
+A፩ = 0x42
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
ä = 0x42
|
||||
µ = 0x42
|
||||
蟒 = 0x42
|
||||
x󠄀 = 0x42
|
||||
មុ = 0x42
|
||||
Q̇_per_meter = 0x42
|
||||
|
||||
A᧚ = 0x42
|
||||
A፩ = 0x42
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
ä = 1
|
||||
µ = 2
|
||||
蟒 = 3
|
||||
x󠄀 = 4
|
||||
មុ = 1
|
||||
Q̇_per_meter = 4
|
||||
|
||||
A᧚ = 3
|
||||
A፩ = 8
|
||||
```
|
||||
|
||||
|
|
@ -22,15 +22,15 @@ a = asdf = fjhalsdljfalflaflapamsakjsdhflakjdslfjhalsdljfalflaflapamsakjsdhflakj
|
|||
```py
|
||||
# break left hand side
|
||||
a1akjdshflkjahdslkfjlasfdahjlfds = bakjdshflkjahdslkfjlasfdahjlfds = cakjdshflkjahdslkfjlasfdahjlfds = kjaödkjaföjfahlfdalfhaöfaöfhaöfha = fkjaödkjaföjfahlfdalfhaöfaöfhaöfha = g = (
|
||||
0x42
|
||||
3
|
||||
)
|
||||
|
||||
# join left hand side
|
||||
a2 = (b2) = 0x42
|
||||
a2 = (b2) = 2
|
||||
|
||||
# Break the last element
|
||||
a = asdf = fjhalsdljfalflaflapamsakjsdhflakjdslfjhalsdljfalflaflapamsakjsdhflakjdslfjhalsdljfal = (
|
||||
0x42
|
||||
1
|
||||
)
|
||||
```
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ while (
|
|||
|
||||
## Output
|
||||
```py
|
||||
while 0x42: # trailing test comment
|
||||
while 34: # trailing test comment
|
||||
NOT_YET_IMPLEMENTED_StmtPass # trailing last statement comment
|
||||
|
||||
# trailing while body comment
|
||||
|
@ -59,7 +59,7 @@ while (
|
|||
NOT_YET_IMPLEMENTED_StmtPass
|
||||
|
||||
else:
|
||||
0x42
|
||||
...
|
||||
|
||||
while NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2: # comment
|
||||
NOT_IMPLEMENTED_call()
|
||||
|
|
|
@ -44,11 +44,11 @@ e = 50 # one empty line before
|
|||
```py
|
||||
# Removes the line above
|
||||
|
||||
a = 0x42 # Keeps the line above
|
||||
a = 10 # Keeps the line above
|
||||
|
||||
# Separated by one line from `a` and `b`
|
||||
|
||||
b = 0x42
|
||||
b = 20
|
||||
|
||||
|
||||
# Adds two lines after `b`
|
||||
|
@ -57,22 +57,22 @@ NOT_YET_IMPLEMENTED_StmtClassDef
|
|||
|
||||
# two lines before, one line after
|
||||
|
||||
c = 0x42
|
||||
c = 30
|
||||
|
||||
while NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
|
||||
0x42
|
||||
...
|
||||
|
||||
# trailing comment with one line before
|
||||
|
||||
# one line before this leading comment
|
||||
|
||||
d = 0x42
|
||||
d = 40
|
||||
|
||||
while NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
|
||||
0x42
|
||||
...
|
||||
# no empty line before
|
||||
|
||||
e = 0x42 # one empty line before
|
||||
e = 50 # one empty line before
|
||||
```
|
||||
|
||||
|
||||
|
|
|
@ -234,22 +234,22 @@ def trailing_func():
|
|||
|
||||
assert_eq!(
|
||||
formatted,
|
||||
r#"a = 0x42
|
||||
r#"a = 10
|
||||
|
||||
|
||||
three_leading_newlines = 0x42
|
||||
three_leading_newlines = 80
|
||||
|
||||
|
||||
two_leading_newlines = 0x42
|
||||
two_leading_newlines = 20
|
||||
|
||||
one_leading_newline = 0x42
|
||||
no_leading_newline = 0x42
|
||||
one_leading_newline = 10
|
||||
no_leading_newline = 30
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
|
||||
|
||||
trailing_statement = 0x42
|
||||
trailing_statement = 1
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||
|
@ -265,18 +265,18 @@ NOT_YET_IMPLEMENTED_StmtFunctionDef"#
|
|||
|
||||
assert_eq!(
|
||||
formatted,
|
||||
r#"a = 0x42
|
||||
r#"a = 10
|
||||
|
||||
three_leading_newlines = 0x42
|
||||
three_leading_newlines = 80
|
||||
|
||||
two_leading_newlines = 0x42
|
||||
two_leading_newlines = 20
|
||||
|
||||
one_leading_newline = 0x42
|
||||
no_leading_newline = 0x42
|
||||
one_leading_newline = 10
|
||||
no_leading_newline = 30
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
|
||||
trailing_statement = 0x42
|
||||
trailing_statement = 1
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue