mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-27 04:19:18 +00:00
Replace verbatim text with NOT_YET_IMPLEMENTED
(#4904)
<!-- Thank you for contributing to Ruff! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? - Does this pull request include references to any relevant issues? --> ## Summary This PR replaces the `verbatim_text` builder with a `not_yet_implemented` builder that emits `NOT_YET_IMPLEMENTED_<NodeKind>` for not yet implemented nodes. The motivation for this change is that partially formatting compound statements can result in incorrectly indented code, which is a syntax error: ```python def func_no_args(): a; b; c if True: raise RuntimeError if False: ... for i in range(10): print(i) continue ``` Get's reformatted to ```python def func_no_args(): a; b; c if True: raise RuntimeError if False: ... for i in range(10): print(i) continue ``` because our formatter does not yet support `for` statements and just inserts the text from the source. ## Downsides Using an identifier will not work in all situations. For example, an identifier is invalid in an `Arguments ` position. That's why I kept `verbatim_text` around and e.g. use it in the `Arguments` formatting logic where incorrect indentations are impossible (to my knowledge). Meaning, `verbatim_text` we can opt in to `verbatim_text` when we want to iterate quickly on nodes that we don't want to provide a full implementation yet and using an identifier would be invalid. ## Upsides Running this on main discovered stability issues with the newline handling that were previously "hidden" because of the verbatim formatting. I guess that's an upside :) ## Test Plan None?
This commit is contained in:
parent
2f125f4019
commit
bcf745c5ba
134 changed files with 5308 additions and 4385 deletions
|
@ -191,16 +191,16 @@ no_leading_newline = 30
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
&printed,
|
&printed,
|
||||||
r#"a = 10
|
r#"NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
|
|
||||||
three_leading_newlines = 80
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
|
|
||||||
two_leading_newlines = 20
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
one_leading_newline = 10
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
no_leading_newline = 30"#
|
NOT_YET_IMPLEMENTED_StmtAssign"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,14 +211,14 @@ no_leading_newline = 30"#
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
&printed,
|
&printed,
|
||||||
r#"a = 10
|
r#"NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
three_leading_newlines = 80
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
two_leading_newlines = 20
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
one_leading_newline = 10
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
no_leading_newline = 30"#
|
NOT_YET_IMPLEMENTED_StmtAssign"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,11 +229,11 @@ no_leading_newline = 30"#
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
&printed,
|
&printed,
|
||||||
r#"a = 10
|
r#"NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
three_leading_newlines = 80
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
two_leading_newlines = 20
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
one_leading_newline = 10
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
no_leading_newline = 30"#
|
NOT_YET_IMPLEMENTED_StmtAssign"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::expression::parentheses::{
|
use crate::expression::parentheses::{
|
||||||
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
||||||
};
|
};
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::ExprAttribute;
|
use rustpython_parser::ast::ExprAttribute;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ pub struct FormatExprAttribute;
|
||||||
|
|
||||||
impl FormatNodeRule<ExprAttribute> for FormatExprAttribute {
|
impl FormatNodeRule<ExprAttribute> for FormatExprAttribute {
|
||||||
fn fmt_fields(&self, item: &ExprAttribute, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &ExprAttribute, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::expression::parentheses::{
|
use crate::expression::parentheses::{
|
||||||
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
||||||
};
|
};
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::ExprAwait;
|
use rustpython_parser::ast::ExprAwait;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ pub struct FormatExprAwait;
|
||||||
|
|
||||||
impl FormatNodeRule<ExprAwait> for FormatExprAwait {
|
impl FormatNodeRule<ExprAwait> for FormatExprAwait {
|
||||||
fn fmt_fields(&self, item: &ExprAwait, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &ExprAwait, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::expression::parentheses::{
|
use crate::expression::parentheses::{
|
||||||
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
||||||
};
|
};
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::ExprBoolOp;
|
use rustpython_parser::ast::ExprBoolOp;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ pub struct FormatExprBoolOp;
|
||||||
|
|
||||||
impl FormatNodeRule<ExprBoolOp> for 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, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::expression::parentheses::{
|
use crate::expression::parentheses::{
|
||||||
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
||||||
};
|
};
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::ExprCall;
|
use rustpython_parser::ast::ExprCall;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ pub struct FormatExprCall;
|
||||||
|
|
||||||
impl FormatNodeRule<ExprCall> for 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, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::expression::parentheses::{
|
use crate::expression::parentheses::{
|
||||||
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
||||||
};
|
};
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::ExprCompare;
|
use rustpython_parser::ast::ExprCompare;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ pub struct FormatExprCompare;
|
||||||
|
|
||||||
impl FormatNodeRule<ExprCompare> for 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, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::expression::parentheses::{
|
use crate::expression::parentheses::{
|
||||||
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
||||||
};
|
};
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::ExprConstant;
|
use rustpython_parser::ast::ExprConstant;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ pub struct FormatExprConstant;
|
||||||
|
|
||||||
impl FormatNodeRule<ExprConstant> for FormatExprConstant {
|
impl FormatNodeRule<ExprConstant> for FormatExprConstant {
|
||||||
fn fmt_fields(&self, item: &ExprConstant, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &ExprConstant, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::expression::parentheses::{
|
use crate::expression::parentheses::{
|
||||||
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
||||||
};
|
};
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::ExprDict;
|
use rustpython_parser::ast::ExprDict;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ pub struct FormatExprDict;
|
||||||
|
|
||||||
impl FormatNodeRule<ExprDict> for 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, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::expression::parentheses::{
|
use crate::expression::parentheses::{
|
||||||
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
||||||
};
|
};
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::ExprDictComp;
|
use rustpython_parser::ast::ExprDictComp;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ pub struct FormatExprDictComp;
|
||||||
|
|
||||||
impl FormatNodeRule<ExprDictComp> for 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, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::expression::parentheses::{
|
use crate::expression::parentheses::{
|
||||||
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
||||||
};
|
};
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::ExprFormattedValue;
|
use rustpython_parser::ast::ExprFormattedValue;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ pub struct FormatExprFormattedValue;
|
||||||
|
|
||||||
impl FormatNodeRule<ExprFormattedValue> for FormatExprFormattedValue {
|
impl FormatNodeRule<ExprFormattedValue> for FormatExprFormattedValue {
|
||||||
fn fmt_fields(&self, item: &ExprFormattedValue, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &ExprFormattedValue, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::expression::parentheses::{
|
use crate::expression::parentheses::{
|
||||||
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
||||||
};
|
};
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::ExprGeneratorExp;
|
use rustpython_parser::ast::ExprGeneratorExp;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ pub struct FormatExprGeneratorExp;
|
||||||
|
|
||||||
impl FormatNodeRule<ExprGeneratorExp> for FormatExprGeneratorExp {
|
impl FormatNodeRule<ExprGeneratorExp> for FormatExprGeneratorExp {
|
||||||
fn fmt_fields(&self, item: &ExprGeneratorExp, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &ExprGeneratorExp, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::expression::parentheses::{
|
use crate::expression::parentheses::{
|
||||||
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
||||||
};
|
};
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::ExprIfExp;
|
use rustpython_parser::ast::ExprIfExp;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ pub struct FormatExprIfExp;
|
||||||
|
|
||||||
impl FormatNodeRule<ExprIfExp> for 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, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::expression::parentheses::{
|
use crate::expression::parentheses::{
|
||||||
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
||||||
};
|
};
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::ExprJoinedStr;
|
use rustpython_parser::ast::ExprJoinedStr;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ pub struct FormatExprJoinedStr;
|
||||||
|
|
||||||
impl FormatNodeRule<ExprJoinedStr> for FormatExprJoinedStr {
|
impl FormatNodeRule<ExprJoinedStr> for FormatExprJoinedStr {
|
||||||
fn fmt_fields(&self, item: &ExprJoinedStr, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &ExprJoinedStr, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::expression::parentheses::{
|
use crate::expression::parentheses::{
|
||||||
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
||||||
};
|
};
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::ExprLambda;
|
use rustpython_parser::ast::ExprLambda;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ pub struct FormatExprLambda;
|
||||||
|
|
||||||
impl FormatNodeRule<ExprLambda> for FormatExprLambda {
|
impl FormatNodeRule<ExprLambda> for FormatExprLambda {
|
||||||
fn fmt_fields(&self, item: &ExprLambda, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &ExprLambda, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::expression::parentheses::{
|
use crate::expression::parentheses::{
|
||||||
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
||||||
};
|
};
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::ExprListComp;
|
use rustpython_parser::ast::ExprListComp;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ pub struct FormatExprListComp;
|
||||||
|
|
||||||
impl FormatNodeRule<ExprListComp> for FormatExprListComp {
|
impl FormatNodeRule<ExprListComp> for FormatExprListComp {
|
||||||
fn fmt_fields(&self, item: &ExprListComp, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &ExprListComp, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::expression::parentheses::{
|
use crate::expression::parentheses::{
|
||||||
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
||||||
};
|
};
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::ExprNamedExpr;
|
use rustpython_parser::ast::ExprNamedExpr;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ pub struct FormatExprNamedExpr;
|
||||||
|
|
||||||
impl FormatNodeRule<ExprNamedExpr> for FormatExprNamedExpr {
|
impl FormatNodeRule<ExprNamedExpr> for FormatExprNamedExpr {
|
||||||
fn fmt_fields(&self, item: &ExprNamedExpr, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &ExprNamedExpr, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::expression::parentheses::{
|
use crate::expression::parentheses::{
|
||||||
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
||||||
};
|
};
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::ExprSet;
|
use rustpython_parser::ast::ExprSet;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ pub struct FormatExprSet;
|
||||||
|
|
||||||
impl FormatNodeRule<ExprSet> for FormatExprSet {
|
impl FormatNodeRule<ExprSet> for FormatExprSet {
|
||||||
fn fmt_fields(&self, item: &ExprSet, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &ExprSet, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::expression::parentheses::{
|
use crate::expression::parentheses::{
|
||||||
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
||||||
};
|
};
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::ExprSetComp;
|
use rustpython_parser::ast::ExprSetComp;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ pub struct FormatExprSetComp;
|
||||||
|
|
||||||
impl FormatNodeRule<ExprSetComp> for FormatExprSetComp {
|
impl FormatNodeRule<ExprSetComp> for FormatExprSetComp {
|
||||||
fn fmt_fields(&self, item: &ExprSetComp, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &ExprSetComp, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::expression::parentheses::{
|
use crate::expression::parentheses::{
|
||||||
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
||||||
};
|
};
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::ExprSlice;
|
use rustpython_parser::ast::ExprSlice;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ pub struct FormatExprSlice;
|
||||||
|
|
||||||
impl FormatNodeRule<ExprSlice> for 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, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::expression::parentheses::{
|
use crate::expression::parentheses::{
|
||||||
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
||||||
};
|
};
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::ExprStarred;
|
use rustpython_parser::ast::ExprStarred;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ pub struct FormatExprStarred;
|
||||||
|
|
||||||
impl FormatNodeRule<ExprStarred> for FormatExprStarred {
|
impl FormatNodeRule<ExprStarred> for FormatExprStarred {
|
||||||
fn fmt_fields(&self, item: &ExprStarred, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &ExprStarred, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::expression::parentheses::{
|
use crate::expression::parentheses::{
|
||||||
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
||||||
};
|
};
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::ExprSubscript;
|
use rustpython_parser::ast::ExprSubscript;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ pub struct FormatExprSubscript;
|
||||||
|
|
||||||
impl FormatNodeRule<ExprSubscript> for 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, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::expression::parentheses::{
|
use crate::expression::parentheses::{
|
||||||
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
||||||
};
|
};
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::ExprTuple;
|
use rustpython_parser::ast::ExprTuple;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ pub struct FormatExprTuple;
|
||||||
|
|
||||||
impl FormatNodeRule<ExprTuple> for FormatExprTuple {
|
impl FormatNodeRule<ExprTuple> for FormatExprTuple {
|
||||||
fn fmt_fields(&self, item: &ExprTuple, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &ExprTuple, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::expression::parentheses::{
|
use crate::expression::parentheses::{
|
||||||
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
||||||
};
|
};
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::ExprUnaryOp;
|
use rustpython_parser::ast::ExprUnaryOp;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ pub struct FormatExprUnaryOp;
|
||||||
|
|
||||||
impl FormatNodeRule<ExprUnaryOp> for FormatExprUnaryOp {
|
impl FormatNodeRule<ExprUnaryOp> for FormatExprUnaryOp {
|
||||||
fn fmt_fields(&self, item: &ExprUnaryOp, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &ExprUnaryOp, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::expression::parentheses::{
|
use crate::expression::parentheses::{
|
||||||
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
||||||
};
|
};
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::ExprYield;
|
use rustpython_parser::ast::ExprYield;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ pub struct FormatExprYield;
|
||||||
|
|
||||||
impl FormatNodeRule<ExprYield> for FormatExprYield {
|
impl FormatNodeRule<ExprYield> for FormatExprYield {
|
||||||
fn fmt_fields(&self, item: &ExprYield, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &ExprYield, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::expression::parentheses::{
|
use crate::expression::parentheses::{
|
||||||
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
||||||
};
|
};
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::ExprYieldFrom;
|
use rustpython_parser::ast::ExprYieldFrom;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ pub struct FormatExprYieldFrom;
|
||||||
|
|
||||||
impl FormatNodeRule<ExprYieldFrom> for FormatExprYieldFrom {
|
impl FormatNodeRule<ExprYieldFrom> for FormatExprYieldFrom {
|
||||||
fn fmt_fields(&self, item: &ExprYieldFrom, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &ExprYieldFrom, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,22 +1,15 @@
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
use ruff_text_size::TextRange;
|
use ruff_formatter::prelude::*;
|
||||||
use rustpython_parser::ast::Mod;
|
use ruff_formatter::{format, write};
|
||||||
|
use ruff_formatter::{Formatted, IndentStyle, Printed, SimpleFormatOptions, SourceCode};
|
||||||
|
use ruff_python_ast::node::{AnyNodeRef, AstNode, NodeKind};
|
||||||
|
use ruff_python_ast::source_code::{CommentRanges, CommentRangesBuilder, Locator};
|
||||||
|
use ruff_text_size::{TextLen, TextRange};
|
||||||
|
use rustpython_parser::ast::{Mod, Ranged};
|
||||||
use rustpython_parser::lexer::lex;
|
use rustpython_parser::lexer::lex;
|
||||||
use rustpython_parser::{parse_tokens, Mode};
|
use rustpython_parser::{parse_tokens, Mode};
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use ruff_formatter::format_element::tag::VerbatimKind;
|
|
||||||
use ruff_formatter::formatter::Formatter;
|
|
||||||
use ruff_formatter::prelude::{
|
|
||||||
dynamic_text, source_position, source_text_slice, ContainsNewlines, Tag,
|
|
||||||
};
|
|
||||||
use ruff_formatter::{
|
|
||||||
format, normalize_newlines, write, Buffer, Format, FormatElement, FormatResult, Formatted,
|
|
||||||
IndentStyle, Printed, SimpleFormatOptions, SourceCode,
|
|
||||||
};
|
|
||||||
use ruff_python_ast::node::AstNode;
|
|
||||||
use ruff_python_ast::source_code::{CommentRanges, CommentRangesBuilder, Locator};
|
|
||||||
|
|
||||||
use crate::comments::{
|
use crate::comments::{
|
||||||
dangling_node_comments, leading_node_comments, trailing_node_comments, Comments,
|
dangling_node_comments, leading_node_comments, trailing_node_comments, Comments,
|
||||||
};
|
};
|
||||||
|
@ -142,16 +135,49 @@ pub fn format_node<'a>(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) struct NotYetImplemented(NodeKind);
|
||||||
|
|
||||||
|
/// Formats a placeholder for nodes that have not yet been implemented
|
||||||
|
pub(crate) fn not_yet_implemented<'a, T>(node: T) -> NotYetImplemented
|
||||||
|
where
|
||||||
|
T: Into<AnyNodeRef<'a>>,
|
||||||
|
{
|
||||||
|
NotYetImplemented(node.into().kind())
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Format<PyFormatContext<'_>> for NotYetImplemented {
|
||||||
|
fn fmt(&self, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
|
let text = std::format!("NOT_YET_IMPLEMENTED_{:?}", self.0);
|
||||||
|
|
||||||
|
f.write_element(FormatElement::Tag(Tag::StartVerbatim(
|
||||||
|
tag::VerbatimKind::Verbatim {
|
||||||
|
length: text.text_len(),
|
||||||
|
},
|
||||||
|
)))?;
|
||||||
|
|
||||||
|
f.write_element(FormatElement::DynamicText {
|
||||||
|
text: Box::from(text),
|
||||||
|
})?;
|
||||||
|
|
||||||
|
f.write_element(FormatElement::Tag(Tag::EndVerbatim))?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) struct VerbatimText(TextRange);
|
pub(crate) struct VerbatimText(TextRange);
|
||||||
|
|
||||||
pub(crate) const fn verbatim_text(range: TextRange) -> VerbatimText {
|
#[allow(unused)]
|
||||||
VerbatimText(range)
|
pub(crate) fn verbatim_text<T>(item: &T) -> VerbatimText
|
||||||
|
where
|
||||||
|
T: Ranged,
|
||||||
|
{
|
||||||
|
VerbatimText(item.range())
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Format<PyFormatContext<'_>> for VerbatimText {
|
impl Format<PyFormatContext<'_>> for VerbatimText {
|
||||||
fn fmt(&self, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt(&self, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
f.write_element(FormatElement::Tag(Tag::StartVerbatim(
|
f.write_element(FormatElement::Tag(Tag::StartVerbatim(
|
||||||
VerbatimKind::Verbatim {
|
tag::VerbatimKind::Verbatim {
|
||||||
length: self.0.len(),
|
length: self.0.len(),
|
||||||
},
|
},
|
||||||
)))?;
|
)))?;
|
||||||
|
@ -203,8 +229,7 @@ if True:
|
||||||
# trailing
|
# trailing
|
||||||
"#;
|
"#;
|
||||||
let expected = r#"# preceding
|
let expected = r#"# preceding
|
||||||
if True:
|
NOT_YET_IMPLEMENTED_StmtIf
|
||||||
print( "hi" )
|
|
||||||
# trailing
|
# trailing
|
||||||
"#;
|
"#;
|
||||||
let actual = format_module(input)?.as_code().to_string();
|
let actual = format_module(input)?.as_code().to_string();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::ModExpression;
|
use rustpython_parser::ast::ModExpression;
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@ pub struct FormatModExpression;
|
||||||
|
|
||||||
impl FormatNodeRule<ModExpression> for FormatModExpression {
|
impl FormatNodeRule<ModExpression> for FormatModExpression {
|
||||||
fn fmt_fields(&self, item: &ModExpression, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &ModExpression, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::ModFunctionType;
|
use rustpython_parser::ast::ModFunctionType;
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@ pub struct FormatModFunctionType;
|
||||||
|
|
||||||
impl FormatNodeRule<ModFunctionType> for FormatModFunctionType {
|
impl FormatNodeRule<ModFunctionType> for FormatModFunctionType {
|
||||||
fn fmt_fields(&self, item: &ModFunctionType, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &ModFunctionType, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::ModInteractive;
|
use rustpython_parser::ast::ModInteractive;
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@ pub struct FormatModInteractive;
|
||||||
|
|
||||||
impl FormatNodeRule<ModInteractive> for FormatModInteractive {
|
impl FormatNodeRule<ModInteractive> for FormatModInteractive {
|
||||||
fn fmt_fields(&self, item: &ModInteractive, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &ModInteractive, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::Alias;
|
use rustpython_parser::ast::Alias;
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@ pub struct FormatAlias;
|
||||||
|
|
||||||
impl FormatNodeRule<Alias> for FormatAlias {
|
impl FormatNodeRule<Alias> for FormatAlias {
|
||||||
fn fmt_fields(&self, item: &Alias, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &Alias, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::Arg;
|
use rustpython_parser::ast::Arg;
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@ pub struct FormatArg;
|
||||||
|
|
||||||
impl FormatNodeRule<Arg> for FormatArg {
|
impl FormatNodeRule<Arg> for FormatArg {
|
||||||
fn fmt_fields(&self, item: &Arg, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &Arg, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::Arguments;
|
use rustpython_parser::ast::Arguments;
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@ pub struct FormatArguments;
|
||||||
|
|
||||||
impl FormatNodeRule<Arguments> for FormatArguments {
|
impl FormatNodeRule<Arguments> for FormatArguments {
|
||||||
fn fmt_fields(&self, item: &Arguments, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &Arguments, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::Comprehension;
|
use rustpython_parser::ast::Comprehension;
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@ pub struct FormatComprehension;
|
||||||
|
|
||||||
impl FormatNodeRule<Comprehension> for FormatComprehension {
|
impl FormatNodeRule<Comprehension> for FormatComprehension {
|
||||||
fn fmt_fields(&self, item: &Comprehension, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &Comprehension, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::ExcepthandlerExceptHandler;
|
use rustpython_parser::ast::ExcepthandlerExceptHandler;
|
||||||
|
|
||||||
|
@ -11,6 +11,6 @@ impl FormatNodeRule<ExcepthandlerExceptHandler> for FormatExcepthandlerExceptHan
|
||||||
item: &ExcepthandlerExceptHandler,
|
item: &ExcepthandlerExceptHandler,
|
||||||
f: &mut PyFormatter,
|
f: &mut PyFormatter,
|
||||||
) -> FormatResult<()> {
|
) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::Keyword;
|
use rustpython_parser::ast::Keyword;
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@ pub struct FormatKeyword;
|
||||||
|
|
||||||
impl FormatNodeRule<Keyword> for FormatKeyword {
|
impl FormatNodeRule<Keyword> for FormatKeyword {
|
||||||
fn fmt_fields(&self, item: &Keyword, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &Keyword, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::MatchCase;
|
use rustpython_parser::ast::MatchCase;
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@ pub struct FormatMatchCase;
|
||||||
|
|
||||||
impl FormatNodeRule<MatchCase> for FormatMatchCase {
|
impl FormatNodeRule<MatchCase> for FormatMatchCase {
|
||||||
fn fmt_fields(&self, item: &MatchCase, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &MatchCase, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::TypeIgnoreTypeIgnore;
|
use rustpython_parser::ast::TypeIgnoreTypeIgnore;
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@ pub struct FormatTypeIgnoreTypeIgnore;
|
||||||
|
|
||||||
impl FormatNodeRule<TypeIgnoreTypeIgnore> for FormatTypeIgnoreTypeIgnore {
|
impl FormatNodeRule<TypeIgnoreTypeIgnore> for FormatTypeIgnoreTypeIgnore {
|
||||||
fn fmt_fields(&self, item: &TypeIgnoreTypeIgnore, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &TypeIgnoreTypeIgnore, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::Withitem;
|
use rustpython_parser::ast::Withitem;
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@ pub struct FormatWithitem;
|
||||||
|
|
||||||
impl FormatNodeRule<Withitem> for FormatWithitem {
|
impl FormatNodeRule<Withitem> for FormatWithitem {
|
||||||
fn fmt_fields(&self, item: &Withitem, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &Withitem, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::PatternMatchAs;
|
use rustpython_parser::ast::PatternMatchAs;
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@ pub struct FormatPatternMatchAs;
|
||||||
|
|
||||||
impl FormatNodeRule<PatternMatchAs> for FormatPatternMatchAs {
|
impl FormatNodeRule<PatternMatchAs> for FormatPatternMatchAs {
|
||||||
fn fmt_fields(&self, item: &PatternMatchAs, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &PatternMatchAs, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::PatternMatchClass;
|
use rustpython_parser::ast::PatternMatchClass;
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@ pub struct FormatPatternMatchClass;
|
||||||
|
|
||||||
impl FormatNodeRule<PatternMatchClass> for FormatPatternMatchClass {
|
impl FormatNodeRule<PatternMatchClass> for FormatPatternMatchClass {
|
||||||
fn fmt_fields(&self, item: &PatternMatchClass, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &PatternMatchClass, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::PatternMatchMapping;
|
use rustpython_parser::ast::PatternMatchMapping;
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@ pub struct FormatPatternMatchMapping;
|
||||||
|
|
||||||
impl FormatNodeRule<PatternMatchMapping> for FormatPatternMatchMapping {
|
impl FormatNodeRule<PatternMatchMapping> for FormatPatternMatchMapping {
|
||||||
fn fmt_fields(&self, item: &PatternMatchMapping, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &PatternMatchMapping, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::PatternMatchOr;
|
use rustpython_parser::ast::PatternMatchOr;
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@ pub struct FormatPatternMatchOr;
|
||||||
|
|
||||||
impl FormatNodeRule<PatternMatchOr> for FormatPatternMatchOr {
|
impl FormatNodeRule<PatternMatchOr> for FormatPatternMatchOr {
|
||||||
fn fmt_fields(&self, item: &PatternMatchOr, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &PatternMatchOr, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::PatternMatchSequence;
|
use rustpython_parser::ast::PatternMatchSequence;
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@ pub struct FormatPatternMatchSequence;
|
||||||
|
|
||||||
impl FormatNodeRule<PatternMatchSequence> for FormatPatternMatchSequence {
|
impl FormatNodeRule<PatternMatchSequence> for FormatPatternMatchSequence {
|
||||||
fn fmt_fields(&self, item: &PatternMatchSequence, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &PatternMatchSequence, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::PatternMatchSingleton;
|
use rustpython_parser::ast::PatternMatchSingleton;
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@ pub struct FormatPatternMatchSingleton;
|
||||||
|
|
||||||
impl FormatNodeRule<PatternMatchSingleton> for FormatPatternMatchSingleton {
|
impl FormatNodeRule<PatternMatchSingleton> for FormatPatternMatchSingleton {
|
||||||
fn fmt_fields(&self, item: &PatternMatchSingleton, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &PatternMatchSingleton, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::PatternMatchStar;
|
use rustpython_parser::ast::PatternMatchStar;
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@ pub struct FormatPatternMatchStar;
|
||||||
|
|
||||||
impl FormatNodeRule<PatternMatchStar> for FormatPatternMatchStar {
|
impl FormatNodeRule<PatternMatchStar> for FormatPatternMatchStar {
|
||||||
fn fmt_fields(&self, item: &PatternMatchStar, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &PatternMatchStar, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
|
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use rustpython_parser::ast::PatternMatchValue;
|
use rustpython_parser::ast::PatternMatchValue;
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@ pub struct FormatPatternMatchValue;
|
||||||
|
|
||||||
impl FormatNodeRule<PatternMatchValue> for FormatPatternMatchValue {
|
impl FormatNodeRule<PatternMatchValue> for FormatPatternMatchValue {
|
||||||
fn fmt_fields(&self, item: &PatternMatchValue, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &PatternMatchValue, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [verbatim_text(item.range)])
|
write!(f, [not_yet_implemented(item)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,10 +35,9 @@ y = 100(no)
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -1,21 +1,21 @@
|
@@ -1,22 +1,21 @@
|
||||||
-x = (123456789).bit_count()
|
-x = (123456789).bit_count()
|
||||||
+x = 123456789 .bit_count()
|
-x = (123456).__abs__()
|
||||||
x = (123456).__abs__()
|
|
||||||
-x = (0.1).is_integer()
|
-x = (0.1).is_integer()
|
||||||
-x = (1.0).imag
|
-x = (1.0).imag
|
||||||
-x = (1e1).imag
|
-x = (1e1).imag
|
||||||
|
@ -53,53 +52,57 @@ y = 100(no)
|
||||||
-x = 0o777.real
|
-x = 0o777.real
|
||||||
-x = (0.000000006).hex()
|
-x = (0.000000006).hex()
|
||||||
-x = -100.0000j
|
-x = -100.0000j
|
||||||
+x = .1.is_integer()
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
+x = 1. .imag
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
+x = 1E+1.imag
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
+x = 1E-1.real
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
+x = 123456789.123456789.hex()
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
+x = 123456789.123456789E123456789 .real
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
+x = 123456789E123456789 .conjugate()
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
+x = 123456789J.real
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
+x = 123456789.123456789J.__add__(0b1011.bit_length())
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
+x = 0XB1ACC.conjugate()
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
+x = 0B1011 .conjugate()
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
+x = 0O777 .real
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
+x = 0.000000006 .hex()
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
+x = -100.0000J
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
-if (10).real:
|
-if (10).real:
|
||||||
+if 10 .real:
|
- ...
|
||||||
...
|
+NOT_YET_IMPLEMENTED_StmtIf
|
||||||
|
|
||||||
y = 100[no]
|
-y = 100[no]
|
||||||
|
-y = 100(no)
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
x = 123456789 .bit_count()
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
x = (123456).__abs__()
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
x = .1.is_integer()
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
x = 1. .imag
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
x = 1E+1.imag
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
x = 1E-1.real
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
x = 123456789.123456789.hex()
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
x = 123456789.123456789E123456789 .real
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
x = 123456789E123456789 .conjugate()
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
x = 123456789J.real
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
x = 123456789.123456789J.__add__(0b1011.bit_length())
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
x = 0XB1ACC.conjugate()
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
x = 0B1011 .conjugate()
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
x = 0O777 .real
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
x = 0.000000006 .hex()
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
x = -100.0000J
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
if 10 .real:
|
NOT_YET_IMPLEMENTED_StmtIf
|
||||||
...
|
|
||||||
|
|
||||||
y = 100[no]
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
y = 100(no)
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
---
|
||||||
|
source: crates/ruff_python_formatter/src/lib.rs
|
||||||
|
expression: snapshot
|
||||||
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_cases/beginning_backslash.py
|
||||||
|
---
|
||||||
|
## Input
|
||||||
|
|
||||||
|
```py
|
||||||
|
\
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
print("hello, world")
|
||||||
|
```
|
||||||
|
|
||||||
|
## Black Differences
|
||||||
|
|
||||||
|
```diff
|
||||||
|
--- Black
|
||||||
|
+++ Ruff
|
||||||
|
@@ -1 +1 @@
|
||||||
|
-print("hello, world")
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprCall
|
||||||
|
```
|
||||||
|
|
||||||
|
## Ruff Output
|
||||||
|
|
||||||
|
```py
|
||||||
|
NOT_YET_IMPLEMENTED_ExprCall
|
||||||
|
```
|
||||||
|
|
||||||
|
## Black Output
|
||||||
|
|
||||||
|
```py
|
||||||
|
print("hello, world")
|
||||||
|
```
|
||||||
|
|
||||||
|
|
|
@ -19,27 +19,22 @@ lambda x=lambda y={1: 3}: y['x':lambda y: {1: 2}]: x
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -1,4 +1,6 @@
|
@@ -1,4 +1,3 @@
|
||||||
-for ((x in {}) or {})["a"] in x:
|
-for ((x in {}) or {})["a"] in x:
|
||||||
+for ((x in {}) or {})['a'] in x:
|
- pass
|
||||||
pass
|
|
||||||
-pem_spam = lambda l, spam={"x": 3}: not spam.get(l.strip())
|
-pem_spam = lambda l, spam={"x": 3}: not spam.get(l.strip())
|
||||||
-lambda x=lambda y={1: 3}: y["x" : lambda y: {1: 2}]: x
|
-lambda x=lambda y={1: 3}: y["x" : lambda y: {1: 2}]: x
|
||||||
+pem_spam = lambda l, spam = {
|
+NOT_YET_IMPLEMENTED_StmtFor
|
||||||
+ "x": 3
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
+}: not spam.get(l.strip())
|
+NOT_YET_IMPLEMENTED_ExprLambda
|
||||||
+lambda x=lambda y={1: 3}: y['x':lambda y: {1: 2}]: x
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
for ((x in {}) or {})['a'] in x:
|
NOT_YET_IMPLEMENTED_StmtFor
|
||||||
pass
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
pem_spam = lambda l, spam = {
|
NOT_YET_IMPLEMENTED_ExprLambda
|
||||||
"x": 3
|
|
||||||
}: not spam.get(l.strip())
|
|
||||||
lambda x=lambda y={1: 3}: y['x':lambda y: {1: 2}]: x
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -36,77 +36,64 @@ class NormalClass (
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -1,16 +1,16 @@
|
@@ -1,30 +1,16 @@
|
||||||
-class SimpleClassWithBlankParentheses:
|
-class SimpleClassWithBlankParentheses:
|
||||||
+class SimpleClassWithBlankParentheses():
|
- pass
|
||||||
pass
|
-
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
|
|
||||||
-class ClassWithSpaceParentheses:
|
-class ClassWithSpaceParentheses:
|
||||||
+class ClassWithSpaceParentheses ( ):
|
- first_test_data = 90
|
||||||
first_test_data = 90
|
- second_test_data = 100
|
||||||
second_test_data = 100
|
|
||||||
-
|
- def test_func(self):
|
||||||
def test_func(self):
|
- return None
|
||||||
return None
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
|
|
||||||
|
|
||||||
class ClassWithEmptyFunc(object):
|
-class ClassWithEmptyFunc(object):
|
||||||
+
|
- def func_with_blank_parentheses():
|
||||||
def func_with_blank_parentheses():
|
- return 5
|
||||||
return 5
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
|
|
||||||
@@ -20,11 +20,12 @@
|
|
||||||
|
|
||||||
|
|
||||||
def class_under_the_func_with_blank_parentheses():
|
-def public_func_with_blank_parentheses():
|
||||||
|
- return None
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
-def class_under_the_func_with_blank_parentheses():
|
||||||
- class InsideFunc:
|
- class InsideFunc:
|
||||||
+ class InsideFunc():
|
- pass
|
||||||
pass
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
-class NormalClass:
|
-class NormalClass:
|
||||||
+class NormalClass (
|
- def func_for_testing(self, first, second):
|
||||||
+):
|
- sum = first + second
|
||||||
def func_for_testing(self, first, second):
|
- return sum
|
||||||
sum = first + second
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
return sum
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
class SimpleClassWithBlankParentheses():
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ClassWithSpaceParentheses ( ):
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
first_test_data = 90
|
|
||||||
second_test_data = 100
|
|
||||||
def test_func(self):
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
class ClassWithEmptyFunc(object):
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
|
|
||||||
def func_with_blank_parentheses():
|
|
||||||
return 5
|
|
||||||
|
|
||||||
|
|
||||||
def public_func_with_blank_parentheses():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def class_under_the_func_with_blank_parentheses():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
class InsideFunc():
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class NormalClass (
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
):
|
|
||||||
def func_for_testing(self, first, second):
|
|
||||||
sum = first + second
|
|
||||||
return sum
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -113,290 +113,259 @@ class ClassWithDecoInitAndVarsAndDocstringWithInner2:
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -17,23 +17,19 @@
|
@@ -1,165 +1,61 @@
|
||||||
|
-class ClassSimplest:
|
||||||
class ClassWithTheDocstringAndInit:
|
- pass
|
||||||
"""Just a docstring."""
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
-
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ClassWithInitAndVars:
|
-class ClassWithSingleField:
|
||||||
cls_var = 100
|
- a = 1
|
||||||
-
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ClassWithInitAndVarsAndDocstring:
|
-class ClassWithJustTheDocstring:
|
||||||
"""Test class"""
|
- """Just a docstring."""
|
||||||
-
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
cls_var = 100
|
|
||||||
-
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
@@ -46,7 +42,6 @@
|
|
||||||
|
|
||||||
class ClassWithDecoInitAndVars:
|
|
||||||
cls_var = 100
|
|
||||||
-
|
|
||||||
@deco
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
@@ -54,9 +49,7 @@
|
|
||||||
|
|
||||||
class ClassWithDecoInitAndVarsAndDocstring:
|
|
||||||
"""Test class"""
|
|
||||||
-
|
|
||||||
cls_var = 100
|
|
||||||
-
|
|
||||||
@deco
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
@@ -70,21 +63,18 @@
|
|
||||||
class ClassSimplestWithInnerWithDocstring:
|
|
||||||
class Inner:
|
|
||||||
"""Just a docstring."""
|
|
||||||
-
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ClassWithSingleFieldWithInner:
|
-class ClassWithInit:
|
||||||
a = 1
|
- def __init__(self):
|
||||||
-
|
- pass
|
||||||
class Inner:
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ClassWithJustTheDocstringWithInner:
|
-class ClassWithTheDocstringAndInit:
|
||||||
"""Just a docstring."""
|
- """Just a docstring."""
|
||||||
-
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
class Inner:
|
|
||||||
pass
|
|
||||||
|
|
||||||
@@ -92,29 +82,23 @@
|
- def __init__(self):
|
||||||
class ClassWithInitWithInner:
|
- pass
|
||||||
class Inner:
|
|
||||||
pass
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
-
|
|
||||||
def __init__(self):
|
-class ClassWithInitAndVars:
|
||||||
pass
|
- cls_var = 100
|
||||||
|
|
||||||
|
- def __init__(self):
|
||||||
|
- pass
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
|
|
||||||
|
|
||||||
class ClassWithInitAndVarsWithInner:
|
-class ClassWithInitAndVarsAndDocstring:
|
||||||
cls_var = 100
|
- """Test class"""
|
||||||
-
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
class Inner:
|
|
||||||
pass
|
- cls_var = 100
|
||||||
-
|
|
||||||
def __init__(self):
|
- def __init__(self):
|
||||||
pass
|
- pass
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
|
|
||||||
|
|
||||||
class ClassWithInitAndVarsAndDocstringWithInner:
|
-class ClassWithDecoInit:
|
||||||
"""Test class"""
|
- @deco
|
||||||
-
|
- def __init__(self):
|
||||||
cls_var = 100
|
- pass
|
||||||
-
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
class Inner:
|
|
||||||
pass
|
|
||||||
-
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
@@ -122,7 +106,6 @@
|
|
||||||
class ClassWithDecoInitWithInner:
|
|
||||||
class Inner:
|
|
||||||
pass
|
|
||||||
-
|
|
||||||
@deco
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
@@ -130,10 +113,8 @@
|
|
||||||
|
|
||||||
class ClassWithDecoInitAndVarsWithInner:
|
-class ClassWithDecoInitAndVars:
|
||||||
cls_var = 100
|
- cls_var = 100
|
||||||
-
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
class Inner:
|
|
||||||
pass
|
|
||||||
-
|
|
||||||
@deco
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
@@ -141,12 +122,9 @@
|
|
||||||
|
|
||||||
class ClassWithDecoInitAndVarsAndDocstringWithInner:
|
- @deco
|
||||||
"""Test class"""
|
- def __init__(self):
|
||||||
-
|
- pass
|
||||||
cls_var = 100
|
|
||||||
-
|
|
||||||
class Inner:
|
|
||||||
pass
|
|
||||||
-
|
|
||||||
@deco
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
@@ -154,12 +132,9 @@
|
|
||||||
|
|
||||||
class ClassWithDecoInitAndVarsAndDocstringWithInner2:
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
"""Test class"""
|
|
||||||
|
-class ClassWithDecoInitAndVarsAndDocstring:
|
||||||
|
- """Test class"""
|
||||||
|
|
||||||
|
- cls_var = 100
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
|
|
||||||
|
- @deco
|
||||||
|
- def __init__(self):
|
||||||
|
- pass
|
||||||
|
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
|
|
||||||
|
-class ClassSimplestWithInner:
|
||||||
|
- class Inner:
|
||||||
|
- pass
|
||||||
|
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
|
|
||||||
|
-class ClassSimplestWithInnerWithDocstring:
|
||||||
|
- class Inner:
|
||||||
|
- """Just a docstring."""
|
||||||
|
|
||||||
|
- def __init__(self):
|
||||||
|
- pass
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
|
|
||||||
|
|
||||||
|
-class ClassWithSingleFieldWithInner:
|
||||||
|
- a = 1
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
|
|
||||||
|
- class Inner:
|
||||||
|
- pass
|
||||||
|
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
|
|
||||||
|
-class ClassWithJustTheDocstringWithInner:
|
||||||
|
- """Just a docstring."""
|
||||||
|
|
||||||
|
- class Inner:
|
||||||
|
- pass
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
|
|
||||||
|
|
||||||
|
-class ClassWithInitWithInner:
|
||||||
|
- class Inner:
|
||||||
|
- pass
|
||||||
-
|
-
|
||||||
class Inner:
|
- def __init__(self):
|
||||||
pass
|
- pass
|
||||||
-
|
-
|
||||||
cls_var = 100
|
|
||||||
-
|
-
|
||||||
@deco
|
-class ClassWithInitAndVarsWithInner:
|
||||||
def __init__(self):
|
- cls_var = 100
|
||||||
pass
|
-
|
||||||
|
- class Inner:
|
||||||
|
- pass
|
||||||
|
-
|
||||||
|
- def __init__(self):
|
||||||
|
- pass
|
||||||
|
-
|
||||||
|
-
|
||||||
|
-class ClassWithInitAndVarsAndDocstringWithInner:
|
||||||
|
- """Test class"""
|
||||||
|
-
|
||||||
|
- cls_var = 100
|
||||||
|
-
|
||||||
|
- class Inner:
|
||||||
|
- pass
|
||||||
|
-
|
||||||
|
- def __init__(self):
|
||||||
|
- pass
|
||||||
|
-
|
||||||
|
-
|
||||||
|
-class ClassWithDecoInitWithInner:
|
||||||
|
- class Inner:
|
||||||
|
- pass
|
||||||
|
-
|
||||||
|
- @deco
|
||||||
|
- def __init__(self):
|
||||||
|
- pass
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
|
|
||||||
|
|
||||||
|
-class ClassWithDecoInitAndVarsWithInner:
|
||||||
|
- cls_var = 100
|
||||||
|
-
|
||||||
|
- class Inner:
|
||||||
|
- pass
|
||||||
|
-
|
||||||
|
- @deco
|
||||||
|
- def __init__(self):
|
||||||
|
- pass
|
||||||
|
-
|
||||||
|
-
|
||||||
|
-class ClassWithDecoInitAndVarsAndDocstringWithInner:
|
||||||
|
- """Test class"""
|
||||||
|
-
|
||||||
|
- cls_var = 100
|
||||||
|
-
|
||||||
|
- class Inner:
|
||||||
|
- pass
|
||||||
|
-
|
||||||
|
- @deco
|
||||||
|
- def __init__(self):
|
||||||
|
- pass
|
||||||
|
-
|
||||||
|
-
|
||||||
|
-class ClassWithDecoInitAndVarsAndDocstringWithInner2:
|
||||||
|
- """Test class"""
|
||||||
|
-
|
||||||
|
- class Inner:
|
||||||
|
- pass
|
||||||
|
-
|
||||||
|
- cls_var = 100
|
||||||
|
-
|
||||||
|
- @deco
|
||||||
|
- def __init__(self):
|
||||||
|
- pass
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
class ClassSimplest:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ClassWithSingleField:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
a = 1
|
|
||||||
|
|
||||||
|
|
||||||
class ClassWithJustTheDocstring:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
"""Just a docstring."""
|
|
||||||
|
|
||||||
|
|
||||||
class ClassWithInit:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ClassWithTheDocstringAndInit:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
"""Just a docstring."""
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ClassWithInitAndVars:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
cls_var = 100
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ClassWithInitAndVarsAndDocstring:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
"""Test class"""
|
|
||||||
cls_var = 100
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ClassWithDecoInit:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
@deco
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ClassWithDecoInitAndVars:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
cls_var = 100
|
|
||||||
@deco
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ClassWithDecoInitAndVarsAndDocstring:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
"""Test class"""
|
|
||||||
cls_var = 100
|
|
||||||
@deco
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ClassSimplestWithInner:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
class Inner:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ClassSimplestWithInnerWithDocstring:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
class Inner:
|
|
||||||
"""Just a docstring."""
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ClassWithSingleFieldWithInner:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
a = 1
|
|
||||||
class Inner:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ClassWithJustTheDocstringWithInner:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
"""Just a docstring."""
|
|
||||||
class Inner:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ClassWithInitWithInner:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
class Inner:
|
|
||||||
pass
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ClassWithInitAndVarsWithInner:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
cls_var = 100
|
|
||||||
class Inner:
|
|
||||||
pass
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ClassWithInitAndVarsAndDocstringWithInner:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
"""Test class"""
|
|
||||||
cls_var = 100
|
|
||||||
class Inner:
|
|
||||||
pass
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ClassWithDecoInitWithInner:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
class Inner:
|
|
||||||
pass
|
|
||||||
@deco
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ClassWithDecoInitAndVarsWithInner:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
cls_var = 100
|
|
||||||
class Inner:
|
|
||||||
pass
|
|
||||||
@deco
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ClassWithDecoInitAndVarsAndDocstringWithInner:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
"""Test class"""
|
|
||||||
cls_var = 100
|
|
||||||
class Inner:
|
|
||||||
pass
|
|
||||||
@deco
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ClassWithDecoInitAndVarsAndDocstringWithInner2:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
"""Test class"""
|
|
||||||
class Inner:
|
|
||||||
pass
|
|
||||||
cls_var = 100
|
|
||||||
@deco
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -84,9 +84,31 @@ if True:
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -18,44 +18,26 @@
|
@@ -1,99 +1,48 @@
|
||||||
xyzzy as magic,
|
-import core, time, a
|
||||||
)
|
+NOT_YET_IMPLEMENTED_StmtImport
|
||||||
|
|
||||||
|
-from . import A, B, C
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
|
|
||||||
|
# keeps existing trailing comma
|
||||||
|
-from foo import (
|
||||||
|
- bar,
|
||||||
|
-)
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
|
|
||||||
|
# also keeps existing structure
|
||||||
|
-from foo import (
|
||||||
|
- baz,
|
||||||
|
- qux,
|
||||||
|
-)
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
|
|
||||||
|
# `as` works as well
|
||||||
|
-from foo import (
|
||||||
|
- xyzzy as magic,
|
||||||
|
-)
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
|
|
||||||
-a = {
|
-a = {
|
||||||
- 1,
|
- 1,
|
||||||
|
@ -94,15 +116,11 @@ if True:
|
||||||
- 3,
|
- 3,
|
||||||
-}
|
-}
|
||||||
-b = {1, 2, 3}
|
-b = {1, 2, 3}
|
||||||
+a = {1,2,3,}
|
-c = {
|
||||||
+b = {
|
- 1,
|
||||||
+1,2,
|
- 2,
|
||||||
+ 3}
|
- 3,
|
||||||
c = {
|
-}
|
||||||
1,
|
|
||||||
2,
|
|
||||||
3,
|
|
||||||
}
|
|
||||||
-x = (1,)
|
-x = (1,)
|
||||||
-y = (narf(),)
|
-y = (narf(),)
|
||||||
-nested = {
|
-nested = {
|
||||||
|
@ -116,20 +134,27 @@ if True:
|
||||||
- "cccccccccccccccccccccccccccccccccccccccc",
|
- "cccccccccccccccccccccccccccccccccccccccc",
|
||||||
- (1, 2, 3),
|
- (1, 2, 3),
|
||||||
- "dddddddddddddddddddddddddddddddddddddddd",
|
- "dddddddddddddddddddddddddddddddddddddddd",
|
||||||
-]
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprDict
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprDict
|
||||||
|
+[
|
||||||
|
+ NOT_YET_IMPLEMENTED_ExprConstant,
|
||||||
|
+ NOT_YET_IMPLEMENTED_ExprConstant
|
||||||
|
+ % NOT_YET_IMPLEMENTED_ExprTuple,
|
||||||
|
]
|
||||||
-{
|
-{
|
||||||
- "oneple": (1,),
|
- "oneple": (1,),
|
||||||
-}
|
-}
|
||||||
+x = 1,
|
-{"oneple": (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,)]
|
-["ls", "lsoneple/%s" % (foo,)]
|
||||||
+['ls', 'lsoneple/%s' % (foo,)]
|
-x = {"oneple": (1,)}
|
||||||
x = {"oneple": (1,)}
|
|
||||||
-y = {
|
-y = {
|
||||||
- "oneple": (1,),
|
- "oneple": (1,),
|
||||||
-}
|
-}
|
||||||
|
@ -137,130 +162,112 @@ if True:
|
||||||
- "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa wraps %s"
|
- "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa wraps %s"
|
||||||
- % bar
|
- % bar
|
||||||
-)
|
-)
|
||||||
+y = {"oneple": (1,),}
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
+assert False, ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa wraps %s" % bar)
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssert
|
||||||
|
|
||||||
# looping over a 1-tuple should also not get wrapped
|
# looping over a 1-tuple should also not get wrapped
|
||||||
for x in (1,):
|
-for x in (1,):
|
||||||
@@ -63,13 +45,9 @@
|
- pass
|
||||||
for (x,) in (1,), (2,), (3,):
|
-for (x,) in (1,), (2,), (3,):
|
||||||
pass
|
- pass
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFor
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFor
|
||||||
|
|
||||||
-[
|
[
|
||||||
- 1,
|
- 1,
|
||||||
- 2,
|
- 2,
|
||||||
- 3,
|
- 3,
|
||||||
-]
|
+ NOT_YET_IMPLEMENTED_ExprConstant,
|
||||||
+[1, 2, 3]
|
+ NOT_YET_IMPLEMENTED_ExprConstant,
|
||||||
|
+ NOT_YET_IMPLEMENTED_ExprConstant,
|
||||||
|
]
|
||||||
|
|
||||||
-division_result_tuple = (6 / 2,)
|
-division_result_tuple = (6 / 2,)
|
||||||
+division_result_tuple = (6/2,)
|
-print("foo %r", (foo.bar,))
|
||||||
print("foo %r", (foo.bar,))
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprCall
|
||||||
|
|
||||||
if True:
|
-if True:
|
||||||
@@ -79,21 +57,15 @@
|
- IGNORED_TYPES_FOR_ATTRIBUTE_CHECKING = (
|
||||||
)
|
- Config.IGNORED_TYPES_FOR_ATTRIBUTE_CHECKING
|
||||||
|
- | {pylons.controllers.WSGIController}
|
||||||
if True:
|
|
||||||
- ec2client.get_waiter("instance_stopped").wait(
|
|
||||||
+ ec2client.get_waiter('instance_stopped').wait(
|
|
||||||
InstanceIds=[instance.id],
|
|
||||||
WaiterConfig={
|
|
||||||
- "Delay": 5,
|
|
||||||
- },
|
|
||||||
- )
|
- )
|
||||||
+ 'Delay': 5,
|
+NOT_YET_IMPLEMENTED_StmtIf
|
||||||
+ })
|
|
||||||
ec2client.get_waiter("instance_stopped").wait(
|
-if True:
|
||||||
InstanceIds=[instance.id],
|
- ec2client.get_waiter("instance_stopped").wait(
|
||||||
- WaiterConfig={
|
|
||||||
- "Delay": 5,
|
|
||||||
- },
|
|
||||||
+ WaiterConfig={"Delay": 5,},
|
|
||||||
)
|
|
||||||
ec2client.get_waiter("instance_stopped").wait(
|
|
||||||
- InstanceIds=[instance.id],
|
- InstanceIds=[instance.id],
|
||||||
- WaiterConfig={
|
- WaiterConfig={
|
||||||
- "Delay": 5,
|
- "Delay": 5,
|
||||||
- },
|
- },
|
||||||
+ 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,
|
||||||
|
- },
|
||||||
|
- )
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtIf
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
import core, time, a
|
NOT_YET_IMPLEMENTED_StmtImport
|
||||||
|
|
||||||
from . import A, B, C
|
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
|
|
||||||
# keeps existing trailing comma
|
# keeps existing trailing comma
|
||||||
from foo import (
|
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
bar,
|
|
||||||
)
|
|
||||||
|
|
||||||
# also keeps existing structure
|
# also keeps existing structure
|
||||||
from foo import (
|
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
baz,
|
|
||||||
qux,
|
|
||||||
)
|
|
||||||
|
|
||||||
# `as` works as well
|
# `as` works as well
|
||||||
from foo import (
|
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
xyzzy as magic,
|
|
||||||
)
|
|
||||||
|
|
||||||
a = {1,2,3,}
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
b = {
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
1,2,
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
3}
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
c = {
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
1,
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
2,
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
3,
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
}
|
NOT_YET_IMPLEMENTED_ExprDict
|
||||||
x = 1,
|
NOT_YET_IMPLEMENTED_ExprDict
|
||||||
y = narf(),
|
[
|
||||||
nested = {(1,2,3),(4,5,6),}
|
NOT_YET_IMPLEMENTED_ExprConstant,
|
||||||
nested_no_trailing_comma = {(1,2,3),(4,5,6)}
|
NOT_YET_IMPLEMENTED_ExprConstant
|
||||||
nested_long_lines = ["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "cccccccccccccccccccccccccccccccccccccccc", (1, 2, 3), "dddddddddddddddddddddddddddddddddddddddd"]
|
% NOT_YET_IMPLEMENTED_ExprTuple,
|
||||||
{"oneple": (1,),}
|
]
|
||||||
{"oneple": (1,)}
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
['ls', 'lsoneple/%s' % (foo,)]
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
x = {"oneple": (1,)}
|
NOT_YET_IMPLEMENTED_StmtAssert
|
||||||
y = {"oneple": (1,),}
|
|
||||||
assert False, ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa wraps %s" % bar)
|
|
||||||
|
|
||||||
# looping over a 1-tuple should also not get wrapped
|
# looping over a 1-tuple should also not get wrapped
|
||||||
for x in (1,):
|
NOT_YET_IMPLEMENTED_StmtFor
|
||||||
pass
|
NOT_YET_IMPLEMENTED_StmtFor
|
||||||
for (x,) in (1,), (2,), (3,):
|
|
||||||
pass
|
|
||||||
|
|
||||||
[1, 2, 3]
|
[
|
||||||
|
NOT_YET_IMPLEMENTED_ExprConstant,
|
||||||
|
NOT_YET_IMPLEMENTED_ExprConstant,
|
||||||
|
NOT_YET_IMPLEMENTED_ExprConstant,
|
||||||
|
]
|
||||||
|
|
||||||
division_result_tuple = (6/2,)
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
print("foo %r", (foo.bar,))
|
NOT_YET_IMPLEMENTED_ExprCall
|
||||||
|
|
||||||
if True:
|
NOT_YET_IMPLEMENTED_StmtIf
|
||||||
IGNORED_TYPES_FOR_ATTRIBUTE_CHECKING = (
|
|
||||||
Config.IGNORED_TYPES_FOR_ATTRIBUTE_CHECKING
|
|
||||||
| {pylons.controllers.WSGIController}
|
|
||||||
)
|
|
||||||
|
|
||||||
if True:
|
NOT_YET_IMPLEMENTED_StmtIf
|
||||||
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
|
## Black Output
|
||||||
|
|
|
@ -22,32 +22,24 @@ def bobtwo(): \
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -1,6 +1,9 @@
|
@@ -1,6 +1,4 @@
|
||||||
-def bob(): # pylint: disable=W9016
|
-def bob(): # pylint: disable=W9016
|
||||||
+def bob(): \
|
- pass
|
||||||
+ # pylint: disable=W9016
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
-def bobtwo(): # some comment here
|
-def bobtwo(): # some comment here
|
||||||
+def bobtwo(): \
|
- pass
|
||||||
+ \
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+ # some comment here
|
|
||||||
pass
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
def bob(): \
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
# pylint: disable=W9016
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def bobtwo(): \
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
\
|
|
||||||
# some comment here
|
|
||||||
pass
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -178,36 +178,28 @@ instruction()#comment with bad spacing
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -1,39 +1,40 @@
|
@@ -1,165 +1,23 @@
|
||||||
from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
|
-from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
|
||||||
- MyLovelyCompanyTeamProjectComponent, # NOT DRY
|
- MyLovelyCompanyTeamProjectComponent, # NOT DRY
|
||||||
+ MyLovelyCompanyTeamProjectComponent # NOT DRY
|
-)
|
||||||
)
|
-from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
|
||||||
from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
|
|
||||||
- MyLovelyCompanyTeamProjectComponent as component, # DRY
|
- MyLovelyCompanyTeamProjectComponent as component, # DRY
|
||||||
+ MyLovelyCompanyTeamProjectComponent as component # DRY
|
-)
|
||||||
)
|
+NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
|
|
||||||
# Please keep __all__ alphabetized within each category.
|
# Please keep __all__ alphabetized within each category.
|
||||||
|
|
||||||
__all__ = [
|
-__all__ = [
|
||||||
# Super-special typing primitives.
|
- # Super-special typing primitives.
|
||||||
- "Any",
|
- "Any",
|
||||||
- "Callable",
|
- "Callable",
|
||||||
- "ClassVar",
|
- "ClassVar",
|
||||||
+ 'Any',
|
- # ABCs (from collections.abc).
|
||||||
+ 'Callable',
|
|
||||||
+ 'ClassVar',
|
|
||||||
+
|
|
||||||
# ABCs (from collections.abc).
|
|
||||||
- "AbstractSet", # collections.abc.Set.
|
- "AbstractSet", # collections.abc.Set.
|
||||||
- "ByteString",
|
- "ByteString",
|
||||||
- "Container",
|
- "Container",
|
||||||
+ 'AbstractSet', # collections.abc.Set.
|
- # Concrete collection types.
|
||||||
+ 'ByteString',
|
|
||||||
+ 'Container',
|
|
||||||
+
|
|
||||||
# Concrete collection types.
|
|
||||||
- "Counter",
|
- "Counter",
|
||||||
- "Deque",
|
- "Deque",
|
||||||
- "Dict",
|
- "Dict",
|
||||||
|
@ -217,59 +209,56 @@ instruction()#comment with bad spacing
|
||||||
- "FrozenSet",
|
- "FrozenSet",
|
||||||
- "NamedTuple", # Not really a type.
|
- "NamedTuple", # Not really a type.
|
||||||
- "Generator",
|
- "Generator",
|
||||||
+ 'Counter',
|
-]
|
||||||
+ 'Deque',
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
+ 'Dict',
|
|
||||||
+ 'DefaultDict',
|
|
||||||
+ 'List',
|
|
||||||
+ 'Set',
|
|
||||||
+ 'FrozenSet',
|
|
||||||
+ 'NamedTuple', # Not really a type.
|
|
||||||
+ 'Generator',
|
|
||||||
]
|
|
||||||
|
|
||||||
not_shareables = [
|
-not_shareables = [
|
||||||
# singletons
|
- # singletons
|
||||||
True,
|
- True,
|
||||||
False,
|
- False,
|
||||||
- NotImplemented,
|
- NotImplemented,
|
||||||
- ...,
|
- ...,
|
||||||
+ NotImplemented, ...,
|
- # builtin types and objects
|
||||||
# builtin types and objects
|
- type,
|
||||||
type,
|
- object,
|
||||||
object,
|
- object(),
|
||||||
@@ -48,20 +49,23 @@
|
- Exception(),
|
||||||
SubBytes(b"spam"),
|
- 42,
|
||||||
]
|
- 100.0,
|
||||||
|
- "spam",
|
||||||
|
- # user-defined types and objects
|
||||||
|
- Cheese,
|
||||||
|
- Cheese("Wensleydale"),
|
||||||
|
- SubBytes(b"spam"),
|
||||||
|
-]
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
-if "PYTHON" in os.environ:
|
-if "PYTHON" in os.environ:
|
||||||
+if 'PYTHON' in os.environ:
|
- add_compiler(compiler_from_env())
|
||||||
add_compiler(compiler_from_env())
|
-else:
|
||||||
else:
|
- # for compiler in compilers.values():
|
||||||
# for compiler in compilers.values():
|
|
||||||
- # add_compiler(compiler)
|
- # add_compiler(compiler)
|
||||||
+ # add_compiler(compiler)
|
- add_compiler(compilers[(7.0, 32)])
|
||||||
add_compiler(compilers[(7.0, 32)])
|
|
||||||
- # add_compiler(compilers[(7.1, 64)])
|
- # add_compiler(compilers[(7.1, 64)])
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtIf
|
||||||
|
|
||||||
|
|
||||||
# Comment before function.
|
# Comment before function.
|
||||||
def inline_comments_in_brackets_ruin_everything():
|
-def inline_comments_in_brackets_ruin_everything():
|
||||||
if typedargslist:
|
- if typedargslist:
|
||||||
- parameters.children = [children[0], body, children[-1]] # (1 # )1
|
- parameters.children = [children[0], body, children[-1]] # (1 # )1
|
||||||
parameters.children = [
|
- parameters.children = [
|
||||||
+ children[0], # (1
|
- children[0],
|
||||||
+ body,
|
- body,
|
||||||
+ children[-1] # )1
|
- children[-1], # type: ignore
|
||||||
+ ]
|
- ]
|
||||||
+ parameters.children = [
|
- else:
|
||||||
children[0],
|
- parameters.children = [
|
||||||
body,
|
- parameters.children[0], # (2 what if this was actually long
|
||||||
children[-1], # type: ignore
|
- body,
|
||||||
@@ -73,49 +77,42 @@
|
- parameters.children[-1], # )2
|
||||||
parameters.children[-1], # )2
|
- ]
|
||||||
]
|
- parameters.children = [parameters.what_if_this_was_actually_long.children[0], body, parameters.children[-1]] # type: ignore
|
||||||
parameters.children = [parameters.what_if_this_was_actually_long.children[0], body, parameters.children[-1]] # type: ignore
|
|
||||||
- if (
|
- if (
|
||||||
- self._proc is not None
|
- self._proc is not None
|
||||||
- # has the child process finished?
|
- # has the child process finished?
|
||||||
|
@ -278,92 +267,74 @@ instruction()#comment with bad spacing
|
||||||
- # transport hasn't been notified yet?
|
- # transport hasn't been notified yet?
|
||||||
- and self._proc.poll() is None
|
- and self._proc.poll() is None
|
||||||
- ):
|
- ):
|
||||||
+ if (self._proc is not None
|
- pass
|
||||||
+ # has the child process finished?
|
- # no newline before or after
|
||||||
+ and self._returncode is None
|
- short = [
|
||||||
+ # 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
|
|
||||||
short = [
|
|
||||||
- # one
|
- # one
|
||||||
- 1,
|
- 1,
|
||||||
- # two
|
- # two
|
||||||
- 2,
|
- 2,
|
||||||
- ]
|
- ]
|
||||||
+ # one
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+ 1,
|
|
||||||
+ # two
|
|
||||||
+ 2]
|
|
||||||
|
|
||||||
# no newline after
|
- # no newline after
|
||||||
- call(
|
- call(
|
||||||
- arg1,
|
- arg1,
|
||||||
- arg2,
|
- arg2,
|
||||||
- """
|
- """
|
||||||
+ call(arg1, arg2, """
|
-short
|
||||||
short
|
|
||||||
-""",
|
-""",
|
||||||
- arg3=True,
|
- arg3=True,
|
||||||
- )
|
- )
|
||||||
+""", arg3=True)
|
|
||||||
|
|
||||||
############################################################################
|
- ############################################################################
|
||||||
|
-
|
||||||
call2(
|
- call2(
|
||||||
- # short
|
- # short
|
||||||
- arg1,
|
- arg1,
|
||||||
- # but
|
- # but
|
||||||
- arg2,
|
- arg2,
|
||||||
- # multiline
|
- # multiline
|
||||||
- """
|
- """
|
||||||
+ #short
|
-short
|
||||||
+ arg1,
|
-""",
|
||||||
+ #but
|
|
||||||
+ arg2,
|
|
||||||
+ #multiline
|
|
||||||
+ """
|
|
||||||
short
|
|
||||||
""",
|
|
||||||
- # yup
|
- # yup
|
||||||
- arg3=True,
|
- arg3=True,
|
||||||
- )
|
- )
|
||||||
+ # yup
|
- lcomp = [
|
||||||
+ arg3=True)
|
|
||||||
lcomp = [
|
|
||||||
- element for element in collection if element is not None # yup # yup # right
|
- element for element in collection if element is not None # yup # yup # right
|
||||||
+ element # yup
|
- ]
|
||||||
+ for element in collection # yup
|
- lcomp2 = [
|
||||||
+ if element is not None # right
|
- # hello
|
||||||
]
|
- element
|
||||||
lcomp2 = [
|
- # yup
|
||||||
# hello
|
- for element in collection
|
||||||
@@ -127,7 +124,7 @@
|
- # right
|
||||||
]
|
- if element is not None
|
||||||
lcomp3 = [
|
- ]
|
||||||
# This one is actually too long to fit in a single line.
|
- lcomp3 = [
|
||||||
|
- # This one is actually too long to fit in a single line.
|
||||||
- element.split("\n", 1)[0]
|
- element.split("\n", 1)[0]
|
||||||
+ element.split('\n', 1)[0]
|
- # yup
|
||||||
# yup
|
- for element in collection.select_elements()
|
||||||
for element in collection.select_elements()
|
- # right
|
||||||
# right
|
- if element is not None
|
||||||
@@ -140,25 +137,23 @@
|
- ]
|
||||||
# and round and round we go
|
- while True:
|
||||||
# and round and round we go
|
- if False:
|
||||||
|
- continue
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign # type: Final
|
||||||
|
|
||||||
|
- # and round and round we go
|
||||||
|
- # and round and round we go
|
||||||
|
|
||||||
- # let's return
|
- # let's return
|
||||||
+ # let's return
|
- return Node(
|
||||||
return Node(
|
- syms.simple_stmt,
|
||||||
syms.simple_stmt,
|
|
||||||
- [Node(statement, result), Leaf(token.NEWLINE, "\n")], # FIXME: \r\n?
|
- [Node(statement, result), Leaf(token.NEWLINE, "\n")], # FIXME: \r\n?
|
||||||
+ [
|
- )
|
||||||
+ Node(statement, result),
|
-
|
||||||
+ Leaf(token.NEWLINE, '\n') # FIXME: \r\n?
|
-
|
||||||
+ ],
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
-CONFIG_FILES = (
|
-CONFIG_FILES = (
|
||||||
- [
|
- [
|
||||||
- CONFIG_FILE,
|
- CONFIG_FILE,
|
||||||
|
@ -371,179 +342,50 @@ instruction()#comment with bad spacing
|
||||||
- + SHARED_CONFIG_FILES
|
- + SHARED_CONFIG_FILES
|
||||||
- + USER_CONFIG_FILES
|
- + USER_CONFIG_FILES
|
||||||
-) # type: Final
|
-) # type: Final
|
||||||
+CONFIG_FILES = [CONFIG_FILE, ] + SHARED_CONFIG_FILES + USER_CONFIG_FILES # type: Final
|
-
|
||||||
|
-
|
||||||
|
-class Test:
|
||||||
class Test:
|
- def _init_host(self, parsed) -> None:
|
||||||
def _init_host(self, parsed) -> None:
|
|
||||||
- if parsed.hostname is None or not parsed.hostname.strip(): # type: ignore
|
- if parsed.hostname is None or not parsed.hostname.strip(): # type: ignore
|
||||||
+ if (parsed.hostname is None or # type: ignore
|
- pass
|
||||||
+ not parsed.hostname.strip()):
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
|
#######################
|
||||||
|
@@ -167,7 +25,7 @@
|
||||||
|
#######################
|
||||||
|
|
||||||
|
|
||||||
|
-instruction() # comment with bad spacing
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprCall # comment with bad spacing
|
||||||
|
|
||||||
|
# END COMMENTS
|
||||||
|
# MORE END COMMENTS
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
|
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
MyLovelyCompanyTeamProjectComponent # NOT DRY
|
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
)
|
|
||||||
from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
|
|
||||||
MyLovelyCompanyTeamProjectComponent as component # DRY
|
|
||||||
)
|
|
||||||
|
|
||||||
# Please keep __all__ alphabetized within each category.
|
# Please keep __all__ alphabetized within each category.
|
||||||
|
|
||||||
__all__ = [
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
# Super-special typing primitives.
|
|
||||||
'Any',
|
|
||||||
'Callable',
|
|
||||||
'ClassVar',
|
|
||||||
|
|
||||||
# ABCs (from collections.abc).
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
'AbstractSet', # collections.abc.Set.
|
|
||||||
'ByteString',
|
|
||||||
'Container',
|
|
||||||
|
|
||||||
# Concrete collection types.
|
NOT_YET_IMPLEMENTED_StmtIf
|
||||||
'Counter',
|
|
||||||
'Deque',
|
|
||||||
'Dict',
|
|
||||||
'DefaultDict',
|
|
||||||
'List',
|
|
||||||
'Set',
|
|
||||||
'FrozenSet',
|
|
||||||
'NamedTuple', # Not really a type.
|
|
||||||
'Generator',
|
|
||||||
]
|
|
||||||
|
|
||||||
not_shareables = [
|
|
||||||
# singletons
|
|
||||||
True,
|
|
||||||
False,
|
|
||||||
NotImplemented, ...,
|
|
||||||
# builtin types and objects
|
|
||||||
type,
|
|
||||||
object,
|
|
||||||
object(),
|
|
||||||
Exception(),
|
|
||||||
42,
|
|
||||||
100.0,
|
|
||||||
"spam",
|
|
||||||
# user-defined types and objects
|
|
||||||
Cheese,
|
|
||||||
Cheese("Wensleydale"),
|
|
||||||
SubBytes(b"spam"),
|
|
||||||
]
|
|
||||||
|
|
||||||
if 'PYTHON' in os.environ:
|
|
||||||
add_compiler(compiler_from_env())
|
|
||||||
else:
|
|
||||||
# for compiler in compilers.values():
|
|
||||||
# add_compiler(compiler)
|
|
||||||
add_compiler(compilers[(7.0, 32)])
|
|
||||||
|
|
||||||
|
|
||||||
# Comment before function.
|
# Comment before function.
|
||||||
def inline_comments_in_brackets_ruin_everything():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
if typedargslist:
|
|
||||||
parameters.children = [
|
|
||||||
children[0], # (1
|
|
||||||
body,
|
|
||||||
children[-1] # )1
|
|
||||||
]
|
|
||||||
parameters.children = [
|
|
||||||
children[0],
|
|
||||||
body,
|
|
||||||
children[-1], # type: ignore
|
|
||||||
]
|
|
||||||
else:
|
|
||||||
parameters.children = [
|
|
||||||
parameters.children[0], # (2 what if this was actually long
|
|
||||||
body,
|
|
||||||
parameters.children[-1], # )2
|
|
||||||
]
|
|
||||||
parameters.children = [parameters.what_if_this_was_actually_long.children[0], body, parameters.children[-1]] # 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):
|
|
||||||
pass
|
|
||||||
# no newline before or after
|
|
||||||
short = [
|
|
||||||
# one
|
|
||||||
1,
|
|
||||||
# two
|
|
||||||
2]
|
|
||||||
|
|
||||||
# no newline after
|
|
||||||
call(arg1, arg2, """
|
|
||||||
short
|
|
||||||
""", arg3=True)
|
|
||||||
|
|
||||||
############################################################################
|
|
||||||
|
|
||||||
call2(
|
|
||||||
#short
|
|
||||||
arg1,
|
|
||||||
#but
|
|
||||||
arg2,
|
|
||||||
#multiline
|
|
||||||
"""
|
|
||||||
short
|
|
||||||
""",
|
|
||||||
# yup
|
|
||||||
arg3=True)
|
|
||||||
lcomp = [
|
|
||||||
element # yup
|
|
||||||
for element in collection # yup
|
|
||||||
if element is not None # right
|
|
||||||
]
|
|
||||||
lcomp2 = [
|
|
||||||
# hello
|
|
||||||
element
|
|
||||||
# yup
|
|
||||||
for element in collection
|
|
||||||
# right
|
|
||||||
if element is not None
|
|
||||||
]
|
|
||||||
lcomp3 = [
|
|
||||||
# This one is actually too long to fit in a single line.
|
|
||||||
element.split('\n', 1)[0]
|
|
||||||
# yup
|
|
||||||
for element in collection.select_elements()
|
|
||||||
# right
|
|
||||||
if element is not None
|
|
||||||
]
|
|
||||||
while True:
|
|
||||||
if False:
|
|
||||||
continue
|
|
||||||
|
|
||||||
# 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?
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
CONFIG_FILES = [CONFIG_FILE, ] + SHARED_CONFIG_FILES + USER_CONFIG_FILES # type: Final
|
NOT_YET_IMPLEMENTED_StmtAssign # type: Final
|
||||||
|
|
||||||
|
|
||||||
class Test:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
def _init_host(self, parsed) -> None:
|
|
||||||
if (parsed.hostname is None or # type: ignore
|
|
||||||
not parsed.hostname.strip()):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
|
@ -551,7 +393,7 @@ class Test:
|
||||||
#######################
|
#######################
|
||||||
|
|
||||||
|
|
||||||
instruction() # comment with bad spacing
|
NOT_YET_IMPLEMENTED_ExprCall # comment with bad spacing
|
||||||
|
|
||||||
# END COMMENTS
|
# END COMMENTS
|
||||||
# MORE END COMMENTS
|
# MORE END COMMENTS
|
||||||
|
|
|
@ -0,0 +1,181 @@
|
||||||
|
---
|
||||||
|
source: crates/ruff_python_formatter/src/lib.rs
|
||||||
|
expression: snapshot
|
||||||
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_cases/comments3.py
|
||||||
|
---
|
||||||
|
## Input
|
||||||
|
|
||||||
|
```py
|
||||||
|
# The percent-percent comments are Spyder IDE cells.
|
||||||
|
|
||||||
|
|
||||||
|
# %%
|
||||||
|
def func():
|
||||||
|
x = """
|
||||||
|
a really long string
|
||||||
|
"""
|
||||||
|
lcomp3 = [
|
||||||
|
# This one is actually too long to fit in a single line.
|
||||||
|
element.split("\n", 1)[0]
|
||||||
|
# yup
|
||||||
|
for element in collection.select_elements()
|
||||||
|
# right
|
||||||
|
if element is not None
|
||||||
|
]
|
||||||
|
# Capture each of the exceptions in the MultiError along with each of their causes and contexts
|
||||||
|
if isinstance(exc_value, MultiError):
|
||||||
|
embedded = []
|
||||||
|
for exc in exc_value.exceptions:
|
||||||
|
if exc not in _seen:
|
||||||
|
embedded.append(
|
||||||
|
# This should be left alone (before)
|
||||||
|
traceback.TracebackException.from_exception(
|
||||||
|
exc,
|
||||||
|
limit=limit,
|
||||||
|
lookup_lines=lookup_lines,
|
||||||
|
capture_locals=capture_locals,
|
||||||
|
# copy the set of _seen exceptions so that duplicates
|
||||||
|
# shared between sub-exceptions are not omitted
|
||||||
|
_seen=set(_seen),
|
||||||
|
)
|
||||||
|
# This should be left alone (after)
|
||||||
|
)
|
||||||
|
|
||||||
|
# everything is fine if the expression isn't nested
|
||||||
|
traceback.TracebackException.from_exception(
|
||||||
|
exc,
|
||||||
|
limit=limit,
|
||||||
|
lookup_lines=lookup_lines,
|
||||||
|
capture_locals=capture_locals,
|
||||||
|
# copy the set of _seen exceptions so that duplicates
|
||||||
|
# shared between sub-exceptions are not omitted
|
||||||
|
_seen=set(_seen),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# %%
|
||||||
|
```
|
||||||
|
|
||||||
|
## Black Differences
|
||||||
|
|
||||||
|
```diff
|
||||||
|
--- Black
|
||||||
|
+++ Ruff
|
||||||
|
@@ -2,47 +2,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
# %%
|
||||||
|
-def func():
|
||||||
|
- x = """
|
||||||
|
- a really long string
|
||||||
|
- """
|
||||||
|
- lcomp3 = [
|
||||||
|
- # This one is actually too long to fit in a single line.
|
||||||
|
- element.split("\n", 1)[0]
|
||||||
|
- # yup
|
||||||
|
- for element in collection.select_elements()
|
||||||
|
- # right
|
||||||
|
- if element is not None
|
||||||
|
- ]
|
||||||
|
- # Capture each of the exceptions in the MultiError along with each of their causes and contexts
|
||||||
|
- if isinstance(exc_value, MultiError):
|
||||||
|
- embedded = []
|
||||||
|
- for exc in exc_value.exceptions:
|
||||||
|
- if exc not in _seen:
|
||||||
|
- embedded.append(
|
||||||
|
- # This should be left alone (before)
|
||||||
|
- traceback.TracebackException.from_exception(
|
||||||
|
- exc,
|
||||||
|
- limit=limit,
|
||||||
|
- lookup_lines=lookup_lines,
|
||||||
|
- capture_locals=capture_locals,
|
||||||
|
- # copy the set of _seen exceptions so that duplicates
|
||||||
|
- # shared between sub-exceptions are not omitted
|
||||||
|
- _seen=set(_seen),
|
||||||
|
- )
|
||||||
|
- # This should be left alone (after)
|
||||||
|
- )
|
||||||
|
-
|
||||||
|
- # everything is fine if the expression isn't nested
|
||||||
|
- traceback.TracebackException.from_exception(
|
||||||
|
- exc,
|
||||||
|
- limit=limit,
|
||||||
|
- lookup_lines=lookup_lines,
|
||||||
|
- capture_locals=capture_locals,
|
||||||
|
- # copy the set of _seen exceptions so that duplicates
|
||||||
|
- # shared between sub-exceptions are not omitted
|
||||||
|
- _seen=set(_seen),
|
||||||
|
- )
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
# %%
|
||||||
|
```
|
||||||
|
|
||||||
|
## Ruff Output
|
||||||
|
|
||||||
|
```py
|
||||||
|
# The percent-percent comments are Spyder IDE cells.
|
||||||
|
|
||||||
|
|
||||||
|
# %%
|
||||||
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
# %%
|
||||||
|
```
|
||||||
|
|
||||||
|
## Black Output
|
||||||
|
|
||||||
|
```py
|
||||||
|
# The percent-percent comments are Spyder IDE cells.
|
||||||
|
|
||||||
|
|
||||||
|
# %%
|
||||||
|
def func():
|
||||||
|
x = """
|
||||||
|
a really long string
|
||||||
|
"""
|
||||||
|
lcomp3 = [
|
||||||
|
# This one is actually too long to fit in a single line.
|
||||||
|
element.split("\n", 1)[0]
|
||||||
|
# yup
|
||||||
|
for element in collection.select_elements()
|
||||||
|
# right
|
||||||
|
if element is not None
|
||||||
|
]
|
||||||
|
# Capture each of the exceptions in the MultiError along with each of their causes and contexts
|
||||||
|
if isinstance(exc_value, MultiError):
|
||||||
|
embedded = []
|
||||||
|
for exc in exc_value.exceptions:
|
||||||
|
if exc not in _seen:
|
||||||
|
embedded.append(
|
||||||
|
# This should be left alone (before)
|
||||||
|
traceback.TracebackException.from_exception(
|
||||||
|
exc,
|
||||||
|
limit=limit,
|
||||||
|
lookup_lines=lookup_lines,
|
||||||
|
capture_locals=capture_locals,
|
||||||
|
# copy the set of _seen exceptions so that duplicates
|
||||||
|
# shared between sub-exceptions are not omitted
|
||||||
|
_seen=set(_seen),
|
||||||
|
)
|
||||||
|
# This should be left alone (after)
|
||||||
|
)
|
||||||
|
|
||||||
|
# everything is fine if the expression isn't nested
|
||||||
|
traceback.TracebackException.from_exception(
|
||||||
|
exc,
|
||||||
|
limit=limit,
|
||||||
|
lookup_lines=lookup_lines,
|
||||||
|
capture_locals=capture_locals,
|
||||||
|
# copy the set of _seen exceptions so that duplicates
|
||||||
|
# shared between sub-exceptions are not omitted
|
||||||
|
_seen=set(_seen),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# %%
|
||||||
|
```
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,331 @@
|
||||||
|
---
|
||||||
|
source: crates/ruff_python_formatter/src/lib.rs
|
||||||
|
expression: snapshot
|
||||||
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_cases/comments4.py
|
||||||
|
---
|
||||||
|
## Input
|
||||||
|
|
||||||
|
```py
|
||||||
|
from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
|
||||||
|
MyLovelyCompanyTeamProjectComponent, # NOT DRY
|
||||||
|
)
|
||||||
|
from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
|
||||||
|
MyLovelyCompanyTeamProjectComponent as component, # DRY
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class C:
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
("post_data", "message"),
|
||||||
|
[
|
||||||
|
# metadata_version errors.
|
||||||
|
(
|
||||||
|
{},
|
||||||
|
"None is an invalid value for Metadata-Version. Error: This field is"
|
||||||
|
" required. see"
|
||||||
|
" https://packaging.python.org/specifications/core-metadata",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
{"metadata_version": "-1"},
|
||||||
|
"'-1' is an invalid value for Metadata-Version. Error: Unknown Metadata"
|
||||||
|
" Version see"
|
||||||
|
" https://packaging.python.org/specifications/core-metadata",
|
||||||
|
),
|
||||||
|
# name errors.
|
||||||
|
(
|
||||||
|
{"metadata_version": "1.2"},
|
||||||
|
"'' is an invalid value for Name. Error: This field is required. see"
|
||||||
|
" https://packaging.python.org/specifications/core-metadata",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
{"metadata_version": "1.2", "name": "foo-"},
|
||||||
|
"'foo-' is an invalid value for Name. Error: Must start and end with a"
|
||||||
|
" letter or numeral and contain only ascii numeric and '.', '_' and"
|
||||||
|
" '-'. see https://packaging.python.org/specifications/core-metadata",
|
||||||
|
),
|
||||||
|
# version errors.
|
||||||
|
(
|
||||||
|
{"metadata_version": "1.2", "name": "example"},
|
||||||
|
"'' is an invalid value for Version. Error: This field is required. see"
|
||||||
|
" https://packaging.python.org/specifications/core-metadata",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
{"metadata_version": "1.2", "name": "example", "version": "dog"},
|
||||||
|
"'dog' is an invalid value for Version. Error: Must start and end with"
|
||||||
|
" a letter or numeral and contain only ascii numeric and '.', '_' and"
|
||||||
|
" '-'. see https://packaging.python.org/specifications/core-metadata",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_fails_invalid_post_data(
|
||||||
|
self, pyramid_config, db_request, post_data, message
|
||||||
|
):
|
||||||
|
pyramid_config.testing_securitypolicy(userid=1)
|
||||||
|
db_request.POST = MultiDict(post_data)
|
||||||
|
|
||||||
|
|
||||||
|
def foo(list_a, list_b):
|
||||||
|
results = (
|
||||||
|
User.query.filter(User.foo == "bar")
|
||||||
|
.filter( # Because foo.
|
||||||
|
db.or_(User.field_a.astext.in_(list_a), User.field_b.astext.in_(list_b))
|
||||||
|
)
|
||||||
|
.filter(User.xyz.is_(None))
|
||||||
|
# Another comment about the filtering on is_quux goes here.
|
||||||
|
.filter(db.not_(User.is_pending.astext.cast(db.Boolean).is_(True)))
|
||||||
|
.order_by(User.created_at.desc())
|
||||||
|
.with_for_update(key_share=True)
|
||||||
|
.all()
|
||||||
|
)
|
||||||
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
def foo2(list_a, list_b):
|
||||||
|
# Standalone comment reasonably placed.
|
||||||
|
return (
|
||||||
|
User.query.filter(User.foo == "bar")
|
||||||
|
.filter(
|
||||||
|
db.or_(User.field_a.astext.in_(list_a), User.field_b.astext.in_(list_b))
|
||||||
|
)
|
||||||
|
.filter(User.xyz.is_(None))
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def foo3(list_a, list_b):
|
||||||
|
return (
|
||||||
|
# Standalone comment but weirdly placed.
|
||||||
|
User.query.filter(User.foo == "bar")
|
||||||
|
.filter(
|
||||||
|
db.or_(User.field_a.astext.in_(list_a), User.field_b.astext.in_(list_b))
|
||||||
|
)
|
||||||
|
.filter(User.xyz.is_(None))
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Black Differences
|
||||||
|
|
||||||
|
```diff
|
||||||
|
--- Black
|
||||||
|
+++ Ruff
|
||||||
|
@@ -1,94 +1,14 @@
|
||||||
|
-from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
|
||||||
|
- MyLovelyCompanyTeamProjectComponent, # NOT DRY
|
||||||
|
-)
|
||||||
|
-from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
|
||||||
|
- MyLovelyCompanyTeamProjectComponent as component, # DRY
|
||||||
|
-)
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
|
|
||||||
|
|
||||||
|
-class C:
|
||||||
|
- @pytest.mark.parametrize(
|
||||||
|
- ("post_data", "message"),
|
||||||
|
- [
|
||||||
|
- # metadata_version errors.
|
||||||
|
- (
|
||||||
|
- {},
|
||||||
|
- "None is an invalid value for Metadata-Version. Error: This field is"
|
||||||
|
- " required. see"
|
||||||
|
- " https://packaging.python.org/specifications/core-metadata",
|
||||||
|
- ),
|
||||||
|
- (
|
||||||
|
- {"metadata_version": "-1"},
|
||||||
|
- "'-1' is an invalid value for Metadata-Version. Error: Unknown Metadata"
|
||||||
|
- " Version see"
|
||||||
|
- " https://packaging.python.org/specifications/core-metadata",
|
||||||
|
- ),
|
||||||
|
- # name errors.
|
||||||
|
- (
|
||||||
|
- {"metadata_version": "1.2"},
|
||||||
|
- "'' is an invalid value for Name. Error: This field is required. see"
|
||||||
|
- " https://packaging.python.org/specifications/core-metadata",
|
||||||
|
- ),
|
||||||
|
- (
|
||||||
|
- {"metadata_version": "1.2", "name": "foo-"},
|
||||||
|
- "'foo-' is an invalid value for Name. Error: Must start and end with a"
|
||||||
|
- " letter or numeral and contain only ascii numeric and '.', '_' and"
|
||||||
|
- " '-'. see https://packaging.python.org/specifications/core-metadata",
|
||||||
|
- ),
|
||||||
|
- # version errors.
|
||||||
|
- (
|
||||||
|
- {"metadata_version": "1.2", "name": "example"},
|
||||||
|
- "'' is an invalid value for Version. Error: This field is required. see"
|
||||||
|
- " https://packaging.python.org/specifications/core-metadata",
|
||||||
|
- ),
|
||||||
|
- (
|
||||||
|
- {"metadata_version": "1.2", "name": "example", "version": "dog"},
|
||||||
|
- "'dog' is an invalid value for Version. Error: Must start and end with"
|
||||||
|
- " a letter or numeral and contain only ascii numeric and '.', '_' and"
|
||||||
|
- " '-'. see https://packaging.python.org/specifications/core-metadata",
|
||||||
|
- ),
|
||||||
|
- ],
|
||||||
|
- )
|
||||||
|
- def test_fails_invalid_post_data(
|
||||||
|
- self, pyramid_config, db_request, post_data, message
|
||||||
|
- ):
|
||||||
|
- pyramid_config.testing_securitypolicy(userid=1)
|
||||||
|
- db_request.POST = MultiDict(post_data)
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
|
|
||||||
|
|
||||||
|
-def foo(list_a, list_b):
|
||||||
|
- results = (
|
||||||
|
- User.query.filter(User.foo == "bar")
|
||||||
|
- .filter( # Because foo.
|
||||||
|
- db.or_(User.field_a.astext.in_(list_a), User.field_b.astext.in_(list_b))
|
||||||
|
- )
|
||||||
|
- .filter(User.xyz.is_(None))
|
||||||
|
- # Another comment about the filtering on is_quux goes here.
|
||||||
|
- .filter(db.not_(User.is_pending.astext.cast(db.Boolean).is_(True)))
|
||||||
|
- .order_by(User.created_at.desc())
|
||||||
|
- .with_for_update(key_share=True)
|
||||||
|
- .all()
|
||||||
|
- )
|
||||||
|
- return results
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
-def foo2(list_a, list_b):
|
||||||
|
- # Standalone comment reasonably placed.
|
||||||
|
- return (
|
||||||
|
- User.query.filter(User.foo == "bar")
|
||||||
|
- .filter(
|
||||||
|
- db.or_(User.field_a.astext.in_(list_a), User.field_b.astext.in_(list_b))
|
||||||
|
- )
|
||||||
|
- .filter(User.xyz.is_(None))
|
||||||
|
- )
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
-def foo3(list_a, list_b):
|
||||||
|
- return (
|
||||||
|
- # Standalone comment but weirdly placed.
|
||||||
|
- User.query.filter(User.foo == "bar")
|
||||||
|
- .filter(
|
||||||
|
- db.or_(User.field_a.astext.in_(list_a), User.field_b.astext.in_(list_b))
|
||||||
|
- )
|
||||||
|
- .filter(User.xyz.is_(None))
|
||||||
|
- )
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
```
|
||||||
|
|
||||||
|
## Ruff Output
|
||||||
|
|
||||||
|
```py
|
||||||
|
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
|
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
|
|
||||||
|
|
||||||
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
|
|
||||||
|
|
||||||
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
```
|
||||||
|
|
||||||
|
## Black Output
|
||||||
|
|
||||||
|
```py
|
||||||
|
from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
|
||||||
|
MyLovelyCompanyTeamProjectComponent, # NOT DRY
|
||||||
|
)
|
||||||
|
from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
|
||||||
|
MyLovelyCompanyTeamProjectComponent as component, # DRY
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class C:
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
("post_data", "message"),
|
||||||
|
[
|
||||||
|
# metadata_version errors.
|
||||||
|
(
|
||||||
|
{},
|
||||||
|
"None is an invalid value for Metadata-Version. Error: This field is"
|
||||||
|
" required. see"
|
||||||
|
" https://packaging.python.org/specifications/core-metadata",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
{"metadata_version": "-1"},
|
||||||
|
"'-1' is an invalid value for Metadata-Version. Error: Unknown Metadata"
|
||||||
|
" Version see"
|
||||||
|
" https://packaging.python.org/specifications/core-metadata",
|
||||||
|
),
|
||||||
|
# name errors.
|
||||||
|
(
|
||||||
|
{"metadata_version": "1.2"},
|
||||||
|
"'' is an invalid value for Name. Error: This field is required. see"
|
||||||
|
" https://packaging.python.org/specifications/core-metadata",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
{"metadata_version": "1.2", "name": "foo-"},
|
||||||
|
"'foo-' is an invalid value for Name. Error: Must start and end with a"
|
||||||
|
" letter or numeral and contain only ascii numeric and '.', '_' and"
|
||||||
|
" '-'. see https://packaging.python.org/specifications/core-metadata",
|
||||||
|
),
|
||||||
|
# version errors.
|
||||||
|
(
|
||||||
|
{"metadata_version": "1.2", "name": "example"},
|
||||||
|
"'' is an invalid value for Version. Error: This field is required. see"
|
||||||
|
" https://packaging.python.org/specifications/core-metadata",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
{"metadata_version": "1.2", "name": "example", "version": "dog"},
|
||||||
|
"'dog' is an invalid value for Version. Error: Must start and end with"
|
||||||
|
" a letter or numeral and contain only ascii numeric and '.', '_' and"
|
||||||
|
" '-'. see https://packaging.python.org/specifications/core-metadata",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_fails_invalid_post_data(
|
||||||
|
self, pyramid_config, db_request, post_data, message
|
||||||
|
):
|
||||||
|
pyramid_config.testing_securitypolicy(userid=1)
|
||||||
|
db_request.POST = MultiDict(post_data)
|
||||||
|
|
||||||
|
|
||||||
|
def foo(list_a, list_b):
|
||||||
|
results = (
|
||||||
|
User.query.filter(User.foo == "bar")
|
||||||
|
.filter( # Because foo.
|
||||||
|
db.or_(User.field_a.astext.in_(list_a), User.field_b.astext.in_(list_b))
|
||||||
|
)
|
||||||
|
.filter(User.xyz.is_(None))
|
||||||
|
# Another comment about the filtering on is_quux goes here.
|
||||||
|
.filter(db.not_(User.is_pending.astext.cast(db.Boolean).is_(True)))
|
||||||
|
.order_by(User.created_at.desc())
|
||||||
|
.with_for_update(key_share=True)
|
||||||
|
.all()
|
||||||
|
)
|
||||||
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
def foo2(list_a, list_b):
|
||||||
|
# Standalone comment reasonably placed.
|
||||||
|
return (
|
||||||
|
User.query.filter(User.foo == "bar")
|
||||||
|
.filter(
|
||||||
|
db.or_(User.field_a.astext.in_(list_a), User.field_b.astext.in_(list_b))
|
||||||
|
)
|
||||||
|
.filter(User.xyz.is_(None))
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def foo3(list_a, list_b):
|
||||||
|
return (
|
||||||
|
# Standalone comment but weirdly placed.
|
||||||
|
User.query.filter(User.foo == "bar")
|
||||||
|
.filter(
|
||||||
|
db.or_(User.field_a.astext.in_(list_a), User.field_b.astext.in_(list_b))
|
||||||
|
)
|
||||||
|
.filter(User.xyz.is_(None))
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
|
@ -86,91 +86,124 @@ if __name__ == "__main__":
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -1,7 +1,6 @@
|
@@ -1,61 +1,33 @@
|
||||||
while True:
|
-while True:
|
||||||
if something.changed:
|
- if something.changed:
|
||||||
- do.stuff() # trailing comment
|
- do.stuff() # trailing comment
|
||||||
- # Comment belongs to the `if` block.
|
- # Comment belongs to the `if` block.
|
||||||
+ do.stuff()
|
+while NOT_YET_IMPLEMENTED_ExprConstant:
|
||||||
# This one belongs to the `while` block.
|
+ NOT_YET_IMPLEMENTED_StmtIf
|
||||||
|
|
||||||
# Should this one, too? I guess so.
|
|
||||||
@@ -15,7 +14,6 @@
|
|
||||||
|
|
||||||
# then we do this
|
|
||||||
print(i)
|
|
||||||
- # and finally we loop around
|
|
||||||
|
|
||||||
with open(some_temp_file) as f:
|
|
||||||
data = f.read()
|
|
||||||
@@ -33,7 +31,6 @@
|
|
||||||
# leading function comment
|
|
||||||
def wat():
|
|
||||||
...
|
|
||||||
- # trailing function comment
|
|
||||||
|
|
||||||
|
|
||||||
# SECTION COMMENT
|
|
||||||
```
|
|
||||||
|
|
||||||
## Ruff Output
|
|
||||||
|
|
||||||
```py
|
|
||||||
while True:
|
|
||||||
if something.changed:
|
|
||||||
do.stuff()
|
|
||||||
# This one belongs to the `while` block.
|
# This one belongs to the `while` block.
|
||||||
|
|
||||||
# Should this one, too? I guess so.
|
# Should this one, too? I guess so.
|
||||||
|
|
||||||
# This one is properly standalone now.
|
# This one is properly standalone now.
|
||||||
|
|
||||||
for i in range(100):
|
-for i in range(100):
|
||||||
# first we do this
|
- # first we do this
|
||||||
if i % 33 == 0:
|
- if i % 33 == 0:
|
||||||
break
|
- break
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFor
|
||||||
|
|
||||||
# then we do this
|
- # then we do this
|
||||||
print(i)
|
- print(i)
|
||||||
|
- # and finally we loop around
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtWith
|
||||||
|
|
||||||
with open(some_temp_file) as f:
|
-with open(some_temp_file) as f:
|
||||||
data = f.read()
|
- data = f.read()
|
||||||
|
-
|
||||||
|
-try:
|
||||||
|
- with open(some_other_file) as w:
|
||||||
|
- w.write(data)
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtTry
|
||||||
|
|
||||||
try:
|
-except OSError:
|
||||||
with open(some_other_file) as w:
|
- print("problems")
|
||||||
w.write(data)
|
-
|
||||||
|
-import sys
|
||||||
except OSError:
|
+NOT_YET_IMPLEMENTED_StmtImport
|
||||||
print("problems")
|
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
|
|
||||||
# leading function comment
|
# leading function comment
|
||||||
def wat():
|
-def wat():
|
||||||
...
|
- ...
|
||||||
|
- # trailing function comment
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
# SECTION COMMENT
|
# SECTION COMMENT
|
||||||
|
|
||||||
|
|
||||||
# leading 1
|
# leading 1
|
||||||
@deco1
|
-@deco1
|
||||||
# leading 2
|
-# leading 2
|
||||||
@deco2(with_args=True)
|
-@deco2(with_args=True)
|
||||||
# leading 3
|
-# leading 3
|
||||||
@deco3
|
-@deco3
|
||||||
def decorated1():
|
-def decorated1():
|
||||||
...
|
- ...
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
# leading 1
|
# leading 1
|
||||||
@deco1
|
-@deco1
|
||||||
# leading 2
|
-# leading 2
|
||||||
@deco2(with_args=True)
|
-@deco2(with_args=True)
|
||||||
|
-# leading function comment
|
||||||
|
-def decorated1():
|
||||||
|
- ...
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
# Note: this is fixed in
|
||||||
|
@@ -65,9 +37,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
# This comment should be split from `some_instruction` by two lines but isn't.
|
||||||
|
-def g():
|
||||||
|
- ...
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
-if __name__ == "__main__":
|
||||||
|
- main()
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtIf
|
||||||
|
```
|
||||||
|
|
||||||
|
## Ruff Output
|
||||||
|
|
||||||
|
```py
|
||||||
|
while NOT_YET_IMPLEMENTED_ExprConstant:
|
||||||
|
NOT_YET_IMPLEMENTED_StmtIf
|
||||||
|
# This one belongs to the `while` block.
|
||||||
|
|
||||||
|
# Should this one, too? I guess so.
|
||||||
|
|
||||||
|
# This one is properly standalone now.
|
||||||
|
|
||||||
|
NOT_YET_IMPLEMENTED_StmtFor
|
||||||
|
|
||||||
|
NOT_YET_IMPLEMENTED_StmtWith
|
||||||
|
|
||||||
|
NOT_YET_IMPLEMENTED_StmtTry
|
||||||
|
|
||||||
|
NOT_YET_IMPLEMENTED_StmtImport
|
||||||
|
|
||||||
|
|
||||||
# leading function comment
|
# leading function comment
|
||||||
def decorated1():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
...
|
|
||||||
|
|
||||||
|
# SECTION COMMENT
|
||||||
|
|
||||||
|
|
||||||
|
# leading 1
|
||||||
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
# leading 1
|
||||||
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
# Note: this is fixed in
|
# Note: this is fixed in
|
||||||
|
@ -180,12 +213,10 @@ some_instruction
|
||||||
|
|
||||||
|
|
||||||
# This comment should be split from `some_instruction` by two lines but isn't.
|
# This comment should be split from `some_instruction` by two lines but isn't.
|
||||||
def g():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
...
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
NOT_YET_IMPLEMENTED_StmtIf
|
||||||
main()
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -131,138 +131,178 @@ aaaaaaaaaaaaa, bbbbbbbbb = map(list, map(itertools.chain.from_iterable, zip(*ite
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -66,7 +66,7 @@
|
@@ -1,118 +1,35 @@
|
||||||
+ element
|
-from typing import Any, Tuple
|
||||||
+ another_element
|
+NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
+ another_element_with_long_name
|
|
||||||
|
|
||||||
|
-def f(
|
||||||
|
- a, # type: int
|
||||||
|
-):
|
||||||
|
- pass
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
# test type comments
|
||||||
|
-def f(a, b, c, d, e, f, g, h, i):
|
||||||
|
- # type: (int, int, int, int, int, int, int, int, int) -> None
|
||||||
|
- pass
|
||||||
|
-
|
||||||
|
-
|
||||||
|
-def f(
|
||||||
|
- a, # type: int
|
||||||
|
- b, # type: int
|
||||||
|
- c, # type: int
|
||||||
|
- d, # type: int
|
||||||
|
- e, # type: int
|
||||||
|
- f, # type: int
|
||||||
|
- g, # type: int
|
||||||
|
- h, # type: int
|
||||||
|
- i, # type: int
|
||||||
|
-):
|
||||||
|
- # type: (...) -> None
|
||||||
|
- pass
|
||||||
|
-
|
||||||
|
-
|
||||||
|
-def f(
|
||||||
|
- arg, # type: int
|
||||||
|
- *args, # type: *Any
|
||||||
|
- default=False, # type: bool
|
||||||
|
- **kwargs, # type: **Any
|
||||||
|
-):
|
||||||
|
- # type: (...) -> None
|
||||||
|
- pass
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
-def f(
|
||||||
|
- a, # type: int
|
||||||
|
- b, # type: int
|
||||||
|
- c, # type: int
|
||||||
|
- d, # type: int
|
||||||
|
-):
|
||||||
|
- # type: (...) -> None
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
- element = 0 # type: int
|
||||||
|
- another_element = 1 # type: float
|
||||||
|
- another_element_with_long_name = 2 # type: int
|
||||||
|
- another_really_really_long_element_with_a_unnecessarily_long_name_to_describe_what_it_does_enterprise_style = (
|
||||||
|
- 3
|
||||||
- ) # type: int
|
- ) # type: int
|
||||||
+ )
|
- an_element_with_a_long_value = calls() or more_calls() and more() # type: bool
|
||||||
|
|
||||||
|
- tup = (
|
||||||
|
- another_element,
|
||||||
|
- another_really_really_long_element_with_a_unnecessarily_long_name_to_describe_what_it_does_enterprise_style,
|
||||||
|
- ) # type: Tuple[int, int]
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
- a = (
|
||||||
|
- element
|
||||||
|
- + another_element
|
||||||
|
- + another_element_with_long_name
|
||||||
|
- + element
|
||||||
|
- + another_element
|
||||||
|
- + another_element_with_long_name
|
||||||
|
- ) # type: int
|
||||||
|
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
-def f(
|
||||||
|
- x, # not a type comment
|
||||||
|
- y, # type: int
|
||||||
|
-):
|
||||||
|
- # type: (...) -> None
|
||||||
|
- pass
|
||||||
|
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
-def f(
|
||||||
|
- x, # not a type comment
|
||||||
|
-): # type: (int) -> None
|
||||||
|
- pass
|
||||||
|
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
-def func(
|
||||||
|
- a=some_list[0], # type: int
|
||||||
|
-): # type: () -> int
|
||||||
|
- c = call(
|
||||||
|
- 0.0123,
|
||||||
|
- 0.0456,
|
||||||
|
- 0.0789,
|
||||||
|
- 0.0123,
|
||||||
|
- 0.0456,
|
||||||
|
- 0.0789,
|
||||||
|
- 0.0123,
|
||||||
|
- 0.0456,
|
||||||
|
- 0.0789,
|
||||||
|
- a[-1], # type: ignore
|
||||||
|
- )
|
||||||
|
|
||||||
|
- c = call(
|
||||||
|
- "aaaaaaaa", "aaaaaaaa", "aaaaaaaa", "aaaaaaaa", "aaaaaaaa", "aaaaaaaa", "aaaaaaaa" # type: ignore
|
||||||
|
- )
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
def f(
|
-result = ( # aaa
|
||||||
|
- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||||
|
-)
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
|
-AAAAAAAAAAAAA = [AAAAAAAAAAAAA] + SHARED_AAAAAAAAAAAAA + USER_AAAAAAAAAAAAA + AAAAAAAAAAAAA # type: ignore
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign # type: ignore
|
||||||
|
|
||||||
|
-call_to_some_function_asdf(
|
||||||
|
- foo,
|
||||||
|
- [AAAAAAAAAAAAAAAAAAAAAAA, AAAAAAAAAAAAAAAAAAAAAAA, AAAAAAAAAAAAAAAAAAAAAAA, BBBBBBBBBBBB], # type: ignore
|
||||||
|
-)
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprCall
|
||||||
|
|
||||||
|
-aaaaaaaaaaaaa, bbbbbbbbb = map(list, map(itertools.chain.from_iterable, zip(*items))) # type: ignore[arg-type]
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign # type: ignore[arg-type]
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
from typing import Any, Tuple
|
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
|
|
||||||
|
|
||||||
def f(
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
a, # type: int
|
|
||||||
):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
# test type comments
|
# test type comments
|
||||||
def f(a, b, c, d, e, f, g, h, i):
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
# type: (int, int, int, int, int, int, int, int, int) -> None
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def f(
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
a, # type: int
|
|
||||||
b, # type: int
|
|
||||||
c, # type: int
|
|
||||||
d, # type: int
|
|
||||||
e, # type: int
|
|
||||||
f, # type: int
|
|
||||||
g, # type: int
|
|
||||||
h, # type: int
|
|
||||||
i, # type: int
|
|
||||||
):
|
|
||||||
# type: (...) -> None
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def f(
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
arg, # type: int
|
|
||||||
*args, # type: *Any
|
|
||||||
default=False, # type: bool
|
|
||||||
**kwargs, # type: **Any
|
|
||||||
):
|
|
||||||
# type: (...) -> None
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def f(
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
a, # type: int
|
|
||||||
b, # type: int
|
|
||||||
c, # type: int
|
|
||||||
d, # type: int
|
|
||||||
):
|
|
||||||
# type: (...) -> None
|
|
||||||
|
|
||||||
element = 0 # type: int
|
|
||||||
another_element = 1 # type: float
|
|
||||||
another_element_with_long_name = 2 # type: int
|
|
||||||
another_really_really_long_element_with_a_unnecessarily_long_name_to_describe_what_it_does_enterprise_style = (
|
|
||||||
3
|
|
||||||
) # type: int
|
|
||||||
an_element_with_a_long_value = calls() or more_calls() and more() # type: bool
|
|
||||||
|
|
||||||
tup = (
|
|
||||||
another_element,
|
|
||||||
another_really_really_long_element_with_a_unnecessarily_long_name_to_describe_what_it_does_enterprise_style,
|
|
||||||
) # type: Tuple[int, int]
|
|
||||||
|
|
||||||
a = (
|
|
||||||
element
|
|
||||||
+ another_element
|
|
||||||
+ another_element_with_long_name
|
|
||||||
+ element
|
|
||||||
+ another_element
|
|
||||||
+ another_element_with_long_name
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def f(
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
x, # not a type comment
|
|
||||||
y, # type: int
|
|
||||||
):
|
|
||||||
# type: (...) -> None
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def f(
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
x, # not a type comment
|
|
||||||
): # type: (int) -> None
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def func(
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
a=some_list[0], # type: int
|
|
||||||
): # type: () -> int
|
|
||||||
c = call(
|
|
||||||
0.0123,
|
|
||||||
0.0456,
|
|
||||||
0.0789,
|
|
||||||
0.0123,
|
|
||||||
0.0456,
|
|
||||||
0.0789,
|
|
||||||
0.0123,
|
|
||||||
0.0456,
|
|
||||||
0.0789,
|
|
||||||
a[-1], # type: ignore
|
|
||||||
)
|
|
||||||
|
|
||||||
c = call(
|
|
||||||
"aaaaaaaa", "aaaaaaaa", "aaaaaaaa", "aaaaaaaa", "aaaaaaaa", "aaaaaaaa", "aaaaaaaa" # type: ignore
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
result = ( # aaa
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
||||||
)
|
|
||||||
|
|
||||||
AAAAAAAAAAAAA = [AAAAAAAAAAAAA] + SHARED_AAAAAAAAAAAAA + USER_AAAAAAAAAAAAA + AAAAAAAAAAAAA # type: ignore
|
NOT_YET_IMPLEMENTED_StmtAssign # type: ignore
|
||||||
|
|
||||||
call_to_some_function_asdf(
|
NOT_YET_IMPLEMENTED_ExprCall
|
||||||
foo,
|
|
||||||
[AAAAAAAAAAAAAAAAAAAAAAA, AAAAAAAAAAAAAAAAAAAAAAA, AAAAAAAAAAAAAAAAAAAAAAA, BBBBBBBBBBBB], # type: ignore
|
|
||||||
)
|
|
||||||
|
|
||||||
aaaaaaaaaaaaa, bbbbbbbbb = map(list, map(itertools.chain.from_iterable, zip(*items))) # type: ignore[arg-type]
|
NOT_YET_IMPLEMENTED_StmtAssign # type: ignore[arg-type]
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -152,60 +152,195 @@ def bar():
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -35,9 +35,10 @@
|
@@ -1,161 +1,90 @@
|
||||||
|
# Test for https://github.com/psf/black/issues/246.
|
||||||
|
|
||||||
|
-some = statement
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
|
|
||||||
some = statement
|
# This comment should be split from the statement above by two lines.
|
||||||
-# This should be stick to the statement above
|
-def function():
|
||||||
|
- pass
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
+# This should be stick to the statement above
|
-some = statement
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
|
|
||||||
|
# This multiline comments section
|
||||||
|
# should be split from the statement
|
||||||
|
# above by two lines.
|
||||||
|
-def function():
|
||||||
|
- pass
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
-some = statement
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
|
|
||||||
|
# This comment should be split from the statement above by two lines.
|
||||||
|
-async def async_function():
|
||||||
|
- pass
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
-some = statement
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
|
|
||||||
|
# This comment should be split from the statement above by two lines.
|
||||||
|
-class MyClass:
|
||||||
|
- pass
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
+
|
+
|
||||||
|
+
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
|
|
||||||
|
-some = statement
|
||||||
|
# This should be stick to the statement above
|
||||||
|
|
||||||
|
-
|
||||||
# This should be split from the above by two lines
|
# This should be split from the above by two lines
|
||||||
class MyClassWithComplexLeadingComments:
|
-class MyClassWithComplexLeadingComments:
|
||||||
pass
|
- pass
|
||||||
@@ -102,11 +103,9 @@
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
# Leading comment before inline function
|
|
||||||
def inline():
|
|
||||||
pass
|
-class ClassWithDocstring:
|
||||||
|
- """A docstring."""
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
|
|
||||||
|
|
||||||
|
# Leading comment after a class with just a docstring
|
||||||
|
-class MyClassAfterAnotherClassWithDocstring:
|
||||||
|
- pass
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
|
|
||||||
|
|
||||||
|
-some = statement
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
|
|
||||||
|
# leading 1
|
||||||
|
-@deco1
|
||||||
|
-# leading 2
|
||||||
|
-# leading 2 extra
|
||||||
|
-@deco2(with_args=True)
|
||||||
|
-# leading 3
|
||||||
|
-@deco3
|
||||||
|
-# leading 4
|
||||||
|
-def decorated():
|
||||||
|
- pass
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
-some = statement
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
|
|
||||||
|
# leading 1
|
||||||
|
-@deco1
|
||||||
|
-# leading 2
|
||||||
|
-@deco2(with_args=True)
|
||||||
-
|
-
|
||||||
# Another leading comment
|
-# leading 3 that already has an empty line
|
||||||
def another_inline():
|
-@deco3
|
||||||
pass
|
-# leading 4
|
||||||
|
-def decorated_with_split_leading_comments():
|
||||||
|
- pass
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
-some = statement
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
|
|
||||||
|
# leading 1
|
||||||
|
-@deco1
|
||||||
|
-# leading 2
|
||||||
|
-@deco2(with_args=True)
|
||||||
|
-# leading 3
|
||||||
|
-@deco3
|
||||||
-
|
-
|
||||||
else:
|
-# leading 4 that already has an empty line
|
||||||
# More leading comments
|
-def decorated_with_split_leading_comments():
|
||||||
def inline_after_else():
|
- pass
|
||||||
@@ -117,11 +116,9 @@
|
|
||||||
# Leading comment before "top-level inline" function
|
|
||||||
def top_level_quote_inline():
|
|
||||||
pass
|
|
||||||
-
|
-
|
||||||
# Another leading comment
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
def another_top_level_quote_inline_inline():
|
|
||||||
pass
|
-def main():
|
||||||
|
- if a:
|
||||||
|
- # Leading comment before inline function
|
||||||
|
- def inline():
|
||||||
|
- pass
|
||||||
|
|
||||||
|
- # Another leading comment
|
||||||
|
- def another_inline():
|
||||||
|
- pass
|
||||||
-
|
-
|
||||||
else:
|
- else:
|
||||||
# More leading comments
|
- # More leading comments
|
||||||
def top_level_quote_inline_after_else():
|
- def inline_after_else():
|
||||||
@@ -138,7 +135,6 @@
|
- pass
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
-if a:
|
||||||
|
- # Leading comment before "top-level inline" function
|
||||||
|
- def top_level_quote_inline():
|
||||||
|
- pass
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtIf
|
||||||
|
|
||||||
|
- # Another leading comment
|
||||||
|
- def another_top_level_quote_inline_inline():
|
||||||
|
- pass
|
||||||
|
|
||||||
|
-else:
|
||||||
|
- # More leading comments
|
||||||
|
- def top_level_quote_inline_after_else():
|
||||||
|
- pass
|
||||||
|
-
|
||||||
|
-
|
||||||
|
-class MyClass:
|
||||||
|
- # First method has no empty lines between bare class def.
|
||||||
|
- # More comments.
|
||||||
|
- def first_method(self):
|
||||||
|
- pass
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
|
|
||||||
|
|
||||||
# Regression test for https://github.com/psf/black/issues/3454.
|
# Regression test for https://github.com/psf/black/issues/3454.
|
||||||
def foo():
|
-def foo():
|
||||||
pass
|
- pass
|
||||||
- # Trailing comment that belongs to this function
|
- # Trailing comment that belongs to this function
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
-@decorator1
|
||||||
|
-@decorator2 # fmt: skip
|
||||||
|
-def bar():
|
||||||
|
- pass
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
@decorator1
|
|
||||||
@@ -150,9 +146,6 @@
|
|
||||||
# Regression test for https://github.com/psf/black/issues/3454.
|
# Regression test for https://github.com/psf/black/issues/3454.
|
||||||
def foo():
|
-def foo():
|
||||||
pass
|
- pass
|
||||||
- # Trailing comment that belongs to this function.
|
- # Trailing comment that belongs to this function.
|
||||||
- # NOTE this comment only has one empty line below, and the formatter
|
- # NOTE this comment only has one empty line below, and the formatter
|
||||||
- # should enforce two blank lines.
|
- # should enforce two blank lines.
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
@decorator1
|
-@decorator1
|
||||||
|
-# A standalone comment
|
||||||
|
-def bar():
|
||||||
|
- pass
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
@ -213,158 +348,94 @@ def bar():
|
||||||
```py
|
```py
|
||||||
# Test for https://github.com/psf/black/issues/246.
|
# Test for https://github.com/psf/black/issues/246.
|
||||||
|
|
||||||
some = statement
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
|
|
||||||
# This comment should be split from the statement above by two lines.
|
# This comment should be split from the statement above by two lines.
|
||||||
def function():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
some = statement
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
|
|
||||||
# This multiline comments section
|
# This multiline comments section
|
||||||
# should be split from the statement
|
# should be split from the statement
|
||||||
# above by two lines.
|
# above by two lines.
|
||||||
def function():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
some = statement
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
|
|
||||||
# This comment should be split from the statement above by two lines.
|
# This comment should be split from the statement above by two lines.
|
||||||
async def async_function():
|
NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
some = statement
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
|
|
||||||
# This comment should be split from the statement above by two lines.
|
# This comment should be split from the statement above by two lines.
|
||||||
class MyClass:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
some = statement
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
|
|
||||||
# This should be stick to the statement above
|
# This should be stick to the statement above
|
||||||
|
|
||||||
# This should be split from the above by two lines
|
# This should be split from the above by two lines
|
||||||
class MyClassWithComplexLeadingComments:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ClassWithDocstring:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
"""A docstring."""
|
|
||||||
|
|
||||||
|
|
||||||
# Leading comment after a class with just a docstring
|
# Leading comment after a class with just a docstring
|
||||||
class MyClassAfterAnotherClassWithDocstring:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
some = statement
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
|
|
||||||
# leading 1
|
# leading 1
|
||||||
@deco1
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
# leading 2
|
|
||||||
# leading 2 extra
|
|
||||||
@deco2(with_args=True)
|
|
||||||
# leading 3
|
|
||||||
@deco3
|
|
||||||
# leading 4
|
|
||||||
def decorated():
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
some = statement
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
|
|
||||||
# leading 1
|
# leading 1
|
||||||
@deco1
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
# leading 2
|
|
||||||
@deco2(with_args=True)
|
|
||||||
|
|
||||||
# leading 3 that already has an empty line
|
|
||||||
@deco3
|
|
||||||
# leading 4
|
|
||||||
def decorated_with_split_leading_comments():
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
some = statement
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
|
|
||||||
# leading 1
|
# leading 1
|
||||||
@deco1
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
# leading 2
|
|
||||||
@deco2(with_args=True)
|
|
||||||
# leading 3
|
|
||||||
@deco3
|
|
||||||
|
|
||||||
# leading 4 that already has an empty line
|
|
||||||
def decorated_with_split_leading_comments():
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
if a:
|
|
||||||
# Leading comment before inline function
|
|
||||||
def inline():
|
|
||||||
pass
|
|
||||||
# Another leading comment
|
|
||||||
def another_inline():
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
# More leading comments
|
|
||||||
def inline_after_else():
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
if a:
|
NOT_YET_IMPLEMENTED_StmtIf
|
||||||
# Leading comment before "top-level inline" function
|
|
||||||
def top_level_quote_inline():
|
|
||||||
pass
|
|
||||||
# Another leading comment
|
|
||||||
def another_top_level_quote_inline_inline():
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
# More leading comments
|
|
||||||
def top_level_quote_inline_after_else():
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class MyClass:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
# First method has no empty lines between bare class def.
|
|
||||||
# More comments.
|
|
||||||
def first_method(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
# Regression test for https://github.com/psf/black/issues/3454.
|
# Regression test for https://github.com/psf/black/issues/3454.
|
||||||
def foo():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
@decorator1
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
@decorator2 # fmt: skip
|
|
||||||
def bar():
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
# Regression test for https://github.com/psf/black/issues/3454.
|
# Regression test for https://github.com/psf/black/issues/3454.
|
||||||
def foo():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
@decorator1
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
# A standalone comment
|
|
||||||
def bar():
|
|
||||||
pass
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -32,63 +32,53 @@ def function(a:int=42):
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -1,23 +1,20 @@
|
@@ -1,23 +1,11 @@
|
||||||
-from .config import (
|
-from .config import (
|
||||||
- ConfigTypeAttributes,
|
- ConfigTypeAttributes,
|
||||||
- Int,
|
- Int,
|
||||||
- Path, # String,
|
- Path, # String,
|
||||||
- # DEFAULT_TYPE_ATTRIBUTES,
|
- # DEFAULT_TYPE_ATTRIBUTES,
|
||||||
+from .config import ( ConfigTypeAttributes, Int, Path, # String,
|
-)
|
||||||
+ # DEFAULT_TYPE_ATTRIBUTES,
|
+NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
)
|
|
||||||
|
|
||||||
result = 1 # A simple comment
|
-result = 1 # A simple comment
|
||||||
-result = (1,) # Another one
|
-result = (1,) # Another one
|
||||||
+result = ( 1, ) # Another one
|
+NOT_YET_IMPLEMENTED_StmtAssign # A simple comment
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign # Another one
|
||||||
|
|
||||||
result = 1 # type: ignore
|
-result = 1 # type: ignore
|
||||||
result = 1 # This comment is talking about type: ignore
|
-result = 1 # This comment is talking about type: ignore
|
||||||
square = Square(4) # type: Optional[Square]
|
-square = Square(4) # type: Optional[Square]
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign # type: ignore
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign # This comment is talking about type: ignore
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign # type: Optional[Square]
|
||||||
|
|
||||||
|
|
||||||
-def function(a: int = 42):
|
-def function(a: int = 42):
|
||||||
- """This docstring is already formatted
|
- """This docstring is already formatted
|
||||||
- a
|
- a
|
||||||
- b
|
- b
|
||||||
+def function(a:int=42):
|
- """
|
||||||
+ """ This docstring is already formatted
|
|
||||||
+ a
|
|
||||||
+ b
|
|
||||||
"""
|
|
||||||
- # There's a NBSP + 3 spaces before
|
- # There's a NBSP + 3 spaces before
|
||||||
+ # There's a NBSP + 3 spaces before
|
- # And 4 spaces on the next line
|
||||||
# And 4 spaces on the next line
|
- pass
|
||||||
pass
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
from .config import ( ConfigTypeAttributes, Int, Path, # String,
|
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
# DEFAULT_TYPE_ATTRIBUTES,
|
|
||||||
)
|
|
||||||
|
|
||||||
result = 1 # A simple comment
|
NOT_YET_IMPLEMENTED_StmtAssign # A simple comment
|
||||||
result = ( 1, ) # Another one
|
NOT_YET_IMPLEMENTED_StmtAssign # Another one
|
||||||
|
|
||||||
result = 1 # type: ignore
|
NOT_YET_IMPLEMENTED_StmtAssign # type: ignore
|
||||||
result = 1 # This comment is talking about type: ignore
|
NOT_YET_IMPLEMENTED_StmtAssign # This comment is talking about type: ignore
|
||||||
square = Square(4) # type: Optional[Square]
|
NOT_YET_IMPLEMENTED_StmtAssign # type: Optional[Square]
|
||||||
|
|
||||||
|
|
||||||
def function(a:int=42):
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
""" This docstring is already formatted
|
|
||||||
a
|
|
||||||
b
|
|
||||||
"""
|
|
||||||
# There's a NBSP + 3 spaces before
|
|
||||||
# And 4 spaces on the next line
|
|
||||||
pass
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -109,31 +109,107 @@ async def wat():
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -4,10 +4,12 @@
|
@@ -4,93 +4,42 @@
|
||||||
#
|
#
|
||||||
# Has many lines. Many, many lines.
|
# Has many lines. Many, many lines.
|
||||||
# Many, many, many lines.
|
# Many, many, many lines.
|
||||||
-"""Module docstring.
|
-"""Module docstring.
|
||||||
+(
|
+NOT_YET_IMPLEMENTED_ExprConstant
|
||||||
+ """Module docstring.
|
|
||||||
|
|
||||||
Possibly also many, many lines.
|
-Possibly also many, many lines.
|
||||||
"""
|
-"""
|
||||||
+)
|
+NOT_YET_IMPLEMENTED_StmtImport
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtImport
|
||||||
|
|
||||||
import os.path
|
-import os.path
|
||||||
import sys
|
-import sys
|
||||||
@@ -19,9 +21,6 @@
|
-
|
||||||
import fast
|
-import a
|
||||||
except ImportError:
|
-from b.c import X # some noqa comment
|
||||||
import slow as fast
|
+NOT_YET_IMPLEMENTED_StmtImport
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtImportFrom # some noqa comment
|
||||||
|
|
||||||
|
-try:
|
||||||
|
- import fast
|
||||||
|
-except ImportError:
|
||||||
|
- import slow as fast
|
||||||
-
|
-
|
||||||
-
|
-
|
||||||
-# Some comment before a function.
|
-# Some comment before a function.
|
||||||
y = 1
|
-y = 1
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtTry
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
(
|
(
|
||||||
# some strings
|
# some strings
|
||||||
@@ -93,4 +92,4 @@
|
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
|
||||||
|
|
||||||
|
|
||||||
|
# Explains why we use global state.
|
||||||
|
-GLOBAL_STATE = {"a": a(1), "b": a(2), "c": a(3)}
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
|
|
||||||
|
# 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
|
||||||
|
-
|
||||||
|
- flox = 1.5 #: Doc comment for Foo.flox. One line only.
|
||||||
|
-
|
||||||
|
- baz = 2
|
||||||
|
- """Docstring for class attribute Foo.baz."""
|
||||||
|
-
|
||||||
|
- def __init__(self):
|
||||||
|
- #: Doc comment for instance attribute qux.
|
||||||
|
- self.qux = 3
|
||||||
|
-
|
||||||
|
- self.spam = 4
|
||||||
|
- """Docstring for instance attribute spam."""
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
|
|
||||||
|
|
||||||
|
#' <h1>This is pweave!</h1>
|
||||||
|
|
||||||
|
|
||||||
|
-@fast(really=True)
|
||||||
|
-async def wat():
|
||||||
|
- # This comment, for some reason \
|
||||||
|
- # contains a trailing backslash.
|
||||||
|
- async with X.open_async() as x: # Some more comments
|
||||||
|
- result = await x.method1()
|
||||||
|
- # Comment after ending a block.
|
||||||
|
- if result:
|
||||||
|
- print("A OK", file=sys.stdout)
|
||||||
|
- # Comment between things.
|
||||||
|
- print()
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
|
|
||||||
|
|
||||||
# Some closing comments.
|
# Some closing comments.
|
||||||
# Maybe Vim or Emacs directives for formatting.
|
# Maybe Vim or Emacs directives for formatting.
|
||||||
|
@ -151,90 +227,40 @@ async def wat():
|
||||||
#
|
#
|
||||||
# Has many lines. Many, many lines.
|
# Has many lines. Many, many lines.
|
||||||
# Many, many, many lines.
|
# Many, many, many lines.
|
||||||
(
|
NOT_YET_IMPLEMENTED_ExprConstant
|
||||||
"""Module docstring.
|
|
||||||
|
|
||||||
Possibly also many, many lines.
|
NOT_YET_IMPLEMENTED_StmtImport
|
||||||
"""
|
NOT_YET_IMPLEMENTED_StmtImport
|
||||||
)
|
|
||||||
|
|
||||||
import os.path
|
NOT_YET_IMPLEMENTED_StmtImport
|
||||||
import sys
|
NOT_YET_IMPLEMENTED_StmtImportFrom # some noqa comment
|
||||||
|
|
||||||
import a
|
NOT_YET_IMPLEMENTED_StmtTry
|
||||||
from b.c import X # some noqa comment
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
try:
|
|
||||||
import fast
|
|
||||||
except ImportError:
|
|
||||||
import slow as fast
|
|
||||||
y = 1
|
|
||||||
(
|
(
|
||||||
# some strings
|
# some strings
|
||||||
y # type: ignore
|
y # type: ignore
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def function(default=None):
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
"""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
|
|
||||||
|
|
||||||
|
|
||||||
# Explains why we use global state.
|
# Explains why we use global state.
|
||||||
GLOBAL_STATE = {"a": a(1), "b": a(2), "c": a(3)}
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
|
|
||||||
# Another comment!
|
# Another comment!
|
||||||
# This time two lines.
|
# This time two lines.
|
||||||
|
|
||||||
|
|
||||||
class Foo:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
"""Docstring for class Foo. Example from Sphinx docs."""
|
|
||||||
|
|
||||||
#: Doc comment for class attribute Foo.bar.
|
|
||||||
#: It can have multiple lines.
|
|
||||||
bar = 1
|
|
||||||
|
|
||||||
flox = 1.5 #: Doc comment for Foo.flox. One line only.
|
|
||||||
|
|
||||||
baz = 2
|
|
||||||
"""Docstring for class attribute Foo.baz."""
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
#: Doc comment for instance attribute qux.
|
|
||||||
self.qux = 3
|
|
||||||
|
|
||||||
self.spam = 4
|
|
||||||
"""Docstring for instance attribute spam."""
|
|
||||||
|
|
||||||
|
|
||||||
#' <h1>This is pweave!</h1>
|
#' <h1>This is pweave!</h1>
|
||||||
|
|
||||||
|
|
||||||
@fast(really=True)
|
NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
async def wat():
|
|
||||||
# This comment, for some reason \
|
|
||||||
# contains a trailing backslash.
|
|
||||||
async with X.open_async() as x: # Some more comments
|
|
||||||
result = await x.method1()
|
|
||||||
# Comment after ending a block.
|
|
||||||
if result:
|
|
||||||
print("A OK", file=sys.stdout)
|
|
||||||
# Comment between things.
|
|
||||||
print()
|
|
||||||
|
|
||||||
|
|
||||||
# Some closing comments.
|
# Some closing comments.
|
||||||
|
|
|
@ -194,272 +194,195 @@ class C:
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -34,7 +34,7 @@
|
@@ -1,181 +1 @@
|
||||||
xxxxxxxxxxxxxxxx = Yyyy2YyyyyYyyyyy(
|
-class C:
|
||||||
push_manager=context.request.resource_manager,
|
- def test(self) -> None:
|
||||||
max_items_to_push=num_items,
|
- with patch("black.out", print):
|
||||||
|
- self.assertEqual(
|
||||||
|
- unstyle(str(report)), "1 file reformatted, 1 file failed to reformat."
|
||||||
|
- )
|
||||||
|
- self.assertEqual(
|
||||||
|
- unstyle(str(report)),
|
||||||
|
- "1 file reformatted, 1 file left unchanged, 1 file failed to reformat.",
|
||||||
|
- )
|
||||||
|
- self.assertEqual(
|
||||||
|
- unstyle(str(report)),
|
||||||
|
- "2 files reformatted, 1 file left unchanged, 1 file failed to"
|
||||||
|
- " reformat.",
|
||||||
|
- )
|
||||||
|
- self.assertEqual(
|
||||||
|
- unstyle(str(report)),
|
||||||
|
- "2 files reformatted, 2 files left unchanged, 2 files failed to"
|
||||||
|
- " reformat.",
|
||||||
|
- )
|
||||||
|
- for i in (a,):
|
||||||
|
- if (
|
||||||
|
- # Rule 1
|
||||||
|
- i % 2 == 0
|
||||||
|
- # Rule 2
|
||||||
|
- and i % 3 == 0
|
||||||
|
- ):
|
||||||
|
- while (
|
||||||
|
- # Just a comment
|
||||||
|
- call()
|
||||||
|
- # Another
|
||||||
|
- ):
|
||||||
|
- print(i)
|
||||||
|
- xxxxxxxxxxxxxxxx = Yyyy2YyyyyYyyyyy(
|
||||||
|
- push_manager=context.request.resource_manager,
|
||||||
|
- max_items_to_push=num_items,
|
||||||
- batch_size=Yyyy2YyyyYyyyyYyyy.FULL_SIZE,
|
- batch_size=Yyyy2YyyyYyyyyYyyy.FULL_SIZE,
|
||||||
+ batch_size=Yyyy2YyyyYyyyyYyyy.FULL_SIZE
|
- ).push(
|
||||||
).push(
|
- # Only send the first n items.
|
||||||
# Only send the first n items.
|
- items=items[:num_items]
|
||||||
items=items[:num_items]
|
- )
|
||||||
@@ -68,7 +68,7 @@
|
- return (
|
||||||
key6: value6,
|
- 'Utterly failed doctest test for %s\n File "%s", line %s, in %s\n\n%s'
|
||||||
key7: value7,
|
- % (test.name, test.filename, lineno, lname, err)
|
||||||
key8: value8,
|
- )
|
||||||
|
-
|
||||||
|
- def omitting_trailers(self) -> None:
|
||||||
|
- get_collection(
|
||||||
|
- hey_this_is_a_very_long_call, it_has_funny_attributes, really=True
|
||||||
|
- )[OneLevelIndex]
|
||||||
|
- get_collection(
|
||||||
|
- hey_this_is_a_very_long_call, it_has_funny_attributes, really=True
|
||||||
|
- )[OneLevelIndex][TwoLevelIndex][ThreeLevelIndex][FourLevelIndex]
|
||||||
|
- d[0][1][2][3][4][5][6][7][8][9][10][11][12][13][14][15][16][17][18][19][20][21][
|
||||||
|
- 22
|
||||||
|
- ]
|
||||||
|
- assignment = (
|
||||||
|
- some.rather.elaborate.rule() and another.rule.ending_with.index[123]
|
||||||
|
- )
|
||||||
|
-
|
||||||
|
- def easy_asserts(self) -> None:
|
||||||
|
- assert {
|
||||||
|
- key1: value1,
|
||||||
|
- key2: value2,
|
||||||
|
- key3: value3,
|
||||||
|
- key4: value4,
|
||||||
|
- key5: value5,
|
||||||
|
- key6: value6,
|
||||||
|
- key7: value7,
|
||||||
|
- key8: value8,
|
||||||
- key9: value9,
|
- key9: value9,
|
||||||
+ key9: value9
|
- } == expected, "Not what we expected"
|
||||||
} == expected, "Not what we expected"
|
-
|
||||||
|
- assert expected == {
|
||||||
assert expected == {
|
- key1: value1,
|
||||||
@@ -80,7 +80,7 @@
|
- key2: value2,
|
||||||
key6: value6,
|
- key3: value3,
|
||||||
key7: value7,
|
- key4: value4,
|
||||||
key8: value8,
|
- key5: value5,
|
||||||
|
- key6: value6,
|
||||||
|
- key7: value7,
|
||||||
|
- key8: value8,
|
||||||
- key9: value9,
|
- key9: value9,
|
||||||
+ key9: value9
|
- }, "Not what we expected"
|
||||||
}, "Not what we expected"
|
-
|
||||||
|
- assert expected == {
|
||||||
assert expected == {
|
- key1: value1,
|
||||||
@@ -92,7 +92,7 @@
|
- key2: value2,
|
||||||
key6: value6,
|
- key3: value3,
|
||||||
key7: value7,
|
- key4: value4,
|
||||||
key8: value8,
|
- key5: value5,
|
||||||
|
- key6: value6,
|
||||||
|
- key7: value7,
|
||||||
|
- key8: value8,
|
||||||
- key9: value9,
|
- key9: value9,
|
||||||
+ key9: value9
|
- }
|
||||||
}
|
-
|
||||||
|
- def tricky_asserts(self) -> None:
|
||||||
def tricky_asserts(self) -> None:
|
- assert {
|
||||||
@@ -105,7 +105,7 @@
|
- key1: value1,
|
||||||
key6: value6,
|
- key2: value2,
|
||||||
key7: value7,
|
- key3: value3,
|
||||||
key8: value8,
|
- key4: value4,
|
||||||
|
- key5: value5,
|
||||||
|
- key6: value6,
|
||||||
|
- key7: value7,
|
||||||
|
- key8: value8,
|
||||||
- key9: value9,
|
- key9: value9,
|
||||||
+ key9: value9
|
- } == expected(
|
||||||
} == expected(
|
- value, is_going_to_be="too long to fit in a single line", srsly=True
|
||||||
value, is_going_to_be="too long to fit in a single line", srsly=True
|
- ), "Not what we expected"
|
||||||
), "Not what we expected"
|
-
|
||||||
@@ -119,7 +119,7 @@
|
- assert {
|
||||||
key6: value6,
|
- key1: value1,
|
||||||
key7: value7,
|
- key2: value2,
|
||||||
key8: value8,
|
- key3: value3,
|
||||||
|
- key4: value4,
|
||||||
|
- key5: value5,
|
||||||
|
- key6: value6,
|
||||||
|
- key7: value7,
|
||||||
|
- key8: value8,
|
||||||
- key9: value9,
|
- key9: value9,
|
||||||
+ key9: value9
|
- } == expected, (
|
||||||
} == expected, (
|
- "Not what we expected and the message is too long to fit in one line"
|
||||||
"Not what we expected and the message is too long to fit in one line"
|
- )
|
||||||
)
|
-
|
||||||
@@ -135,7 +135,7 @@
|
- assert expected(
|
||||||
key6: value6,
|
- value, is_going_to_be="too long to fit in a single line", srsly=True
|
||||||
key7: value7,
|
- ) == {
|
||||||
key8: value8,
|
- key1: value1,
|
||||||
|
- key2: value2,
|
||||||
|
- key3: value3,
|
||||||
|
- key4: value4,
|
||||||
|
- key5: value5,
|
||||||
|
- key6: value6,
|
||||||
|
- key7: value7,
|
||||||
|
- key8: value8,
|
||||||
- key9: value9,
|
- key9: value9,
|
||||||
+ key9: value9
|
- }, "Not what we expected"
|
||||||
}, "Not what we expected"
|
-
|
||||||
|
- assert expected == {
|
||||||
assert expected == {
|
- key1: value1,
|
||||||
@@ -147,7 +147,7 @@
|
- key2: value2,
|
||||||
key6: value6,
|
- key3: value3,
|
||||||
key7: value7,
|
- key4: value4,
|
||||||
key8: value8,
|
- key5: value5,
|
||||||
|
- key6: value6,
|
||||||
|
- key7: value7,
|
||||||
|
- key8: value8,
|
||||||
- key9: value9,
|
- key9: value9,
|
||||||
+ key9: value9
|
- }, (
|
||||||
}, (
|
- "Not what we expected and the message is too long to fit in one line"
|
||||||
"Not what we expected and the message is too long to fit in one line"
|
- " because it's too long"
|
||||||
" because it's too long"
|
- )
|
||||||
@@ -176,6 +176,6 @@
|
-
|
||||||
key6: value6,
|
- dis_c_instance_method = """\
|
||||||
key7: value7,
|
- %3d 0 LOAD_FAST 1 (x)
|
||||||
key8: value8,
|
- 2 LOAD_CONST 1 (1)
|
||||||
|
- 4 COMPARE_OP 2 (==)
|
||||||
|
- 6 LOAD_FAST 0 (self)
|
||||||
|
- 8 STORE_ATTR 0 (x)
|
||||||
|
- 10 LOAD_CONST 0 (None)
|
||||||
|
- 12 RETURN_VALUE
|
||||||
|
- """ % (
|
||||||
|
- _C.__init__.__code__.co_firstlineno + 1,
|
||||||
|
- )
|
||||||
|
-
|
||||||
|
- assert (
|
||||||
|
- expectedexpectedexpectedexpectedexpectedexpectedexpectedexpectedexpect
|
||||||
|
- == {
|
||||||
|
- key1: value1,
|
||||||
|
- key2: value2,
|
||||||
|
- key3: value3,
|
||||||
|
- key4: value4,
|
||||||
|
- key5: value5,
|
||||||
|
- key6: value6,
|
||||||
|
- key7: value7,
|
||||||
|
- key8: value8,
|
||||||
- key9: value9,
|
- key9: value9,
|
||||||
+ key9: value9
|
- }
|
||||||
}
|
- )
|
||||||
)
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
class C:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
def test(self) -> None:
|
|
||||||
with patch("black.out", print):
|
|
||||||
self.assertEqual(
|
|
||||||
unstyle(str(report)), "1 file reformatted, 1 file failed to reformat."
|
|
||||||
)
|
|
||||||
self.assertEqual(
|
|
||||||
unstyle(str(report)),
|
|
||||||
"1 file reformatted, 1 file left unchanged, 1 file failed to reformat.",
|
|
||||||
)
|
|
||||||
self.assertEqual(
|
|
||||||
unstyle(str(report)),
|
|
||||||
"2 files reformatted, 1 file left unchanged, 1 file failed to"
|
|
||||||
" reformat.",
|
|
||||||
)
|
|
||||||
self.assertEqual(
|
|
||||||
unstyle(str(report)),
|
|
||||||
"2 files reformatted, 2 files left unchanged, 2 files failed to"
|
|
||||||
" reformat.",
|
|
||||||
)
|
|
||||||
for i in (a,):
|
|
||||||
if (
|
|
||||||
# Rule 1
|
|
||||||
i % 2 == 0
|
|
||||||
# Rule 2
|
|
||||||
and i % 3 == 0
|
|
||||||
):
|
|
||||||
while (
|
|
||||||
# Just a comment
|
|
||||||
call()
|
|
||||||
# Another
|
|
||||||
):
|
|
||||||
print(i)
|
|
||||||
xxxxxxxxxxxxxxxx = Yyyy2YyyyyYyyyyy(
|
|
||||||
push_manager=context.request.resource_manager,
|
|
||||||
max_items_to_push=num_items,
|
|
||||||
batch_size=Yyyy2YyyyYyyyyYyyy.FULL_SIZE
|
|
||||||
).push(
|
|
||||||
# Only send the first n items.
|
|
||||||
items=items[:num_items]
|
|
||||||
)
|
|
||||||
return (
|
|
||||||
'Utterly failed doctest test for %s\n File "%s", line %s, in %s\n\n%s'
|
|
||||||
% (test.name, test.filename, lineno, lname, err)
|
|
||||||
)
|
|
||||||
|
|
||||||
def omitting_trailers(self) -> None:
|
|
||||||
get_collection(
|
|
||||||
hey_this_is_a_very_long_call, it_has_funny_attributes, really=True
|
|
||||||
)[OneLevelIndex]
|
|
||||||
get_collection(
|
|
||||||
hey_this_is_a_very_long_call, it_has_funny_attributes, really=True
|
|
||||||
)[OneLevelIndex][TwoLevelIndex][ThreeLevelIndex][FourLevelIndex]
|
|
||||||
d[0][1][2][3][4][5][6][7][8][9][10][11][12][13][14][15][16][17][18][19][20][21][
|
|
||||||
22
|
|
||||||
]
|
|
||||||
assignment = (
|
|
||||||
some.rather.elaborate.rule() and another.rule.ending_with.index[123]
|
|
||||||
)
|
|
||||||
|
|
||||||
def easy_asserts(self) -> None:
|
|
||||||
assert {
|
|
||||||
key1: value1,
|
|
||||||
key2: value2,
|
|
||||||
key3: value3,
|
|
||||||
key4: value4,
|
|
||||||
key5: value5,
|
|
||||||
key6: value6,
|
|
||||||
key7: value7,
|
|
||||||
key8: value8,
|
|
||||||
key9: value9
|
|
||||||
} == expected, "Not what we expected"
|
|
||||||
|
|
||||||
assert expected == {
|
|
||||||
key1: value1,
|
|
||||||
key2: value2,
|
|
||||||
key3: value3,
|
|
||||||
key4: value4,
|
|
||||||
key5: value5,
|
|
||||||
key6: value6,
|
|
||||||
key7: value7,
|
|
||||||
key8: value8,
|
|
||||||
key9: value9
|
|
||||||
}, "Not what we expected"
|
|
||||||
|
|
||||||
assert expected == {
|
|
||||||
key1: value1,
|
|
||||||
key2: value2,
|
|
||||||
key3: value3,
|
|
||||||
key4: value4,
|
|
||||||
key5: value5,
|
|
||||||
key6: value6,
|
|
||||||
key7: value7,
|
|
||||||
key8: value8,
|
|
||||||
key9: value9
|
|
||||||
}
|
|
||||||
|
|
||||||
def tricky_asserts(self) -> None:
|
|
||||||
assert {
|
|
||||||
key1: value1,
|
|
||||||
key2: value2,
|
|
||||||
key3: value3,
|
|
||||||
key4: value4,
|
|
||||||
key5: value5,
|
|
||||||
key6: value6,
|
|
||||||
key7: value7,
|
|
||||||
key8: value8,
|
|
||||||
key9: value9
|
|
||||||
} == expected(
|
|
||||||
value, is_going_to_be="too long to fit in a single line", srsly=True
|
|
||||||
), "Not what we expected"
|
|
||||||
|
|
||||||
assert {
|
|
||||||
key1: value1,
|
|
||||||
key2: value2,
|
|
||||||
key3: value3,
|
|
||||||
key4: value4,
|
|
||||||
key5: value5,
|
|
||||||
key6: value6,
|
|
||||||
key7: value7,
|
|
||||||
key8: value8,
|
|
||||||
key9: value9
|
|
||||||
} == 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
|
|
||||||
) == {
|
|
||||||
key1: value1,
|
|
||||||
key2: value2,
|
|
||||||
key3: value3,
|
|
||||||
key4: value4,
|
|
||||||
key5: value5,
|
|
||||||
key6: value6,
|
|
||||||
key7: value7,
|
|
||||||
key8: value8,
|
|
||||||
key9: value9
|
|
||||||
}, "Not what we expected"
|
|
||||||
|
|
||||||
assert expected == {
|
|
||||||
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 line"
|
|
||||||
" because it's too long"
|
|
||||||
)
|
|
||||||
|
|
||||||
dis_c_instance_method = """\
|
|
||||||
%3d 0 LOAD_FAST 1 (x)
|
|
||||||
2 LOAD_CONST 1 (1)
|
|
||||||
4 COMPARE_OP 2 (==)
|
|
||||||
6 LOAD_FAST 0 (self)
|
|
||||||
8 STORE_ATTR 0 (x)
|
|
||||||
10 LOAD_CONST 0 (None)
|
|
||||||
12 RETURN_VALUE
|
|
||||||
""" % (
|
|
||||||
_C.__init__.__code__.co_firstlineno + 1,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert (
|
|
||||||
expectedexpectedexpectedexpectedexpectedexpectedexpectedexpectedexpect
|
|
||||||
== {
|
|
||||||
key1: value1,
|
|
||||||
key2: value2,
|
|
||||||
key3: value3,
|
|
||||||
key4: value4,
|
|
||||||
key5: value5,
|
|
||||||
key6: value6,
|
|
||||||
key7: value7,
|
|
||||||
key8: value8,
|
|
||||||
key9: value9
|
|
||||||
}
|
|
||||||
)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -0,0 +1,574 @@
|
||||||
|
---
|
||||||
|
source: crates/ruff_python_formatter/src/lib.rs
|
||||||
|
expression: snapshot
|
||||||
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_cases/composition.py
|
||||||
|
---
|
||||||
|
## Input
|
||||||
|
|
||||||
|
```py
|
||||||
|
class C:
|
||||||
|
def test(self) -> None:
|
||||||
|
with patch("black.out", print):
|
||||||
|
self.assertEqual(
|
||||||
|
unstyle(str(report)), "1 file reformatted, 1 file failed to reformat."
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
unstyle(str(report)),
|
||||||
|
"1 file reformatted, 1 file left unchanged, 1 file failed to reformat.",
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
unstyle(str(report)),
|
||||||
|
"2 files reformatted, 1 file left unchanged, 1 file failed to"
|
||||||
|
" reformat.",
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
unstyle(str(report)),
|
||||||
|
"2 files reformatted, 2 files left unchanged, 2 files failed to"
|
||||||
|
" reformat.",
|
||||||
|
)
|
||||||
|
for i in (a,):
|
||||||
|
if (
|
||||||
|
# Rule 1
|
||||||
|
i % 2 == 0
|
||||||
|
# Rule 2
|
||||||
|
and i % 3 == 0
|
||||||
|
):
|
||||||
|
while (
|
||||||
|
# Just a comment
|
||||||
|
call()
|
||||||
|
# Another
|
||||||
|
):
|
||||||
|
print(i)
|
||||||
|
xxxxxxxxxxxxxxxx = Yyyy2YyyyyYyyyyy(
|
||||||
|
push_manager=context.request.resource_manager,
|
||||||
|
max_items_to_push=num_items,
|
||||||
|
batch_size=Yyyy2YyyyYyyyyYyyy.FULL_SIZE,
|
||||||
|
).push(
|
||||||
|
# Only send the first n items.
|
||||||
|
items=items[:num_items]
|
||||||
|
)
|
||||||
|
return (
|
||||||
|
'Utterly failed doctest test for %s\n File "%s", line %s, in %s\n\n%s'
|
||||||
|
% (test.name, test.filename, lineno, lname, err)
|
||||||
|
)
|
||||||
|
|
||||||
|
def omitting_trailers(self) -> None:
|
||||||
|
get_collection(
|
||||||
|
hey_this_is_a_very_long_call, it_has_funny_attributes, really=True
|
||||||
|
)[OneLevelIndex]
|
||||||
|
get_collection(
|
||||||
|
hey_this_is_a_very_long_call, it_has_funny_attributes, really=True
|
||||||
|
)[OneLevelIndex][TwoLevelIndex][ThreeLevelIndex][FourLevelIndex]
|
||||||
|
d[0][1][2][3][4][5][6][7][8][9][10][11][12][13][14][15][16][17][18][19][20][21][
|
||||||
|
22
|
||||||
|
]
|
||||||
|
assignment = (
|
||||||
|
some.rather.elaborate.rule() and another.rule.ending_with.index[123]
|
||||||
|
)
|
||||||
|
|
||||||
|
def easy_asserts(self) -> None:
|
||||||
|
assert {
|
||||||
|
key1: value1,
|
||||||
|
key2: value2,
|
||||||
|
key3: value3,
|
||||||
|
key4: value4,
|
||||||
|
key5: value5,
|
||||||
|
key6: value6,
|
||||||
|
key7: value7,
|
||||||
|
key8: value8,
|
||||||
|
key9: value9,
|
||||||
|
} == expected, "Not what we expected"
|
||||||
|
|
||||||
|
assert expected == {
|
||||||
|
key1: value1,
|
||||||
|
key2: value2,
|
||||||
|
key3: value3,
|
||||||
|
key4: value4,
|
||||||
|
key5: value5,
|
||||||
|
key6: value6,
|
||||||
|
key7: value7,
|
||||||
|
key8: value8,
|
||||||
|
key9: value9,
|
||||||
|
}, "Not what we expected"
|
||||||
|
|
||||||
|
assert expected == {
|
||||||
|
key1: value1,
|
||||||
|
key2: value2,
|
||||||
|
key3: value3,
|
||||||
|
key4: value4,
|
||||||
|
key5: value5,
|
||||||
|
key6: value6,
|
||||||
|
key7: value7,
|
||||||
|
key8: value8,
|
||||||
|
key9: value9,
|
||||||
|
}
|
||||||
|
|
||||||
|
def tricky_asserts(self) -> None:
|
||||||
|
assert {
|
||||||
|
key1: value1,
|
||||||
|
key2: value2,
|
||||||
|
key3: value3,
|
||||||
|
key4: value4,
|
||||||
|
key5: value5,
|
||||||
|
key6: value6,
|
||||||
|
key7: value7,
|
||||||
|
key8: value8,
|
||||||
|
key9: value9,
|
||||||
|
} == expected(
|
||||||
|
value, is_going_to_be="too long to fit in a single line", srsly=True
|
||||||
|
), "Not what we expected"
|
||||||
|
|
||||||
|
assert {
|
||||||
|
key1: value1,
|
||||||
|
key2: value2,
|
||||||
|
key3: value3,
|
||||||
|
key4: value4,
|
||||||
|
key5: value5,
|
||||||
|
key6: value6,
|
||||||
|
key7: value7,
|
||||||
|
key8: value8,
|
||||||
|
key9: value9,
|
||||||
|
} == 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
|
||||||
|
) == {
|
||||||
|
key1: value1,
|
||||||
|
key2: value2,
|
||||||
|
key3: value3,
|
||||||
|
key4: value4,
|
||||||
|
key5: value5,
|
||||||
|
key6: value6,
|
||||||
|
key7: value7,
|
||||||
|
key8: value8,
|
||||||
|
key9: value9,
|
||||||
|
}, "Not what we expected"
|
||||||
|
|
||||||
|
assert expected == {
|
||||||
|
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 line"
|
||||||
|
" because it's too long"
|
||||||
|
)
|
||||||
|
|
||||||
|
dis_c_instance_method = """\
|
||||||
|
%3d 0 LOAD_FAST 1 (x)
|
||||||
|
2 LOAD_CONST 1 (1)
|
||||||
|
4 COMPARE_OP 2 (==)
|
||||||
|
6 LOAD_FAST 0 (self)
|
||||||
|
8 STORE_ATTR 0 (x)
|
||||||
|
10 LOAD_CONST 0 (None)
|
||||||
|
12 RETURN_VALUE
|
||||||
|
""" % (
|
||||||
|
_C.__init__.__code__.co_firstlineno + 1,
|
||||||
|
)
|
||||||
|
|
||||||
|
assert (
|
||||||
|
expectedexpectedexpectedexpectedexpectedexpectedexpectedexpectedexpect
|
||||||
|
== {
|
||||||
|
key1: value1,
|
||||||
|
key2: value2,
|
||||||
|
key3: value3,
|
||||||
|
key4: value4,
|
||||||
|
key5: value5,
|
||||||
|
key6: value6,
|
||||||
|
key7: value7,
|
||||||
|
key8: value8,
|
||||||
|
key9: value9,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Black Differences
|
||||||
|
|
||||||
|
```diff
|
||||||
|
--- Black
|
||||||
|
+++ Ruff
|
||||||
|
@@ -1,181 +1 @@
|
||||||
|
-class C:
|
||||||
|
- def test(self) -> None:
|
||||||
|
- with patch("black.out", print):
|
||||||
|
- self.assertEqual(
|
||||||
|
- unstyle(str(report)), "1 file reformatted, 1 file failed to reformat."
|
||||||
|
- )
|
||||||
|
- self.assertEqual(
|
||||||
|
- unstyle(str(report)),
|
||||||
|
- "1 file reformatted, 1 file left unchanged, 1 file failed to reformat.",
|
||||||
|
- )
|
||||||
|
- self.assertEqual(
|
||||||
|
- unstyle(str(report)),
|
||||||
|
- "2 files reformatted, 1 file left unchanged, 1 file failed to"
|
||||||
|
- " reformat.",
|
||||||
|
- )
|
||||||
|
- self.assertEqual(
|
||||||
|
- unstyle(str(report)),
|
||||||
|
- "2 files reformatted, 2 files left unchanged, 2 files failed to"
|
||||||
|
- " reformat.",
|
||||||
|
- )
|
||||||
|
- for i in (a,):
|
||||||
|
- if (
|
||||||
|
- # Rule 1
|
||||||
|
- i % 2 == 0
|
||||||
|
- # Rule 2
|
||||||
|
- and i % 3 == 0
|
||||||
|
- ):
|
||||||
|
- while (
|
||||||
|
- # Just a comment
|
||||||
|
- call()
|
||||||
|
- # Another
|
||||||
|
- ):
|
||||||
|
- print(i)
|
||||||
|
- xxxxxxxxxxxxxxxx = Yyyy2YyyyyYyyyyy(
|
||||||
|
- push_manager=context.request.resource_manager,
|
||||||
|
- max_items_to_push=num_items,
|
||||||
|
- batch_size=Yyyy2YyyyYyyyyYyyy.FULL_SIZE,
|
||||||
|
- ).push(
|
||||||
|
- # Only send the first n items.
|
||||||
|
- items=items[:num_items]
|
||||||
|
- )
|
||||||
|
- return (
|
||||||
|
- 'Utterly failed doctest test for %s\n File "%s", line %s, in %s\n\n%s'
|
||||||
|
- % (test.name, test.filename, lineno, lname, err)
|
||||||
|
- )
|
||||||
|
-
|
||||||
|
- def omitting_trailers(self) -> None:
|
||||||
|
- get_collection(
|
||||||
|
- hey_this_is_a_very_long_call, it_has_funny_attributes, really=True
|
||||||
|
- )[OneLevelIndex]
|
||||||
|
- get_collection(
|
||||||
|
- hey_this_is_a_very_long_call, it_has_funny_attributes, really=True
|
||||||
|
- )[OneLevelIndex][TwoLevelIndex][ThreeLevelIndex][FourLevelIndex]
|
||||||
|
- d[0][1][2][3][4][5][6][7][8][9][10][11][12][13][14][15][16][17][18][19][20][21][
|
||||||
|
- 22
|
||||||
|
- ]
|
||||||
|
- assignment = (
|
||||||
|
- some.rather.elaborate.rule() and another.rule.ending_with.index[123]
|
||||||
|
- )
|
||||||
|
-
|
||||||
|
- def easy_asserts(self) -> None:
|
||||||
|
- assert {
|
||||||
|
- key1: value1,
|
||||||
|
- key2: value2,
|
||||||
|
- key3: value3,
|
||||||
|
- key4: value4,
|
||||||
|
- key5: value5,
|
||||||
|
- key6: value6,
|
||||||
|
- key7: value7,
|
||||||
|
- key8: value8,
|
||||||
|
- key9: value9,
|
||||||
|
- } == expected, "Not what we expected"
|
||||||
|
-
|
||||||
|
- assert expected == {
|
||||||
|
- key1: value1,
|
||||||
|
- key2: value2,
|
||||||
|
- key3: value3,
|
||||||
|
- key4: value4,
|
||||||
|
- key5: value5,
|
||||||
|
- key6: value6,
|
||||||
|
- key7: value7,
|
||||||
|
- key8: value8,
|
||||||
|
- key9: value9,
|
||||||
|
- }, "Not what we expected"
|
||||||
|
-
|
||||||
|
- assert expected == {
|
||||||
|
- key1: value1,
|
||||||
|
- key2: value2,
|
||||||
|
- key3: value3,
|
||||||
|
- key4: value4,
|
||||||
|
- key5: value5,
|
||||||
|
- key6: value6,
|
||||||
|
- key7: value7,
|
||||||
|
- key8: value8,
|
||||||
|
- key9: value9,
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- def tricky_asserts(self) -> None:
|
||||||
|
- assert {
|
||||||
|
- key1: value1,
|
||||||
|
- key2: value2,
|
||||||
|
- key3: value3,
|
||||||
|
- key4: value4,
|
||||||
|
- key5: value5,
|
||||||
|
- key6: value6,
|
||||||
|
- key7: value7,
|
||||||
|
- key8: value8,
|
||||||
|
- key9: value9,
|
||||||
|
- } == expected(
|
||||||
|
- value, is_going_to_be="too long to fit in a single line", srsly=True
|
||||||
|
- ), "Not what we expected"
|
||||||
|
-
|
||||||
|
- assert {
|
||||||
|
- key1: value1,
|
||||||
|
- key2: value2,
|
||||||
|
- key3: value3,
|
||||||
|
- key4: value4,
|
||||||
|
- key5: value5,
|
||||||
|
- key6: value6,
|
||||||
|
- key7: value7,
|
||||||
|
- key8: value8,
|
||||||
|
- key9: value9,
|
||||||
|
- } == 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
|
||||||
|
- ) == {
|
||||||
|
- key1: value1,
|
||||||
|
- key2: value2,
|
||||||
|
- key3: value3,
|
||||||
|
- key4: value4,
|
||||||
|
- key5: value5,
|
||||||
|
- key6: value6,
|
||||||
|
- key7: value7,
|
||||||
|
- key8: value8,
|
||||||
|
- key9: value9,
|
||||||
|
- }, "Not what we expected"
|
||||||
|
-
|
||||||
|
- assert expected == {
|
||||||
|
- 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 line"
|
||||||
|
- " because it's too long"
|
||||||
|
- )
|
||||||
|
-
|
||||||
|
- dis_c_instance_method = """\
|
||||||
|
- %3d 0 LOAD_FAST 1 (x)
|
||||||
|
- 2 LOAD_CONST 1 (1)
|
||||||
|
- 4 COMPARE_OP 2 (==)
|
||||||
|
- 6 LOAD_FAST 0 (self)
|
||||||
|
- 8 STORE_ATTR 0 (x)
|
||||||
|
- 10 LOAD_CONST 0 (None)
|
||||||
|
- 12 RETURN_VALUE
|
||||||
|
- """ % (
|
||||||
|
- _C.__init__.__code__.co_firstlineno + 1,
|
||||||
|
- )
|
||||||
|
-
|
||||||
|
- assert (
|
||||||
|
- expectedexpectedexpectedexpectedexpectedexpectedexpectedexpectedexpect
|
||||||
|
- == {
|
||||||
|
- key1: value1,
|
||||||
|
- key2: value2,
|
||||||
|
- key3: value3,
|
||||||
|
- key4: value4,
|
||||||
|
- key5: value5,
|
||||||
|
- key6: value6,
|
||||||
|
- key7: value7,
|
||||||
|
- key8: value8,
|
||||||
|
- key9: value9,
|
||||||
|
- }
|
||||||
|
- )
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
|
```
|
||||||
|
|
||||||
|
## Ruff Output
|
||||||
|
|
||||||
|
```py
|
||||||
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
|
```
|
||||||
|
|
||||||
|
## Black Output
|
||||||
|
|
||||||
|
```py
|
||||||
|
class C:
|
||||||
|
def test(self) -> None:
|
||||||
|
with patch("black.out", print):
|
||||||
|
self.assertEqual(
|
||||||
|
unstyle(str(report)), "1 file reformatted, 1 file failed to reformat."
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
unstyle(str(report)),
|
||||||
|
"1 file reformatted, 1 file left unchanged, 1 file failed to reformat.",
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
unstyle(str(report)),
|
||||||
|
"2 files reformatted, 1 file left unchanged, 1 file failed to"
|
||||||
|
" reformat.",
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
unstyle(str(report)),
|
||||||
|
"2 files reformatted, 2 files left unchanged, 2 files failed to"
|
||||||
|
" reformat.",
|
||||||
|
)
|
||||||
|
for i in (a,):
|
||||||
|
if (
|
||||||
|
# Rule 1
|
||||||
|
i % 2 == 0
|
||||||
|
# Rule 2
|
||||||
|
and i % 3 == 0
|
||||||
|
):
|
||||||
|
while (
|
||||||
|
# Just a comment
|
||||||
|
call()
|
||||||
|
# Another
|
||||||
|
):
|
||||||
|
print(i)
|
||||||
|
xxxxxxxxxxxxxxxx = Yyyy2YyyyyYyyyyy(
|
||||||
|
push_manager=context.request.resource_manager,
|
||||||
|
max_items_to_push=num_items,
|
||||||
|
batch_size=Yyyy2YyyyYyyyyYyyy.FULL_SIZE,
|
||||||
|
).push(
|
||||||
|
# Only send the first n items.
|
||||||
|
items=items[:num_items]
|
||||||
|
)
|
||||||
|
return (
|
||||||
|
'Utterly failed doctest test for %s\n File "%s", line %s, in %s\n\n%s'
|
||||||
|
% (test.name, test.filename, lineno, lname, err)
|
||||||
|
)
|
||||||
|
|
||||||
|
def omitting_trailers(self) -> None:
|
||||||
|
get_collection(
|
||||||
|
hey_this_is_a_very_long_call, it_has_funny_attributes, really=True
|
||||||
|
)[OneLevelIndex]
|
||||||
|
get_collection(
|
||||||
|
hey_this_is_a_very_long_call, it_has_funny_attributes, really=True
|
||||||
|
)[OneLevelIndex][TwoLevelIndex][ThreeLevelIndex][FourLevelIndex]
|
||||||
|
d[0][1][2][3][4][5][6][7][8][9][10][11][12][13][14][15][16][17][18][19][20][21][
|
||||||
|
22
|
||||||
|
]
|
||||||
|
assignment = (
|
||||||
|
some.rather.elaborate.rule() and another.rule.ending_with.index[123]
|
||||||
|
)
|
||||||
|
|
||||||
|
def easy_asserts(self) -> None:
|
||||||
|
assert {
|
||||||
|
key1: value1,
|
||||||
|
key2: value2,
|
||||||
|
key3: value3,
|
||||||
|
key4: value4,
|
||||||
|
key5: value5,
|
||||||
|
key6: value6,
|
||||||
|
key7: value7,
|
||||||
|
key8: value8,
|
||||||
|
key9: value9,
|
||||||
|
} == expected, "Not what we expected"
|
||||||
|
|
||||||
|
assert expected == {
|
||||||
|
key1: value1,
|
||||||
|
key2: value2,
|
||||||
|
key3: value3,
|
||||||
|
key4: value4,
|
||||||
|
key5: value5,
|
||||||
|
key6: value6,
|
||||||
|
key7: value7,
|
||||||
|
key8: value8,
|
||||||
|
key9: value9,
|
||||||
|
}, "Not what we expected"
|
||||||
|
|
||||||
|
assert expected == {
|
||||||
|
key1: value1,
|
||||||
|
key2: value2,
|
||||||
|
key3: value3,
|
||||||
|
key4: value4,
|
||||||
|
key5: value5,
|
||||||
|
key6: value6,
|
||||||
|
key7: value7,
|
||||||
|
key8: value8,
|
||||||
|
key9: value9,
|
||||||
|
}
|
||||||
|
|
||||||
|
def tricky_asserts(self) -> None:
|
||||||
|
assert {
|
||||||
|
key1: value1,
|
||||||
|
key2: value2,
|
||||||
|
key3: value3,
|
||||||
|
key4: value4,
|
||||||
|
key5: value5,
|
||||||
|
key6: value6,
|
||||||
|
key7: value7,
|
||||||
|
key8: value8,
|
||||||
|
key9: value9,
|
||||||
|
} == expected(
|
||||||
|
value, is_going_to_be="too long to fit in a single line", srsly=True
|
||||||
|
), "Not what we expected"
|
||||||
|
|
||||||
|
assert {
|
||||||
|
key1: value1,
|
||||||
|
key2: value2,
|
||||||
|
key3: value3,
|
||||||
|
key4: value4,
|
||||||
|
key5: value5,
|
||||||
|
key6: value6,
|
||||||
|
key7: value7,
|
||||||
|
key8: value8,
|
||||||
|
key9: value9,
|
||||||
|
} == 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
|
||||||
|
) == {
|
||||||
|
key1: value1,
|
||||||
|
key2: value2,
|
||||||
|
key3: value3,
|
||||||
|
key4: value4,
|
||||||
|
key5: value5,
|
||||||
|
key6: value6,
|
||||||
|
key7: value7,
|
||||||
|
key8: value8,
|
||||||
|
key9: value9,
|
||||||
|
}, "Not what we expected"
|
||||||
|
|
||||||
|
assert expected == {
|
||||||
|
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 line"
|
||||||
|
" because it's too long"
|
||||||
|
)
|
||||||
|
|
||||||
|
dis_c_instance_method = """\
|
||||||
|
%3d 0 LOAD_FAST 1 (x)
|
||||||
|
2 LOAD_CONST 1 (1)
|
||||||
|
4 COMPARE_OP 2 (==)
|
||||||
|
6 LOAD_FAST 0 (self)
|
||||||
|
8 STORE_ATTR 0 (x)
|
||||||
|
10 LOAD_CONST 0 (None)
|
||||||
|
12 RETURN_VALUE
|
||||||
|
""" % (
|
||||||
|
_C.__init__.__code__.co_firstlineno + 1,
|
||||||
|
)
|
||||||
|
|
||||||
|
assert (
|
||||||
|
expectedexpectedexpectedexpectedexpectedexpectedexpectedexpectedexpect
|
||||||
|
== {
|
||||||
|
key1: value1,
|
||||||
|
key2: value2,
|
||||||
|
key3: value3,
|
||||||
|
key4: value4,
|
||||||
|
key5: value5,
|
||||||
|
key6: value6,
|
||||||
|
key7: value7,
|
||||||
|
key8: value8,
|
||||||
|
key9: value9,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
---
|
||||||
|
source: crates/ruff_python_formatter/src/lib.rs
|
||||||
|
expression: snapshot
|
||||||
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_cases/docstring_no_extra_empty_line_before_eof.py
|
||||||
|
---
|
||||||
|
## Input
|
||||||
|
|
||||||
|
```py
|
||||||
|
# Make sure when the file ends with class's docstring,
|
||||||
|
# It doesn't add extra blank lines.
|
||||||
|
class ClassWithDocstring:
|
||||||
|
"""A docstring."""
|
||||||
|
```
|
||||||
|
|
||||||
|
## Black Differences
|
||||||
|
|
||||||
|
```diff
|
||||||
|
--- Black
|
||||||
|
+++ Ruff
|
||||||
|
@@ -1,4 +1,3 @@
|
||||||
|
# Make sure when the file ends with class's docstring,
|
||||||
|
# It doesn't add extra blank lines.
|
||||||
|
-class ClassWithDocstring:
|
||||||
|
- """A docstring."""
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
|
```
|
||||||
|
|
||||||
|
## Ruff Output
|
||||||
|
|
||||||
|
```py
|
||||||
|
# Make sure when the file ends with class's docstring,
|
||||||
|
# It doesn't add extra blank lines.
|
||||||
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
|
```
|
||||||
|
|
||||||
|
## Black Output
|
||||||
|
|
||||||
|
```py
|
||||||
|
# Make sure when the file ends with class's docstring,
|
||||||
|
# It doesn't add extra blank lines.
|
||||||
|
class ClassWithDocstring:
|
||||||
|
"""A docstring."""
|
||||||
|
```
|
||||||
|
|
||||||
|
|
|
@ -63,81 +63,98 @@ def single_quote_docstring_over_line_limit2():
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -1,9 +1,11 @@
|
@@ -1,48 +1,28 @@
|
||||||
def docstring_almost_at_line_limit():
|
-def docstring_almost_at_line_limit():
|
||||||
- """long docstring................................................................."""
|
- """long docstring................................................................."""
|
||||||
+ """long docstring.................................................................
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+ """
|
|
||||||
|
|
||||||
|
|
||||||
def docstring_almost_at_line_limit_with_prefix():
|
-def docstring_almost_at_line_limit_with_prefix():
|
||||||
- f"""long docstring................................................................"""
|
- f"""long docstring................................................................"""
|
||||||
+ f"""long docstring................................................................
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+ """
|
|
||||||
|
|
||||||
|
|
||||||
def mulitline_docstring_almost_at_line_limit():
|
-def mulitline_docstring_almost_at_line_limit():
|
||||||
@@ -45,4 +47,4 @@
|
- """long docstring.................................................................
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
- ..................................................................................
|
||||||
|
- """
|
||||||
|
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
-def mulitline_docstring_almost_at_line_limit_with_prefix():
|
||||||
|
- f"""long docstring................................................................
|
||||||
|
|
||||||
|
- ..................................................................................
|
||||||
|
- """
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
def single_quote_docstring_over_line_limit2():
|
-def docstring_at_line_limit():
|
||||||
|
- """long docstring................................................................"""
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
-def docstring_at_line_limit_with_prefix():
|
||||||
|
- f"""long docstring..............................................................."""
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
-def multiline_docstring_at_line_limit():
|
||||||
|
- """first line-----------------------------------------------------------------------
|
||||||
|
-
|
||||||
|
- second line----------------------------------------------------------------------"""
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
-def multiline_docstring_at_line_limit_with_prefix():
|
||||||
|
- f"""first line----------------------------------------------------------------------
|
||||||
|
-
|
||||||
|
- second line----------------------------------------------------------------------"""
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
-def single_quote_docstring_over_line_limit():
|
||||||
- "We do not want to put the closing quote on a new line as that is invalid (see GH-3141)."
|
- "We do not want to put the closing quote on a new line as that is invalid (see GH-3141)."
|
||||||
+ 'We do not want to put the closing quote on a new line as that is invalid (see GH-3141).'
|
-
|
||||||
|
-
|
||||||
|
-def single_quote_docstring_over_line_limit2():
|
||||||
|
- "We do not want to put the closing quote on a new line as that is invalid (see GH-3141)."
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
def docstring_almost_at_line_limit():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
"""long docstring.................................................................
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
def docstring_almost_at_line_limit_with_prefix():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
f"""long docstring................................................................
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
def mulitline_docstring_almost_at_line_limit():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
"""long docstring.................................................................
|
|
||||||
|
|
||||||
..................................................................................
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
def mulitline_docstring_almost_at_line_limit_with_prefix():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
f"""long docstring................................................................
|
|
||||||
|
|
||||||
..................................................................................
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
def docstring_at_line_limit():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
"""long docstring................................................................"""
|
|
||||||
|
|
||||||
|
|
||||||
def docstring_at_line_limit_with_prefix():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
f"""long docstring..............................................................."""
|
|
||||||
|
|
||||||
|
|
||||||
def multiline_docstring_at_line_limit():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
"""first line-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
second line----------------------------------------------------------------------"""
|
|
||||||
|
|
||||||
|
|
||||||
def multiline_docstring_at_line_limit_with_prefix():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
f"""first line----------------------------------------------------------------------
|
|
||||||
|
|
||||||
second line----------------------------------------------------------------------"""
|
|
||||||
|
|
||||||
|
|
||||||
def single_quote_docstring_over_line_limit():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
"We do not want to put the closing quote on a new line as that is invalid (see GH-3141)."
|
|
||||||
|
|
||||||
|
|
||||||
def single_quote_docstring_over_line_limit2():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
'We do not want to put the closing quote on a new line as that is invalid (see GH-3141).'
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -234,86 +234,64 @@ def stable_quote_normalization_with_immediate_inner_single_quote(self):
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -1,83 +1,85 @@
|
@@ -1,219 +1,105 @@
|
||||||
class MyClass:
|
-class MyClass:
|
||||||
+ """ Multiline
|
- """Multiline
|
||||||
+ class docstring
|
|
||||||
+ """
|
|
||||||
+
|
|
||||||
+ def method(self):
|
|
||||||
"""Multiline
|
|
||||||
- class docstring
|
- class docstring
|
||||||
+ method docstring
|
- """
|
||||||
"""
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
-
|
|
||||||
- def method(self):
|
- def method(self):
|
||||||
- """Multiline
|
- """Multiline
|
||||||
- method docstring
|
- method docstring
|
||||||
- """
|
- """
|
||||||
- pass
|
- pass
|
||||||
+ pass
|
|
||||||
|
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
def foo():
|
-def foo():
|
||||||
- """This is a docstring with
|
- """This is a docstring with
|
||||||
- some lines of text here
|
- some lines of text here
|
||||||
- """
|
- """
|
||||||
- return
|
- return
|
||||||
+ """This is a docstring with
|
|
||||||
+ some lines of text here
|
|
||||||
+ """
|
|
||||||
+ return
|
|
||||||
|
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
def bar():
|
-def bar():
|
||||||
- """This is another docstring
|
- """This is another docstring
|
||||||
- with more lines of text
|
- with more lines of text
|
||||||
- """
|
- """
|
||||||
- return
|
- return
|
||||||
+ '''This is another docstring
|
|
||||||
+ with more lines of text
|
|
||||||
+ '''
|
|
||||||
+ return
|
|
||||||
|
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
def baz():
|
-def baz():
|
||||||
- '''"This" is a string with some
|
- '''"This" is a string with some
|
||||||
- embedded "quotes"'''
|
- embedded "quotes"'''
|
||||||
- return
|
- return
|
||||||
+ '''"This" is a string with some
|
|
||||||
+ embedded "quotes"'''
|
|
||||||
+ return
|
|
||||||
|
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
def troz():
|
-def troz():
|
||||||
- """Indentation with tabs
|
- """Indentation with tabs
|
||||||
- is just as OK
|
- is just as OK
|
||||||
- """
|
- """
|
||||||
- return
|
- return
|
||||||
+ '''Indentation with tabs
|
|
||||||
+ is just as OK
|
|
||||||
+ '''
|
|
||||||
+ return
|
|
||||||
|
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
def zort():
|
-def zort():
|
||||||
- """Another
|
- """Another
|
||||||
- multiline
|
- multiline
|
||||||
- docstring
|
- docstring
|
||||||
- """
|
- """
|
||||||
- pass
|
- pass
|
||||||
+ """Another
|
|
||||||
+ multiline
|
|
||||||
+ docstring
|
|
||||||
+ """
|
|
||||||
+ pass
|
|
||||||
|
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
def poit():
|
-def poit():
|
||||||
- """
|
- """
|
||||||
- Lorem ipsum dolor sit amet.
|
- Lorem ipsum dolor sit amet.
|
||||||
+ """
|
|
||||||
+ Lorem ipsum dolor sit amet.
|
|
||||||
|
|
||||||
- Consectetur adipiscing elit:
|
- Consectetur adipiscing elit:
|
||||||
- - sed do eiusmod tempor incididunt ut labore
|
- - sed do eiusmod tempor incididunt ut labore
|
||||||
|
@ -323,133 +301,110 @@ def stable_quote_normalization_with_immediate_inner_single_quote(self):
|
||||||
- - aliquip ex ea commodo consequat
|
- - aliquip ex ea commodo consequat
|
||||||
- """
|
- """
|
||||||
- pass
|
- pass
|
||||||
+ Consectetur adipiscing elit:
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+ - sed do eiusmod tempor incididunt ut labore
|
|
||||||
+ - dolore magna aliqua
|
|
||||||
+ - enim ad minim veniam
|
|
||||||
+ - quis nostrud exercitation ullamco laboris nisi
|
|
||||||
+ - aliquip ex ea commodo consequat
|
|
||||||
+ """
|
|
||||||
+ pass
|
|
||||||
|
|
||||||
|
|
||||||
def under_indent():
|
-def under_indent():
|
||||||
- """
|
- """
|
||||||
- These lines are indented in a way that does not
|
- These lines are indented in a way that does not
|
||||||
- make sense.
|
- make sense.
|
||||||
- """
|
- """
|
||||||
- pass
|
- pass
|
||||||
+ """
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+ These lines are indented in a way that does not
|
|
||||||
+make sense.
|
|
||||||
+ """
|
|
||||||
+ pass
|
|
||||||
|
|
||||||
|
|
||||||
def over_indent():
|
-def over_indent():
|
||||||
- """
|
- """
|
||||||
- This has a shallow indent
|
- This has a shallow indent
|
||||||
- - But some lines are deeper
|
- - But some lines are deeper
|
||||||
- - And the closing quote is too deep
|
- - And the closing quote is too deep
|
||||||
+ """
|
- """
|
||||||
+ This has a shallow indent
|
|
||||||
+ - But some lines are deeper
|
|
||||||
+ - And the closing quote is too deep
|
|
||||||
"""
|
|
||||||
- pass
|
- pass
|
||||||
+ pass
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
def single_line():
|
-def single_line():
|
||||||
- """But with a newline after it!"""
|
- """But with a newline after it!"""
|
||||||
+ """But with a newline after it!
|
- pass
|
||||||
+
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+ """
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
@@ -88,25 +90,30 @@
|
-def this():
|
||||||
|
- r"""
|
||||||
|
- 'hey ho'
|
||||||
|
- """
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
def that():
|
-def that():
|
||||||
- """ "hey yah" """
|
- """ "hey yah" """
|
||||||
+ """ "hey yah" """
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
def and_that():
|
-def and_that():
|
||||||
- """
|
- """
|
||||||
- "hey yah" """
|
- "hey yah" """
|
||||||
+ """
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+ "hey yah" """
|
|
||||||
|
|
||||||
|
|
||||||
def and_this():
|
-def and_this():
|
||||||
- '''
|
- '''
|
||||||
- "hey yah"'''
|
- "hey yah"'''
|
||||||
+ '''
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+ "hey yah"'''
|
|
||||||
|
|
||||||
|
|
||||||
def multiline_whitespace():
|
-def multiline_whitespace():
|
||||||
- """ """
|
- """ """
|
||||||
+ '''
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+ '''
|
|
||||||
|
|
||||||
|
|
||||||
def oneline_whitespace():
|
-def oneline_whitespace():
|
||||||
- """ """
|
- """ """
|
||||||
+ ''' '''
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
def empty():
|
-def empty():
|
||||||
@@ -114,12 +121,11 @@
|
- """"""
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
def single_quotes():
|
-def single_quotes():
|
||||||
- "testing"
|
- "testing"
|
||||||
+ 'testing'
|
-
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
-def believe_it_or_not_this_is_in_the_py_stdlib():
|
-def believe_it_or_not_this_is_in_the_py_stdlib():
|
||||||
- '''
|
- '''
|
||||||
- "hey yah"'''
|
- "hey yah"'''
|
||||||
+def believe_it_or_not_this_is_in_the_py_stdlib(): '''
|
|
||||||
+"hey yah"'''
|
|
||||||
|
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
def ignored_docstring():
|
-def ignored_docstring():
|
||||||
@@ -128,32 +134,32 @@
|
- """a => \
|
||||||
|
-b"""
|
||||||
|
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
def single_line_docstring_with_whitespace():
|
-def single_line_docstring_with_whitespace():
|
||||||
- """This should be stripped"""
|
- """This should be stripped"""
|
||||||
+ """ This should be stripped """
|
|
||||||
|
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
def docstring_with_inline_tabs_and_space_indentation():
|
-def docstring_with_inline_tabs_and_space_indentation():
|
||||||
"""hey
|
- """hey
|
||||||
|
|
||||||
tab separated value
|
- tab separated value
|
||||||
- tab at start of line and then a tab separated value
|
- tab at start of line and then a tab separated value
|
||||||
- multiple tabs at the beginning and inline
|
- multiple tabs at the beginning and inline
|
||||||
- mixed tabs and spaces at beginning. next line has mixed tabs and spaces only.
|
- mixed tabs and spaces at beginning. next line has mixed tabs and spaces only.
|
||||||
-
|
-
|
||||||
- line ends with some tabs
|
- line ends with some tabs
|
||||||
+ tab at start of line and then a tab separated value
|
- """
|
||||||
+ multiple tabs at the beginning and inline
|
-
|
||||||
+ mixed tabs and spaces at beginning. next line has mixed tabs and spaces only.
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+
|
|
||||||
+ line ends with some tabs
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
-def docstring_with_inline_tabs_and_tab_indentation():
|
||||||
def docstring_with_inline_tabs_and_tab_indentation():
|
|
||||||
- """hey
|
- """hey
|
||||||
+ """hey
|
|
||||||
|
|
||||||
- tab separated value
|
- tab separated value
|
||||||
- tab at start of line and then a tab separated value
|
- tab at start of line and then a tab separated value
|
||||||
|
@ -459,296 +414,191 @@ def stable_quote_normalization_with_immediate_inner_single_quote(self):
|
||||||
- line ends with some tabs
|
- line ends with some tabs
|
||||||
- """
|
- """
|
||||||
- pass
|
- pass
|
||||||
+ tab separated value
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+ tab at start of line and then a tab separated value
|
|
||||||
+ multiple tabs at the beginning and inline
|
|
||||||
+ mixed tabs and spaces at beginning. next line has mixed tabs and spaces only.
|
|
||||||
+
|
|
||||||
+ line ends with some tabs
|
|
||||||
+ """
|
|
||||||
+ pass
|
|
||||||
|
|
||||||
|
|
||||||
def backslash_space():
|
-def backslash_space():
|
||||||
@@ -161,14 +167,14 @@
|
- """\ """
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
def multiline_backslash_1():
|
-def multiline_backslash_1():
|
||||||
- """
|
- """
|
||||||
+ '''
|
- hey\there\
|
||||||
hey\there\
|
|
||||||
- \ """
|
- \ """
|
||||||
+ \ '''
|
-
|
||||||
|
-
|
||||||
|
-def multiline_backslash_2():
|
||||||
def multiline_backslash_2():
|
|
||||||
- """
|
- """
|
||||||
- hey there \ """
|
- hey there \ """
|
||||||
+ '''
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+ hey there \ '''
|
|
||||||
|
|
||||||
|
|
||||||
# Regression test for #3425
|
# Regression test for #3425
|
||||||
@@ -178,8 +184,8 @@
|
-def multiline_backslash_really_long_dont_crash():
|
||||||
|
- """
|
||||||
|
- hey there hello guten tag hi hoow are you ola zdravstvuyte ciao como estas ca va \ """
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
def multiline_backslash_3():
|
-def multiline_backslash_3():
|
||||||
- """
|
- """
|
||||||
- already escaped \\"""
|
- already escaped \\"""
|
||||||
+ '''
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+ already escaped \\ '''
|
|
||||||
|
|
||||||
|
|
||||||
def my_god_its_full_of_stars_1():
|
-def my_god_its_full_of_stars_1():
|
||||||
@@ -188,7 +194,7 @@
|
- "I'm sorry Dave\u2001"
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
# the space below is actually a \u2001, removed in output
|
# the space below is actually a \u2001, removed in output
|
||||||
def my_god_its_full_of_stars_2():
|
-def my_god_its_full_of_stars_2():
|
||||||
- "I'm sorry Dave"
|
- "I'm sorry Dave"
|
||||||
+ "I'm sorry Dave "
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
def docstring_almost_at_line_limit():
|
-def docstring_almost_at_line_limit():
|
||||||
@@ -213,7 +219,7 @@
|
- """long docstring................................................................."""
|
||||||
|
-
|
||||||
|
-
|
||||||
def stable_quote_normalization_with_immediate_inner_single_quote(self):
|
-def docstring_almost_at_line_limit2():
|
||||||
- """'<text here>
|
- """long docstring.................................................................
|
||||||
+ ''''<text here>
|
-
|
||||||
|
- ..................................................................................
|
||||||
<text here, since without another non-empty line black is stable>
|
|
||||||
- """
|
- """
|
||||||
+ '''
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
-def docstring_at_line_limit():
|
||||||
|
- """long docstring................................................................"""
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
-def multiline_docstring_at_line_limit():
|
||||||
|
- """first line-----------------------------------------------------------------------
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
- second line----------------------------------------------------------------------"""
|
||||||
|
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
-def stable_quote_normalization_with_immediate_inner_single_quote(self):
|
||||||
|
- """'<text here>
|
||||||
|
|
||||||
|
- <text here, since without another non-empty line black is stable>
|
||||||
|
- """
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
class MyClass:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
""" Multiline
|
|
||||||
class docstring
|
|
||||||
"""
|
|
||||||
|
|
||||||
def method(self):
|
|
||||||
"""Multiline
|
|
||||||
method docstring
|
|
||||||
"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def foo():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
"""This is a docstring with
|
|
||||||
some lines of text here
|
|
||||||
"""
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
def bar():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
'''This is another docstring
|
|
||||||
with more lines of text
|
|
||||||
'''
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
def baz():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
'''"This" is a string with some
|
|
||||||
embedded "quotes"'''
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
def troz():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
'''Indentation with tabs
|
|
||||||
is just as OK
|
|
||||||
'''
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
def zort():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
"""Another
|
|
||||||
multiline
|
|
||||||
docstring
|
|
||||||
"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def poit():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
"""
|
|
||||||
Lorem ipsum dolor sit amet.
|
|
||||||
|
|
||||||
Consectetur adipiscing elit:
|
|
||||||
- sed do eiusmod tempor incididunt ut labore
|
|
||||||
- dolore magna aliqua
|
|
||||||
- enim ad minim veniam
|
|
||||||
- quis nostrud exercitation ullamco laboris nisi
|
|
||||||
- aliquip ex ea commodo consequat
|
|
||||||
"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def under_indent():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
"""
|
|
||||||
These lines are indented in a way that does not
|
|
||||||
make sense.
|
|
||||||
"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def over_indent():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
"""
|
|
||||||
This has a shallow indent
|
|
||||||
- But some lines are deeper
|
|
||||||
- And the closing quote is too deep
|
|
||||||
"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def single_line():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
"""But with a newline after it!
|
|
||||||
|
|
||||||
"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def this():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
r"""
|
|
||||||
'hey ho'
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
def that():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
""" "hey yah" """
|
|
||||||
|
|
||||||
|
|
||||||
def and_that():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
"""
|
|
||||||
"hey yah" """
|
|
||||||
|
|
||||||
|
|
||||||
def and_this():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
'''
|
|
||||||
"hey yah"'''
|
|
||||||
|
|
||||||
|
|
||||||
def multiline_whitespace():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
'''
|
|
||||||
|
|
||||||
|
|
||||||
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
'''
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
def oneline_whitespace():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
''' '''
|
|
||||||
|
|
||||||
|
|
||||||
def empty():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
""""""
|
|
||||||
|
|
||||||
|
|
||||||
def single_quotes():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
'testing'
|
|
||||||
|
|
||||||
|
|
||||||
def believe_it_or_not_this_is_in_the_py_stdlib(): '''
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
"hey yah"'''
|
|
||||||
|
|
||||||
|
|
||||||
def ignored_docstring():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
"""a => \
|
|
||||||
b"""
|
|
||||||
|
|
||||||
|
|
||||||
def single_line_docstring_with_whitespace():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
""" This should be stripped """
|
|
||||||
|
|
||||||
|
|
||||||
def docstring_with_inline_tabs_and_space_indentation():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
"""hey
|
|
||||||
|
|
||||||
tab separated value
|
|
||||||
tab at start of line and then a tab separated value
|
|
||||||
multiple tabs at the beginning and inline
|
|
||||||
mixed tabs and spaces at beginning. next line has mixed tabs and spaces only.
|
|
||||||
|
|
||||||
line ends with some tabs
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
def docstring_with_inline_tabs_and_tab_indentation():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
"""hey
|
|
||||||
|
|
||||||
tab separated value
|
|
||||||
tab at start of line and then a tab separated value
|
|
||||||
multiple tabs at the beginning and inline
|
|
||||||
mixed tabs and spaces at beginning. next line has mixed tabs and spaces only.
|
|
||||||
|
|
||||||
line ends with some tabs
|
|
||||||
"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def backslash_space():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
"""\ """
|
|
||||||
|
|
||||||
|
|
||||||
def multiline_backslash_1():
|
|
||||||
'''
|
|
||||||
hey\there\
|
|
||||||
\ '''
|
|
||||||
|
|
||||||
|
|
||||||
def multiline_backslash_2():
|
|
||||||
'''
|
|
||||||
hey there \ '''
|
|
||||||
|
|
||||||
|
|
||||||
# Regression test for #3425
|
# Regression test for #3425
|
||||||
def multiline_backslash_really_long_dont_crash():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
"""
|
|
||||||
hey there hello guten tag hi hoow are you ola zdravstvuyte ciao como estas ca va \ """
|
|
||||||
|
|
||||||
|
|
||||||
def multiline_backslash_3():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
'''
|
|
||||||
already escaped \\ '''
|
|
||||||
|
|
||||||
|
|
||||||
def my_god_its_full_of_stars_1():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
"I'm sorry Dave\u2001"
|
|
||||||
|
|
||||||
|
|
||||||
# the space below is actually a \u2001, removed in output
|
# the space below is actually a \u2001, removed in output
|
||||||
def my_god_its_full_of_stars_2():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
"I'm sorry Dave "
|
|
||||||
|
|
||||||
|
|
||||||
def docstring_almost_at_line_limit():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
"""long docstring................................................................."""
|
|
||||||
|
|
||||||
|
|
||||||
def docstring_almost_at_line_limit2():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
"""long docstring.................................................................
|
|
||||||
|
|
||||||
..................................................................................
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
def docstring_at_line_limit():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
"""long docstring................................................................"""
|
|
||||||
|
|
||||||
|
|
||||||
def multiline_docstring_at_line_limit():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
"""first line-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
second line----------------------------------------------------------------------"""
|
|
||||||
|
|
||||||
|
|
||||||
def stable_quote_normalization_with_immediate_inner_single_quote(self):
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
''''<text here>
|
|
||||||
|
|
||||||
<text here, since without another non-empty line black is stable>
|
|
||||||
'''
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -105,162 +105,116 @@ def g():
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -3,9 +3,9 @@
|
@@ -1,89 +1,12 @@
|
||||||
|
-"""Docstring."""
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprConstant
|
||||||
|
|
||||||
|
|
||||||
# leading comment
|
# leading comment
|
||||||
def f():
|
-def f():
|
||||||
- NO = ""
|
- NO = ""
|
||||||
- SPACE = " "
|
- SPACE = " "
|
||||||
- DOUBLESPACE = " "
|
- DOUBLESPACE = " "
|
||||||
+ NO = ''
|
-
|
||||||
+ SPACE = ' '
|
- t = leaf.type
|
||||||
+ DOUBLESPACE = ' '
|
- p = leaf.parent # trailing comment
|
||||||
|
- v = leaf.value
|
||||||
|
-
|
||||||
|
- if t in ALWAYS_NO_SPACE:
|
||||||
|
- pass
|
||||||
|
- if t == token.COMMENT: # another trailing comment
|
||||||
|
- return DOUBLESPACE
|
||||||
|
-
|
||||||
|
- assert p is not None, f"INTERNAL ERROR: hand-made leaf without parent: {leaf!r}"
|
||||||
|
-
|
||||||
|
- prev = leaf.prev_sibling
|
||||||
|
- if not prev:
|
||||||
|
- prevp = preceding_leaf(p)
|
||||||
|
- if not prevp or prevp.type in OPENING_BRACKETS:
|
||||||
|
- return NO
|
||||||
|
-
|
||||||
|
- if prevp.type == token.EQUAL:
|
||||||
|
- if prevp.parent and prevp.parent.type in {
|
||||||
|
- syms.typedargslist,
|
||||||
|
- syms.varargslist,
|
||||||
|
- syms.parameters,
|
||||||
|
- syms.arglist,
|
||||||
|
- syms.argument,
|
||||||
|
- }:
|
||||||
|
- return NO
|
||||||
|
-
|
||||||
|
- elif prevp.type == token.DOUBLESTAR:
|
||||||
|
- if prevp.parent and prevp.parent.type in {
|
||||||
|
- syms.typedargslist,
|
||||||
|
- syms.varargslist,
|
||||||
|
- syms.parameters,
|
||||||
|
- syms.arglist,
|
||||||
|
- syms.dictsetmaker,
|
||||||
|
- }:
|
||||||
|
- return NO
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
t = leaf.type
|
|
||||||
p = leaf.parent # trailing comment
|
|
||||||
@@ -16,14 +16,19 @@
|
|
||||||
if t == token.COMMENT: # another trailing comment
|
|
||||||
return DOUBLESPACE
|
|
||||||
|
|
||||||
+
|
|
||||||
assert p is not None, f"INTERNAL ERROR: hand-made leaf without parent: {leaf!r}"
|
|
||||||
|
|
||||||
+
|
|
||||||
prev = leaf.prev_sibling
|
|
||||||
if not prev:
|
|
||||||
prevp = preceding_leaf(p)
|
|
||||||
if not prevp or prevp.type in OPENING_BRACKETS:
|
|
||||||
+
|
|
||||||
+
|
|
||||||
return NO
|
|
||||||
|
|
||||||
+
|
|
||||||
if prevp.type == token.EQUAL:
|
|
||||||
if prevp.parent and prevp.parent.type in {
|
|
||||||
syms.typedargslist,
|
|
||||||
@@ -48,12 +53,11 @@
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# SECTION BECAUSE SECTIONS
|
# SECTION BECAUSE SECTIONS
|
||||||
###############################################################################
|
###############################################################################
|
||||||
-
|
-
|
||||||
|
|
||||||
def g():
|
-def g():
|
||||||
- NO = ""
|
- NO = ""
|
||||||
- SPACE = " "
|
- SPACE = " "
|
||||||
- DOUBLESPACE = " "
|
- DOUBLESPACE = " "
|
||||||
+ NO = ''
|
-
|
||||||
+ SPACE = ' '
|
- t = leaf.type
|
||||||
+ DOUBLESPACE = ' '
|
- p = leaf.parent
|
||||||
|
- v = leaf.value
|
||||||
t = leaf.type
|
-
|
||||||
p = leaf.parent
|
- # Comment because comments
|
||||||
@@ -67,7 +71,7 @@
|
-
|
||||||
return DOUBLESPACE
|
- if t in ALWAYS_NO_SPACE:
|
||||||
|
- pass
|
||||||
# Another comment because more comments
|
- if t == token.COMMENT:
|
||||||
|
- return DOUBLESPACE
|
||||||
|
-
|
||||||
|
- # Another comment because more comments
|
||||||
- assert p is not None, f"INTERNAL ERROR: hand-made leaf without parent: {leaf!r}"
|
- assert p is not None, f"INTERNAL ERROR: hand-made leaf without parent: {leaf!r}"
|
||||||
+ assert p is not None, f'INTERNAL ERROR: hand-made leaf without parent: {leaf!r}'
|
-
|
||||||
|
- prev = leaf.prev_sibling
|
||||||
prev = leaf.prev_sibling
|
- if not prev:
|
||||||
if not prev:
|
- prevp = preceding_leaf(p)
|
||||||
|
-
|
||||||
|
- if not prevp or prevp.type in OPENING_BRACKETS:
|
||||||
|
- # Start of the line or a bracketed expression.
|
||||||
|
- # More than one line for the comment.
|
||||||
|
- return NO
|
||||||
|
-
|
||||||
|
- if prevp.type == token.EQUAL:
|
||||||
|
- if prevp.parent and prevp.parent.type in {
|
||||||
|
- syms.typedargslist,
|
||||||
|
- syms.varargslist,
|
||||||
|
- syms.parameters,
|
||||||
|
- syms.arglist,
|
||||||
|
- syms.argument,
|
||||||
|
- }:
|
||||||
|
- return NO
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
"""Docstring."""
|
NOT_YET_IMPLEMENTED_ExprConstant
|
||||||
|
|
||||||
|
|
||||||
# leading comment
|
# leading comment
|
||||||
def f():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
NO = ''
|
|
||||||
SPACE = ' '
|
|
||||||
DOUBLESPACE = ' '
|
|
||||||
|
|
||||||
t = leaf.type
|
|
||||||
p = leaf.parent # trailing comment
|
|
||||||
v = leaf.value
|
|
||||||
|
|
||||||
if t in ALWAYS_NO_SPACE:
|
|
||||||
pass
|
|
||||||
if t == token.COMMENT: # another trailing comment
|
|
||||||
return DOUBLESPACE
|
|
||||||
|
|
||||||
|
|
||||||
assert p is not None, f"INTERNAL ERROR: hand-made leaf without parent: {leaf!r}"
|
|
||||||
|
|
||||||
|
|
||||||
prev = leaf.prev_sibling
|
|
||||||
if not prev:
|
|
||||||
prevp = preceding_leaf(p)
|
|
||||||
if not prevp or prevp.type in OPENING_BRACKETS:
|
|
||||||
|
|
||||||
|
|
||||||
return NO
|
|
||||||
|
|
||||||
|
|
||||||
if prevp.type == token.EQUAL:
|
|
||||||
if prevp.parent and prevp.parent.type in {
|
|
||||||
syms.typedargslist,
|
|
||||||
syms.varargslist,
|
|
||||||
syms.parameters,
|
|
||||||
syms.arglist,
|
|
||||||
syms.argument,
|
|
||||||
}:
|
|
||||||
return NO
|
|
||||||
|
|
||||||
elif prevp.type == token.DOUBLESTAR:
|
|
||||||
if prevp.parent and prevp.parent.type in {
|
|
||||||
syms.typedargslist,
|
|
||||||
syms.varargslist,
|
|
||||||
syms.parameters,
|
|
||||||
syms.arglist,
|
|
||||||
syms.dictsetmaker,
|
|
||||||
}:
|
|
||||||
return NO
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# SECTION BECAUSE SECTIONS
|
# SECTION BECAUSE SECTIONS
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
def g():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
NO = ''
|
|
||||||
SPACE = ' '
|
|
||||||
DOUBLESPACE = ' '
|
|
||||||
|
|
||||||
t = leaf.type
|
|
||||||
p = leaf.parent
|
|
||||||
v = leaf.value
|
|
||||||
|
|
||||||
# Comment because comments
|
|
||||||
|
|
||||||
if t in ALWAYS_NO_SPACE:
|
|
||||||
pass
|
|
||||||
if t == token.COMMENT:
|
|
||||||
return DOUBLESPACE
|
|
||||||
|
|
||||||
# Another comment because more comments
|
|
||||||
assert p is not None, f'INTERNAL ERROR: hand-made leaf without parent: {leaf!r}'
|
|
||||||
|
|
||||||
prev = leaf.prev_sibling
|
|
||||||
if not prev:
|
|
||||||
prevp = preceding_leaf(p)
|
|
||||||
|
|
||||||
if not prevp or prevp.type in OPENING_BRACKETS:
|
|
||||||
# Start of the line or a bracketed expression.
|
|
||||||
# More than one line for the comment.
|
|
||||||
return NO
|
|
||||||
|
|
||||||
if prevp.type == token.EQUAL:
|
|
||||||
if prevp.parent and prevp.parent.type in {
|
|
||||||
syms.typedargslist,
|
|
||||||
syms.varargslist,
|
|
||||||
syms.parameters,
|
|
||||||
syms.arglist,
|
|
||||||
syms.argument,
|
|
||||||
}:
|
|
||||||
return NO
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -53,46 +53,67 @@ def test_calculate_fades():
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -3,6 +3,7 @@
|
@@ -1,40 +1,26 @@
|
||||||
TmSt = 1
|
-import pytest
|
||||||
TmEx = 2
|
+NOT_YET_IMPLEMENTED_StmtImport
|
||||||
|
|
||||||
|
-TmSt = 1
|
||||||
|
-TmEx = 2
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
+
|
+
|
||||||
|
|
||||||
# fmt: off
|
# fmt: off
|
||||||
|
|
||||||
# Test data:
|
# Test data:
|
||||||
@@ -18,18 +19,22 @@
|
# Position, Volume, State, TmSt/TmEx/None, [call, [arg1...]]
|
||||||
def test_fader(test):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
-@pytest.mark.parametrize('test', [
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+
|
+
|
||||||
def check_fader(test):
|
|
||||||
|
|
||||||
pass
|
|
||||||
|
|
||||||
+
|
+
|
||||||
def verify_fader(test):
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
# misaligned comment
|
|
||||||
pass
|
|
||||||
|
|
||||||
+
|
- # Test don't manage the volume
|
||||||
def verify_fader(test):
|
- [
|
||||||
"""Hey, ho."""
|
- ('stuff', 'in')
|
||||||
assert test.passed()
|
- ],
|
||||||
|
-])
|
||||||
|
-def test_fader(test):
|
||||||
|
- pass
|
||||||
|
|
||||||
+
|
-def check_fader(test):
|
||||||
def test_calculate_fades():
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
calcs = [
|
|
||||||
# one is zero/none
|
- pass
|
||||||
|
|
||||||
|
-def verify_fader(test):
|
||||||
|
- # misaligned comment
|
||||||
|
- pass
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
-def verify_fader(test):
|
||||||
|
- """Hey, ho."""
|
||||||
|
- assert test.passed()
|
||||||
|
|
||||||
|
-def test_calculate_fades():
|
||||||
|
- calcs = [
|
||||||
|
- # one is zero/none
|
||||||
|
- (0, 4, 0, 0, 10, 0, 0, 6, 10),
|
||||||
|
- (None, 4, 0, 0, 10, 0, 0, 6, 10),
|
||||||
|
- ]
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
# fmt: on
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
import pytest
|
NOT_YET_IMPLEMENTED_StmtImport
|
||||||
|
|
||||||
TmSt = 1
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
TmEx = 2
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
|
|
||||||
# fmt: off
|
# fmt: off
|
||||||
|
@ -100,38 +121,19 @@ TmEx = 2
|
||||||
# Test data:
|
# Test data:
|
||||||
# Position, Volume, State, TmSt/TmEx/None, [call, [arg1...]]
|
# Position, Volume, State, TmSt/TmEx/None, [call, [arg1...]]
|
||||||
|
|
||||||
@pytest.mark.parametrize('test', [
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
# Test don't manage the volume
|
|
||||||
[
|
|
||||||
('stuff', 'in')
|
|
||||||
],
|
|
||||||
])
|
|
||||||
def test_fader(test):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def check_fader(test):
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def verify_fader(test):
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
# misaligned comment
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def verify_fader(test):
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
"""Hey, ho."""
|
|
||||||
assert test.passed()
|
|
||||||
|
|
||||||
|
|
||||||
def test_calculate_fades():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
calcs = [
|
|
||||||
# one is zero/none
|
|
||||||
(0, 4, 0, 0, 10, 0, 0, 6, 10),
|
|
||||||
(None, 4, 0, 0, 10, 0, 0, 6, 10),
|
|
||||||
]
|
|
||||||
|
|
||||||
# fmt: on
|
# fmt: on
|
||||||
```
|
```
|
||||||
|
|
|
@ -30,36 +30,39 @@ x = [
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -12,4 +12,6 @@
|
@@ -1,15 +1,9 @@
|
||||||
]
|
# fmt: off
|
||||||
|
-x = [
|
||||||
|
- 1, 2,
|
||||||
|
- 3, 4,
|
||||||
|
-]
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
# fmt: on
|
||||||
|
|
||||||
|
# fmt: off
|
||||||
|
-x = [
|
||||||
|
- 1, 2,
|
||||||
|
- 3, 4,
|
||||||
|
-]
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
# fmt: on
|
# fmt: on
|
||||||
|
|
||||||
-x = [1, 2, 3, 4]
|
-x = [1, 2, 3, 4]
|
||||||
+x = [
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
+ 1, 2, 3, 4
|
|
||||||
+]
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
# fmt: off
|
# fmt: off
|
||||||
x = [
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
1, 2,
|
|
||||||
3, 4,
|
|
||||||
]
|
|
||||||
# fmt: on
|
# fmt: on
|
||||||
|
|
||||||
# fmt: off
|
# fmt: off
|
||||||
x = [
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
1, 2,
|
|
||||||
3, 4,
|
|
||||||
]
|
|
||||||
# fmt: on
|
# fmt: on
|
||||||
|
|
||||||
x = [
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
1, 2, 3, 4
|
|
||||||
]
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -26,13 +26,16 @@ def f(): pass
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -4,17 +4,11 @@
|
@@ -1,20 +1,5 @@
|
||||||
3, 4,
|
# fmt: off
|
||||||
])
|
-@test([
|
||||||
# fmt: on
|
- 1, 2,
|
||||||
|
- 3, 4,
|
||||||
|
-])
|
||||||
|
-# fmt: on
|
||||||
-def f():
|
-def f():
|
||||||
- pass
|
- pass
|
||||||
+def f(): pass
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
-@test(
|
-@test(
|
||||||
|
@ -45,30 +48,17 @@ def f(): pass
|
||||||
-)
|
-)
|
||||||
-def f():
|
-def f():
|
||||||
- pass
|
- pass
|
||||||
+@test([
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+ 1, 2,
|
|
||||||
+ 3, 4,
|
|
||||||
+])
|
|
||||||
+def f(): pass
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
# fmt: off
|
# fmt: off
|
||||||
@test([
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
1, 2,
|
|
||||||
3, 4,
|
|
||||||
])
|
|
||||||
# fmt: on
|
|
||||||
def f(): pass
|
|
||||||
|
|
||||||
|
|
||||||
@test([
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
1, 2,
|
|
||||||
3, 4,
|
|
||||||
])
|
|
||||||
def f(): pass
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -97,133 +97,136 @@ elif unformatted:
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -44,7 +44,7 @@
|
@@ -1,87 +1,29 @@
|
||||||
print ( "This won't be formatted" )
|
# Regression test for https://github.com/psf/black/issues/3129.
|
||||||
print ( "This won't be formatted either" )
|
-setup(
|
||||||
else:
|
- entry_points={
|
||||||
|
- # fmt: off
|
||||||
|
- "console_scripts": [
|
||||||
|
- "foo-bar"
|
||||||
|
- "=foo.bar.:main",
|
||||||
|
- # fmt: on
|
||||||
|
- ] # Includes an formatted indentation.
|
||||||
|
- },
|
||||||
|
-)
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprCall
|
||||||
|
|
||||||
|
|
||||||
|
# Regression test for https://github.com/psf/black/issues/2015.
|
||||||
|
-run(
|
||||||
|
- # fmt: off
|
||||||
|
- [
|
||||||
|
- "ls",
|
||||||
|
- "-la",
|
||||||
|
- ]
|
||||||
|
- # fmt: on
|
||||||
|
- + path,
|
||||||
|
- check=True,
|
||||||
|
-)
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprCall
|
||||||
|
|
||||||
|
|
||||||
|
# Regression test for https://github.com/psf/black/issues/3026.
|
||||||
|
-def test_func():
|
||||||
|
- # yapf: disable
|
||||||
|
- if unformatted( args ):
|
||||||
|
- return True
|
||||||
|
- # yapf: enable
|
||||||
|
- elif b:
|
||||||
|
- return True
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
- return False
|
||||||
|
|
||||||
|
-
|
||||||
|
# Regression test for https://github.com/psf/black/issues/2567.
|
||||||
|
-if True:
|
||||||
|
- # fmt: off
|
||||||
|
- for _ in range( 1 ):
|
||||||
|
- # fmt: on
|
||||||
|
- print ( "This won't be formatted" )
|
||||||
|
- print ( "This won't be formatted either" )
|
||||||
|
-else:
|
||||||
- print("This will be formatted")
|
- print("This will be formatted")
|
||||||
+ print ( "This will be formatted" )
|
+NOT_YET_IMPLEMENTED_StmtIf
|
||||||
|
|
||||||
|
|
||||||
# Regression test for https://github.com/psf/black/issues/3184.
|
# Regression test for https://github.com/psf/black/issues/3184.
|
||||||
@@ -61,7 +61,7 @@
|
-class A:
|
||||||
elif param[0:4] in ("ZZZZ",):
|
- async def call(param):
|
||||||
print ( "This won't be formatted either" )
|
- if param:
|
||||||
|
- # fmt: off
|
||||||
|
- if param[0:4] in (
|
||||||
|
- "ABCD", "EFGH"
|
||||||
|
- ) :
|
||||||
|
- # fmt: on
|
||||||
|
- print ( "This won't be formatted" )
|
||||||
|
-
|
||||||
|
- elif param[0:4] in ("ZZZZ",):
|
||||||
|
- print ( "This won't be formatted either" )
|
||||||
|
-
|
||||||
- print("This will be formatted")
|
- print("This will be formatted")
|
||||||
+ print ( "This will be formatted" )
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
|
|
||||||
|
|
||||||
# Regression test for https://github.com/psf/black/issues/2985.
|
# Regression test for https://github.com/psf/black/issues/2985.
|
||||||
@@ -72,10 +72,7 @@
|
-class Named(t.Protocol):
|
||||||
|
- # fmt: off
|
||||||
|
- @property
|
||||||
|
- def this_wont_be_formatted ( self ) -> str: ...
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
|
|
||||||
|
|
||||||
class Factory(t.Protocol):
|
-class Factory(t.Protocol):
|
||||||
- def this_will_be_formatted(self, **kwargs) -> Named:
|
- def this_will_be_formatted(self, **kwargs) -> Named:
|
||||||
- ...
|
- ...
|
||||||
-
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
- # fmt: on
|
|
||||||
+ def this_will_be_formatted ( self, **kwargs ) -> Named: ...
|
|
||||||
|
|
||||||
|
- # fmt: on
|
||||||
|
-
|
||||||
|
|
||||||
# Regression test for https://github.com/psf/black/issues/3436.
|
# Regression test for https://github.com/psf/black/issues/3436.
|
||||||
@@ -83,5 +80,5 @@
|
-if x:
|
||||||
return x
|
- return x
|
||||||
# fmt: off
|
-# fmt: off
|
||||||
elif unformatted:
|
-elif unformatted:
|
||||||
- # fmt: on
|
- # fmt: on
|
||||||
- will_be_formatted()
|
- will_be_formatted()
|
||||||
+# fmt: on
|
+NOT_YET_IMPLEMENTED_StmtIf
|
||||||
+ will_be_formatted ()
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
# Regression test for https://github.com/psf/black/issues/3129.
|
# Regression test for https://github.com/psf/black/issues/3129.
|
||||||
setup(
|
NOT_YET_IMPLEMENTED_ExprCall
|
||||||
entry_points={
|
|
||||||
# fmt: off
|
|
||||||
"console_scripts": [
|
|
||||||
"foo-bar"
|
|
||||||
"=foo.bar.:main",
|
|
||||||
# fmt: on
|
|
||||||
] # Includes an formatted indentation.
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# Regression test for https://github.com/psf/black/issues/2015.
|
# Regression test for https://github.com/psf/black/issues/2015.
|
||||||
run(
|
NOT_YET_IMPLEMENTED_ExprCall
|
||||||
# fmt: off
|
|
||||||
[
|
|
||||||
"ls",
|
|
||||||
"-la",
|
|
||||||
]
|
|
||||||
# fmt: on
|
|
||||||
+ path,
|
|
||||||
check=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# Regression test for https://github.com/psf/black/issues/3026.
|
# Regression test for https://github.com/psf/black/issues/3026.
|
||||||
def test_func():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
# yapf: disable
|
|
||||||
if unformatted( args ):
|
|
||||||
return True
|
|
||||||
# yapf: enable
|
|
||||||
elif b:
|
|
||||||
return True
|
|
||||||
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
# Regression test for https://github.com/psf/black/issues/2567.
|
# Regression test for https://github.com/psf/black/issues/2567.
|
||||||
if True:
|
NOT_YET_IMPLEMENTED_StmtIf
|
||||||
# fmt: off
|
|
||||||
for _ in range( 1 ):
|
|
||||||
# fmt: on
|
|
||||||
print ( "This won't be formatted" )
|
|
||||||
print ( "This won't be formatted either" )
|
|
||||||
else:
|
|
||||||
print ( "This will be formatted" )
|
|
||||||
|
|
||||||
|
|
||||||
# Regression test for https://github.com/psf/black/issues/3184.
|
# Regression test for https://github.com/psf/black/issues/3184.
|
||||||
class A:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
async def call(param):
|
|
||||||
if param:
|
|
||||||
# fmt: off
|
|
||||||
if param[0:4] in (
|
|
||||||
"ABCD", "EFGH"
|
|
||||||
) :
|
|
||||||
# fmt: on
|
|
||||||
print ( "This won't be formatted" )
|
|
||||||
|
|
||||||
elif param[0:4] in ("ZZZZ",):
|
|
||||||
print ( "This won't be formatted either" )
|
|
||||||
|
|
||||||
print ( "This will be formatted" )
|
|
||||||
|
|
||||||
|
|
||||||
# Regression test for https://github.com/psf/black/issues/2985.
|
# Regression test for https://github.com/psf/black/issues/2985.
|
||||||
class Named(t.Protocol):
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
# fmt: off
|
|
||||||
@property
|
|
||||||
def this_wont_be_formatted ( self ) -> str: ...
|
|
||||||
|
|
||||||
|
|
||||||
class Factory(t.Protocol):
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
def this_will_be_formatted ( self, **kwargs ) -> Named: ...
|
|
||||||
|
|
||||||
|
|
||||||
# Regression test for https://github.com/psf/black/issues/3436.
|
# Regression test for https://github.com/psf/black/issues/3436.
|
||||||
if x:
|
NOT_YET_IMPLEMENTED_StmtIf
|
||||||
return x
|
|
||||||
# fmt: off
|
|
||||||
elif unformatted:
|
|
||||||
# fmt: on
|
|
||||||
will_be_formatted ()
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -199,58 +199,60 @@ d={'a':1,
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -4,17 +4,18 @@
|
@@ -1,224 +1,73 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
-import asyncio
|
||||||
|
-import sys
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtImport
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtImport
|
||||||
|
|
||||||
from third_party import X, Y, Z
|
-from third_party import X, Y, Z
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
|
|
||||||
-from library import some_connection, some_decorator
|
-from library import some_connection, some_decorator
|
||||||
-
|
-
|
||||||
+from library import some_connection, \
|
+NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
+ some_decorator
|
|
||||||
# fmt: off
|
# fmt: off
|
||||||
from third_party import (X,
|
-from third_party import (X,
|
||||||
Y, Z)
|
- Y, Z)
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
# fmt: on
|
# fmt: on
|
||||||
-f"trigger 3.6 mode"
|
-f"trigger 3.6 mode"
|
||||||
+f'trigger 3.6 mode'
|
+NOT_YET_IMPLEMENTED_ExprJoinedStr
|
||||||
+
|
+
|
||||||
+
|
+
|
||||||
# Comment 1
|
# Comment 1
|
||||||
|
|
||||||
# Comment 2
|
# Comment 2
|
||||||
-
|
|
||||||
|
|
||||||
|
-
|
||||||
# fmt: off
|
# fmt: off
|
||||||
def func_no_args():
|
-def func_no_args():
|
||||||
@@ -26,11 +27,15 @@
|
- a; b; c
|
||||||
continue
|
- if True: raise RuntimeError
|
||||||
exec('new-style exec', {}, {})
|
- if False: ...
|
||||||
return None
|
- for i in range(10):
|
||||||
+
|
- print(i)
|
||||||
+
|
- continue
|
||||||
async def coroutine(arg, exec=False):
|
- exec('new-style exec', {}, {})
|
||||||
'Single-line docstring. Multiline is harder to reformat.'
|
- return None
|
||||||
async with some_connection() as conn:
|
-async def coroutine(arg, exec=False):
|
||||||
await conn.do_what_i_mean('SELECT bobby, tables FROM xkcd', timeout=2)
|
- 'Single-line docstring. Multiline is harder to reformat.'
|
||||||
await asyncio.sleep(1)
|
- async with some_connection() as conn:
|
||||||
+
|
- await conn.do_what_i_mean('SELECT bobby, tables FROM xkcd', timeout=2)
|
||||||
+
|
- await asyncio.sleep(1)
|
||||||
@asyncio.coroutine
|
-@asyncio.coroutine
|
||||||
@some_decorator(
|
-@some_decorator(
|
||||||
with_args=True,
|
-with_args=True,
|
||||||
@@ -38,28 +43,19 @@
|
-many_args=[1,2,3]
|
||||||
)
|
-)
|
||||||
def function_signature_stress_test(number:int,no_annotation=None,text:str='default',* ,debug:bool=False,**kwargs) -> str:
|
-def function_signature_stress_test(number:int,no_annotation=None,text:str='default',* ,debug:bool=False,**kwargs) -> str:
|
||||||
return text[number:-1]
|
- return text[number:-1]
|
||||||
+
|
-# fmt: on
|
||||||
+
|
|
||||||
# fmt: on
|
|
||||||
-def spaces(a=1, b=(), c=[], d={}, e=True, f=-1, g=1 if False else 2, h="", i=r""):
|
-def spaces(a=1, b=(), c=[], d={}, e=True, f=-1, g=1 if False else 2, h="", i=r""):
|
||||||
- offset = attr.ib(default=attr.Factory(lambda: _r.uniform(1, 2)))
|
- offset = attr.ib(default=attr.Factory(lambda: _r.uniform(1, 2)))
|
||||||
- assert task._cancel_stack[: len(old_stack)] == old_stack
|
- assert task._cancel_stack[: len(old_stack)] == old_stack
|
||||||
+def spaces(a=1, b=(), c=[], d={}, e=True, f=-1, g=1 if False else 2, h="", i=r''):
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+ offset = attr.ib(default=attr.Factory( lambda: _r.uniform(1, 2)))
|
|
||||||
+ assert task._cancel_stack[:len(old_stack)] == old_stack
|
|
||||||
|
|
||||||
|
|
||||||
-def spaces_types(
|
-def spaces_types(
|
||||||
|
@ -265,115 +267,162 @@ d={'a':1,
|
||||||
- i: str = r"",
|
- i: str = r"",
|
||||||
-):
|
-):
|
||||||
- ...
|
- ...
|
||||||
+def spaces_types(a: int = 1, b: tuple = (), c: list = [], d: dict = {}, e: bool = True, f: int = -1, g: int = 1 if False else 2, h: str = "", i: str = r''): ...
|
+NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
|
|
||||||
|
|
||||||
-def spaces2(result=_core.Value(None)):
|
-def spaces2(result=_core.Value(None)):
|
||||||
- ...
|
- ...
|
||||||
+def spaces2(result= _core.Value(None)):
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+ ...
|
|
||||||
|
|
||||||
|
|
||||||
something = {
|
-something = {
|
||||||
@@ -74,23 +70,20 @@
|
- # fmt: off
|
||||||
'some big and',
|
- key: 'value',
|
||||||
'complex subscript',
|
-}
|
||||||
# fmt: on
|
+# fmt: on
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
-def subscriptlist():
|
||||||
|
- atom[
|
||||||
|
- # fmt: off
|
||||||
|
- 'some big and',
|
||||||
|
- 'complex subscript',
|
||||||
|
- # fmt: on
|
||||||
- goes + here,
|
- goes + here,
|
||||||
- andhere,
|
- andhere,
|
||||||
- ]
|
- ]
|
||||||
+ goes + here, andhere,
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+ ]
|
|
||||||
|
|
||||||
|
|
||||||
def import_as_names():
|
-def import_as_names():
|
||||||
# fmt: off
|
- # fmt: off
|
||||||
from hello import a, b
|
- from hello import a, b
|
||||||
'unformatted'
|
- 'unformatted'
|
||||||
- # fmt: on
|
- # fmt: on
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
def testlist_star_expr():
|
-def testlist_star_expr():
|
||||||
# fmt: off
|
- # fmt: off
|
||||||
a , b = *hello
|
- a , b = *hello
|
||||||
'unformatted'
|
- 'unformatted'
|
||||||
- # fmt: on
|
- # fmt: on
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
|
|
||||||
def yield_expr():
|
-def yield_expr():
|
||||||
@@ -98,11 +91,10 @@
|
- # fmt: off
|
||||||
yield hello
|
- yield hello
|
||||||
'unformatted'
|
- 'unformatted'
|
||||||
# fmt: on
|
- # fmt: on
|
||||||
- "formatted"
|
- "formatted"
|
||||||
+ 'formatted'
|
- # fmt: off
|
||||||
# fmt: off
|
- ( yield hello )
|
||||||
( yield hello )
|
- 'unformatted'
|
||||||
'unformatted'
|
|
||||||
- # fmt: on
|
- # fmt: on
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
def example(session):
|
-def example(session):
|
||||||
@@ -113,7 +105,6 @@
|
- # fmt: off
|
||||||
models.Customer.email == email_address)\
|
- result = session\
|
||||||
.order_by(models.Customer.id.asc())\
|
- .query(models.Customer.id)\
|
||||||
.all()
|
- .filter(models.Customer.account_id == account_id,
|
||||||
|
- models.Customer.email == email_address)\
|
||||||
|
- .order_by(models.Customer.id.asc())\
|
||||||
|
- .all()
|
||||||
- # fmt: on
|
- # fmt: on
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
def off_and_on_without_data():
|
-def off_and_on_without_data():
|
||||||
@@ -123,8 +114,10 @@
|
- """All comments here are technically on the same prefix.
|
||||||
"""
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
# fmt: off
|
|
||||||
|
- The comments between will be formatted. This is a known limitation.
|
||||||
|
- """
|
||||||
|
- # fmt: off
|
||||||
|
|
||||||
- # hey, that won't work
|
- # hey, that won't work
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
+ #hey, that won't work
|
- # fmt: on
|
||||||
+
|
- pass
|
||||||
+
|
|
||||||
# fmt: on
|
|
||||||
pass
|
|
||||||
|
|
||||||
@@ -137,21 +130,12 @@
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
and_=indeed . it is not formatted
|
|
||||||
because . the . handling . inside . generate_ignored_nodes()
|
-def on_and_off_broken():
|
||||||
now . considers . multiple . fmt . directives . within . one . prefix
|
- """Another known limitation."""
|
||||||
|
- # fmt: on
|
||||||
|
- # fmt: off
|
||||||
|
- this=should.not_be.formatted()
|
||||||
|
- and_=indeed . it is not formatted
|
||||||
|
- because . the . handling . inside . generate_ignored_nodes()
|
||||||
|
- now . considers . multiple . fmt . directives . within . one . prefix
|
||||||
- # fmt: on
|
- # fmt: on
|
||||||
- # fmt: off
|
- # fmt: off
|
||||||
- # ...but comments still get reformatted even though they should not be
|
- # ...but comments still get reformatted even though they should not be
|
||||||
- # fmt: on
|
- # fmt: on
|
||||||
|
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
def long_lines():
|
-def long_lines():
|
||||||
if True:
|
- if True:
|
||||||
typedargslist.extend(
|
- typedargslist.extend(
|
||||||
- gen_annotated_params(
|
- gen_annotated_params(
|
||||||
- ast_args.kwonlyargs,
|
- ast_args.kwonlyargs,
|
||||||
- ast_args.kw_defaults,
|
- ast_args.kw_defaults,
|
||||||
- parameters,
|
- parameters,
|
||||||
- implicit_default=True,
|
- implicit_default=True,
|
||||||
- )
|
- )
|
||||||
+ gen_annotated_params(ast_args.kwonlyargs, ast_args.kw_defaults, parameters, implicit_default=True)
|
- )
|
||||||
)
|
- # fmt: off
|
||||||
# fmt: off
|
- a = (
|
||||||
a = (
|
- unnecessary_bracket()
|
||||||
@@ -186,20 +170,19 @@
|
- )
|
||||||
|
- # fmt: on
|
||||||
|
- _type_comment_re = re.compile(
|
||||||
|
- r"""
|
||||||
|
- ^
|
||||||
|
- [\t ]*
|
||||||
|
- \#[ ]type:[ ]*
|
||||||
|
- (?P<type>
|
||||||
|
- [^#\t\n]+?
|
||||||
|
- )
|
||||||
|
- (?<!ignore) # note: this will force the non-greedy + in <type> to match
|
||||||
|
- # a trailing space which is why we need the silliness below
|
||||||
|
- (?<!ignore[ ]{1})(?<!ignore[ ]{2})(?<!ignore[ ]{3})(?<!ignore[ ]{4})
|
||||||
|
- (?<!ignore[ ]{5})(?<!ignore[ ]{6})(?<!ignore[ ]{7})(?<!ignore[ ]{8})
|
||||||
|
- (?<!ignore[ ]{9})(?<!ignore[ ]{10})
|
||||||
|
- [\t ]*
|
||||||
|
- (?P<nl>
|
||||||
|
- (?:\#[^\n]*)?
|
||||||
|
- \n?
|
||||||
|
- )
|
||||||
|
- $
|
||||||
|
- """,
|
||||||
|
- # fmt: off
|
||||||
|
- re.MULTILINE|re.VERBOSE
|
||||||
|
- # fmt: on
|
||||||
|
- )
|
||||||
|
|
||||||
def single_literal_yapf_disable():
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
"""Black does not support this."""
|
|
||||||
|
-def single_literal_yapf_disable():
|
||||||
|
- """Black does not support this."""
|
||||||
- BAZ = {(1, 2, 3, 4), (5, 6, 7, 8), (9, 10, 11, 12)} # yapf: disable
|
- BAZ = {(1, 2, 3, 4), (5, 6, 7, 8), (9, 10, 11, 12)} # yapf: disable
|
||||||
+ BAZ = {
|
|
||||||
+ (1, 2, 3, 4),
|
|
||||||
+ (5, 6, 7, 8),
|
|
||||||
+ (9, 10, 11, 12)
|
|
||||||
+ }
|
|
||||||
|
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
+
|
||||||
|
|
||||||
cfg.rule(
|
-cfg.rule(
|
||||||
- "Default",
|
- "Default",
|
||||||
- "address",
|
- "address",
|
||||||
+ "Default", "address",
|
- xxxx_xxxx=["xxx-xxxxxx-xxxxxxxxxx"],
|
||||||
xxxx_xxxx=["xxx-xxxxxx-xxxxxxxxxx"],
|
|
||||||
- xxxxxx="xx_xxxxx",
|
- xxxxxx="xx_xxxxx",
|
||||||
- xxxxxxx="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
- xxxxxxx="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||||
- xxxxxxxxx_xxxx=True,
|
- xxxxxxxxx_xxxx=True,
|
||||||
|
@ -381,39 +430,48 @@ d={'a':1,
|
||||||
- xxxxxx_xxxxxx=2,
|
- xxxxxx_xxxxxx=2,
|
||||||
- xxxxxx_xxxxx_xxxxxxxx=70,
|
- xxxxxx_xxxxx_xxxxxxxx=70,
|
||||||
- xxxxxx_xxxxxx_xxxxx=True,
|
- xxxxxx_xxxxxx_xxxxx=True,
|
||||||
+ xxxxxx="xx_xxxxx", xxxxxxx="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
- # fmt: off
|
||||||
+ xxxxxxxxx_xxxx=True, xxxxxxxx_xxxxxxxxxx=False,
|
- xxxxxxx_xxxxxxxxxxxx={
|
||||||
+ xxxxxx_xxxxxx=2, xxxxxx_xxxxx_xxxxxxxx=70, xxxxxx_xxxxxx_xxxxx=True,
|
- "xxxxxxxx": {
|
||||||
# fmt: off
|
- "xxxxxx": False,
|
||||||
xxxxxxx_xxxxxxxxxxxx={
|
- "xxxxxxx": False,
|
||||||
"xxxxxxxx": {
|
- "xxxx_xxxxxx": "xxxxx",
|
||||||
@@ -214,7 +197,7 @@
|
- },
|
||||||
},
|
- "xxxxxxxx-xxxxx": {
|
||||||
},
|
- "xxxxxx": False,
|
||||||
# fmt: on
|
- "xxxxxxx": True,
|
||||||
|
- "xxxx_xxxxxx": "xxxxxx",
|
||||||
|
- },
|
||||||
|
- },
|
||||||
|
- # fmt: on
|
||||||
- xxxxxxxxxx_xxxxxxxxxxx_xxxxxxx_xxxxxxxxx=5,
|
- xxxxxxxxxx_xxxxxxxxxxx_xxxxxxx_xxxxxxxxx=5,
|
||||||
+ xxxxxxxxxx_xxxxxxxxxxx_xxxxxxx_xxxxxxxxx=5
|
-)
|
||||||
)
|
+NOT_YET_IMPLEMENTED_ExprCall
|
||||||
# fmt: off
|
# fmt: off
|
||||||
yield 'hello'
|
-yield 'hello'
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprYield
|
||||||
|
# No formatting to the end of the file
|
||||||
|
-l=[1,2,3]
|
||||||
|
-d={'a':1,
|
||||||
|
- 'b':2}
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import asyncio
|
NOT_YET_IMPLEMENTED_StmtImport
|
||||||
import sys
|
NOT_YET_IMPLEMENTED_StmtImport
|
||||||
|
|
||||||
from third_party import X, Y, Z
|
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
|
|
||||||
from library import some_connection, \
|
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
some_decorator
|
|
||||||
# fmt: off
|
# fmt: off
|
||||||
from third_party import (X,
|
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
Y, Z)
|
|
||||||
# fmt: on
|
# fmt: on
|
||||||
f'trigger 3.6 mode'
|
NOT_YET_IMPLEMENTED_ExprJoinedStr
|
||||||
|
|
||||||
|
|
||||||
# Comment 1
|
# Comment 1
|
||||||
|
@ -421,193 +479,61 @@ f'trigger 3.6 mode'
|
||||||
# Comment 2
|
# Comment 2
|
||||||
|
|
||||||
# fmt: off
|
# fmt: off
|
||||||
def func_no_args():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
a; b; c
|
|
||||||
if True: raise RuntimeError
|
|
||||||
if False: ...
|
|
||||||
for i in range(10):
|
|
||||||
print(i)
|
|
||||||
continue
|
|
||||||
exec('new-style exec', {}, {})
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
async def coroutine(arg, exec=False):
|
NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
'Single-line docstring. Multiline is harder to reformat.'
|
|
||||||
async with some_connection() as conn:
|
|
||||||
await conn.do_what_i_mean('SELECT bobby, tables FROM xkcd', timeout=2)
|
|
||||||
await asyncio.sleep(1)
|
|
||||||
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
@some_decorator(
|
|
||||||
with_args=True,
|
|
||||||
many_args=[1,2,3]
|
|
||||||
)
|
|
||||||
def function_signature_stress_test(number:int,no_annotation=None,text:str='default',* ,debug:bool=False,**kwargs) -> str:
|
|
||||||
return text[number:-1]
|
|
||||||
|
|
||||||
|
|
||||||
# fmt: on
|
# fmt: on
|
||||||
def spaces(a=1, b=(), c=[], d={}, e=True, f=-1, g=1 if False else 2, h="", i=r''):
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
offset = attr.ib(default=attr.Factory( lambda: _r.uniform(1, 2)))
|
|
||||||
assert task._cancel_stack[:len(old_stack)] == old_stack
|
|
||||||
|
|
||||||
|
|
||||||
def spaces_types(a: int = 1, b: tuple = (), c: list = [], d: dict = {}, e: bool = True, f: int = -1, g: int = 1 if False else 2, h: str = "", i: str = r''): ...
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
def spaces2(result= _core.Value(None)):
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
...
|
|
||||||
|
|
||||||
|
|
||||||
something = {
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
|
|
||||||
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
NOT_YET_IMPLEMENTED_ExprCall
|
||||||
# fmt: off
|
# fmt: off
|
||||||
key: 'value',
|
NOT_YET_IMPLEMENTED_ExprYield
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def subscriptlist():
|
|
||||||
atom[
|
|
||||||
# fmt: off
|
|
||||||
'some big and',
|
|
||||||
'complex subscript',
|
|
||||||
# fmt: on
|
|
||||||
goes + here, andhere,
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def import_as_names():
|
|
||||||
# fmt: off
|
|
||||||
from hello import a, b
|
|
||||||
'unformatted'
|
|
||||||
|
|
||||||
|
|
||||||
def testlist_star_expr():
|
|
||||||
# fmt: off
|
|
||||||
a , b = *hello
|
|
||||||
'unformatted'
|
|
||||||
|
|
||||||
|
|
||||||
def yield_expr():
|
|
||||||
# fmt: off
|
|
||||||
yield hello
|
|
||||||
'unformatted'
|
|
||||||
# fmt: on
|
|
||||||
'formatted'
|
|
||||||
# fmt: off
|
|
||||||
( yield hello )
|
|
||||||
'unformatted'
|
|
||||||
|
|
||||||
|
|
||||||
def example(session):
|
|
||||||
# fmt: off
|
|
||||||
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()
|
|
||||||
|
|
||||||
|
|
||||||
def off_and_on_without_data():
|
|
||||||
"""All comments here are technically on the same prefix.
|
|
||||||
|
|
||||||
The comments between will be formatted. This is a known limitation.
|
|
||||||
"""
|
|
||||||
# fmt: off
|
|
||||||
|
|
||||||
|
|
||||||
#hey, that won't work
|
|
||||||
|
|
||||||
|
|
||||||
# fmt: on
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def on_and_off_broken():
|
|
||||||
"""Another known limitation."""
|
|
||||||
# fmt: on
|
|
||||||
# fmt: off
|
|
||||||
this=should.not_be.formatted()
|
|
||||||
and_=indeed . it is not formatted
|
|
||||||
because . the . handling . inside . generate_ignored_nodes()
|
|
||||||
now . considers . multiple . fmt . directives . within . one . prefix
|
|
||||||
|
|
||||||
|
|
||||||
def long_lines():
|
|
||||||
if True:
|
|
||||||
typedargslist.extend(
|
|
||||||
gen_annotated_params(ast_args.kwonlyargs, ast_args.kw_defaults, parameters, implicit_default=True)
|
|
||||||
)
|
|
||||||
# fmt: off
|
|
||||||
a = (
|
|
||||||
unnecessary_bracket()
|
|
||||||
)
|
|
||||||
# fmt: on
|
|
||||||
_type_comment_re = re.compile(
|
|
||||||
r"""
|
|
||||||
^
|
|
||||||
[\t ]*
|
|
||||||
\#[ ]type:[ ]*
|
|
||||||
(?P<type>
|
|
||||||
[^#\t\n]+?
|
|
||||||
)
|
|
||||||
(?<!ignore) # note: this will force the non-greedy + in <type> to match
|
|
||||||
# a trailing space which is why we need the silliness below
|
|
||||||
(?<!ignore[ ]{1})(?<!ignore[ ]{2})(?<!ignore[ ]{3})(?<!ignore[ ]{4})
|
|
||||||
(?<!ignore[ ]{5})(?<!ignore[ ]{6})(?<!ignore[ ]{7})(?<!ignore[ ]{8})
|
|
||||||
(?<!ignore[ ]{9})(?<!ignore[ ]{10})
|
|
||||||
[\t ]*
|
|
||||||
(?P<nl>
|
|
||||||
(?:\#[^\n]*)?
|
|
||||||
\n?
|
|
||||||
)
|
|
||||||
$
|
|
||||||
""",
|
|
||||||
# fmt: off
|
|
||||||
re.MULTILINE|re.VERBOSE
|
|
||||||
# fmt: on
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def single_literal_yapf_disable():
|
|
||||||
"""Black does not support this."""
|
|
||||||
BAZ = {
|
|
||||||
(1, 2, 3, 4),
|
|
||||||
(5, 6, 7, 8),
|
|
||||||
(9, 10, 11, 12)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
cfg.rule(
|
|
||||||
"Default", "address",
|
|
||||||
xxxx_xxxx=["xxx-xxxxxx-xxxxxxxxxx"],
|
|
||||||
xxxxxx="xx_xxxxx", xxxxxxx="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
|
||||||
xxxxxxxxx_xxxx=True, xxxxxxxx_xxxxxxxxxx=False,
|
|
||||||
xxxxxx_xxxxxx=2, xxxxxx_xxxxx_xxxxxxxx=70, xxxxxx_xxxxxx_xxxxx=True,
|
|
||||||
# fmt: off
|
|
||||||
xxxxxxx_xxxxxxxxxxxx={
|
|
||||||
"xxxxxxxx": {
|
|
||||||
"xxxxxx": False,
|
|
||||||
"xxxxxxx": False,
|
|
||||||
"xxxx_xxxxxx": "xxxxx",
|
|
||||||
},
|
|
||||||
"xxxxxxxx-xxxxx": {
|
|
||||||
"xxxxxx": False,
|
|
||||||
"xxxxxxx": True,
|
|
||||||
"xxxx_xxxxxx": "xxxxxx",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
# fmt: on
|
|
||||||
xxxxxxxxxx_xxxxxxxxxxx_xxxxxxx_xxxxxxxxx=5
|
|
||||||
)
|
|
||||||
# fmt: off
|
|
||||||
yield 'hello'
|
|
||||||
# No formatting to the end of the file
|
# No formatting to the end of the file
|
||||||
l=[1,2,3]
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
d={'a':1,
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
'b':2}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -22,22 +22,23 @@ l3 = ["I have", "trailing comma", "so I should be braked",]
|
||||||
- "into multiple lines",
|
- "into multiple lines",
|
||||||
- "because it is way too long",
|
- "because it is way too long",
|
||||||
-]
|
-]
|
||||||
+l1 = ["This list should be broken up", "into multiple lines", "because it is way too long"]
|
-l2 = ["But this list shouldn't", "even though it also has", "way too many characters in it"] # fmt: skip
|
||||||
l2 = ["But this list shouldn't", "even though it also has", "way too many characters in it"] # fmt: skip
|
|
||||||
-l3 = [
|
-l3 = [
|
||||||
- "I have",
|
- "I have",
|
||||||
- "trailing comma",
|
- "trailing comma",
|
||||||
- "so I should be braked",
|
- "so I should be braked",
|
||||||
-]
|
-]
|
||||||
+l3 = ["I have", "trailing comma", "so I should be braked",]
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign # fmt: skip
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
l1 = ["This list should be broken up", "into multiple lines", "because it is way too long"]
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
l2 = ["But this list shouldn't", "even though it also has", "way too many characters in it"] # fmt: skip
|
NOT_YET_IMPLEMENTED_StmtAssign # fmt: skip
|
||||||
l3 = ["I have", "trailing comma", "so I should be braked",]
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -22,29 +22,32 @@ f = ["This is a very long line that should be formatted into a clearer line ", "
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -1,10 +1,7 @@
|
@@ -1,10 +1,7 @@
|
||||||
-a = 3
|
-a = 3
|
||||||
+a = 3
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
# fmt: off
|
# fmt: off
|
||||||
b, c = 1, 2
|
-b, c = 1, 2
|
||||||
d = 6 # fmt: skip
|
-d = 6 # fmt: skip
|
||||||
e = 5
|
-e = 5
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign # fmt: skip
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
# fmt: on
|
# fmt: on
|
||||||
-f = [
|
-f = [
|
||||||
- "This is a very long line that should be formatted into a clearer line ",
|
- "This is a very long line that should be formatted into a clearer line ",
|
||||||
- "by rearranging.",
|
- "by rearranging.",
|
||||||
-]
|
-]
|
||||||
+f = ["This is a very long line that should be formatted into a clearer line ", "by rearranging."]
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
a = 3
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
# fmt: off
|
# fmt: off
|
||||||
b, c = 1, 2
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
d = 6 # fmt: skip
|
NOT_YET_IMPLEMENTED_StmtAssign # fmt: skip
|
||||||
e = 5
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
# fmt: on
|
# fmt: on
|
||||||
f = ["This is a very long line that should be formatted into a clearer line ", "by rearranging."]
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -18,22 +18,22 @@ l = [1, 2, 3,]
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -1,7 +1,3 @@
|
@@ -1,7 +1,3 @@
|
||||||
-a = 2
|
-a = 2
|
||||||
+a = 2
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
# fmt: skip
|
# fmt: skip
|
||||||
-l = [
|
-l = [
|
||||||
- 1,
|
- 1,
|
||||||
- 2,
|
- 2,
|
||||||
- 3,
|
- 3,
|
||||||
-]
|
-]
|
||||||
+l = [1, 2, 3,]
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
a = 2
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
# fmt: skip
|
# fmt: skip
|
||||||
l = [1, 2, 3,]
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -22,29 +22,25 @@ else:
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -1,6 +1,6 @@
|
@@ -1,9 +1,2 @@
|
||||||
-a, b, c = 3, 4, 5
|
-a, b, c = 3, 4, 5
|
||||||
+a, b, c = 3, 4, 5
|
-if (
|
||||||
if (
|
|
||||||
- a == 3
|
- a == 3
|
||||||
+ a == 3
|
- and b != 9 # fmt: skip
|
||||||
and b != 9 # fmt: skip
|
- and c is not None
|
||||||
and c is not None
|
-):
|
||||||
):
|
- print("I'm good!")
|
||||||
|
-else:
|
||||||
|
- print("I'm bad")
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtIf
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
a, b, c = 3, 4, 5
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
if (
|
NOT_YET_IMPLEMENTED_StmtIf
|
||||||
a == 3
|
|
||||||
and b != 9 # fmt: skip
|
|
||||||
and c is not None
|
|
||||||
):
|
|
||||||
print("I'm good!")
|
|
||||||
else:
|
|
||||||
print("I'm bad")
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -18,22 +18,19 @@ class A:
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -2,4 +2,4 @@
|
@@ -1,5 +1 @@
|
||||||
def f(self):
|
-class A:
|
||||||
for line in range(10):
|
- def f(self):
|
||||||
if True:
|
- for line in range(10):
|
||||||
|
- if True:
|
||||||
- pass # fmt: skip
|
- pass # fmt: skip
|
||||||
+ pass
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
class A:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
def f(self):
|
|
||||||
for line in range(10):
|
|
||||||
if True:
|
|
||||||
pass
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -19,19 +19,22 @@ d = "thisisasuperlongstringthisisasuperlongstringthisisasuperlongstringthisisasu
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -1,4 +1,4 @@
|
@@ -1,4 +1,4 @@
|
||||||
-a = "this is some code"
|
-a = "this is some code"
|
||||||
+a = "this is some code"
|
-b = 5 # fmt:skip
|
||||||
b = 5 # fmt:skip
|
-c = 9 # fmt: skip
|
||||||
c = 9 # fmt: skip
|
-d = "thisisasuperlongstringthisisasuperlongstringthisisasuperlongstringthisisasuperlongstring" # fmt:skip
|
||||||
d = "thisisasuperlongstringthisisasuperlongstringthisisasuperlongstringthisisasuperlongstring" # fmt:skip
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign # fmt:skip
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign # fmt: skip
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign # fmt:skip
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
a = "this is some code"
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
b = 5 # fmt:skip
|
NOT_YET_IMPLEMENTED_StmtAssign # fmt:skip
|
||||||
c = 9 # fmt: skip
|
NOT_YET_IMPLEMENTED_StmtAssign # fmt: skip
|
||||||
d = "thisisasuperlongstringthisisasuperlongstringthisisasuperlongstringthisisasuperlongstring" # fmt:skip
|
NOT_YET_IMPLEMENTED_StmtAssign # fmt:skip
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -75,108 +75,118 @@ async def test_async_with():
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -2,7 +2,6 @@
|
@@ -1,62 +1,33 @@
|
||||||
def some_func( unformatted, args ): # fmt: skip
|
# Make sure a leading comment is not removed.
|
||||||
print("I am some_func")
|
-def some_func( unformatted, args ): # fmt: skip
|
||||||
return 0
|
- print("I am some_func")
|
||||||
|
- return 0
|
||||||
- # Make sure this comment is not removed.
|
- # Make sure this comment is not removed.
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
# Make sure a leading comment is not removed.
|
# Make sure a leading comment is not removed.
|
||||||
@@ -29,15 +28,15 @@
|
-async def some_async_func( unformatted, args): # fmt: skip
|
||||||
elif another_unformatted_call( args ): # fmt: skip
|
- print("I am some_async_func")
|
||||||
print("Second branch")
|
- await asyncio.sleep(1)
|
||||||
else : # fmt: skip
|
+NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
# Make sure a leading comment is not removed.
|
||||||
|
-class SomeClass( Unformatted, SuperClasses ): # fmt: skip
|
||||||
|
- def some_method( self, unformatted, args ): # fmt: skip
|
||||||
|
- print("I am some_method")
|
||||||
|
- return 0
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
|
|
||||||
|
- async def some_async_method( self, unformatted, args ): # fmt: skip
|
||||||
|
- print("I am some_async_method")
|
||||||
|
- await asyncio.sleep(1)
|
||||||
|
|
||||||
|
-
|
||||||
|
# Make sure a leading comment is not removed.
|
||||||
|
-if unformatted_call( args ): # fmt: skip
|
||||||
|
- print("First branch")
|
||||||
|
- # Make sure this is not removed.
|
||||||
|
-elif another_unformatted_call( args ): # fmt: skip
|
||||||
|
- print("Second branch")
|
||||||
|
-else : # fmt: skip
|
||||||
- print("Last branch")
|
- print("Last branch")
|
||||||
+ print("Last branch") # fmt: skip
|
+NOT_YET_IMPLEMENTED_StmtIf # fmt: skip
|
||||||
|
|
||||||
|
|
||||||
-while some_condition( unformatted, args ): # fmt: skip
|
-while some_condition( unformatted, args ): # fmt: skip
|
||||||
+while some_condition( unformatted, args ): # fmt: skip
|
|
||||||
print("Do something")
|
|
||||||
|
|
||||||
|
|
||||||
for i in some_iter( unformatted, args ): # fmt: skip
|
|
||||||
- print("Do something")
|
- print("Do something")
|
||||||
+ print("Do something") # fmt: skip
|
+while NOT_YET_IMPLEMENTED_ExprCall: # fmt: skip
|
||||||
|
+ NOT_YET_IMPLEMENTED_ExprCall
|
||||||
|
|
||||||
|
|
||||||
async def test_async_for():
|
-for i in some_iter( unformatted, args ): # fmt: skip
|
||||||
@@ -54,7 +53,7 @@
|
|
||||||
|
|
||||||
|
|
||||||
with give_me_context( unformatted, args ): # fmt: skip
|
|
||||||
- print("Do something")
|
- print("Do something")
|
||||||
+ print("Do something") # fmt: skip
|
+NOT_YET_IMPLEMENTED_StmtFor # fmt: skip
|
||||||
|
|
||||||
|
|
||||||
async def test_async_with():
|
-async def test_async_for():
|
||||||
|
- async for i in some_async_iter( unformatted, args ): # fmt: skip
|
||||||
|
- print("Do something")
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
-try : # fmt: skip
|
||||||
|
- some_call()
|
||||||
|
-except UnformattedError as ex: # fmt: skip
|
||||||
|
- handle_exception()
|
||||||
|
-finally : # fmt: skip
|
||||||
|
- finally_call()
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtTry
|
||||||
|
|
||||||
|
|
||||||
|
-with give_me_context( unformatted, args ): # fmt: skip
|
||||||
|
- print("Do something")
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtWith # fmt: skip
|
||||||
|
|
||||||
|
|
||||||
|
-async def test_async_with():
|
||||||
|
- async with give_me_async_context( unformatted, args ): # fmt: skip
|
||||||
|
- print("Do something")
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
# Make sure a leading comment is not removed.
|
# Make sure a leading comment is not removed.
|
||||||
def some_func( unformatted, args ): # fmt: skip
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
print("I am some_func")
|
|
||||||
return 0
|
|
||||||
|
|
||||||
|
|
||||||
# Make sure a leading comment is not removed.
|
# Make sure a leading comment is not removed.
|
||||||
async def some_async_func( unformatted, args): # fmt: skip
|
NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
print("I am some_async_func")
|
|
||||||
await asyncio.sleep(1)
|
|
||||||
|
|
||||||
|
|
||||||
# Make sure a leading comment is not removed.
|
# Make sure a leading comment is not removed.
|
||||||
class SomeClass( Unformatted, SuperClasses ): # fmt: skip
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
def some_method( self, unformatted, args ): # fmt: skip
|
|
||||||
print("I am some_method")
|
|
||||||
return 0
|
|
||||||
|
|
||||||
async def some_async_method( self, unformatted, args ): # fmt: skip
|
|
||||||
print("I am some_async_method")
|
|
||||||
await asyncio.sleep(1)
|
|
||||||
|
|
||||||
|
|
||||||
# Make sure a leading comment is not removed.
|
# Make sure a leading comment is not removed.
|
||||||
if unformatted_call( args ): # fmt: skip
|
NOT_YET_IMPLEMENTED_StmtIf # fmt: skip
|
||||||
print("First branch")
|
|
||||||
# Make sure this is not removed.
|
|
||||||
elif another_unformatted_call( args ): # fmt: skip
|
|
||||||
print("Second branch")
|
|
||||||
else : # fmt: skip
|
|
||||||
print("Last branch") # fmt: skip
|
|
||||||
|
|
||||||
|
|
||||||
while some_condition( unformatted, args ): # fmt: skip
|
while NOT_YET_IMPLEMENTED_ExprCall: # fmt: skip
|
||||||
print("Do something")
|
NOT_YET_IMPLEMENTED_ExprCall
|
||||||
|
|
||||||
|
|
||||||
for i in some_iter( unformatted, args ): # fmt: skip
|
NOT_YET_IMPLEMENTED_StmtFor # fmt: skip
|
||||||
print("Do something") # fmt: skip
|
|
||||||
|
|
||||||
|
|
||||||
async def test_async_for():
|
NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
async for i in some_async_iter( unformatted, args ): # fmt: skip
|
|
||||||
print("Do something")
|
|
||||||
|
|
||||||
|
|
||||||
try : # fmt: skip
|
NOT_YET_IMPLEMENTED_StmtTry
|
||||||
some_call()
|
|
||||||
except UnformattedError as ex: # fmt: skip
|
|
||||||
handle_exception()
|
|
||||||
finally : # fmt: skip
|
|
||||||
finally_call()
|
|
||||||
|
|
||||||
|
|
||||||
with give_me_context( unformatted, args ): # fmt: skip
|
NOT_YET_IMPLEMENTED_StmtWith # fmt: skip
|
||||||
print("Do something") # fmt: skip
|
|
||||||
|
|
||||||
|
|
||||||
async def test_async_with():
|
NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
async with give_me_async_context( unformatted, args ): # fmt: skip
|
|
||||||
print("Do something")
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
---
|
||||||
|
source: crates/ruff_python_formatter/src/lib.rs
|
||||||
|
expression: snapshot
|
||||||
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_cases/fmtskip.py
|
||||||
|
---
|
||||||
|
## Input
|
||||||
|
|
||||||
|
```py
|
||||||
|
a, b = 1, 2
|
||||||
|
c = 6 # fmt: skip
|
||||||
|
d = 5
|
||||||
|
```
|
||||||
|
|
||||||
|
## Black Differences
|
||||||
|
|
||||||
|
```diff
|
||||||
|
--- Black
|
||||||
|
+++ Ruff
|
||||||
|
@@ -1,3 +1,3 @@
|
||||||
|
-a, b = 1, 2
|
||||||
|
-c = 6 # fmt: skip
|
||||||
|
-d = 5
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign # fmt: skip
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
```
|
||||||
|
|
||||||
|
## Ruff Output
|
||||||
|
|
||||||
|
```py
|
||||||
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
NOT_YET_IMPLEMENTED_StmtAssign # fmt: skip
|
||||||
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
```
|
||||||
|
|
||||||
|
## Black Output
|
||||||
|
|
||||||
|
```py
|
||||||
|
a, b = 1, 2
|
||||||
|
c = 6 # fmt: skip
|
||||||
|
d = 5
|
||||||
|
```
|
||||||
|
|
||||||
|
|
|
@ -22,28 +22,39 @@ f'Hello \'{tricky + "example"}\''
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -1,6 +1,6 @@
|
@@ -1,9 +1,9 @@
|
||||||
f"f-string without formatted values is just a string"
|
-f"f-string without formatted values is just a string"
|
||||||
f"{{NOT a formatted value}}"
|
-f"{{NOT a formatted value}}"
|
||||||
-f'{{NOT \'a\' "formatted" "value"}}'
|
-f'{{NOT \'a\' "formatted" "value"}}'
|
||||||
+f"{{NOT 'a' \"formatted\" \"value\"}}"
|
-f"some f-string with {a} {few():.2f} {formatted.values!r}"
|
||||||
f"some f-string with {a} {few():.2f} {formatted.values!r}"
|
-f'some f-string with {a} {few(""):.2f} {formatted.values!r}'
|
||||||
f'some f-string with {a} {few(""):.2f} {formatted.values!r}'
|
-f"{f'''{'nested'} inner'''} outer"
|
||||||
f"{f'''{'nested'} inner'''} outer"
|
-f"\"{f'{nested} inner'}\" outer"
|
||||||
|
-f"space between opening braces: { {a for a in (1, 2, 3)}}"
|
||||||
|
-f'Hello \'{tricky + "example"}\''
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprJoinedStr
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprJoinedStr
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprJoinedStr
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprJoinedStr
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprJoinedStr
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprJoinedStr
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprJoinedStr
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprJoinedStr
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprJoinedStr
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
f"f-string without formatted values is just a string"
|
NOT_YET_IMPLEMENTED_ExprJoinedStr
|
||||||
f"{{NOT a formatted value}}"
|
NOT_YET_IMPLEMENTED_ExprJoinedStr
|
||||||
f"{{NOT 'a' \"formatted\" \"value\"}}"
|
NOT_YET_IMPLEMENTED_ExprJoinedStr
|
||||||
f"some f-string with {a} {few():.2f} {formatted.values!r}"
|
NOT_YET_IMPLEMENTED_ExprJoinedStr
|
||||||
f'some f-string with {a} {few(""):.2f} {formatted.values!r}'
|
NOT_YET_IMPLEMENTED_ExprJoinedStr
|
||||||
f"{f'''{'nested'} inner'''} outer"
|
NOT_YET_IMPLEMENTED_ExprJoinedStr
|
||||||
f"\"{f'{nested} inner'}\" outer"
|
NOT_YET_IMPLEMENTED_ExprJoinedStr
|
||||||
f"space between opening braces: { {a for a in (1, 2, 3)}}"
|
NOT_YET_IMPLEMENTED_ExprJoinedStr
|
||||||
f'Hello \'{tricky + "example"}\''
|
NOT_YET_IMPLEMENTED_ExprJoinedStr
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -66,128 +66,94 @@ with hmm_but_this_should_get_two_preceding_newlines():
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -1,11 +1,11 @@
|
@@ -1,65 +1,12 @@
|
||||||
def f(
|
-def f(
|
||||||
- a,
|
- a,
|
||||||
- **kwargs,
|
- **kwargs,
|
||||||
+ a,
|
-) -> A:
|
||||||
+ **kwargs,
|
- with cache_dir():
|
||||||
) -> A:
|
- if something:
|
||||||
with cache_dir():
|
|
||||||
if something:
|
|
||||||
- result = CliRunner().invoke(
|
- result = CliRunner().invoke(
|
||||||
- black.main, [str(src1), str(src2), "--diff", "--check"]
|
- black.main, [str(src1), str(src2), "--diff", "--check"]
|
||||||
+ result = (
|
- )
|
||||||
+ CliRunner().invoke(black.main, [str(src1), str(src2), "--diff", "--check"])
|
- limited.append(-limited.pop()) # negate top
|
||||||
)
|
- return A(
|
||||||
limited.append(-limited.pop()) # negate top
|
- very_long_argument_name1=very_long_value_for_the_argument,
|
||||||
return A(
|
- very_long_argument_name2=-very.long.value.for_the_argument,
|
||||||
@@ -17,30 +17,24 @@
|
- **kwargs,
|
||||||
|
- )
|
||||||
def g():
|
|
||||||
"Docstring."
|
|
||||||
-
|
-
|
||||||
def inner():
|
|
||||||
pass
|
|
||||||
-
|
-
|
||||||
print("Inner defs should breathe a little.")
|
-def g():
|
||||||
|
- "Docstring."
|
||||||
|
|
||||||
def h():
|
|
||||||
def inner():
|
|
||||||
pass
|
|
||||||
-
|
-
|
||||||
print("Inner defs should breathe a little.")
|
- def inner():
|
||||||
|
- pass
|
||||||
|
|
||||||
if os.name == "posix":
|
|
||||||
import termios
|
|
||||||
-
|
-
|
||||||
def i_should_be_followed_by_only_one_newline():
|
- print("Inner defs should breathe a little.")
|
||||||
pass
|
|
||||||
-
|
-
|
||||||
elif os.name == "nt":
|
|
||||||
try:
|
|
||||||
import msvcrt
|
|
||||||
-
|
-
|
||||||
def i_should_be_followed_by_only_one_newline():
|
-def h():
|
||||||
pass
|
- def inner():
|
||||||
|
- pass
|
||||||
|
-
|
||||||
|
- print("Inner defs should breathe a little.")
|
||||||
|
-
|
||||||
|
-
|
||||||
|
-if os.name == "posix":
|
||||||
|
- import termios
|
||||||
|
-
|
||||||
|
- def i_should_be_followed_by_only_one_newline():
|
||||||
|
- pass
|
||||||
|
-
|
||||||
|
-elif os.name == "nt":
|
||||||
|
- try:
|
||||||
|
- import msvcrt
|
||||||
|
-
|
||||||
|
- def i_should_be_followed_by_only_one_newline():
|
||||||
|
- pass
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
@@ -54,12 +48,10 @@
|
- except ImportError:
|
||||||
class IHopeYouAreHavingALovelyDay:
|
|
||||||
def __call__(self):
|
|
||||||
print("i_should_be_followed_by_only_one_newline")
|
|
||||||
-
|
|
||||||
else:
|
|
||||||
|
|
||||||
def foo():
|
- def i_should_be_followed_by_only_one_newline():
|
||||||
pass
|
- pass
|
||||||
-
|
-
|
||||||
|
-elif False:
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
with hmm_but_this_should_get_two_preceding_newlines():
|
- class IHopeYouAreHavingALovelyDay:
|
||||||
pass
|
- def __call__(self):
|
||||||
|
- print("i_should_be_followed_by_only_one_newline")
|
||||||
|
|
||||||
|
-else:
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
- def foo():
|
||||||
|
- pass
|
||||||
|
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtIf
|
||||||
|
|
||||||
|
-with hmm_but_this_should_get_two_preceding_newlines():
|
||||||
|
- pass
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtWith
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
def f(
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
a,
|
|
||||||
**kwargs,
|
|
||||||
) -> A:
|
|
||||||
with cache_dir():
|
|
||||||
if something:
|
|
||||||
result = (
|
|
||||||
CliRunner().invoke(black.main, [str(src1), str(src2), "--diff", "--check"])
|
|
||||||
)
|
|
||||||
limited.append(-limited.pop()) # negate top
|
|
||||||
return A(
|
|
||||||
very_long_argument_name1=very_long_value_for_the_argument,
|
|
||||||
very_long_argument_name2=-very.long.value.for_the_argument,
|
|
||||||
**kwargs,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def g():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
"Docstring."
|
|
||||||
def inner():
|
|
||||||
pass
|
|
||||||
print("Inner defs should breathe a little.")
|
|
||||||
|
|
||||||
|
|
||||||
def h():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
def inner():
|
|
||||||
pass
|
|
||||||
print("Inner defs should breathe a little.")
|
|
||||||
|
|
||||||
|
|
||||||
if os.name == "posix":
|
NOT_YET_IMPLEMENTED_StmtIf
|
||||||
import termios
|
|
||||||
def i_should_be_followed_by_only_one_newline():
|
|
||||||
pass
|
|
||||||
elif os.name == "nt":
|
|
||||||
try:
|
|
||||||
import msvcrt
|
|
||||||
def i_should_be_followed_by_only_one_newline():
|
|
||||||
pass
|
|
||||||
|
|
||||||
except ImportError:
|
NOT_YET_IMPLEMENTED_StmtWith
|
||||||
|
|
||||||
def i_should_be_followed_by_only_one_newline():
|
|
||||||
pass
|
|
||||||
|
|
||||||
elif False:
|
|
||||||
|
|
||||||
class IHopeYouAreHavingALovelyDay:
|
|
||||||
def __call__(self):
|
|
||||||
print("i_should_be_followed_by_only_one_newline")
|
|
||||||
else:
|
|
||||||
|
|
||||||
def foo():
|
|
||||||
pass
|
|
||||||
|
|
||||||
with hmm_but_this_should_get_two_preceding_newlines():
|
|
||||||
pass
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -108,19 +108,24 @@ def __await__(): return (yield)
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -4,97 +4,67 @@
|
@@ -1,148 +1,41 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
-import asyncio
|
||||||
|
-import sys
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtImport
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtImport
|
||||||
|
|
||||||
from third_party import X, Y, Z
|
-from third_party import X, Y, Z
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
|
|
||||||
-from library import some_connection, some_decorator
|
-from library import some_connection, some_decorator
|
||||||
+from library import some_connection, \
|
+NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
+ some_decorator
|
+NOT_YET_IMPLEMENTED_ExprJoinedStr
|
||||||
+f'trigger 3.6 mode'
|
|
||||||
|
|
||||||
-f"trigger 3.6 mode"
|
-f"trigger 3.6 mode"
|
||||||
-
|
-
|
||||||
|
|
||||||
def func_no_args():
|
-def func_no_args():
|
||||||
- a
|
- a
|
||||||
- b
|
- b
|
||||||
- c
|
- c
|
||||||
|
@ -133,28 +138,18 @@ def __await__(): return (yield)
|
||||||
- continue
|
- continue
|
||||||
- exec("new-style exec", {}, {})
|
- exec("new-style exec", {}, {})
|
||||||
- return None
|
- return None
|
||||||
+ a; b; c
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+ if True: raise RuntimeError
|
|
||||||
+ if False: ...
|
|
||||||
+ for i in range(10):
|
|
||||||
+ print(i)
|
|
||||||
+ continue
|
|
||||||
+ exec("new-style exec", {}, {})
|
|
||||||
+ return None
|
|
||||||
|
|
||||||
|
|
||||||
async def coroutine(arg, exec=False):
|
-async def coroutine(arg, exec=False):
|
||||||
- "Single-line docstring. Multiline is harder to reformat."
|
- "Single-line docstring. Multiline is harder to reformat."
|
||||||
- async with some_connection() as conn:
|
- async with some_connection() as conn:
|
||||||
- await conn.do_what_i_mean("SELECT bobby, tables FROM xkcd", timeout=2)
|
- await conn.do_what_i_mean("SELECT bobby, tables FROM xkcd", timeout=2)
|
||||||
- await asyncio.sleep(1)
|
- await asyncio.sleep(1)
|
||||||
+ "Single-line docstring. Multiline is harder to reformat."
|
+NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
+ async with some_connection() as conn:
|
|
||||||
+ await conn.do_what_i_mean('SELECT bobby, tables FROM xkcd', timeout=2)
|
|
||||||
+ await asyncio.sleep(1)
|
|
||||||
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
-@asyncio.coroutine
|
||||||
-@some_decorator(with_args=True, many_args=[1, 2, 3])
|
-@some_decorator(with_args=True, many_args=[1, 2, 3])
|
||||||
-def function_signature_stress_test(
|
-def function_signature_stress_test(
|
||||||
- number: int,
|
- number: int,
|
||||||
|
@ -165,20 +160,13 @@ def __await__(): return (yield)
|
||||||
- **kwargs,
|
- **kwargs,
|
||||||
-) -> str:
|
-) -> str:
|
||||||
- return text[number:-1]
|
- return text[number:-1]
|
||||||
+@some_decorator(
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+with_args=True,
|
|
||||||
+many_args=[1,2,3]
|
|
||||||
+)
|
|
||||||
+def function_signature_stress_test(number:int,no_annotation=None,text:str="default",* ,debug:bool=False,**kwargs) -> str:
|
|
||||||
+ return text[number:-1]
|
|
||||||
|
|
||||||
|
|
||||||
-def spaces(a=1, b=(), c=[], d={}, e=True, f=-1, g=1 if False else 2, h="", i=r""):
|
-def spaces(a=1, b=(), c=[], d={}, e=True, f=-1, g=1 if False else 2, h="", i=r""):
|
||||||
- offset = attr.ib(default=attr.Factory(lambda: _r.uniform(10000, 200000)))
|
- offset = attr.ib(default=attr.Factory(lambda: _r.uniform(10000, 200000)))
|
||||||
- assert task._cancel_stack[: len(old_stack)] == old_stack
|
- assert task._cancel_stack[: len(old_stack)] == old_stack
|
||||||
+def spaces(a=1, b=(), c=[], d={}, e=True, f=-1, g=1 if False else 2, h="", i=r''):
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+ offset = attr.ib(default=attr.Factory( lambda: _r.uniform(10000, 200000)))
|
|
||||||
+ assert task._cancel_stack[:len(old_stack)] == old_stack
|
|
||||||
|
|
||||||
|
|
||||||
-def spaces_types(
|
-def spaces_types(
|
||||||
|
@ -193,16 +181,15 @@ def __await__(): return (yield)
|
||||||
- i: str = r"",
|
- i: str = r"",
|
||||||
-):
|
-):
|
||||||
- ...
|
- ...
|
||||||
+def spaces_types(a: int = 1, b: tuple = (), c: list = [], d: dict = {}, e: bool = True, f: int = -1, g: int = 1 if False else 2, h: str = "", i: str = r''): ...
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
-def spaces2(result=_core.Value(None)):
|
-def spaces2(result=_core.Value(None)):
|
||||||
- assert fut is self._read_fut, (fut, self._read_fut)
|
- assert fut is self._read_fut, (fut, self._read_fut)
|
||||||
+def spaces2(result= _core.Value(None)):
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+ assert fut is self._read_fut, (fut, self._read_fut)
|
|
||||||
|
|
||||||
|
|
||||||
def example(session):
|
-def example(session):
|
||||||
- result = (
|
- result = (
|
||||||
- session.query(models.Customer.id)
|
- session.query(models.Customer.id)
|
||||||
- .filter(
|
- .filter(
|
||||||
|
@ -212,195 +199,126 @@ def __await__(): return (yield)
|
||||||
- .order_by(models.Customer.id.asc())
|
- .order_by(models.Customer.id.asc())
|
||||||
- .all()
|
- .all()
|
||||||
- )
|
- )
|
||||||
+ result = session.query(models.Customer.id).filter(
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+ models.Customer.account_id == account_id,
|
|
||||||
+ models.Customer.email == email_address,
|
|
||||||
+ ).order_by(
|
|
||||||
+ models.Customer.id.asc()
|
|
||||||
+ ).all()
|
|
||||||
|
|
||||||
|
|
||||||
def long_lines():
|
-def long_lines():
|
||||||
if True:
|
- if True:
|
||||||
typedargslist.extend(
|
- typedargslist.extend(
|
||||||
- gen_annotated_params(
|
- gen_annotated_params(
|
||||||
- ast_args.kwonlyargs,
|
- ast_args.kwonlyargs,
|
||||||
- ast_args.kw_defaults,
|
- ast_args.kw_defaults,
|
||||||
- parameters,
|
- parameters,
|
||||||
- implicit_default=True,
|
- implicit_default=True,
|
||||||
- )
|
- )
|
||||||
+ gen_annotated_params(ast_args.kwonlyargs, ast_args.kw_defaults, parameters, implicit_default=True)
|
- )
|
||||||
)
|
- typedargslist.extend(
|
||||||
typedargslist.extend(
|
- gen_annotated_params(
|
||||||
gen_annotated_params(
|
|
||||||
- ast_args.kwonlyargs,
|
- ast_args.kwonlyargs,
|
||||||
- ast_args.kw_defaults,
|
- ast_args.kw_defaults,
|
||||||
- parameters,
|
- parameters,
|
||||||
- implicit_default=True,
|
- implicit_default=True,
|
||||||
+ ast_args.kwonlyargs, ast_args.kw_defaults, parameters, implicit_default=True,
|
- # trailing standalone comment
|
||||||
# trailing standalone comment
|
- )
|
||||||
)
|
- )
|
||||||
)
|
- _type_comment_re = re.compile(
|
||||||
@@ -117,23 +87,22 @@
|
- r"""
|
||||||
\n?
|
- ^
|
||||||
)
|
- [\t ]*
|
||||||
$
|
- \#[ ]type:[ ]*
|
||||||
|
- (?P<type>
|
||||||
|
- [^#\t\n]+?
|
||||||
|
- )
|
||||||
|
- (?<!ignore) # note: this will force the non-greedy + in <type> to match
|
||||||
|
- # a trailing space which is why we need the silliness below
|
||||||
|
- (?<!ignore[ ]{1})(?<!ignore[ ]{2})(?<!ignore[ ]{3})(?<!ignore[ ]{4})
|
||||||
|
- (?<!ignore[ ]{5})(?<!ignore[ ]{6})(?<!ignore[ ]{7})(?<!ignore[ ]{8})
|
||||||
|
- (?<!ignore[ ]{9})(?<!ignore[ ]{10})
|
||||||
|
- [\t ]*
|
||||||
|
- (?P<nl>
|
||||||
|
- (?:\#[^\n]*)?
|
||||||
|
- \n?
|
||||||
|
- )
|
||||||
|
- $
|
||||||
- """,
|
- """,
|
||||||
- re.MULTILINE | re.VERBOSE,
|
- re.MULTILINE | re.VERBOSE,
|
||||||
+ """, re.MULTILINE | re.VERBOSE
|
- )
|
||||||
)
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
def trailing_comma():
|
-def trailing_comma():
|
||||||
mapping = {
|
- mapping = {
|
||||||
- A: 0.25 * (10.0 / 12),
|
- A: 0.25 * (10.0 / 12),
|
||||||
- B: 0.1 * (10.0 / 12),
|
- B: 0.1 * (10.0 / 12),
|
||||||
- C: 0.1 * (10.0 / 12),
|
- C: 0.1 * (10.0 / 12),
|
||||||
- D: 0.1 * (10.0 / 12),
|
- D: 0.1 * (10.0 / 12),
|
||||||
- }
|
- }
|
||||||
+ A: 0.25 * (10.0 / 12),
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+ B: 0.1 * (10.0 / 12),
|
|
||||||
+ C: 0.1 * (10.0 / 12),
|
|
||||||
+ D: 0.1 * (10.0 / 12),
|
|
||||||
+}
|
|
||||||
|
|
||||||
|
|
||||||
def f(
|
-def f(
|
||||||
- a,
|
- a,
|
||||||
- **kwargs,
|
- **kwargs,
|
||||||
+ a,
|
-) -> A:
|
||||||
+ **kwargs,
|
- return (
|
||||||
) -> A:
|
- yield from A(
|
||||||
return (
|
- very_long_argument_name1=very_long_value_for_the_argument,
|
||||||
yield from A(
|
- very_long_argument_name2=very_long_value_for_the_argument,
|
||||||
@@ -144,5 +113,4 @@
|
- **kwargs,
|
||||||
)
|
- )
|
||||||
|
- )
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
-def __await__():
|
-def __await__():
|
||||||
- return (yield)
|
- return (yield)
|
||||||
+def __await__(): return (yield)
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import asyncio
|
NOT_YET_IMPLEMENTED_StmtImport
|
||||||
import sys
|
NOT_YET_IMPLEMENTED_StmtImport
|
||||||
|
|
||||||
from third_party import X, Y, Z
|
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
|
|
||||||
from library import some_connection, \
|
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
some_decorator
|
NOT_YET_IMPLEMENTED_ExprJoinedStr
|
||||||
f'trigger 3.6 mode'
|
|
||||||
|
|
||||||
|
|
||||||
def func_no_args():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
a; b; c
|
|
||||||
if True: raise RuntimeError
|
|
||||||
if False: ...
|
|
||||||
for i in range(10):
|
|
||||||
print(i)
|
|
||||||
continue
|
|
||||||
exec("new-style exec", {}, {})
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
async def coroutine(arg, exec=False):
|
NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
"Single-line docstring. Multiline is harder to reformat."
|
|
||||||
async with some_connection() as conn:
|
|
||||||
await conn.do_what_i_mean('SELECT bobby, tables FROM xkcd', timeout=2)
|
|
||||||
await asyncio.sleep(1)
|
|
||||||
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
@some_decorator(
|
|
||||||
with_args=True,
|
|
||||||
many_args=[1,2,3]
|
|
||||||
)
|
|
||||||
def function_signature_stress_test(number:int,no_annotation=None,text:str="default",* ,debug:bool=False,**kwargs) -> str:
|
|
||||||
return text[number:-1]
|
|
||||||
|
|
||||||
|
|
||||||
def spaces(a=1, b=(), c=[], d={}, e=True, f=-1, g=1 if False else 2, h="", i=r''):
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
offset = attr.ib(default=attr.Factory( lambda: _r.uniform(10000, 200000)))
|
|
||||||
assert task._cancel_stack[:len(old_stack)] == old_stack
|
|
||||||
|
|
||||||
|
|
||||||
def spaces_types(a: int = 1, b: tuple = (), c: list = [], d: dict = {}, e: bool = True, f: int = -1, g: int = 1 if False else 2, h: str = "", i: str = r''): ...
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
def spaces2(result= _core.Value(None)):
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
assert fut is self._read_fut, (fut, self._read_fut)
|
|
||||||
|
|
||||||
|
|
||||||
def example(session):
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
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()
|
|
||||||
|
|
||||||
|
|
||||||
def long_lines():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
if True:
|
|
||||||
typedargslist.extend(
|
|
||||||
gen_annotated_params(ast_args.kwonlyargs, ast_args.kw_defaults, parameters, implicit_default=True)
|
|
||||||
)
|
|
||||||
typedargslist.extend(
|
|
||||||
gen_annotated_params(
|
|
||||||
ast_args.kwonlyargs, ast_args.kw_defaults, parameters, implicit_default=True,
|
|
||||||
# trailing standalone comment
|
|
||||||
)
|
|
||||||
)
|
|
||||||
_type_comment_re = re.compile(
|
|
||||||
r"""
|
|
||||||
^
|
|
||||||
[\t ]*
|
|
||||||
\#[ ]type:[ ]*
|
|
||||||
(?P<type>
|
|
||||||
[^#\t\n]+?
|
|
||||||
)
|
|
||||||
(?<!ignore) # note: this will force the non-greedy + in <type> to match
|
|
||||||
# a trailing space which is why we need the silliness below
|
|
||||||
(?<!ignore[ ]{1})(?<!ignore[ ]{2})(?<!ignore[ ]{3})(?<!ignore[ ]{4})
|
|
||||||
(?<!ignore[ ]{5})(?<!ignore[ ]{6})(?<!ignore[ ]{7})(?<!ignore[ ]{8})
|
|
||||||
(?<!ignore[ ]{9})(?<!ignore[ ]{10})
|
|
||||||
[\t ]*
|
|
||||||
(?P<nl>
|
|
||||||
(?:\#[^\n]*)?
|
|
||||||
\n?
|
|
||||||
)
|
|
||||||
$
|
|
||||||
""", re.MULTILINE | re.VERBOSE
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def trailing_comma():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
mapping = {
|
|
||||||
A: 0.25 * (10.0 / 12),
|
|
||||||
B: 0.1 * (10.0 / 12),
|
|
||||||
C: 0.1 * (10.0 / 12),
|
|
||||||
D: 0.1 * (10.0 / 12),
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def f(
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
a,
|
|
||||||
**kwargs,
|
|
||||||
) -> A:
|
|
||||||
return (
|
|
||||||
yield from A(
|
|
||||||
very_long_argument_name1=very_long_value_for_the_argument,
|
|
||||||
very_long_argument_name2=very_long_value_for_the_argument,
|
|
||||||
**kwargs,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def __await__(): return (yield)
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -74,16 +74,15 @@ some_module.some_function(
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -1,69 +1,28 @@
|
@@ -1,114 +1,31 @@
|
||||||
-def f(
|
-def f(
|
||||||
- a,
|
- a,
|
||||||
-):
|
-):
|
||||||
- d = {
|
- d = {
|
||||||
- "key": "value",
|
- "key": "value",
|
||||||
- }
|
- }
|
||||||
+def f(a,):
|
- tup = (1,)
|
||||||
+ d = {'key': 'value',}
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
tup = (1,)
|
|
||||||
|
|
||||||
|
|
||||||
-def f2(
|
-def f2(
|
||||||
|
@ -98,9 +97,7 @@ some_module.some_function(
|
||||||
- 1,
|
- 1,
|
||||||
- 2,
|
- 2,
|
||||||
- )
|
- )
|
||||||
+def f2(a,b,):
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+ d = {'key': 'value', 'key2': 'value2',}
|
|
||||||
+ tup = (1,2,)
|
|
||||||
|
|
||||||
|
|
||||||
-def f(
|
-def f(
|
||||||
|
@ -114,13 +111,10 @@ some_module.some_function(
|
||||||
- call2(
|
- call2(
|
||||||
- arg=[1, 2, 3],
|
- arg=[1, 2, 3],
|
||||||
- )
|
- )
|
||||||
+def f(a:int=1,):
|
- x = {
|
||||||
+ call(arg={'explode': 'this',})
|
- "a": 1,
|
||||||
+ call2(arg=[1,2,3],)
|
- "b": 2,
|
||||||
x = {
|
- }["a"]
|
||||||
"a": 1,
|
|
||||||
"b": 2,
|
|
||||||
}["a"]
|
|
||||||
- if (
|
- if (
|
||||||
- a
|
- a
|
||||||
- == {
|
- == {
|
||||||
|
@ -134,8 +128,8 @@ some_module.some_function(
|
||||||
- "h": 8,
|
- "h": 8,
|
||||||
- }["a"]
|
- }["a"]
|
||||||
- ):
|
- ):
|
||||||
+ if a == {"a": 1,"b": 2,"c": 3,"d": 4,"e": 5,"f": 6,"g": 7,"h": 8,}["a"]:
|
- pass
|
||||||
pass
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
-def xxxxxxxxxxxxxxxxxxxxxxxxxxxx() -> (
|
-def xxxxxxxxxxxxxxxxxxxxxxxxxxxx() -> (
|
||||||
|
@ -150,48 +144,51 @@ some_module.some_function(
|
||||||
- }
|
- }
|
||||||
- }
|
- }
|
||||||
- }
|
- }
|
||||||
+def xxxxxxxxxxxxxxxxxxxxxxxxxxxx() -> Set[
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+ "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
||||||
+]:
|
|
||||||
+ json = {"k": {"k2": {"k3": [1,]}}}
|
|
||||||
|
|
||||||
|
|
||||||
# The type annotation shouldn't get a trailing comma since that would change its type.
|
# The type annotation shouldn't get a trailing comma since that would change its type.
|
||||||
@@ -74,24 +33,21 @@
|
# Relevant bug report: https://github.com/psf/black/issues/2381.
|
||||||
pass
|
-def some_function_with_a_really_long_name() -> (
|
||||||
|
- returning_a_deeply_nested_import_of_a_type_i_suppose
|
||||||
|
-):
|
||||||
|
- pass
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
-def some_method_with_a_really_long_name(
|
-def some_method_with_a_really_long_name(
|
||||||
- very_long_parameter_so_yeah: str, another_long_parameter: int
|
- 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:
|
-) -> another_case_of_returning_a_deeply_nested_import_of_a_type_i_suppose_cause_why_not:
|
||||||
+def some_method_with_a_really_long_name(very_long_parameter_so_yeah: str, another_long_parameter: int) -> (
|
- pass
|
||||||
+ another_case_of_returning_a_deeply_nested_import_of_a_type_i_suppose_cause_why_not
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+):
|
|
||||||
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
|
|
||||||
- )
|
|
||||||
+ 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() -> (
|
-def func() -> (
|
||||||
- also_super_long_type_annotation_that_may_cause_an_AST_related_crash_in_black(
|
- also_super_long_type_annotation_that_may_cause_an_AST_related_crash_in_black(
|
||||||
+def func() -> ((also_super_long_type_annotation_that_may_cause_an_AST_related_crash_in_black(
|
- this_shouldn_t_get_a_trailing_comma_too
|
||||||
this_shouldn_t_get_a_trailing_comma_too
|
|
||||||
- )
|
- )
|
||||||
+ ))
|
-):
|
||||||
):
|
- pass
|
||||||
pass
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
@@ -103,12 +59,5 @@
|
|
||||||
|
-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
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
# Make sure inner one-element tuple won't explode
|
||||||
|
-some_module.some_function(
|
||||||
|
- argument1, (one_element_tuple,), argument4, argument5, argument6
|
||||||
|
-)
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprCall
|
||||||
|
|
||||||
# Inner trailing comma causes outer to explode
|
# Inner trailing comma causes outer to explode
|
||||||
some_module.some_function(
|
-some_module.some_function(
|
||||||
- argument1,
|
- argument1,
|
||||||
- (
|
- (
|
||||||
- one,
|
- one,
|
||||||
|
@ -200,76 +197,44 @@ some_module.some_function(
|
||||||
- argument4,
|
- argument4,
|
||||||
- argument5,
|
- argument5,
|
||||||
- argument6,
|
- argument6,
|
||||||
+ argument1, (one, two,), argument4, argument5, argument6
|
-)
|
||||||
)
|
+NOT_YET_IMPLEMENTED_ExprCall
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
def f(a,):
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
d = {'key': 'value',}
|
|
||||||
tup = (1,)
|
|
||||||
|
|
||||||
|
|
||||||
def f2(a,b,):
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
d = {'key': 'value', 'key2': 'value2',}
|
|
||||||
tup = (1,2,)
|
|
||||||
|
|
||||||
|
|
||||||
def f(a:int=1,):
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
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[
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
||||||
]:
|
|
||||||
json = {"k": {"k2": {"k3": [1,]}}}
|
|
||||||
|
|
||||||
|
|
||||||
# The type annotation shouldn't get a trailing comma since that would change its type.
|
# 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.
|
# Relevant bug report: https://github.com/psf/black/issues/2381.
|
||||||
def some_function_with_a_really_long_name() -> (
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
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) -> (
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
another_case_of_returning_a_deeply_nested_import_of_a_type_i_suppose_cause_why_not
|
|
||||||
):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def func() -> (
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
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(
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
this_shouldn_t_get_a_trailing_comma_too
|
|
||||||
))
|
|
||||||
):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
# Make sure inner one-element tuple won't explode
|
# Make sure inner one-element tuple won't explode
|
||||||
some_module.some_function(
|
NOT_YET_IMPLEMENTED_ExprCall
|
||||||
argument1, (one_element_tuple,), argument4, argument5, argument6
|
|
||||||
)
|
|
||||||
|
|
||||||
# Inner trailing comma causes outer to explode
|
# Inner trailing comma causes outer to explode
|
||||||
some_module.some_function(
|
NOT_YET_IMPLEMENTED_ExprCall
|
||||||
argument1, (one, two,), argument4, argument5, argument6
|
|
||||||
)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -62,22 +62,44 @@ __all__ = (
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -2,8 +2,10 @@
|
@@ -1,64 +1,31 @@
|
||||||
|
-"""The asyncio package, tracking PEP 3156."""
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprConstant
|
||||||
|
|
||||||
# flake8: noqa
|
# flake8: noqa
|
||||||
|
|
||||||
-from logging import WARNING
|
-from logging import WARNING
|
||||||
from logging import (
|
-from logging import (
|
||||||
+ WARNING
|
- ERROR,
|
||||||
+)
|
-)
|
||||||
+from logging import (
|
-import sys
|
||||||
ERROR,
|
+NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
)
|
+NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
import sys
|
+NOT_YET_IMPLEMENTED_StmtImport
|
||||||
@@ -22,33 +24,16 @@
|
|
||||||
from ..streams import *
|
|
||||||
|
|
||||||
from some_library import (
|
# This relies on each of the submodules having an __all__ variable.
|
||||||
|
-from .base_events import *
|
||||||
|
-from .coroutines import *
|
||||||
|
-from .events import * # comment here
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtImportFrom # comment here
|
||||||
|
|
||||||
|
-from .futures import *
|
||||||
|
-from .locks import * # comment here
|
||||||
|
-from .protocols import *
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtImportFrom # comment here
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
|
|
||||||
|
-from ..runners import * # comment here
|
||||||
|
-from ..queues import *
|
||||||
|
-from ..streams import *
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtImportFrom # comment here
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
|
|
||||||
|
-from some_library import (
|
||||||
- Just,
|
- Just,
|
||||||
- Enough,
|
- Enough,
|
||||||
- Libraries,
|
- Libraries,
|
||||||
|
@ -92,82 +114,76 @@ __all__ = (
|
||||||
- No,
|
- No,
|
||||||
- Longer,
|
- Longer,
|
||||||
- Use,
|
- Use,
|
||||||
+ 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 (
|
-from name_of_a_company.extremely_long_project_name.component.ttypes import (
|
||||||
- CuteLittleServiceHandlerFactoryyy,
|
- CuteLittleServiceHandlerFactoryyy,
|
||||||
-)
|
-)
|
||||||
+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 name_of_a_company.extremely_long_project_name.extremely_long_component_name.ttypes import *
|
+NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
|
|
||||||
from .a.b.c.subprocess import *
|
-from .a.b.c.subprocess import *
|
||||||
-from . import tasks
|
-from . import tasks
|
||||||
-from . import A, B, C
|
-from . import A, B, C
|
||||||
-from . import (
|
-from . import (
|
||||||
- SomeVeryLongNameAndAllOfItsAdditionalLetters1,
|
- SomeVeryLongNameAndAllOfItsAdditionalLetters1,
|
||||||
- SomeVeryLongNameAndAllOfItsAdditionalLetters2,
|
- SomeVeryLongNameAndAllOfItsAdditionalLetters2,
|
||||||
-)
|
-)
|
||||||
+from . import (tasks)
|
+NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
+from . import (A, B, C)
|
+NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
+from . import SomeVeryLongNameAndAllOfItsAdditionalLetters1, \
|
+NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
+ SomeVeryLongNameAndAllOfItsAdditionalLetters2
|
+NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
|
|
||||||
__all__ = (
|
-__all__ = (
|
||||||
base_events.__all__
|
- base_events.__all__
|
||||||
|
- + coroutines.__all__
|
||||||
|
- + events.__all__
|
||||||
|
- + futures.__all__
|
||||||
|
- + locks.__all__
|
||||||
|
- + protocols.__all__
|
||||||
|
- + runners.__all__
|
||||||
|
- + queues.__all__
|
||||||
|
- + streams.__all__
|
||||||
|
- + tasks.__all__
|
||||||
|
-)
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
"""The asyncio package, tracking PEP 3156."""
|
NOT_YET_IMPLEMENTED_ExprConstant
|
||||||
|
|
||||||
# flake8: noqa
|
# flake8: noqa
|
||||||
|
|
||||||
from logging import (
|
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
WARNING
|
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
)
|
NOT_YET_IMPLEMENTED_StmtImport
|
||||||
from logging import (
|
|
||||||
ERROR,
|
|
||||||
)
|
|
||||||
import sys
|
|
||||||
|
|
||||||
# This relies on each of the submodules having an __all__ variable.
|
# This relies on each of the submodules having an __all__ variable.
|
||||||
from .base_events import *
|
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
from .coroutines import *
|
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
from .events import * # comment here
|
NOT_YET_IMPLEMENTED_StmtImportFrom # comment here
|
||||||
|
|
||||||
from .futures import *
|
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
from .locks import * # comment here
|
NOT_YET_IMPLEMENTED_StmtImportFrom # comment here
|
||||||
from .protocols import *
|
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
|
|
||||||
from ..runners import * # comment here
|
NOT_YET_IMPLEMENTED_StmtImportFrom # comment here
|
||||||
from ..queues import *
|
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
from ..streams import *
|
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
|
|
||||||
from some_library import (
|
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
Just, Enough, Libraries, To, Fit, In, This, Nice, Split, Which, We, No, Longer, Use
|
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
)
|
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
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 *
|
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
from . import (tasks)
|
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
from . import (A, B, C)
|
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
from . import SomeVeryLongNameAndAllOfItsAdditionalLetters1, \
|
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||||
SomeVeryLongNameAndAllOfItsAdditionalLetters2
|
|
||||||
|
|
||||||
__all__ = (
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
base_events.__all__
|
|
||||||
+ coroutines.__all__
|
|
||||||
+ events.__all__
|
|
||||||
+ futures.__all__
|
|
||||||
+ locks.__all__
|
|
||||||
+ protocols.__all__
|
|
||||||
+ runners.__all__
|
|
||||||
+ queues.__all__
|
|
||||||
+ streams.__all__
|
|
||||||
+ tasks.__all__
|
|
||||||
)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -25,8 +25,13 @@ list_of_types = [tuple[int,],]
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -4,19 +4,9 @@
|
@@ -1,22 +1,12 @@
|
||||||
b = tuple[int,]
|
# We should not treat the trailing comma
|
||||||
|
# in a single-element subscript.
|
||||||
|
-a: tuple[int,]
|
||||||
|
-b = tuple[int,]
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAnnAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
# The magic comma still applies to multi-element subscripts.
|
# The magic comma still applies to multi-element subscripts.
|
||||||
-c: tuple[
|
-c: tuple[
|
||||||
|
@ -37,8 +42,8 @@ list_of_types = [tuple[int,],]
|
||||||
- int,
|
- int,
|
||||||
- int,
|
- int,
|
||||||
-]
|
-]
|
||||||
+c: tuple[int, int,]
|
+NOT_YET_IMPLEMENTED_StmtAnnAssign
|
||||||
+d = tuple[int, int,]
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
# Magic commas still work as expected for non-subscripts.
|
# Magic commas still work as expected for non-subscripts.
|
||||||
-small_list = [
|
-small_list = [
|
||||||
|
@ -47,8 +52,8 @@ list_of_types = [tuple[int,],]
|
||||||
-list_of_types = [
|
-list_of_types = [
|
||||||
- tuple[int,],
|
- tuple[int,],
|
||||||
-]
|
-]
|
||||||
+small_list = [1,]
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
+list_of_types = [tuple[int,],]
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
@ -56,16 +61,16 @@ list_of_types = [tuple[int,],]
|
||||||
```py
|
```py
|
||||||
# We should not treat the trailing comma
|
# We should not treat the trailing comma
|
||||||
# in a single-element subscript.
|
# in a single-element subscript.
|
||||||
a: tuple[int,]
|
NOT_YET_IMPLEMENTED_StmtAnnAssign
|
||||||
b = tuple[int,]
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
# The magic comma still applies to multi-element subscripts.
|
# The magic comma still applies to multi-element subscripts.
|
||||||
c: tuple[int, int,]
|
NOT_YET_IMPLEMENTED_StmtAnnAssign
|
||||||
d = tuple[int, int,]
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
# Magic commas still work as expected for non-subscripts.
|
# Magic commas still work as expected for non-subscripts.
|
||||||
small_list = [1,]
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
list_of_types = [tuple[int,],]
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -76,87 +76,166 @@ return np.divide(
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -1,10 +1,10 @@
|
@@ -1,63 +1,51 @@
|
||||||
def function(**kwargs):
|
-def function(**kwargs):
|
||||||
t = a**2 + b**3
|
- t = a**2 + b**3
|
||||||
- return t**2
|
- return t**2
|
||||||
+ return t ** 2
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
def function_replace_spaces(**kwargs):
|
-def function_replace_spaces(**kwargs):
|
||||||
- t = a**2 + b**3 + c**4
|
- t = a**2 + b**3 + c**4
|
||||||
+ t = a **2 + b** 3 + c ** 4
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
def function_dont_replace_spaces():
|
-def function_dont_replace_spaces():
|
||||||
|
- {**a, **b, **c}
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
-a = 5**~4
|
||||||
|
-b = 5 ** f()
|
||||||
|
-c = -(5**2)
|
||||||
|
-d = 5 ** f["hi"]
|
||||||
|
-e = lazy(lambda **kwargs: 5)
|
||||||
|
-f = f() ** 5
|
||||||
|
-g = a.b**c.d
|
||||||
|
-h = 5 ** funcs.f()
|
||||||
|
-i = funcs.f() ** 5
|
||||||
|
-j = super().name ** 5
|
||||||
|
-k = [(2**idx, value) for idx, value in pairs]
|
||||||
|
-l = mod.weights_[0] == pytest.approx(0.95**100, abs=0.001)
|
||||||
|
-m = [([2**63], [1, 2**63])]
|
||||||
|
-n = count <= 10**5
|
||||||
|
-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)]
|
||||||
|
-r = x**y
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
|
-a = 5.0**~4.0
|
||||||
|
-b = 5.0 ** f()
|
||||||
|
-c = -(5.0**2.0)
|
||||||
|
-d = 5.0 ** f["hi"]
|
||||||
|
-e = lazy(lambda **kwargs: 5)
|
||||||
|
-f = f() ** 5.0
|
||||||
|
-g = a.b**c.d
|
||||||
|
-h = 5.0 ** funcs.f()
|
||||||
|
-i = funcs.f() ** 5.0
|
||||||
|
-j = super().name ** 5.0
|
||||||
|
-k = [(2.0**idx, value) for idx, value in pairs]
|
||||||
|
-l = mod.weights_[0] == pytest.approx(0.95**100, abs=0.001)
|
||||||
|
-m = [([2.0**63.0], [1.0, 2**63.0])]
|
||||||
|
-n = count <= 10**5.0
|
||||||
|
-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)]
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
|
|
||||||
|
# WE SHOULD DEFINITELY NOT EAT THESE COMMENTS (https://github.com/psf/black/issues/2873)
|
||||||
|
-if hasattr(view, "sum_of_weights"):
|
||||||
|
- return np.divide( # type: ignore[no-any-return]
|
||||||
|
- view.variance, # type: ignore[union-attr]
|
||||||
|
- view.sum_of_weights, # type: ignore[union-attr]
|
||||||
|
- out=np.full(view.sum_of_weights.shape, np.nan), # type: ignore[union-attr]
|
||||||
|
- where=view.sum_of_weights**2 > view.sum_of_weights_squared, # type: ignore[union-attr]
|
||||||
|
- )
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtIf
|
||||||
|
|
||||||
|
-return np.divide(
|
||||||
|
- where=view.sum_of_weights_of_weight_long**2 > view.sum_of_weights_squared, # type: ignore
|
||||||
|
-)
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtReturn
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
def function(**kwargs):
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
t = a**2 + b**3
|
|
||||||
return t ** 2
|
|
||||||
|
|
||||||
|
|
||||||
def function_replace_spaces(**kwargs):
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
t = a **2 + b** 3 + c ** 4
|
|
||||||
|
|
||||||
|
|
||||||
def function_dont_replace_spaces():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
{**a, **b, **c}
|
|
||||||
|
|
||||||
|
|
||||||
a = 5**~4
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
b = 5 ** f()
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
c = -(5**2)
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
d = 5 ** f["hi"]
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
e = lazy(lambda **kwargs: 5)
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
f = f() ** 5
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
g = a.b**c.d
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
h = 5 ** funcs.f()
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
i = funcs.f() ** 5
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
j = super().name ** 5
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
k = [(2**idx, value) for idx, value in pairs]
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
l = mod.weights_[0] == pytest.approx(0.95**100, abs=0.001)
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
m = [([2**63], [1, 2**63])]
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
n = count <= 10**5
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
o = settings(max_examples=10**6)
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
p = {(k, k**2): v**2 for k, v in pairs}
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
q = [10**i for i in range(6)]
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
r = x**y
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
a = 5.0**~4.0
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
b = 5.0 ** f()
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
c = -(5.0**2.0)
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
d = 5.0 ** f["hi"]
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
e = lazy(lambda **kwargs: 5)
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
f = f() ** 5.0
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
g = a.b**c.d
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
h = 5.0 ** funcs.f()
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
i = funcs.f() ** 5.0
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
j = super().name ** 5.0
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
k = [(2.0**idx, value) for idx, value in pairs]
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
l = mod.weights_[0] == pytest.approx(0.95**100, abs=0.001)
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
m = [([2.0**63.0], [1.0, 2**63.0])]
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
n = count <= 10**5.0
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
o = settings(max_examples=10**6.0)
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
p = {(k, k**2): v**2.0 for k, v in pairs}
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
q = [10.5**i for i in range(6)]
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
|
|
||||||
# WE SHOULD DEFINITELY NOT EAT THESE COMMENTS (https://github.com/psf/black/issues/2873)
|
# WE SHOULD DEFINITELY NOT EAT THESE COMMENTS (https://github.com/psf/black/issues/2873)
|
||||||
if hasattr(view, "sum_of_weights"):
|
NOT_YET_IMPLEMENTED_StmtIf
|
||||||
return np.divide( # type: ignore[no-any-return]
|
|
||||||
view.variance, # type: ignore[union-attr]
|
|
||||||
view.sum_of_weights, # type: ignore[union-attr]
|
|
||||||
out=np.full(view.sum_of_weights.shape, np.nan), # type: ignore[union-attr]
|
|
||||||
where=view.sum_of_weights**2 > view.sum_of_weights_squared, # type: ignore[union-attr]
|
|
||||||
)
|
|
||||||
|
|
||||||
return np.divide(
|
NOT_YET_IMPLEMENTED_StmtReturn
|
||||||
where=view.sum_of_weights_of_weight_long**2 > view.sum_of_weights_squared, # type: ignore
|
|
||||||
)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -25,7 +25,7 @@ xxxxxxxxx_yyy_zzzzzzzz[xx.xxxxxx(x_yyy_zzzzzz.xxxxx[0]), x_yyy_zzzzzz.xxxxxx(xxx
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -2,20 +2,11 @@
|
@@ -2,20 +2,8 @@
|
||||||
|
|
||||||
# Left hand side fits in a single line but will still be exploded by the
|
# Left hand side fits in a single line but will still be exploded by the
|
||||||
# magic trailing comma.
|
# magic trailing comma.
|
||||||
|
@ -37,17 +37,17 @@ xxxxxxxxx_yyy_zzzzzzzz[xx.xxxxxx(x_yyy_zzzzzz.xxxxx[0]), x_yyy_zzzzzz.xxxxxx(xxx
|
||||||
- ),
|
- ),
|
||||||
- third_value,
|
- third_value,
|
||||||
-) = xxxxxx_yyyyyy_zzzzzz_wwwwww_uuuuuuu_vvvvvvvvvvv(
|
-) = xxxxxx_yyyyyy_zzzzzz_wwwwww_uuuuuuu_vvvvvvvvvvv(
|
||||||
+first_value, (m1, m2,), third_value = xxxxxx_yyyyyy_zzzzzz_wwwwww_uuuuuuu_vvvvvvvvvvv(
|
- arg1,
|
||||||
arg1,
|
- arg2,
|
||||||
arg2,
|
-)
|
||||||
)
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
# Make when when the left side of assignment plus the opening paren "... = (" is
|
# 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.
|
# exactly line length limit + 1, it won't be split like that.
|
||||||
-xxxxxxxxx_yyy_zzzzzzzz[
|
-xxxxxxxxx_yyy_zzzzzzzz[
|
||||||
- xx.xxxxxx(x_yyy_zzzzzz.xxxxx[0]), x_yyy_zzzzzz.xxxxxx(xxxx=1)
|
- xx.xxxxxx(x_yyy_zzzzzz.xxxxx[0]), x_yyy_zzzzzz.xxxxxx(xxxx=1)
|
||||||
-] = 1
|
-] = 1
|
||||||
+xxxxxxxxx_yyy_zzzzzzzz[xx.xxxxxx(x_yyy_zzzzzz.xxxxx[0]), x_yyy_zzzzzz.xxxxxx(xxxx=1)] = 1
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
@ -57,14 +57,11 @@ xxxxxxxxx_yyy_zzzzzzzz[xx.xxxxxx(x_yyy_zzzzzz.xxxxx[0]), x_yyy_zzzzzz.xxxxxx(xxx
|
||||||
|
|
||||||
# Left hand side fits in a single line but will still be exploded by the
|
# Left hand side fits in a single line but will still be exploded by the
|
||||||
# magic trailing comma.
|
# magic trailing comma.
|
||||||
first_value, (m1, m2,), third_value = xxxxxx_yyyyyy_zzzzzz_wwwwww_uuuuuuu_vvvvvvvvvvv(
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
arg1,
|
|
||||||
arg2,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Make when when the left side of assignment plus the opening paren "... = (" is
|
# 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.
|
# exactly line length limit + 1, it won't be split like that.
|
||||||
xxxxxxxxx_yyy_zzzzzzzz[xx.xxxxxx(x_yyy_zzzzzz.xxxxx[0]), x_yyy_zzzzzz.xxxxxx(xxxx=1)] = 1
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -94,51 +94,51 @@ async def main():
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -8,59 +8,64 @@
|
@@ -1,93 +1,60 @@
|
||||||
|
-import asyncio
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtImport
|
||||||
|
|
||||||
|
|
||||||
|
# Control example
|
||||||
|
-async def main():
|
||||||
|
- await asyncio.sleep(1)
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
|
|
||||||
|
|
||||||
# Remove brackets for short coroutine/task
|
# Remove brackets for short coroutine/task
|
||||||
async def main():
|
-async def main():
|
||||||
- await asyncio.sleep(1)
|
- await asyncio.sleep(1)
|
||||||
+ await (asyncio.sleep(1))
|
+NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
-async def main():
|
||||||
- await asyncio.sleep(1)
|
- await asyncio.sleep(1)
|
||||||
+ await (
|
+NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
+ asyncio.sleep(1)
|
|
||||||
+ )
|
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
-async def main():
|
||||||
- await asyncio.sleep(1)
|
- await asyncio.sleep(1)
|
||||||
+ await (asyncio.sleep(1)
|
+NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
+ )
|
|
||||||
|
|
||||||
|
|
||||||
# Check comments
|
# Check comments
|
||||||
async def main():
|
-async def main():
|
||||||
- await asyncio.sleep(1) # Hello
|
- await asyncio.sleep(1) # Hello
|
||||||
+ await ( # Hello
|
+NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
+ asyncio.sleep(1)
|
|
||||||
+ )
|
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
-async def main():
|
||||||
- await asyncio.sleep(1) # Hello
|
- await asyncio.sleep(1) # Hello
|
||||||
+ await (
|
+NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
+ asyncio.sleep(1) # Hello
|
|
||||||
+ )
|
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
-async def main():
|
||||||
- await asyncio.sleep(1) # Hello
|
- await asyncio.sleep(1) # Hello
|
||||||
+ await (
|
+NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
+ asyncio.sleep(1)
|
|
||||||
+ )
|
|
||||||
|
|
||||||
|
|
||||||
# Long lines
|
# Long lines
|
||||||
async def main():
|
-async def main():
|
||||||
- await asyncio.gather(
|
- await asyncio.gather(
|
||||||
- asyncio.sleep(1),
|
- asyncio.sleep(1),
|
||||||
- asyncio.sleep(1),
|
- asyncio.sleep(1),
|
||||||
|
@ -148,11 +148,11 @@ async def main():
|
||||||
- asyncio.sleep(1),
|
- asyncio.sleep(1),
|
||||||
- asyncio.sleep(1),
|
- asyncio.sleep(1),
|
||||||
- )
|
- )
|
||||||
+ await asyncio.gather(asyncio.sleep(1), asyncio.sleep(1), asyncio.sleep(1), asyncio.sleep(1), asyncio.sleep(1), asyncio.sleep(1), asyncio.sleep(1))
|
+NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
|
|
||||||
|
|
||||||
# Same as above but with magic trailing comma in function
|
# Same as above but with magic trailing comma in function
|
||||||
async def main():
|
-async def main():
|
||||||
- await asyncio.gather(
|
- await asyncio.gather(
|
||||||
- asyncio.sleep(1),
|
- asyncio.sleep(1),
|
||||||
- asyncio.sleep(1),
|
- asyncio.sleep(1),
|
||||||
|
@ -162,145 +162,115 @@ async def main():
|
||||||
- asyncio.sleep(1),
|
- asyncio.sleep(1),
|
||||||
- asyncio.sleep(1),
|
- asyncio.sleep(1),
|
||||||
- )
|
- )
|
||||||
+ await asyncio.gather(asyncio.sleep(1), asyncio.sleep(1), asyncio.sleep(1), asyncio.sleep(1), asyncio.sleep(1), asyncio.sleep(1), asyncio.sleep(1),)
|
+NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
|
|
||||||
|
|
||||||
# Cr@zY Br@ck3Tz
|
# Cr@zY Br@ck3Tz
|
||||||
async def main():
|
-async def main():
|
||||||
- await black(1)
|
- await black(1)
|
||||||
+ await (
|
+NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
+ (((((((((((((
|
|
||||||
+ ((( (((
|
|
||||||
+ ((( (((
|
|
||||||
+ ((( (((
|
|
||||||
+ ((( (((
|
|
||||||
+ ((black(1)))
|
|
||||||
+ ))) )))
|
|
||||||
+ ))) )))
|
|
||||||
+ ))) )))
|
|
||||||
+ ))) )))
|
|
||||||
+ )))))))))))))
|
|
||||||
+ )
|
|
||||||
|
|
||||||
|
|
||||||
# Keep brackets around non power operations and nested awaits
|
# Keep brackets around non power operations and nested awaits
|
||||||
@@ -82,11 +87,11 @@
|
-async def main():
|
||||||
|
- await (set_of_tasks | other_set)
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
-async def main():
|
||||||
- await (await asyncio.sleep(1))
|
- await (await asyncio.sleep(1))
|
||||||
+ await (await (asyncio.sleep(1)))
|
+NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
# It's awaits all the way down...
|
||||||
|
-async def main():
|
||||||
|
- await (await x)
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
-async def main():
|
||||||
|
- await (yield x)
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
-async def main():
|
||||||
|
- await (await asyncio.sleep(1))
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
-async def main():
|
||||||
- await (await (await (await (await asyncio.sleep(1)))))
|
- await (await (await (await (await asyncio.sleep(1)))))
|
||||||
+ await (await (await (await (await (asyncio.sleep(1))))))
|
+NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
-async def main():
|
||||||
|
- await (yield)
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
import asyncio
|
NOT_YET_IMPLEMENTED_StmtImport
|
||||||
|
|
||||||
|
|
||||||
# Control example
|
# Control example
|
||||||
async def main():
|
NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
await asyncio.sleep(1)
|
|
||||||
|
|
||||||
|
|
||||||
# Remove brackets for short coroutine/task
|
# Remove brackets for short coroutine/task
|
||||||
async def main():
|
NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
await (asyncio.sleep(1))
|
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
await (
|
|
||||||
asyncio.sleep(1)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
await (asyncio.sleep(1)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# Check comments
|
# Check comments
|
||||||
async def main():
|
NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
await ( # Hello
|
|
||||||
asyncio.sleep(1)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
await (
|
|
||||||
asyncio.sleep(1) # Hello
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
await (
|
|
||||||
asyncio.sleep(1)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# Long lines
|
# Long lines
|
||||||
async def main():
|
NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
await asyncio.gather(asyncio.sleep(1), asyncio.sleep(1), asyncio.sleep(1), asyncio.sleep(1), asyncio.sleep(1), asyncio.sleep(1), asyncio.sleep(1))
|
|
||||||
|
|
||||||
|
|
||||||
# Same as above but with magic trailing comma in function
|
# Same as above but with magic trailing comma in function
|
||||||
async def main():
|
NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
await asyncio.gather(asyncio.sleep(1), asyncio.sleep(1), asyncio.sleep(1), asyncio.sleep(1), asyncio.sleep(1), asyncio.sleep(1), asyncio.sleep(1),)
|
|
||||||
|
|
||||||
|
|
||||||
# Cr@zY Br@ck3Tz
|
# Cr@zY Br@ck3Tz
|
||||||
async def main():
|
NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
await (
|
|
||||||
(((((((((((((
|
|
||||||
((( (((
|
|
||||||
((( (((
|
|
||||||
((( (((
|
|
||||||
((( (((
|
|
||||||
((black(1)))
|
|
||||||
))) )))
|
|
||||||
))) )))
|
|
||||||
))) )))
|
|
||||||
))) )))
|
|
||||||
)))))))))))))
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# Keep brackets around non power operations and nested awaits
|
# Keep brackets around non power operations and nested awaits
|
||||||
async def main():
|
NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
await (set_of_tasks | other_set)
|
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
await (await asyncio.sleep(1))
|
|
||||||
|
|
||||||
|
|
||||||
# It's awaits all the way down...
|
# It's awaits all the way down...
|
||||||
async def main():
|
NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
await (await x)
|
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
await (yield x)
|
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
await (await (asyncio.sleep(1)))
|
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
await (await (await (await (await (asyncio.sleep(1))))))
|
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
await (yield)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -48,85 +48,69 @@ except (some.really.really.really.looooooooooooooooooooooooooooooooong.module.ov
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -1,42 +1,27 @@
|
@@ -1,42 +1,9 @@
|
||||||
# These brackets are redundant, therefore remove.
|
# These brackets are redundant, therefore remove.
|
||||||
try:
|
-try:
|
||||||
a.something
|
- a.something
|
||||||
-except AttributeError as err:
|
-except AttributeError as err:
|
||||||
+except (AttributeError) as err:
|
- raise err
|
||||||
raise err
|
|
||||||
-
|
-
|
||||||
-# This is tuple of exceptions.
|
-# This is tuple of exceptions.
|
||||||
-# Although this could be replaced with just the exception,
|
-# Although this could be replaced with just the exception,
|
||||||
-# we do not remove brackets to preserve AST.
|
-# we do not remove brackets to preserve AST.
|
||||||
try:
|
-try:
|
||||||
a.something
|
- a.something
|
||||||
except (AttributeError,) as err:
|
-except (AttributeError,) as err:
|
||||||
raise err
|
- raise err
|
||||||
-
|
-
|
||||||
-# This is a tuple of exceptions. Do not remove brackets.
|
-# This is a tuple of exceptions. Do not remove brackets.
|
||||||
try:
|
-try:
|
||||||
a.something
|
- a.something
|
||||||
except (AttributeError, ValueError) as err:
|
-except (AttributeError, ValueError) as err:
|
||||||
raise err
|
- raise err
|
||||||
-
|
-
|
||||||
-# Test long variants.
|
-# Test long variants.
|
||||||
try:
|
-try:
|
||||||
a.something
|
- a.something
|
||||||
-except (
|
-except (
|
||||||
- some.really.really.really.looooooooooooooooooooooooooooooooong.module.over89.chars.Error
|
- some.really.really.really.looooooooooooooooooooooooooooooooong.module.over89.chars.Error
|
||||||
-) as err:
|
-) as err:
|
||||||
+except (some.really.really.really.looooooooooooooooooooooooooooooooong.module.over89.chars.Error) as err:
|
- raise err
|
||||||
raise err
|
+NOT_YET_IMPLEMENTED_StmtTry
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtTry
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtTry
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtTry
|
||||||
|
|
||||||
try:
|
-try:
|
||||||
a.something
|
- a.something
|
||||||
-except (
|
-except (
|
||||||
- some.really.really.really.looooooooooooooooooooooooooooooooong.module.over89.chars.Error,
|
- some.really.really.really.looooooooooooooooooooooooooooooooong.module.over89.chars.Error,
|
||||||
-) as err:
|
-) as err:
|
||||||
+except (some.really.really.really.looooooooooooooooooooooooooooooooong.module.over89.chars.Error,) as err:
|
- raise err
|
||||||
raise err
|
+NOT_YET_IMPLEMENTED_StmtTry
|
||||||
|
|
||||||
try:
|
-try:
|
||||||
a.something
|
- a.something
|
||||||
-except (
|
-except (
|
||||||
- some.really.really.really.looooooooooooooooooooooooooooooooong.module.over89.chars.Error,
|
- some.really.really.really.looooooooooooooooooooooooooooooooong.module.over89.chars.Error,
|
||||||
- some.really.really.really.looooooooooooooooooooooooooooooooong.module.over89.chars.Error,
|
- some.really.really.really.looooooooooooooooooooooooooooooooong.module.over89.chars.Error,
|
||||||
-) as err:
|
-) as err:
|
||||||
+except (some.really.really.really.looooooooooooooooooooooooooooooooong.module.over89.chars.Error, some.really.really.really.looooooooooooooooooooooooooooooooong.module.over89.chars.Error) as err:
|
- raise err
|
||||||
raise err
|
+NOT_YET_IMPLEMENTED_StmtTry
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
# These brackets are redundant, therefore remove.
|
# These brackets are redundant, therefore remove.
|
||||||
try:
|
NOT_YET_IMPLEMENTED_StmtTry
|
||||||
a.something
|
NOT_YET_IMPLEMENTED_StmtTry
|
||||||
except (AttributeError) as err:
|
NOT_YET_IMPLEMENTED_StmtTry
|
||||||
raise err
|
NOT_YET_IMPLEMENTED_StmtTry
|
||||||
try:
|
|
||||||
a.something
|
|
||||||
except (AttributeError,) as err:
|
|
||||||
raise err
|
|
||||||
try:
|
|
||||||
a.something
|
|
||||||
except (AttributeError, ValueError) as err:
|
|
||||||
raise err
|
|
||||||
try:
|
|
||||||
a.something
|
|
||||||
except (some.really.really.really.looooooooooooooooooooooooooooooooong.module.over89.chars.Error) as err:
|
|
||||||
raise err
|
|
||||||
|
|
||||||
try:
|
NOT_YET_IMPLEMENTED_StmtTry
|
||||||
a.something
|
|
||||||
except (some.really.really.really.looooooooooooooooooooooooooooooooong.module.over89.chars.Error,) as err:
|
|
||||||
raise err
|
|
||||||
|
|
||||||
try:
|
NOT_YET_IMPLEMENTED_StmtTry
|
||||||
a.something
|
|
||||||
except (some.really.really.really.looooooooooooooooooooooooooooooooong.module.over89.chars.Error, some.really.really.really.looooooooooooooooooooooooooooooooong.module.over89.chars.Error) as err:
|
|
||||||
raise err
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -32,23 +32,25 @@ for (((((k, v))))) in d.items():
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -1,5 +1,5 @@
|
@@ -1,27 +1,13 @@
|
||||||
# Only remove tuple brackets after `for`
|
# Only remove tuple brackets after `for`
|
||||||
-for k, v in d.items():
|
-for k, v in d.items():
|
||||||
+for (k, v) in d.items():
|
- print(k, v)
|
||||||
print(k, v)
|
+NOT_YET_IMPLEMENTED_StmtFor
|
||||||
|
|
||||||
# Don't touch tuple brackets after `in`
|
# Don't touch tuple brackets after `in`
|
||||||
@@ -8,20 +8,12 @@
|
-for module in (core, _unicodefun):
|
||||||
module._verify_python3_env = lambda: None
|
- if hasattr(module, "_verify_python3_env"):
|
||||||
|
- module._verify_python3_env = lambda: None
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFor
|
||||||
|
|
||||||
# Brackets remain for long for loop lines
|
# Brackets remain for long for loop lines
|
||||||
-for (
|
-for (
|
||||||
- why_would_anyone_choose_to_name_a_loop_variable_with_a_name_this_long,
|
- why_would_anyone_choose_to_name_a_loop_variable_with_a_name_this_long,
|
||||||
- i_dont_know_but_we_should_still_check_the_behaviour_if_they_do,
|
- i_dont_know_but_we_should_still_check_the_behaviour_if_they_do,
|
||||||
-) in d.items():
|
-) in d.items():
|
||||||
+for (why_would_anyone_choose_to_name_a_loop_variable_with_a_name_this_long, i_dont_know_but_we_should_still_check_the_behaviour_if_they_do) in d.items():
|
- print(k, v)
|
||||||
print(k, v)
|
+NOT_YET_IMPLEMENTED_StmtFor
|
||||||
|
|
||||||
-for (
|
-for (
|
||||||
- k,
|
- k,
|
||||||
|
@ -56,37 +58,31 @@ for (((((k, v))))) in d.items():
|
||||||
-) in (
|
-) in (
|
||||||
- dfkasdjfldsjflkdsjflkdsjfdslkfjldsjfgkjdshgkljjdsfldgkhsdofudsfudsofajdslkfjdslkfjldisfjdffjsdlkfjdlkjjkdflskadjldkfjsalkfjdasj.items()
|
- dfkasdjfldsjflkdsjflkdsjfdslkfjldsjfgkjdshgkljjdsfldgkhsdofudsfudsofajdslkfjdslkfjldisfjdffjsdlkfjdlkjjkdflskadjldkfjsalkfjdasj.items()
|
||||||
-):
|
-):
|
||||||
+for (k, v) in dfkasdjfldsjflkdsjflkdsjfdslkfjldsjfgkjdshgkljjdsfldgkhsdofudsfudsofajdslkfjdslkfjldisfjdffjsdlkfjdlkjjkdflskadjldkfjsalkfjdasj.items():
|
- print(k, v)
|
||||||
print(k, v)
|
+NOT_YET_IMPLEMENTED_StmtFor
|
||||||
|
|
||||||
# Test deeply nested brackets
|
# Test deeply nested brackets
|
||||||
-for k, v in d.items():
|
-for k, v in d.items():
|
||||||
+for (((((k, v))))) in d.items():
|
- print(k, v)
|
||||||
print(k, v)
|
+NOT_YET_IMPLEMENTED_StmtFor
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
# Only remove tuple brackets after `for`
|
# Only remove tuple brackets after `for`
|
||||||
for (k, v) in d.items():
|
NOT_YET_IMPLEMENTED_StmtFor
|
||||||
print(k, v)
|
|
||||||
|
|
||||||
# Don't touch tuple brackets after `in`
|
# Don't touch tuple brackets after `in`
|
||||||
for module in (core, _unicodefun):
|
NOT_YET_IMPLEMENTED_StmtFor
|
||||||
if hasattr(module, "_verify_python3_env"):
|
|
||||||
module._verify_python3_env = lambda: None
|
|
||||||
|
|
||||||
# Brackets remain for long for loop lines
|
# Brackets remain for long for loop lines
|
||||||
for (why_would_anyone_choose_to_name_a_loop_variable_with_a_name_this_long, i_dont_know_but_we_should_still_check_the_behaviour_if_they_do) in d.items():
|
NOT_YET_IMPLEMENTED_StmtFor
|
||||||
print(k, v)
|
|
||||||
|
|
||||||
for (k, v) in dfkasdjfldsjflkdsjflkdsjfdslkfjldsjfgkjdshgkljjdsfldgkhsdofudsfudsofajdslkfjdslkfjldisfjdffjsdlkfjdlkjjkdflskadjldkfjsalkfjdasj.items():
|
NOT_YET_IMPLEMENTED_StmtFor
|
||||||
print(k, v)
|
|
||||||
|
|
||||||
# Test deeply nested brackets
|
# Test deeply nested brackets
|
||||||
for (((((k, v))))) in d.items():
|
NOT_YET_IMPLEMENTED_StmtFor
|
||||||
print(k, v)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -121,200 +121,168 @@ with open("/path/to/file.txt", mode="r") as read_file:
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -2,20 +2,26 @@
|
@@ -1,78 +1,56 @@
|
||||||
|
-import random
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtImport
|
||||||
|
|
||||||
|
|
||||||
def foo1():
|
-def foo1():
|
||||||
+
|
- print("The newline above me should be deleted!")
|
||||||
print("The newline above me should be deleted!")
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
def foo2():
|
-def foo2():
|
||||||
+
|
- print("All the newlines above me should be deleted!")
|
||||||
+
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+
|
|
||||||
print("All the newlines above me should be deleted!")
|
|
||||||
|
|
||||||
|
|
||||||
def foo3():
|
-def foo3():
|
||||||
+
|
- print("No newline above me!")
|
||||||
print("No newline above me!")
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
print("There is a newline above me, and that's OK!")
|
- print("There is a newline above me, and that's OK!")
|
||||||
|
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
-def foo4():
|
||||||
|
- # There is a comment here
|
||||||
|
|
||||||
|
- print("The newline above me should not be deleted!")
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
|
|
||||||
|
|
||||||
def foo4():
|
-class Foo:
|
||||||
+
|
- def bar(self):
|
||||||
# There is a comment here
|
- print("The newline above me should be deleted!")
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFor
|
||||||
print("The newline above me should not be deleted!")
|
|
||||||
@@ -23,27 +29,39 @@
|
|
||||||
|
|
||||||
class Foo:
|
|
||||||
def bar(self):
|
|
||||||
+
|
|
||||||
print("The newline above me should be deleted!")
|
|
||||||
|
|
||||||
|
|
||||||
for i in range(5):
|
-for i in range(5):
|
||||||
+
|
- print(f"{i}) The line above me should be removed!")
|
||||||
print(f"{i}) The line above me should be removed!")
|
+NOT_YET_IMPLEMENTED_StmtFor
|
||||||
|
|
||||||
|
|
||||||
for i in range(5):
|
-for i in range(5):
|
||||||
+
|
- print(f"{i}) The lines above me should be removed!")
|
||||||
+
|
+NOT_YET_IMPLEMENTED_StmtFor
|
||||||
+
|
|
||||||
print(f"{i}) The lines above me should be removed!")
|
|
||||||
|
|
||||||
|
|
||||||
for i in range(5):
|
-for i in range(5):
|
||||||
+
|
- for j in range(7):
|
||||||
for j in range(7):
|
- print(f"{i}) The lines above me should be removed!")
|
||||||
+
|
+NOT_YET_IMPLEMENTED_StmtIf
|
||||||
print(f"{i}) The lines above me should be removed!")
|
|
||||||
|
|
||||||
|
|
||||||
if random.randint(0, 3) == 0:
|
-if random.randint(0, 3) == 0:
|
||||||
+
|
- print("The new line above me is about to be removed!")
|
||||||
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
|
||||||
|
|
||||||
|
|
||||||
if random.randint(0, 3) == 0:
|
-if random.randint(0, 3) == 0:
|
||||||
+
|
- if random.uniform(0, 1) > 0.5:
|
||||||
+
|
- print("Two lines above me are about to be removed!")
|
||||||
+
|
+NOT_YET_IMPLEMENTED_StmtIf
|
||||||
+
|
|
||||||
print("The new lines above me is about to be removed!")
|
|
||||||
|
|
||||||
|
|
||||||
@@ -66,13 +84,19 @@
|
-while True:
|
||||||
|
- print("The newline above me should be deleted!")
|
||||||
|
+while NOT_YET_IMPLEMENTED_ExprConstant:
|
||||||
|
+ NOT_YET_IMPLEMENTED_ExprCall
|
||||||
|
|
||||||
|
|
||||||
with open("/path/to/file.txt", mode="w") as file:
|
-while True:
|
||||||
+
|
- print("The newlines above me should be deleted!")
|
||||||
file.write("The new line above me is about to be removed!")
|
+while NOT_YET_IMPLEMENTED_ExprConstant:
|
||||||
|
+ NOT_YET_IMPLEMENTED_ExprCall
|
||||||
|
|
||||||
|
|
||||||
with open("/path/to/file.txt", mode="w") as file:
|
-while True:
|
||||||
+
|
- while False:
|
||||||
+
|
- print("The newlines above me should be deleted!")
|
||||||
+
|
+while NOT_YET_IMPLEMENTED_ExprConstant:
|
||||||
file.write("The new lines above me is about to be removed!")
|
+ while NOT_YET_IMPLEMENTED_ExprConstant:
|
||||||
|
+ NOT_YET_IMPLEMENTED_ExprCall
|
||||||
|
|
||||||
|
|
||||||
with open("/path/to/file.txt", mode="r") as read_file:
|
-with open("/path/to/file.txt", mode="w") as file:
|
||||||
+
|
- file.write("The new line above me is about to be removed!")
|
||||||
with open("/path/to/output_file.txt", mode="w") as write_file:
|
+NOT_YET_IMPLEMENTED_StmtWith
|
||||||
+
|
|
||||||
write_file.writelines(read_file.readlines())
|
|
||||||
|
-with open("/path/to/file.txt", mode="w") as file:
|
||||||
|
- file.write("The new lines above me is about to be removed!")
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtWith
|
||||||
|
|
||||||
|
|
||||||
|
-with open("/path/to/file.txt", mode="r") as read_file:
|
||||||
|
- with open("/path/to/output_file.txt", mode="w") as write_file:
|
||||||
|
- write_file.writelines(read_file.readlines())
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtWith
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
import random
|
NOT_YET_IMPLEMENTED_StmtImport
|
||||||
|
|
||||||
|
|
||||||
def foo1():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
print("The newline above me should be deleted!")
|
|
||||||
|
|
||||||
|
|
||||||
def foo2():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
print("All the newlines above me should be deleted!")
|
|
||||||
|
|
||||||
|
|
||||||
def foo3():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
print("No newline above me!")
|
|
||||||
|
|
||||||
print("There is a newline above me, and that's OK!")
|
|
||||||
|
|
||||||
|
|
||||||
def foo4():
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
|
|
||||||
# There is a comment here
|
|
||||||
|
|
||||||
print("The newline above me should not be deleted!")
|
|
||||||
|
|
||||||
|
|
||||||
class Foo:
|
NOT_YET_IMPLEMENTED_StmtFor
|
||||||
def bar(self):
|
|
||||||
|
|
||||||
print("The newline above me should be deleted!")
|
|
||||||
|
|
||||||
|
|
||||||
for i in range(5):
|
NOT_YET_IMPLEMENTED_StmtFor
|
||||||
|
|
||||||
print(f"{i}) The line above me should be removed!")
|
|
||||||
|
|
||||||
|
|
||||||
for i in range(5):
|
NOT_YET_IMPLEMENTED_StmtFor
|
||||||
|
|
||||||
|
|
||||||
|
NOT_YET_IMPLEMENTED_StmtIf
|
||||||
print(f"{i}) The lines above me should be removed!")
|
|
||||||
|
|
||||||
|
|
||||||
for i in range(5):
|
NOT_YET_IMPLEMENTED_StmtIf
|
||||||
|
|
||||||
for j in range(7):
|
|
||||||
|
|
||||||
print(f"{i}) The lines above me should be removed!")
|
|
||||||
|
|
||||||
|
|
||||||
if random.randint(0, 3) == 0:
|
NOT_YET_IMPLEMENTED_StmtIf
|
||||||
|
|
||||||
print("The new line above me is about to be removed!")
|
|
||||||
|
|
||||||
|
|
||||||
if random.randint(0, 3) == 0:
|
while NOT_YET_IMPLEMENTED_ExprConstant:
|
||||||
|
NOT_YET_IMPLEMENTED_ExprCall
|
||||||
|
|
||||||
|
|
||||||
|
while NOT_YET_IMPLEMENTED_ExprConstant:
|
||||||
|
NOT_YET_IMPLEMENTED_ExprCall
|
||||||
|
|
||||||
|
|
||||||
print("The new lines above me is about to be removed!")
|
while NOT_YET_IMPLEMENTED_ExprConstant:
|
||||||
|
while NOT_YET_IMPLEMENTED_ExprConstant:
|
||||||
|
NOT_YET_IMPLEMENTED_ExprCall
|
||||||
|
|
||||||
|
|
||||||
if random.randint(0, 3) == 0:
|
NOT_YET_IMPLEMENTED_StmtWith
|
||||||
if random.uniform(0, 1) > 0.5:
|
|
||||||
print("Two lines above me are about to be removed!")
|
|
||||||
|
|
||||||
|
|
||||||
while True:
|
NOT_YET_IMPLEMENTED_StmtWith
|
||||||
print("The newline above me should be deleted!")
|
|
||||||
|
|
||||||
|
|
||||||
while True:
|
NOT_YET_IMPLEMENTED_StmtWith
|
||||||
print("The newlines above me should be deleted!")
|
|
||||||
|
|
||||||
|
|
||||||
while True:
|
|
||||||
while False:
|
|
||||||
print("The newlines above me should be deleted!")
|
|
||||||
|
|
||||||
|
|
||||||
with open("/path/to/file.txt", mode="w") as file:
|
|
||||||
|
|
||||||
file.write("The new line above me is about to be removed!")
|
|
||||||
|
|
||||||
|
|
||||||
with open("/path/to/file.txt", mode="w") as file:
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
file.write("The new lines above me is about to be removed!")
|
|
||||||
|
|
||||||
|
|
||||||
with open("/path/to/file.txt", mode="r") as read_file:
|
|
||||||
|
|
||||||
with open("/path/to/output_file.txt", mode="w") as write_file:
|
|
||||||
|
|
||||||
write_file.writelines(read_file.readlines())
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -68,71 +68,75 @@ def example8():
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -1,5 +1,5 @@
|
@@ -1,85 +1,37 @@
|
||||||
-x = 1
|
-x = 1
|
||||||
-x = 1.2
|
-x = 1.2
|
||||||
+x = (1)
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
+x = (1.2)
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
data = (
|
-data = (
|
||||||
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||||
@@ -11,75 +11,47 @@
|
-).encode()
|
||||||
try:
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
if report_host:
|
|
||||||
data = (
|
|
||||||
|
-async def show_status():
|
||||||
|
- while True:
|
||||||
|
- try:
|
||||||
|
- if report_host:
|
||||||
|
- data = (
|
||||||
- f"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
- f"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||||
- ).encode()
|
- ).encode()
|
||||||
+ f"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
- except Exception as e:
|
||||||
+ ).encode()
|
- pass
|
||||||
except Exception as e:
|
+NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def example():
|
-def example():
|
||||||
- return "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
- return "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||||
+ return (("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"))
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
def example1():
|
-def example1():
|
||||||
- return 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111
|
- return 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111
|
||||||
+ return ((1111111111111111111111111111111111111111111111111111111111111111111111111111111111111))
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
def example1point5():
|
-def example1point5():
|
||||||
- return 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111
|
- return 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111
|
||||||
+ return ((((((1111111111111111111111111111111111111111111111111111111111111111111111111111111111111))))))
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
def example2():
|
-def example2():
|
||||||
- return (
|
- return (
|
||||||
- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||||
- )
|
- )
|
||||||
+ return (("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"))
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
def example3():
|
-def example3():
|
||||||
- return (
|
- return (
|
||||||
- 1111111111111111111111111111111111111111111111111111111111111111111111111111111
|
- 1111111111111111111111111111111111111111111111111111111111111111111111111111111
|
||||||
- )
|
- )
|
||||||
+ return ((1111111111111111111111111111111111111111111111111111111111111111111111111111111))
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
def example4():
|
-def example4():
|
||||||
- return True
|
- return True
|
||||||
+ return ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((True))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
def example5():
|
-def example5():
|
||||||
- return ()
|
- return ()
|
||||||
+ return ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
def example6():
|
-def example6():
|
||||||
- return {a: a for a in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]}
|
- return {a: a for a in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]}
|
||||||
+ return ((((((((({a:a for a in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]})))))))))
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
def example7():
|
-def example7():
|
||||||
- return {
|
- return {
|
||||||
- a: a
|
- a: a
|
||||||
- for a in [
|
- for a in [
|
||||||
|
@ -158,74 +162,54 @@ def example8():
|
||||||
- 20000000000000000000,
|
- 20000000000000000000,
|
||||||
- ]
|
- ]
|
||||||
- }
|
- }
|
||||||
+ return ((((((((({a:a for a in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20000000000000000000]})))))))))
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
def example8():
|
-def example8():
|
||||||
- return None
|
- return None
|
||||||
+ return (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((None)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
x = (1)
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
x = (1.2)
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
data = (
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
||||||
).encode()
|
|
||||||
|
|
||||||
|
|
||||||
async def show_status():
|
NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
while True:
|
|
||||||
try:
|
|
||||||
if report_host:
|
|
||||||
data = (
|
|
||||||
f"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
||||||
).encode()
|
|
||||||
except Exception as e:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def example():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
return (("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"))
|
|
||||||
|
|
||||||
|
|
||||||
def example1():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
return ((1111111111111111111111111111111111111111111111111111111111111111111111111111111111111))
|
|
||||||
|
|
||||||
|
|
||||||
def example1point5():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
return ((((((1111111111111111111111111111111111111111111111111111111111111111111111111111111111111))))))
|
|
||||||
|
|
||||||
|
|
||||||
def example2():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
return (("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"))
|
|
||||||
|
|
||||||
|
|
||||||
def example3():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
return ((1111111111111111111111111111111111111111111111111111111111111111111111111111111))
|
|
||||||
|
|
||||||
|
|
||||||
def example4():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
return ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((True))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
|
|
||||||
|
|
||||||
|
|
||||||
def example5():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
return ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
|
|
||||||
|
|
||||||
|
|
||||||
def example6():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
return ((((((((({a:a for a in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]})))))))))
|
|
||||||
|
|
||||||
|
|
||||||
def example7():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
return ((((((((({a:a for a in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20000000000000000000]})))))))))
|
|
||||||
|
|
||||||
|
|
||||||
def example8():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
return (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((None)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -101,78 +101,67 @@ def foo() -> tuple[int, int, int,]:
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -1,33 +1,41 @@
|
@@ -1,120 +1,65 @@
|
||||||
# Control
|
# Control
|
||||||
def double(a: int) -> int:
|
-def double(a: int) -> int:
|
||||||
- return 2 * a
|
- return 2 * a
|
||||||
+ return 2*a
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
# Remove the brackets
|
# Remove the brackets
|
||||||
-def double(a: int) -> int:
|
-def double(a: int) -> int:
|
||||||
- return 2 * a
|
- return 2 * a
|
||||||
+def double(a: int) -> (int):
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+ return 2*a
|
|
||||||
|
|
||||||
|
|
||||||
# Some newline variations
|
# Some newline variations
|
||||||
-def double(a: int) -> int:
|
-def double(a: int) -> int:
|
||||||
- return 2 * a
|
- return 2 * a
|
||||||
+def double(a: int) -> (
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+ int):
|
|
||||||
+ return 2*a
|
|
||||||
|
|
||||||
|
|
||||||
-def double(a: int) -> int:
|
-def double(a: int) -> int:
|
||||||
- return 2 * a
|
- return 2 * a
|
||||||
+def double(a: int) -> (int
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+):
|
|
||||||
+ return 2*a
|
|
||||||
|
|
||||||
|
|
||||||
-def double(a: int) -> int:
|
-def double(a: int) -> int:
|
||||||
- return 2 * a
|
- return 2 * a
|
||||||
+def double(a: int) -> (
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+ int
|
|
||||||
+):
|
|
||||||
+ return 2*a
|
|
||||||
|
|
||||||
|
|
||||||
# Don't lose the comments
|
# Don't lose the comments
|
||||||
-def double(a: int) -> int: # Hello
|
-def double(a: int) -> int: # Hello
|
||||||
- return 2 * a
|
- return 2 * a
|
||||||
+def double(a: int) -> ( # Hello
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+ int
|
|
||||||
+):
|
|
||||||
+ return 2*a
|
|
||||||
|
|
||||||
|
|
||||||
-def double(a: int) -> int: # Hello
|
-def double(a: int) -> int: # Hello
|
||||||
- return 2 * a
|
- return 2 * a
|
||||||
+def double(a: int) -> (
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+ int # Hello
|
|
||||||
+):
|
|
||||||
+ return 2*a
|
|
||||||
|
|
||||||
|
|
||||||
# Really long annotations
|
# Really long annotations
|
||||||
@@ -37,84 +45,62 @@
|
-def foo() -> (
|
||||||
return 2
|
- intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds
|
||||||
|
-):
|
||||||
|
- return 2
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
-def foo() -> (
|
-def foo() -> (
|
||||||
- intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds
|
- intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds
|
||||||
-):
|
-):
|
||||||
+def foo() -> intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds:
|
- return 2
|
||||||
return 2
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
-def foo() -> (
|
-def foo() -> (
|
||||||
- intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds
|
- intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds
|
||||||
- | intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds
|
- | intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds
|
||||||
-):
|
-):
|
||||||
+def foo() -> intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds | intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds:
|
- return 2
|
||||||
return 2
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
-def foo(
|
-def foo(
|
||||||
|
@ -180,8 +169,8 @@ def foo() -> tuple[int, int, int,]:
|
||||||
- b: int,
|
- b: int,
|
||||||
- c: int,
|
- c: int,
|
||||||
-) -> intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds:
|
-) -> intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds:
|
||||||
+def foo(a: int, b: int, c: int,) -> intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds:
|
- return 2
|
||||||
return 2
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
-def foo(
|
-def foo(
|
||||||
|
@ -192,8 +181,8 @@ def foo() -> tuple[int, int, int,]:
|
||||||
- intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds
|
- intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds
|
||||||
- | intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds
|
- | intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds
|
||||||
-):
|
-):
|
||||||
+def foo(a: int, b: int, c: int,) -> intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds | intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds:
|
- return 2
|
||||||
return 2
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
# Split args but no need to split return
|
# Split args but no need to split return
|
||||||
|
@ -202,45 +191,33 @@ def foo() -> tuple[int, int, int,]:
|
||||||
- b: int,
|
- b: int,
|
||||||
- c: int,
|
- c: int,
|
||||||
-) -> int:
|
-) -> int:
|
||||||
+def foo(a: int, b: int, c: int,) -> int:
|
- return 2
|
||||||
return 2
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
# Deeply nested brackets
|
# Deeply nested brackets
|
||||||
# with *interesting* spacing
|
# with *interesting* spacing
|
||||||
-def double(a: int) -> int:
|
-def double(a: int) -> int:
|
||||||
- return 2 * a
|
- return 2 * a
|
||||||
+def double(a: int) -> (((((int))))):
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+ return 2*a
|
|
||||||
|
|
||||||
|
|
||||||
-def double(a: int) -> int:
|
-def double(a: int) -> int:
|
||||||
- return 2 * a
|
- return 2 * a
|
||||||
+def double(a: int) -> (
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+ ( (
|
|
||||||
+ ((int)
|
|
||||||
+ )
|
|
||||||
+ )
|
|
||||||
+ )
|
|
||||||
+ ):
|
|
||||||
+ return 2*a
|
|
||||||
|
|
||||||
|
|
||||||
def foo() -> (
|
-def foo() -> (
|
||||||
+ ( (
|
- intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds
|
||||||
intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds
|
|
||||||
-):
|
-):
|
||||||
+)
|
- return 2
|
||||||
+)):
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
return 2
|
|
||||||
|
|
||||||
|
|
||||||
# Return type with commas
|
# Return type with commas
|
||||||
-def foo() -> tuple[int, int, int]:
|
-def foo() -> tuple[int, int, int]:
|
||||||
+def foo() -> (
|
- return 2
|
||||||
+ tuple[int, int, int]
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+):
|
|
||||||
return 2
|
|
||||||
|
|
||||||
|
|
||||||
-def foo() -> (
|
-def foo() -> (
|
||||||
|
@ -250,8 +227,8 @@ def foo() -> tuple[int, int, int,]:
|
||||||
- loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong,
|
- loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong,
|
||||||
- ]
|
- ]
|
||||||
-):
|
-):
|
||||||
+def foo() -> tuple[loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong, loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong, loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong]:
|
- return 2
|
||||||
return 2
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
# Magic trailing comma example
|
# Magic trailing comma example
|
||||||
|
@ -262,119 +239,78 @@ def foo() -> tuple[int, int, int,]:
|
||||||
- int,
|
- int,
|
||||||
- ]
|
- ]
|
||||||
-):
|
-):
|
||||||
+def foo() -> tuple[int, int, int,]:
|
- return 2
|
||||||
return 2
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
# Control
|
# Control
|
||||||
def double(a: int) -> int:
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
return 2*a
|
|
||||||
|
|
||||||
|
|
||||||
# Remove the brackets
|
# Remove the brackets
|
||||||
def double(a: int) -> (int):
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
return 2*a
|
|
||||||
|
|
||||||
|
|
||||||
# Some newline variations
|
# Some newline variations
|
||||||
def double(a: int) -> (
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
int):
|
|
||||||
return 2*a
|
|
||||||
|
|
||||||
|
|
||||||
def double(a: int) -> (int
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
):
|
|
||||||
return 2*a
|
|
||||||
|
|
||||||
|
|
||||||
def double(a: int) -> (
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
int
|
|
||||||
):
|
|
||||||
return 2*a
|
|
||||||
|
|
||||||
|
|
||||||
# Don't lose the comments
|
# Don't lose the comments
|
||||||
def double(a: int) -> ( # Hello
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
int
|
|
||||||
):
|
|
||||||
return 2*a
|
|
||||||
|
|
||||||
|
|
||||||
def double(a: int) -> (
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
int # Hello
|
|
||||||
):
|
|
||||||
return 2*a
|
|
||||||
|
|
||||||
|
|
||||||
# Really long annotations
|
# Really long annotations
|
||||||
def foo() -> (
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds
|
|
||||||
):
|
|
||||||
return 2
|
|
||||||
|
|
||||||
|
|
||||||
def foo() -> intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds:
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
return 2
|
|
||||||
|
|
||||||
|
|
||||||
def foo() -> intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds | intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds:
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
return 2
|
|
||||||
|
|
||||||
|
|
||||||
def foo(a: int, b: int, c: int,) -> intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds:
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
return 2
|
|
||||||
|
|
||||||
|
|
||||||
def foo(a: int, b: int, c: int,) -> intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds | intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds:
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
return 2
|
|
||||||
|
|
||||||
|
|
||||||
# Split args but no need to split return
|
# Split args but no need to split return
|
||||||
def foo(a: int, b: int, c: int,) -> int:
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
return 2
|
|
||||||
|
|
||||||
|
|
||||||
# Deeply nested brackets
|
# Deeply nested brackets
|
||||||
# with *interesting* spacing
|
# with *interesting* spacing
|
||||||
def double(a: int) -> (((((int))))):
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
return 2*a
|
|
||||||
|
|
||||||
|
|
||||||
def double(a: int) -> (
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
( (
|
|
||||||
((int)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
):
|
|
||||||
return 2*a
|
|
||||||
|
|
||||||
|
|
||||||
def foo() -> (
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
( (
|
|
||||||
intsdfsafafafdfdsasdfsfsdfasdfafdsafdfdsfasdskdsdsfdsafdsafsdfdasfffsfdsfdsafafhdskfhdsfjdslkfdlfsdkjhsdfjkdshfkljds
|
|
||||||
)
|
|
||||||
)):
|
|
||||||
return 2
|
|
||||||
|
|
||||||
|
|
||||||
# Return type with commas
|
# Return type with commas
|
||||||
def foo() -> (
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
tuple[int, int, int]
|
|
||||||
):
|
|
||||||
return 2
|
|
||||||
|
|
||||||
|
|
||||||
def foo() -> tuple[loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong, loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong, loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong]:
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
return 2
|
|
||||||
|
|
||||||
|
|
||||||
# Magic trailing comma example
|
# Magic trailing comma example
|
||||||
def foo() -> tuple[int, int, int,]:
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
return 2
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -60,114 +60,75 @@ func(
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -3,23 +3,45 @@
|
@@ -1,25 +1,25 @@
|
||||||
b = tuple[int,]
|
# We should not remove the trailing comma in a single-element subscript.
|
||||||
|
-a: tuple[int,]
|
||||||
|
-b = tuple[int,]
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAnnAssign
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
# But commas in multiple element subscripts should be removed.
|
# But commas in multiple element subscripts should be removed.
|
||||||
-c: tuple[int, int]
|
-c: tuple[int, int]
|
||||||
-d = tuple[int, int]
|
-d = tuple[int, int]
|
||||||
+c: tuple[int, int,]
|
+NOT_YET_IMPLEMENTED_StmtAnnAssign
|
||||||
+d = tuple[int, int,]
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
# Remove commas for non-subscripts.
|
# Remove commas for non-subscripts.
|
||||||
-small_list = [1]
|
-small_list = [1]
|
||||||
-list_of_types = [tuple[int,]]
|
-list_of_types = [tuple[int,]]
|
||||||
-small_set = {1}
|
-small_set = {1}
|
||||||
-set_of_types = {tuple[int,]}
|
-set_of_types = {tuple[int,]}
|
||||||
+small_list = [1,]
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
+list_of_types = [tuple[int,],]
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
+small_set = {1,}
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
+set_of_types = {tuple[int,],}
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
# Except single element tuples
|
# Except single element tuples
|
||||||
small_tuple = (1,)
|
-small_tuple = (1,)
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
# Trailing commas in multiple chained non-nested parens.
|
# Trailing commas in multiple chained non-nested parens.
|
||||||
-zero(one).two(three).four(five)
|
-zero(one).two(three).four(five)
|
||||||
+zero(
|
+NOT_YET_IMPLEMENTED_ExprCall
|
||||||
+ one,
|
|
||||||
+).two(
|
|
||||||
+ three,
|
|
||||||
+).four(
|
|
||||||
+ five,
|
|
||||||
+)
|
|
||||||
|
|
||||||
-func1(arg1).func2(arg2).func3(arg3).func4(arg4).func5(arg5)
|
-func1(arg1).func2(arg2).func3(arg3).func4(arg4).func5(arg5)
|
||||||
+func1(arg1).func2(arg2,).func3(arg3).func4(arg4,).func5(arg5)
|
+NOT_YET_IMPLEMENTED_ExprCall
|
||||||
|
|
||||||
-(a, b, c, d) = func1(arg1) and func2(arg2)
|
-(a, b, c, d) = func1(arg1) and func2(arg2)
|
||||||
+(
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
+ a,
|
|
||||||
+ b,
|
|
||||||
+ c,
|
|
||||||
+ d,
|
|
||||||
+) = func1(
|
|
||||||
+ arg1
|
|
||||||
+) and func2(arg2)
|
|
||||||
|
|
||||||
-func(argument1, (one, two), argument4, argument5, argument6)
|
-func(argument1, (one, two), argument4, argument5, argument6)
|
||||||
+func(
|
+NOT_YET_IMPLEMENTED_ExprCall
|
||||||
+ argument1,
|
|
||||||
+ (
|
|
||||||
+ one,
|
|
||||||
+ two,
|
|
||||||
+ ),
|
|
||||||
+ argument4,
|
|
||||||
+ argument5,
|
|
||||||
+ argument6,
|
|
||||||
+)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
# We should not remove the trailing comma in a single-element subscript.
|
# We should not remove the trailing comma in a single-element subscript.
|
||||||
a: tuple[int,]
|
NOT_YET_IMPLEMENTED_StmtAnnAssign
|
||||||
b = tuple[int,]
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
# But commas in multiple element subscripts should be removed.
|
# But commas in multiple element subscripts should be removed.
|
||||||
c: tuple[int, int,]
|
NOT_YET_IMPLEMENTED_StmtAnnAssign
|
||||||
d = tuple[int, int,]
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
# Remove commas for non-subscripts.
|
# Remove commas for non-subscripts.
|
||||||
small_list = [1,]
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
list_of_types = [tuple[int,],]
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
small_set = {1,}
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
set_of_types = {tuple[int,],}
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
# Except single element tuples
|
# Except single element tuples
|
||||||
small_tuple = (1,)
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
|
|
||||||
# Trailing commas in multiple chained non-nested parens.
|
# Trailing commas in multiple chained non-nested parens.
|
||||||
zero(
|
NOT_YET_IMPLEMENTED_ExprCall
|
||||||
one,
|
|
||||||
).two(
|
|
||||||
three,
|
|
||||||
).four(
|
|
||||||
five,
|
|
||||||
)
|
|
||||||
|
|
||||||
func1(arg1).func2(arg2,).func3(arg3).func4(arg4,).func5(arg5)
|
NOT_YET_IMPLEMENTED_ExprCall
|
||||||
|
|
||||||
(
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
a,
|
|
||||||
b,
|
|
||||||
c,
|
|
||||||
d,
|
|
||||||
) = func1(
|
|
||||||
arg1
|
|
||||||
) and func2(arg2)
|
|
||||||
|
|
||||||
func(
|
NOT_YET_IMPLEMENTED_ExprCall
|
||||||
argument1,
|
|
||||||
(
|
|
||||||
one,
|
|
||||||
two,
|
|
||||||
),
|
|
||||||
argument4,
|
|
||||||
argument5,
|
|
||||||
argument6,
|
|
||||||
)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -76,127 +76,137 @@ x[
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -31,14 +31,17 @@
|
@@ -1,59 +1,37 @@
|
||||||
ham[lower + offset : upper + offset]
|
-slice[a.b : c.d]
|
||||||
|
-slice[d :: d + 1]
|
||||||
|
-slice[d + 1 :: d]
|
||||||
|
-slice[d::d]
|
||||||
|
-slice[0]
|
||||||
|
-slice[-1]
|
||||||
|
-slice[:-1]
|
||||||
|
-slice[::-1]
|
||||||
|
-slice[:c, c - 1]
|
||||||
|
-slice[c, c + 1, d::]
|
||||||
|
-slice[ham[c::d] :: 1]
|
||||||
|
-slice[ham[cheese**2 : -1] : 1 : 1, ham[1:2]]
|
||||||
|
-slice[:-1:]
|
||||||
|
-slice[lambda: None : lambda: None]
|
||||||
|
-slice[lambda x, y, *args, really=2, **kwargs: None :, None::]
|
||||||
|
-slice[1 or 2 : True and False]
|
||||||
|
-slice[not so_simple : 1 < val <= 10]
|
||||||
|
-slice[(1 for i in range(42)) : x]
|
||||||
|
-slice[:: [i for i in range(42)]]
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
|
|
||||||
slice[::, ::]
|
|
||||||
|
-async def f():
|
||||||
|
- slice[await x : [i async for i in arange(42)] : 42]
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
# These are from PEP-8:
|
||||||
|
-ham[1:9], ham[1:9:3], ham[:9:3], ham[1::3], ham[1:9:]
|
||||||
|
-ham[lower:upper], ham[lower:upper:], ham[lower::step]
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprTuple
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprTuple
|
||||||
|
# ham[lower+offset : upper+offset]
|
||||||
|
-ham[: upper_fn(x) : step_fn(x)], ham[:: step_fn(x)]
|
||||||
|
-ham[lower + offset : upper + offset]
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprTuple
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
|
|
||||||
|
-slice[::, ::]
|
||||||
-slice[
|
-slice[
|
||||||
+(
|
- # A
|
||||||
+ slice[
|
- :
|
||||||
# A
|
- # B
|
||||||
:
|
- :
|
||||||
# B
|
- # C
|
||||||
:
|
-]
|
||||||
# C
|
|
||||||
]
|
|
||||||
-slice[
|
-slice[
|
||||||
+)
|
- # A
|
||||||
+(
|
- 1:
|
||||||
+ slice[
|
- # B
|
||||||
# A
|
- 2:
|
||||||
1:
|
- # C
|
||||||
# B
|
- 3
|
||||||
@@ -46,8 +49,10 @@
|
-]
|
||||||
# C
|
+NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
3
|
+NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
]
|
+NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
+)
|
|
||||||
|
|
||||||
-slice[
|
-slice[
|
||||||
+(
|
- # A
|
||||||
+ slice[
|
- 1
|
||||||
# A
|
- + 2 :
|
||||||
1
|
- # B
|
||||||
+ 2 :
|
- 3 :
|
||||||
@@ -56,4 +61,11 @@
|
- # C
|
||||||
# C
|
- 4
|
||||||
4
|
-]
|
||||||
]
|
|
||||||
-x[1:2:3] # A # B # C
|
-x[1:2:3] # A # B # C
|
||||||
+)
|
+NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
+(
|
+NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
+ x[
|
|
||||||
+ 1: # A
|
|
||||||
+ 2: # B
|
|
||||||
+ 3 # C
|
|
||||||
+]
|
|
||||||
+)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
slice[a.b : c.d]
|
NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
slice[d :: d + 1]
|
NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
slice[d + 1 :: d]
|
NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
slice[d::d]
|
NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
slice[0]
|
NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
slice[-1]
|
NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
slice[:-1]
|
NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
slice[::-1]
|
NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
slice[:c, c - 1]
|
NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
slice[c, c + 1, d::]
|
NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
slice[ham[c::d] :: 1]
|
NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
slice[ham[cheese**2 : -1] : 1 : 1, ham[1:2]]
|
NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
slice[:-1:]
|
NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
slice[lambda: None : lambda: None]
|
NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
slice[lambda x, y, *args, really=2, **kwargs: None :, None::]
|
NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
slice[1 or 2 : True and False]
|
NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
slice[not so_simple : 1 < val <= 10]
|
NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
slice[(1 for i in range(42)) : x]
|
NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
slice[:: [i for i in range(42)]]
|
NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
|
|
||||||
|
|
||||||
async def f():
|
NOT_YET_IMPLEMENTED_StmtAsyncFunctionDef
|
||||||
slice[await x : [i async for i in arange(42)] : 42]
|
|
||||||
|
|
||||||
|
|
||||||
# These are from PEP-8:
|
# These are from PEP-8:
|
||||||
ham[1:9], ham[1:9:3], ham[:9:3], ham[1::3], ham[1:9:]
|
NOT_YET_IMPLEMENTED_ExprTuple
|
||||||
ham[lower:upper], ham[lower:upper:], ham[lower::step]
|
NOT_YET_IMPLEMENTED_ExprTuple
|
||||||
# ham[lower+offset : upper+offset]
|
# ham[lower+offset : upper+offset]
|
||||||
ham[: upper_fn(x) : step_fn(x)], ham[:: step_fn(x)]
|
NOT_YET_IMPLEMENTED_ExprTuple
|
||||||
ham[lower + offset : upper + offset]
|
NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
|
|
||||||
slice[::, ::]
|
NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
(
|
NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
slice[
|
NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
# A
|
|
||||||
:
|
|
||||||
# B
|
|
||||||
:
|
|
||||||
# C
|
|
||||||
]
|
|
||||||
)
|
|
||||||
(
|
|
||||||
slice[
|
|
||||||
# A
|
|
||||||
1:
|
|
||||||
# B
|
|
||||||
2:
|
|
||||||
# C
|
|
||||||
3
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
(
|
NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
slice[
|
NOT_YET_IMPLEMENTED_ExprSubscript
|
||||||
# A
|
|
||||||
1
|
|
||||||
+ 2 :
|
|
||||||
# B
|
|
||||||
3 :
|
|
||||||
# C
|
|
||||||
4
|
|
||||||
]
|
|
||||||
)
|
|
||||||
(
|
|
||||||
x[
|
|
||||||
1: # A
|
|
||||||
2: # B
|
|
||||||
3 # C
|
|
||||||
]
|
|
||||||
)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -33,25 +33,36 @@ def docstring_multiline():
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -1,13 +1,13 @@
|
@@ -1,20 +1,16 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
name = "Łukasz"
|
-name = "Łukasz"
|
||||||
-(f"hello {name}", f"hello {name}")
|
-(f"hello {name}", f"hello {name}")
|
||||||
-(b"", b"")
|
-(b"", b"")
|
||||||
-("", "")
|
-("", "")
|
||||||
+(f"hello {name}", F"hello {name}")
|
-(r"", R"")
|
||||||
+(b"", B"")
|
+NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
+(u"", U"")
|
+NOT_YET_IMPLEMENTED_ExprTuple
|
||||||
(r"", R"")
|
+NOT_YET_IMPLEMENTED_ExprTuple
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprTuple
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprTuple
|
||||||
|
|
||||||
-(rf"", rf"", Rf"", Rf"", rf"", rf"", Rf"", Rf"")
|
-(rf"", rf"", Rf"", Rf"", rf"", rf"", Rf"", Rf"")
|
||||||
-(rb"", rb"", Rb"", Rb"", rb"", rb"", Rb"", Rb"")
|
-(rb"", rb"", Rb"", Rb"", rb"", rb"", Rb"", Rb"")
|
||||||
+(rf"", fr"", Rf"", fR"", rF"", Fr"", RF"", FR"")
|
+NOT_YET_IMPLEMENTED_ExprTuple
|
||||||
+(rb"", br"", Rb"", bR"", rB"", Br"", RB"", BR"")
|
+NOT_YET_IMPLEMENTED_ExprTuple
|
||||||
|
|
||||||
|
|
||||||
def docstring_singleline():
|
-def docstring_singleline():
|
||||||
|
- R"""2020 was one hell of a year. The good news is that we were able to"""
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
|
|
||||||
|
|
||||||
|
-def docstring_multiline():
|
||||||
|
- R"""
|
||||||
|
- clear out all of the issues opened in that time :p
|
||||||
|
- """
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
@ -59,24 +70,20 @@ def docstring_multiline():
|
||||||
```py
|
```py
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
name = "Łukasz"
|
NOT_YET_IMPLEMENTED_StmtAssign
|
||||||
(f"hello {name}", F"hello {name}")
|
NOT_YET_IMPLEMENTED_ExprTuple
|
||||||
(b"", B"")
|
NOT_YET_IMPLEMENTED_ExprTuple
|
||||||
(u"", U"")
|
NOT_YET_IMPLEMENTED_ExprTuple
|
||||||
(r"", R"")
|
NOT_YET_IMPLEMENTED_ExprTuple
|
||||||
|
|
||||||
(rf"", fr"", Rf"", fR"", rF"", Fr"", RF"", FR"")
|
NOT_YET_IMPLEMENTED_ExprTuple
|
||||||
(rb"", br"", Rb"", bR"", rB"", Br"", RB"", BR"")
|
NOT_YET_IMPLEMENTED_ExprTuple
|
||||||
|
|
||||||
|
|
||||||
def docstring_singleline():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
R"""2020 was one hell of a year. The good news is that we were able to"""
|
|
||||||
|
|
||||||
|
|
||||||
def docstring_multiline():
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
R"""
|
|
||||||
clear out all of the issues opened in that time :p
|
|
||||||
"""
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -42,16 +42,18 @@ assert (
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -2,18 +2,13 @@
|
@@ -1,58 +1,20 @@
|
||||||
|
importA
|
||||||
(
|
(
|
||||||
()
|
- ()
|
||||||
<< 0
|
- << 0
|
||||||
- ** 101234234242352525425252352352525234890264906820496920680926538059059209922523523525
|
- ** 101234234242352525425252352352525234890264906820496920680926538059059209922523523525
|
||||||
+ **101234234242352525425252352352525234890264906820496920680926538059059209922523523525
|
+ NOT_YET_IMPLEMENTED_ExprTuple
|
||||||
|
+ << NOT_YET_IMPLEMENTED_ExprConstant**NOT_YET_IMPLEMENTED_ExprConstant
|
||||||
) #
|
) #
|
||||||
|
|
||||||
assert sort_by_dependency(
|
-assert sort_by_dependency(
|
||||||
{
|
- {
|
||||||
- "1": {"2", "3"},
|
- "1": {"2", "3"},
|
||||||
- "2": {"2a", "2b"},
|
- "2": {"2a", "2b"},
|
||||||
- "3": {"3a", "3b"},
|
- "3": {"3a", "3b"},
|
||||||
|
@ -59,23 +61,27 @@ assert (
|
||||||
- "2b": set(),
|
- "2b": set(),
|
||||||
- "3a": set(),
|
- "3a": set(),
|
||||||
- "3b": set(),
|
- "3b": set(),
|
||||||
+ "1": {"2", "3"}, "2": {"2a", "2b"}, "3": {"3a", "3b"},
|
- }
|
||||||
+ "2a": set(), "2b": set(), "3a": set(), "3b": set()
|
-) == ["2a", "2b", "2", "3a", "3b", "3", "1"]
|
||||||
}
|
+NOT_YET_IMPLEMENTED_StmtAssert
|
||||||
) == ["2a", "2b", "2", "3a", "3b", "3", "1"]
|
|
||||||
|
|
||||||
@@ -25,34 +20,18 @@
|
importA
|
||||||
class A:
|
-0
|
||||||
def foo(self):
|
-0 ^ 0 #
|
||||||
for _ in range(10):
|
+NOT_YET_IMPLEMENTED_ExprConstant
|
||||||
|
+NOT_YET_IMPLEMENTED_ExprConstant ^ NOT_YET_IMPLEMENTED_ExprConstant #
|
||||||
|
|
||||||
|
|
||||||
|
-class A:
|
||||||
|
- def foo(self):
|
||||||
|
- for _ in range(10):
|
||||||
- aaaaaaaaaaaaaaaaaaa = bbbbbbbbbbbbbbb.cccccccccc(
|
- aaaaaaaaaaaaaaaaaaa = bbbbbbbbbbbbbbb.cccccccccc(
|
||||||
+ aaaaaaaaaaaaaaaaaaa = bbbbbbbbbbbbbbb.cccccccccc( # pylint: disable=no-member
|
- xxxxxxxxxxxx
|
||||||
xxxxxxxxxxxx
|
|
||||||
- ) # pylint: disable=no-member
|
- ) # pylint: disable=no-member
|
||||||
+ )
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
|
|
||||||
|
|
||||||
def test(self, othr):
|
-def test(self, othr):
|
||||||
- return 1 == 2 and (
|
- return 1 == 2 and (
|
||||||
- name,
|
- name,
|
||||||
- description,
|
- description,
|
||||||
|
@ -95,19 +101,14 @@ assert (
|
||||||
- othr.meta_data,
|
- othr.meta_data,
|
||||||
- othr.schedule,
|
- othr.schedule,
|
||||||
- )
|
- )
|
||||||
+ return (1 == 2 and
|
+NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
+ (name, description, self.default, self.selected, self.auto_generated, self.parameters, self.meta_data, self.schedule) ==
|
|
||||||
+ (name, description, othr.default, othr.selected, othr.auto_generated, othr.parameters, othr.meta_data, othr.schedule))
|
|
||||||
|
|
||||||
|
|
||||||
-assert a_function(
|
-assert a_function(
|
||||||
- very_long_arguments_that_surpass_the_limit,
|
- very_long_arguments_that_surpass_the_limit,
|
||||||
- which_is_eighty_eight_in_this_case_plus_a_bit_more,
|
- which_is_eighty_eight_in_this_case_plus_a_bit_more,
|
||||||
-) == {"x": "this need to pass the line limit as well", "b": "but only by a little bit"}
|
-) == {"x": "this need to pass the line limit as well", "b": "but only by a little bit"}
|
||||||
+assert (
|
+NOT_YET_IMPLEMENTED_StmtAssert
|
||||||
+ a_function(very_long_arguments_that_surpass_the_limit, which_is_eighty_eight_in_this_case_plus_a_bit_more)
|
|
||||||
+ == {"x": "this need to pass the line limit as well", "b": "but only by a little bit"}
|
|
||||||
+)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
@ -115,41 +116,24 @@ assert (
|
||||||
```py
|
```py
|
||||||
importA
|
importA
|
||||||
(
|
(
|
||||||
()
|
NOT_YET_IMPLEMENTED_ExprTuple
|
||||||
<< 0
|
<< NOT_YET_IMPLEMENTED_ExprConstant**NOT_YET_IMPLEMENTED_ExprConstant
|
||||||
**101234234242352525425252352352525234890264906820496920680926538059059209922523523525
|
|
||||||
) #
|
) #
|
||||||
|
|
||||||
assert sort_by_dependency(
|
NOT_YET_IMPLEMENTED_StmtAssert
|
||||||
{
|
|
||||||
"1": {"2", "3"}, "2": {"2a", "2b"}, "3": {"3a", "3b"},
|
|
||||||
"2a": set(), "2b": set(), "3a": set(), "3b": set()
|
|
||||||
}
|
|
||||||
) == ["2a", "2b", "2", "3a", "3b", "3", "1"]
|
|
||||||
|
|
||||||
importA
|
importA
|
||||||
0
|
NOT_YET_IMPLEMENTED_ExprConstant
|
||||||
0 ^ 0 #
|
NOT_YET_IMPLEMENTED_ExprConstant ^ NOT_YET_IMPLEMENTED_ExprConstant #
|
||||||
|
|
||||||
|
|
||||||
class A:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
def foo(self):
|
|
||||||
for _ in range(10):
|
|
||||||
aaaaaaaaaaaaaaaaaaa = bbbbbbbbbbbbbbb.cccccccccc( # pylint: disable=no-member
|
|
||||||
xxxxxxxxxxxx
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test(self, othr):
|
NOT_YET_IMPLEMENTED_StmtFunctionDef
|
||||||
return (1 == 2 and
|
|
||||||
(name, description, self.default, self.selected, self.auto_generated, self.parameters, self.meta_data, self.schedule) ==
|
|
||||||
(name, description, othr.default, othr.selected, othr.auto_generated, othr.parameters, othr.meta_data, othr.schedule))
|
|
||||||
|
|
||||||
|
|
||||||
assert (
|
NOT_YET_IMPLEMENTED_StmtAssert
|
||||||
a_function(very_long_arguments_that_surpass_the_limit, which_is_eighty_eight_in_this_case_plus_a_bit_more)
|
|
||||||
== {"x": "this need to pass the line limit as well", "b": "but only by a little bit"}
|
|
||||||
)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
|
@ -38,17 +38,16 @@ class A:
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -1,18 +1,11 @@
|
@@ -1,34 +1,9 @@
|
||||||
-if e1234123412341234.winerror not in (
|
-if e1234123412341234.winerror not in (
|
||||||
- _winapi.ERROR_SEM_TIMEOUT,
|
- _winapi.ERROR_SEM_TIMEOUT,
|
||||||
- _winapi.ERROR_PIPE_BUSY,
|
- _winapi.ERROR_PIPE_BUSY,
|
||||||
-) or _check_timeout(t):
|
-) or _check_timeout(t):
|
||||||
+if e1234123412341234.winerror not in (_winapi.ERROR_SEM_TIMEOUT,
|
- pass
|
||||||
+ _winapi.ERROR_PIPE_BUSY) or _check_timeout(t):
|
+NOT_YET_IMPLEMENTED_StmtIf
|
||||||
pass
|
|
||||||
|
|
||||||
if x:
|
-if x:
|
||||||
if y:
|
- if y:
|
||||||
- new_id = (
|
- new_id = (
|
||||||
- max(
|
- max(
|
||||||
- Vegetable.objects.order_by("-id")[0].id,
|
- Vegetable.objects.order_by("-id")[0].id,
|
||||||
|
@ -56,52 +55,42 @@ class A:
|
||||||
- )
|
- )
|
||||||
- + 1
|
- + 1
|
||||||
- )
|
- )
|
||||||
+ new_id = max(Vegetable.objects.order_by('-id')[0].id,
|
+NOT_YET_IMPLEMENTED_StmtIf
|
||||||
+ Mineral.objects.order_by('-id')[0].id) + 1
|
|
||||||
|
|
||||||
|
|
||||||
class X:
|
-class X:
|
||||||
@@ -21,7 +14,7 @@
|
- def get_help_text(self):
|
||||||
"Your password must contain at least %(min_length)d character.",
|
- return ngettext(
|
||||||
"Your password must contain at least %(min_length)d characters.",
|
- "Your password must contain at least %(min_length)d character.",
|
||||||
self.min_length,
|
- "Your password must contain at least %(min_length)d characters.",
|
||||||
|
- self.min_length,
|
||||||
- ) % {"min_length": self.min_length}
|
- ) % {"min_length": self.min_length}
|
||||||
+ ) % {'min_length': self.min_length}
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
|
|
||||||
|
|
||||||
class A:
|
-class A:
|
||||||
|
- def b(self):
|
||||||
|
- if self.connection.mysql_is_mariadb and (
|
||||||
|
- 10,
|
||||||
|
- 4,
|
||||||
|
- 3,
|
||||||
|
- ) < self.connection.mysql_version < (10, 5, 2):
|
||||||
|
- pass
|
||||||
|
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```py
|
||||||
if e1234123412341234.winerror not in (_winapi.ERROR_SEM_TIMEOUT,
|
NOT_YET_IMPLEMENTED_StmtIf
|
||||||
_winapi.ERROR_PIPE_BUSY) or _check_timeout(t):
|
|
||||||
pass
|
|
||||||
|
|
||||||
if x:
|
NOT_YET_IMPLEMENTED_StmtIf
|
||||||
if y:
|
|
||||||
new_id = max(Vegetable.objects.order_by('-id')[0].id,
|
|
||||||
Mineral.objects.order_by('-id')[0].id) + 1
|
|
||||||
|
|
||||||
|
|
||||||
class X:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
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:
|
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||||
def b(self):
|
|
||||||
if self.connection.mysql_is_mariadb and (
|
|
||||||
10,
|
|
||||||
4,
|
|
||||||
3,
|
|
||||||
) < self.connection.mysql_version < (10, 5, 2):
|
|
||||||
pass
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue