Compare commits
16 Commits
charlie/do
...
v0.0.275
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5dd00b19e6 | ||
|
|
c0f93fcf3e | ||
|
|
3238a6ef1f | ||
|
|
96ecfae1c5 | ||
|
|
03694ef649 | ||
|
|
f9f0cf7524 | ||
|
|
eaa10ad2d9 | ||
|
|
84259f5440 | ||
|
|
e8ebe0a425 | ||
|
|
d407165aa7 | ||
|
|
f7e1cf4b51 | ||
|
|
7d4f8e59da | ||
|
|
2c63f8cdea | ||
|
|
1c0a3a467f | ||
|
|
6b8b318d6b | ||
|
|
c0c59b82ec |
6
.github/workflows/release.yaml
vendored
6
.github/workflows/release.yaml
vendored
@@ -491,16 +491,16 @@ jobs:
|
||||
- name: "Publish to GitHub"
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
draft: false
|
||||
draft: true
|
||||
files: binaries/*
|
||||
tag_name: v${{ inputs.tag }}
|
||||
|
||||
# After the release has been published, we update downstream repositories
|
||||
# This is separate because if this fails the release is still fine, we just need to do some manual workflow triggers
|
||||
update-dependents:
|
||||
name: Release
|
||||
name: Update dependents
|
||||
runs-on: ubuntu-latest
|
||||
needs: release
|
||||
needs: publish-release
|
||||
steps:
|
||||
- name: "Update pre-commit mirror"
|
||||
uses: actions/github-script@v6
|
||||
|
||||
18
Cargo.lock
generated
18
Cargo.lock
generated
@@ -733,7 +733,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "flake8-to-ruff"
|
||||
version = "0.0.274"
|
||||
version = "0.0.275"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
@@ -1793,7 +1793,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ruff"
|
||||
version = "0.0.274"
|
||||
version = "0.0.275"
|
||||
dependencies = [
|
||||
"annotate-snippets 0.9.1",
|
||||
"anyhow",
|
||||
@@ -1889,7 +1889,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ruff_cli"
|
||||
version = "0.0.274"
|
||||
version = "0.0.275"
|
||||
dependencies = [
|
||||
"annotate-snippets 0.9.1",
|
||||
"anyhow",
|
||||
@@ -2105,7 +2105,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruff_text_size"
|
||||
version = "0.0.0"
|
||||
source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=08ebbe40d7776cac6e3ba66277d435056f2b8dca#08ebbe40d7776cac6e3ba66277d435056f2b8dca"
|
||||
source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=f60e204b73b95bdb6ce87ccd0de34081b4a17c11#f60e204b73b95bdb6ce87ccd0de34081b4a17c11"
|
||||
dependencies = [
|
||||
"schemars",
|
||||
"serde",
|
||||
@@ -2183,7 +2183,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "rustpython-ast"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=08ebbe40d7776cac6e3ba66277d435056f2b8dca#08ebbe40d7776cac6e3ba66277d435056f2b8dca"
|
||||
source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=f60e204b73b95bdb6ce87ccd0de34081b4a17c11#f60e204b73b95bdb6ce87ccd0de34081b4a17c11"
|
||||
dependencies = [
|
||||
"is-macro",
|
||||
"num-bigint",
|
||||
@@ -2194,7 +2194,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "rustpython-format"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=08ebbe40d7776cac6e3ba66277d435056f2b8dca#08ebbe40d7776cac6e3ba66277d435056f2b8dca"
|
||||
source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=f60e204b73b95bdb6ce87ccd0de34081b4a17c11#f60e204b73b95bdb6ce87ccd0de34081b4a17c11"
|
||||
dependencies = [
|
||||
"bitflags 2.3.1",
|
||||
"itertools",
|
||||
@@ -2206,7 +2206,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "rustpython-literal"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=08ebbe40d7776cac6e3ba66277d435056f2b8dca#08ebbe40d7776cac6e3ba66277d435056f2b8dca"
|
||||
source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=f60e204b73b95bdb6ce87ccd0de34081b4a17c11#f60e204b73b95bdb6ce87ccd0de34081b4a17c11"
|
||||
dependencies = [
|
||||
"hexf-parse",
|
||||
"is-macro",
|
||||
@@ -2218,7 +2218,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "rustpython-parser"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=08ebbe40d7776cac6e3ba66277d435056f2b8dca#08ebbe40d7776cac6e3ba66277d435056f2b8dca"
|
||||
source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=f60e204b73b95bdb6ce87ccd0de34081b4a17c11#f60e204b73b95bdb6ce87ccd0de34081b4a17c11"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"is-macro",
|
||||
@@ -2241,7 +2241,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "rustpython-parser-core"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=08ebbe40d7776cac6e3ba66277d435056f2b8dca#08ebbe40d7776cac6e3ba66277d435056f2b8dca"
|
||||
source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=f60e204b73b95bdb6ce87ccd0de34081b4a17c11#f60e204b73b95bdb6ce87ccd0de34081b4a17c11"
|
||||
dependencies = [
|
||||
"is-macro",
|
||||
"memchr",
|
||||
|
||||
10
Cargo.toml
10
Cargo.toml
@@ -50,15 +50,15 @@ toml = { version = "0.7.2" }
|
||||
# v0.0.1
|
||||
libcst = { git = "https://github.com/charliermarsh/LibCST", rev = "80e4c1399f95e5beb532fdd1e209ad2dbb470438" }
|
||||
# v0.0.3
|
||||
ruff_text_size = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "08ebbe40d7776cac6e3ba66277d435056f2b8dca" }
|
||||
ruff_text_size = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "f60e204b73b95bdb6ce87ccd0de34081b4a17c11" }
|
||||
# v0.0.3
|
||||
rustpython-ast = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "08ebbe40d7776cac6e3ba66277d435056f2b8dca" , default-features = false, features = ["all-nodes-with-ranges", "num-bigint"]}
|
||||
rustpython-ast = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "f60e204b73b95bdb6ce87ccd0de34081b4a17c11" , default-features = false, features = ["all-nodes-with-ranges", "num-bigint"]}
|
||||
# v0.0.3
|
||||
rustpython-format = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "08ebbe40d7776cac6e3ba66277d435056f2b8dca", default-features = false, features = ["num-bigint"] }
|
||||
rustpython-format = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "f60e204b73b95bdb6ce87ccd0de34081b4a17c11", default-features = false, features = ["num-bigint"] }
|
||||
# v0.0.3
|
||||
rustpython-literal = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "08ebbe40d7776cac6e3ba66277d435056f2b8dca", default-features = false }
|
||||
rustpython-literal = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "f60e204b73b95bdb6ce87ccd0de34081b4a17c11", default-features = false }
|
||||
# v0.0.3
|
||||
rustpython-parser = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "08ebbe40d7776cac6e3ba66277d435056f2b8dca" , default-features = false, features = ["full-lexer", "all-nodes-with-ranges", "num-bigint"] }
|
||||
rustpython-parser = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "f60e204b73b95bdb6ce87ccd0de34081b4a17c11" , default-features = false, features = ["full-lexer", "all-nodes-with-ranges", "num-bigint"] }
|
||||
|
||||
[profile.release]
|
||||
lto = "fat"
|
||||
|
||||
@@ -139,7 +139,7 @@ Ruff can also be used as a [pre-commit](https://pre-commit.com) hook:
|
||||
```yaml
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
# Ruff version.
|
||||
rev: v0.0.274
|
||||
rev: v0.0.275
|
||||
hooks:
|
||||
- id: ruff
|
||||
```
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "flake8-to-ruff"
|
||||
version = "0.0.274"
|
||||
version = "0.0.275"
|
||||
description = """
|
||||
Convert Flake8 configuration files to Ruff configuration files.
|
||||
"""
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ruff"
|
||||
version = "0.0.274"
|
||||
version = "0.0.275"
|
||||
publish = false
|
||||
authors = { workspace = true }
|
||||
edition = { workspace = true }
|
||||
|
||||
@@ -48,3 +48,12 @@ if True: from collections import (
|
||||
|
||||
# OK
|
||||
from a import b
|
||||
|
||||
# Ok: `typing_extensions` contains backported improvements.
|
||||
from typing_extensions import SupportsIndex
|
||||
|
||||
# Ok: `typing_extensions` contains backported improvements.
|
||||
from typing_extensions import NamedTuple
|
||||
|
||||
# Ok: `typing_extensions` supports `frozen_default` (backported from 3.12).
|
||||
from typing_extensions import dataclass_transform
|
||||
|
||||
@@ -445,7 +445,7 @@ impl Notebook {
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
mod tests {
|
||||
use std::path::Path;
|
||||
|
||||
use anyhow::Result;
|
||||
|
||||
@@ -6,7 +6,7 @@ use ruff_macros::{derive_message_formats, violation};
|
||||
use crate::checkers::ast::Checker;
|
||||
|
||||
/// ## What it does
|
||||
/// Checks for usages of comparators other than `<` and `>=` for
|
||||
/// Checks for uses of comparators other than `<` and `>=` for
|
||||
/// `sys.version_info` checks in `.pyi` files. All other comparators, such
|
||||
/// as `>`, `<=`, and `==`, are banned.
|
||||
///
|
||||
|
||||
@@ -7,7 +7,7 @@ use ruff_python_semantic::SemanticModel;
|
||||
use crate::checkers::ast::Checker;
|
||||
|
||||
/// ## What it does
|
||||
/// Checks for usages of the builtin `open()` function without an associated context
|
||||
/// Checks for uses of the builtin `open()` function without an associated context
|
||||
/// manager.
|
||||
///
|
||||
/// ## Why is this bad?
|
||||
|
||||
@@ -108,8 +108,7 @@ pub(crate) fn invalid_escape_sequence(
|
||||
let range = TextRange::at(location, next_char.text_len() + TextSize::from(1));
|
||||
let mut diagnostic = Diagnostic::new(InvalidEscapeSequence(*next_char), range);
|
||||
if autofix {
|
||||
#[allow(deprecated)]
|
||||
diagnostic.set_fix(Fix::unspecified(Edit::insertion(
|
||||
diagnostic.set_fix(Fix::automatic(Edit::insertion(
|
||||
r"\".to_string(),
|
||||
range.start() + TextSize::from(1),
|
||||
)));
|
||||
|
||||
@@ -92,8 +92,7 @@ pub(crate) fn missing_whitespace(
|
||||
let mut diagnostic = Diagnostic::new(kind, token.range());
|
||||
|
||||
if autofix {
|
||||
#[allow(deprecated)]
|
||||
diagnostic.set_fix(Fix::unspecified(Edit::insertion(
|
||||
diagnostic.set_fix(Fix::automatic(Edit::insertion(
|
||||
" ".to_string(),
|
||||
token.end(),
|
||||
)));
|
||||
|
||||
@@ -65,8 +65,7 @@ pub(crate) fn whitespace_before_parameters(
|
||||
let mut diagnostic = Diagnostic::new(kind, TextRange::new(start, end));
|
||||
|
||||
if autofix {
|
||||
#[allow(deprecated)]
|
||||
diagnostic.set_fix(Fix::unspecified(Edit::deletion(start, end)));
|
||||
diagnostic.set_fix(Fix::automatic(Edit::deletion(start, end)));
|
||||
}
|
||||
context.push_diagnostic(diagnostic);
|
||||
}
|
||||
|
||||
@@ -55,8 +55,7 @@ pub(crate) fn no_newline_at_end_of_file(
|
||||
|
||||
let mut diagnostic = Diagnostic::new(MissingNewlineAtEndOfFile, range);
|
||||
if autofix {
|
||||
#[allow(deprecated)]
|
||||
diagnostic.set_fix(Fix::unspecified(Edit::insertion(
|
||||
diagnostic.set_fix(Fix::automatic(Edit::insertion(
|
||||
stylist.line_ending().to_string(),
|
||||
range.start(),
|
||||
)));
|
||||
|
||||
@@ -11,7 +11,7 @@ E21.py:2:5: E211 [*] Whitespace before '('
|
||||
|
|
||||
= help: Removed whitespace before '('
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
1 1 | #: E211
|
||||
2 |-spam (1)
|
||||
2 |+spam(1)
|
||||
@@ -30,7 +30,7 @@ E21.py:4:5: E211 [*] Whitespace before '['
|
||||
|
|
||||
= help: Removed whitespace before '['
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
1 1 | #: E211
|
||||
2 2 | spam (1)
|
||||
3 3 | #: E211 E211
|
||||
@@ -51,7 +51,7 @@ E21.py:4:20: E211 [*] Whitespace before '['
|
||||
|
|
||||
= help: Removed whitespace before '['
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
1 1 | #: E211
|
||||
2 2 | spam (1)
|
||||
3 3 | #: E211 E211
|
||||
@@ -72,7 +72,7 @@ E21.py:6:12: E211 [*] Whitespace before '['
|
||||
|
|
||||
= help: Removed whitespace before '['
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
3 3 | #: E211 E211
|
||||
4 4 | dict ['key'] = list [index]
|
||||
5 5 | #: E211
|
||||
|
||||
@@ -11,7 +11,7 @@ E23.py:2:7: E231 [*] Missing whitespace after ','
|
||||
|
|
||||
= help: Added missing whitespace after ','
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
1 1 | #: E231
|
||||
2 |-a = (1,2)
|
||||
2 |+a = (1, 2)
|
||||
@@ -30,7 +30,7 @@ E23.py:4:5: E231 [*] Missing whitespace after ','
|
||||
|
|
||||
= help: Added missing whitespace after ','
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
1 1 | #: E231
|
||||
2 2 | a = (1,2)
|
||||
3 3 | #: E231
|
||||
@@ -51,7 +51,7 @@ E23.py:6:10: E231 [*] Missing whitespace after ':'
|
||||
|
|
||||
= help: Added missing whitespace after ':'
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
3 3 | #: E231
|
||||
4 4 | a[b1,:]
|
||||
5 5 | #: E231
|
||||
@@ -71,7 +71,7 @@ E23.py:19:10: E231 [*] Missing whitespace after ','
|
||||
|
|
||||
= help: Added missing whitespace after ','
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
16 16 |
|
||||
17 17 | def foo() -> None:
|
||||
18 18 | #: E231
|
||||
@@ -91,7 +91,7 @@ E23.py:29:20: E231 [*] Missing whitespace after ':'
|
||||
|
|
||||
= help: Added missing whitespace after ':'
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
26 26 | #: E231:2:20
|
||||
27 27 | mdtypes_template = {
|
||||
28 28 | 'tag_full': [('mdtype', 'u4'), ('byte_count', 'u4')],
|
||||
|
||||
@@ -9,7 +9,7 @@ W292_0.py:2:9: W292 [*] No newline at end of file
|
||||
|
|
||||
= help: Add trailing newline
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
1 1 | def fn() -> None:
|
||||
2 |- pass
|
||||
2 |+ pass
|
||||
|
||||
@@ -11,7 +11,7 @@ W605_0.py:2:10: W605 [*] Invalid escape sequence: `\.`
|
||||
|
|
||||
= help: Add backslash to escape sequence
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
1 1 | #: W605:1:10
|
||||
2 |-regex = '\.png$'
|
||||
2 |+regex = '\\.png$'
|
||||
@@ -29,7 +29,7 @@ W605_0.py:6:1: W605 [*] Invalid escape sequence: `\.`
|
||||
|
|
||||
= help: Add backslash to escape sequence
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
3 3 |
|
||||
4 4 | #: W605:2:1
|
||||
5 5 | regex = '''
|
||||
@@ -49,7 +49,7 @@ W605_0.py:11:6: W605 [*] Invalid escape sequence: `\_`
|
||||
|
|
||||
= help: Add backslash to escape sequence
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
8 8 |
|
||||
9 9 | #: W605:2:6
|
||||
10 10 | f(
|
||||
@@ -70,7 +70,7 @@ W605_0.py:18:6: W605 [*] Invalid escape sequence: `\_`
|
||||
|
|
||||
= help: Add backslash to escape sequence
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
15 15 | """
|
||||
16 16 | multi-line
|
||||
17 17 | literal
|
||||
|
||||
@@ -11,7 +11,7 @@ W605_1.py:2:10: W605 [*] Invalid escape sequence: `\.`
|
||||
|
|
||||
= help: Add backslash to escape sequence
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
1 1 | #: W605:1:10
|
||||
2 |-regex = '\.png$'
|
||||
2 |+regex = '\\.png$'
|
||||
@@ -29,7 +29,7 @@ W605_1.py:6:1: W605 [*] Invalid escape sequence: `\.`
|
||||
|
|
||||
= help: Add backslash to escape sequence
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
3 3 |
|
||||
4 4 | #: W605:2:1
|
||||
5 5 | regex = '''
|
||||
@@ -49,7 +49,7 @@ W605_1.py:11:6: W605 [*] Invalid escape sequence: `\_`
|
||||
|
|
||||
= help: Add backslash to escape sequence
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
8 8 |
|
||||
9 9 | #: W605:2:6
|
||||
10 10 | f(
|
||||
@@ -70,7 +70,7 @@ W605_1.py:18:6: W605 [*] Invalid escape sequence: `\_`
|
||||
|
|
||||
= help: Add backslash to escape sequence
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
15 15 | """
|
||||
16 16 | multi-line
|
||||
17 17 | literal
|
||||
|
||||
@@ -8,7 +8,7 @@ W292_4.py:1:2: W292 [*] No newline at end of file
|
||||
|
|
||||
= help: Add trailing newline
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
1 |-
|
||||
1 |+
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use ruff_macros::{derive_message_formats, violation};
|
||||
use crate::checkers::ast::Checker;
|
||||
|
||||
/// ## What it does
|
||||
/// Checks for usages of the builtin `eval()` function.
|
||||
/// Checks for uses of the builtin `eval()` function.
|
||||
///
|
||||
/// ## Why is this bad?
|
||||
/// The `eval()` function is insecure as it enables arbitrary code execution.
|
||||
|
||||
@@ -6,7 +6,7 @@ use ruff_macros::{derive_message_formats, violation};
|
||||
use crate::checkers::ast::Checker;
|
||||
|
||||
/// ## What it does
|
||||
/// Checks for usages of `await` outside of `async` functions.
|
||||
/// Checks for uses of `await` outside of `async` functions.
|
||||
///
|
||||
/// ## Why is this bad?
|
||||
/// Using `await` outside of an `async` function is a syntax error.
|
||||
|
||||
@@ -7,7 +7,7 @@ use ruff_python_ast::source_code::OneIndexed;
|
||||
use crate::checkers::ast::Checker;
|
||||
|
||||
/// ## What it does
|
||||
/// Checks for usages of names that are declared as `global` prior to the
|
||||
/// Checks for uses of names that are declared as `global` prior to the
|
||||
/// relevant `global` declaration.
|
||||
///
|
||||
/// ## Why is this bad?
|
||||
|
||||
@@ -6,7 +6,7 @@ use ruff_macros::{derive_message_formats, violation};
|
||||
use crate::checkers::ast::Checker;
|
||||
|
||||
/// ## What it does
|
||||
/// Checks for usages of named expressions (e.g., `a := 42`) that can be
|
||||
/// Checks for uses of named expressions (e.g., `a := 42`) that can be
|
||||
/// replaced by regular assignment statements (e.g., `a = 42`).
|
||||
///
|
||||
/// ## Why is this bad?
|
||||
|
||||
@@ -126,7 +126,7 @@ pub(crate) fn remove_import_members(contents: &str, members: &[&str]) -> String
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
mod tests {
|
||||
use crate::rules::pyupgrade::fixes::remove_import_members;
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -43,6 +43,12 @@ enum Deprecation {
|
||||
/// Deprecated imports may be removed in future versions of Python, and
|
||||
/// should be replaced with their new equivalents.
|
||||
///
|
||||
/// Note that, in some cases, it may be preferable to continue importing
|
||||
/// members from `typing_extensions` even after they're added to the Python
|
||||
/// standard library, as `typing_extensions` can backport bugfixes and
|
||||
/// optimizations from later Python versions. This rule thus avoids flagging
|
||||
/// imports from `typing_extensions` in such cases.
|
||||
///
|
||||
/// ## Example
|
||||
/// ```python
|
||||
/// from collections import Sequence
|
||||
@@ -139,10 +145,12 @@ const TYPING_EXTENSIONS_TO_TYPING: &[&str] = &[
|
||||
"ContextManager",
|
||||
"Coroutine",
|
||||
"DefaultDict",
|
||||
"NewType",
|
||||
"TYPE_CHECKING",
|
||||
"Text",
|
||||
"Type",
|
||||
// Introduced in Python 3.5.2, but `typing_extensions` contains backported bugfixes and
|
||||
// optimizations,
|
||||
// "NewType",
|
||||
];
|
||||
|
||||
// Python 3.7+
|
||||
@@ -168,11 +176,13 @@ const MYPY_EXTENSIONS_TO_TYPING_38: &[&str] = &["TypedDict"];
|
||||
// Members of `typing_extensions` that were moved to `typing`.
|
||||
const TYPING_EXTENSIONS_TO_TYPING_38: &[&str] = &[
|
||||
"Final",
|
||||
"Literal",
|
||||
"OrderedDict",
|
||||
"Protocol",
|
||||
"SupportsIndex",
|
||||
"runtime_checkable",
|
||||
// Introduced in Python 3.8, but `typing_extensions` contains backported bugfixes and
|
||||
// optimizations.
|
||||
// "Literal",
|
||||
// "Protocol",
|
||||
// "SupportsIndex",
|
||||
];
|
||||
|
||||
// Python 3.9+
|
||||
@@ -243,6 +253,8 @@ const TYPING_TO_COLLECTIONS_ABC_310: &[&str] = &["Callable"];
|
||||
// Members of `typing_extensions` that were moved to `typing`.
|
||||
const TYPING_EXTENSIONS_TO_TYPING_310: &[&str] = &[
|
||||
"Concatenate",
|
||||
"Literal",
|
||||
"NewType",
|
||||
"ParamSpecArgs",
|
||||
"ParamSpecKwargs",
|
||||
"TypeAlias",
|
||||
@@ -258,21 +270,19 @@ const TYPING_EXTENSIONS_TO_TYPING_310: &[&str] = &[
|
||||
const TYPING_EXTENSIONS_TO_TYPING_311: &[&str] = &[
|
||||
"Any",
|
||||
"LiteralString",
|
||||
"NamedTuple",
|
||||
"Never",
|
||||
"NotRequired",
|
||||
"Required",
|
||||
"Self",
|
||||
"TypedDict",
|
||||
"Unpack",
|
||||
"assert_never",
|
||||
"assert_type",
|
||||
"clear_overloads",
|
||||
"dataclass_transform",
|
||||
"final",
|
||||
"get_overloads",
|
||||
"overload",
|
||||
"reveal_type",
|
||||
// Introduced in Python 3.11, but `typing_extensions` backports the `frozen_default` argument.
|
||||
// "dataclass_transform",
|
||||
];
|
||||
|
||||
struct ImportReplacer<'a> {
|
||||
|
||||
@@ -477,7 +477,7 @@ pub(crate) fn printf_string_formatting(
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
mod tests {
|
||||
use test_case::test_case;
|
||||
|
||||
use super::*;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ruff_cli"
|
||||
version = "0.0.274"
|
||||
version = "0.0.275"
|
||||
publish = false
|
||||
authors = { workspace = true }
|
||||
edition = { workspace = true }
|
||||
|
||||
@@ -299,7 +299,7 @@ pub(crate) fn init(path: &Path) -> Result<()> {
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
mod tests {
|
||||
use std::env::temp_dir;
|
||||
use std::fs;
|
||||
use std::io::{self, Write};
|
||||
|
||||
@@ -346,7 +346,7 @@ pub(crate) fn lint_stdin(
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
mod tests {
|
||||
use std::path::Path;
|
||||
|
||||
use crate::diagnostics::{load_jupyter_notebook, Diagnostics};
|
||||
|
||||
@@ -42,6 +42,9 @@ pub(crate) struct Args {
|
||||
/// Print only the first error and exit, `-x` is same as pytest
|
||||
#[arg(long, short = 'x')]
|
||||
pub(crate) exit_first_error: bool,
|
||||
/// Checks each project inside a directory
|
||||
#[arg(long)]
|
||||
pub(crate) multi_project: bool,
|
||||
}
|
||||
|
||||
/// Generate ourself a `try_parse_from` impl for `CheckArgs`. This is a strange way to use clap but
|
||||
@@ -54,6 +57,35 @@ struct WrapperArgs {
|
||||
}
|
||||
|
||||
pub(crate) fn main(args: &Args) -> anyhow::Result<ExitCode> {
|
||||
let all_success = if args.multi_project {
|
||||
let mut all_success = true;
|
||||
for base_dir in &args.files {
|
||||
for dir in base_dir.read_dir()? {
|
||||
let dir = dir?;
|
||||
println!("Starting {}", dir.path().display());
|
||||
let success = check_repo(&Args {
|
||||
files: vec![dir.path().clone()],
|
||||
..*args
|
||||
});
|
||||
println!("Finished {}: {:?}", dir.path().display(), success);
|
||||
if !matches!(success, Ok(true)) {
|
||||
all_success = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
all_success
|
||||
} else {
|
||||
check_repo(args)?
|
||||
};
|
||||
if all_success {
|
||||
Ok(ExitCode::SUCCESS)
|
||||
} else {
|
||||
Ok(ExitCode::FAILURE)
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns whether the check was successful
|
||||
pub(crate) fn check_repo(args: &Args) -> anyhow::Result<bool> {
|
||||
let start = Instant::now();
|
||||
|
||||
// Find files to check (or in this case, format twice). Adapted from ruff_cli
|
||||
@@ -77,13 +109,20 @@ pub(crate) fn main(args: &Args) -> anyhow::Result<ExitCode> {
|
||||
let (paths, _resolver) = python_files_in_path(&cli.files, &pyproject_config, &overrides)?;
|
||||
assert!(!paths.is_empty(), "no python files in {:?}", cli.files);
|
||||
|
||||
let mut formatted_counter = 0;
|
||||
let errors = paths
|
||||
.into_iter()
|
||||
.map(|dir_entry| {
|
||||
// Doesn't make sense to recover here in this test script
|
||||
let file = dir_entry
|
||||
.expect("Iterating the files in the repository failed")
|
||||
.into_path();
|
||||
dir_entry.expect("Iterating the files in the repository failed")
|
||||
})
|
||||
.filter(|dir_entry| {
|
||||
// For some reason it does not filter in the beginning
|
||||
dir_entry.file_name() != "pyproject.toml"
|
||||
})
|
||||
.map(|dir_entry| {
|
||||
let file = dir_entry.path().to_path_buf();
|
||||
formatted_counter += 1;
|
||||
// Handle panics (mostly in `debug_assert!`)
|
||||
let result = match catch_unwind(|| check_file(&file)) {
|
||||
Ok(result) => result,
|
||||
@@ -166,20 +205,20 @@ Formatted twice:
|
||||
}
|
||||
|
||||
if args.exit_first_error {
|
||||
return Ok(ExitCode::FAILURE);
|
||||
return Ok(false);
|
||||
}
|
||||
}
|
||||
let duration = start.elapsed();
|
||||
println!(
|
||||
"Formatting {} files twice took {:.2}s",
|
||||
cli.files.len(),
|
||||
formatted_counter,
|
||||
duration.as_secs_f32()
|
||||
);
|
||||
|
||||
if any_errors {
|
||||
Ok(ExitCode::FAILURE)
|
||||
Ok(false)
|
||||
} else {
|
||||
Ok(ExitCode::SUCCESS)
|
||||
Ok(true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ fn check_help_text() -> String {
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
mod tests {
|
||||
use anyhow::Result;
|
||||
|
||||
use crate::generate_all::Mode;
|
||||
|
||||
@@ -53,7 +53,7 @@ pub(crate) fn main(args: &Args) -> Result<()> {
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
mod tests {
|
||||
use anyhow::Result;
|
||||
use std::env;
|
||||
|
||||
|
||||
@@ -48,3 +48,11 @@ mapping = {
|
||||
C: 0.1 * (10.0 / 12),
|
||||
D: 0.1 * (10.0 / 12),
|
||||
}
|
||||
|
||||
# Regression test for formatter panic with comment after parenthesized dict value
|
||||
# Originally found in https://github.com/bolucat/Firefox/blob/636a717ef025c16434997dc89e42351ef740ee6b/testing/marionette/client/marionette_driver/geckoinstance.py#L109
|
||||
a = {
|
||||
1: (2),
|
||||
# comment
|
||||
3: True,
|
||||
}
|
||||
|
||||
36
crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/class_definition.py
vendored
Normal file
36
crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/class_definition.py
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
class Test(
|
||||
Aaaaaaaaaaaaaaaaa,
|
||||
Bbbbbbbbbbbbbbbb,
|
||||
DDDDDDDDDDDDDDDD,
|
||||
EEEEEEEEEEEEEE,
|
||||
metaclass=meta,
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
class Test((Aaaaaaaaaaaaaaaaa), Bbbbbbbbbbbbbbbb, metaclass=meta):
|
||||
pass
|
||||
|
||||
class Test( # trailing class comment
|
||||
Aaaaaaaaaaaaaaaaa, # trailing comment
|
||||
|
||||
# in between comment
|
||||
|
||||
Bbbbbbbbbbbbbbbb,
|
||||
# another leading comment
|
||||
DDDDDDDDDDDDDDDD,
|
||||
EEEEEEEEEEEEEE,
|
||||
# meta comment
|
||||
metaclass=meta, # trailing meta comment
|
||||
):
|
||||
pass
|
||||
|
||||
class Test((Aaaa)):
|
||||
...
|
||||
|
||||
|
||||
class Test(aaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbb + cccccccccccccccccccccccc + dddddddddddddddddddddd + eeeeeeeee, ffffffffffffffffff, gggggggggggggggggg):
|
||||
pass
|
||||
|
||||
class Test(Aaaa): # trailing comment
|
||||
pass
|
||||
@@ -582,6 +582,12 @@ fn handle_trailing_end_of_line_condition_comment<'a>(
|
||||
.as_deref()
|
||||
.map(AnyNodeRef::from)
|
||||
.or_else(|| Some(AnyNodeRef::from(args.as_ref()))),
|
||||
AnyNodeRef::StmtClassDef(StmtClassDef {
|
||||
bases, keywords, ..
|
||||
}) => keywords
|
||||
.last()
|
||||
.map(AnyNodeRef::from)
|
||||
.or_else(|| bases.last().map(AnyNodeRef::from)),
|
||||
_ => None,
|
||||
};
|
||||
|
||||
@@ -622,8 +628,13 @@ fn handle_trailing_end_of_line_condition_comment<'a>(
|
||||
TokenKind::RParen => {
|
||||
// Skip over any closing parentheses
|
||||
}
|
||||
_ => {
|
||||
unreachable!("Only ')' or ':' should follow the condition")
|
||||
TokenKind::Comma => {
|
||||
// Skip over any trailing comma
|
||||
}
|
||||
kind => {
|
||||
unreachable!(
|
||||
"Only ')' or ':' should follow the condition but encountered {kind:?}"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -980,14 +991,22 @@ fn handle_dict_unpacking_comment<'a>(
|
||||
.skip_trivia();
|
||||
|
||||
// we start from the preceding node but we skip its token
|
||||
if let Some(first) = tokens.next() {
|
||||
debug_assert!(matches!(
|
||||
first,
|
||||
Token {
|
||||
kind: TokenKind::LBrace | TokenKind::Comma | TokenKind::Colon,
|
||||
..
|
||||
}
|
||||
));
|
||||
for token in tokens.by_ref() {
|
||||
// Skip closing parentheses that are not part of the node range
|
||||
if token.kind == TokenKind::RParen {
|
||||
continue;
|
||||
}
|
||||
debug_assert!(
|
||||
matches!(
|
||||
token,
|
||||
Token {
|
||||
kind: TokenKind::LBrace | TokenKind::Comma | TokenKind::Colon,
|
||||
..
|
||||
}
|
||||
),
|
||||
"{token:?}",
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
// if the remaining tokens from the previous node is exactly `**`,
|
||||
|
||||
@@ -10,11 +10,20 @@ use rustpython_parser::ast::ExprCall;
|
||||
pub struct FormatExprCall;
|
||||
|
||||
impl FormatNodeRule<ExprCall> for FormatExprCall {
|
||||
fn fmt_fields(&self, _item: &ExprCall, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
write!(
|
||||
f,
|
||||
[not_yet_implemented_custom_text("NOT_IMPLEMENTED_call()")]
|
||||
)
|
||||
fn fmt_fields(&self, item: &ExprCall, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
if item.args.is_empty() && item.keywords.is_empty() {
|
||||
write!(
|
||||
f,
|
||||
[not_yet_implemented_custom_text("NOT_IMPLEMENTED_call()")]
|
||||
)
|
||||
} else {
|
||||
write!(
|
||||
f,
|
||||
[not_yet_implemented_custom_text(
|
||||
"NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)"
|
||||
)]
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@ pub(super) fn default_expression_needs_parentheses(
|
||||
#[allow(clippy::if_same_then_else)]
|
||||
if parenthesize.is_always() {
|
||||
Parentheses::Always
|
||||
} else if parenthesize.is_never() {
|
||||
Parentheses::Never
|
||||
}
|
||||
// `Optional` or `Preserve` and expression has parentheses in source code.
|
||||
else if !parenthesize.is_if_breaks() && is_expression_parenthesized(node, source) {
|
||||
@@ -58,7 +60,11 @@ pub enum Parenthesize {
|
||||
/// Parenthesizes the expression only if it doesn't fit on a line.
|
||||
IfBreaks,
|
||||
|
||||
/// Always adds parentheses
|
||||
Always,
|
||||
|
||||
/// Never adds parentheses. Parentheses are handled by the caller.
|
||||
Never,
|
||||
}
|
||||
|
||||
impl Parenthesize {
|
||||
@@ -66,6 +72,10 @@ impl Parenthesize {
|
||||
matches!(self, Parenthesize::Always)
|
||||
}
|
||||
|
||||
pub(crate) const fn is_never(self) -> bool {
|
||||
matches!(self, Parenthesize::Never)
|
||||
}
|
||||
|
||||
pub(crate) const fn is_if_breaks(self) -> bool {
|
||||
matches!(self, Parenthesize::IfBreaks)
|
||||
}
|
||||
|
||||
@@ -247,12 +247,12 @@ mod tests {
|
||||
let input = r#"
|
||||
# preceding
|
||||
if True:
|
||||
print( "hi" )
|
||||
pass
|
||||
# trailing
|
||||
"#;
|
||||
let expected = r#"# preceding
|
||||
if True:
|
||||
NOT_IMPLEMENTED_call()
|
||||
pass
|
||||
# trailing
|
||||
"#;
|
||||
let actual = format_module(input)?.as_code().to_string();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use crate::prelude::*;
|
||||
use crate::FormatNodeRule;
|
||||
use ruff_formatter::write;
|
||||
use rustpython_parser::ast::Keyword;
|
||||
|
||||
#[derive(Default)]
|
||||
@@ -7,6 +8,15 @@ pub struct FormatKeyword;
|
||||
|
||||
impl FormatNodeRule<Keyword> for FormatKeyword {
|
||||
fn fmt_fields(&self, item: &Keyword, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
write!(f, [not_yet_implemented(item)])
|
||||
let Keyword {
|
||||
range: _,
|
||||
arg,
|
||||
value,
|
||||
} = item;
|
||||
if let Some(argument) = arg {
|
||||
write!(f, [argument.format(), text("=")])?;
|
||||
}
|
||||
|
||||
value.format().fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ y = 100(no)
|
||||
+x = (123456789.123456789E123456789).real
|
||||
+x = NOT_IMPLEMENTED_call()
|
||||
+x = 123456789J.real
|
||||
+x = NOT_IMPLEMENTED_call()
|
||||
+x = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+x = NOT_IMPLEMENTED_call()
|
||||
+x = NOT_IMPLEMENTED_call()
|
||||
+x = (0O777).real
|
||||
@@ -74,7 +74,7 @@ y = 100(no)
|
||||
|
||||
y = 100[no]
|
||||
-y = 100(no)
|
||||
+y = NOT_IMPLEMENTED_call()
|
||||
+y = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
@@ -90,7 +90,7 @@ x = NOT_IMPLEMENTED_call()
|
||||
x = (123456789.123456789E123456789).real
|
||||
x = NOT_IMPLEMENTED_call()
|
||||
x = 123456789J.real
|
||||
x = NOT_IMPLEMENTED_call()
|
||||
x = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
x = NOT_IMPLEMENTED_call()
|
||||
x = NOT_IMPLEMENTED_call()
|
||||
x = (0O777).real
|
||||
@@ -101,7 +101,7 @@ if (10).real:
|
||||
...
|
||||
|
||||
y = 100[no]
|
||||
y = NOT_IMPLEMENTED_call()
|
||||
y = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
||||
@@ -22,13 +22,13 @@ print("hello, world")
|
||||
+++ Ruff
|
||||
@@ -1 +1 @@
|
||||
-print("hello, world")
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
||||
@@ -1,135 +0,0 @@
|
||||
---
|
||||
source: crates/ruff_python_formatter/src/lib.rs
|
||||
expression: snapshot
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_cases/class_blank_parentheses.py
|
||||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
class SimpleClassWithBlankParentheses():
|
||||
pass
|
||||
class ClassWithSpaceParentheses ( ):
|
||||
first_test_data = 90
|
||||
second_test_data = 100
|
||||
def test_func(self):
|
||||
return None
|
||||
class ClassWithEmptyFunc(object):
|
||||
|
||||
def func_with_blank_parentheses():
|
||||
return 5
|
||||
|
||||
|
||||
def public_func_with_blank_parentheses():
|
||||
return None
|
||||
def class_under_the_func_with_blank_parentheses():
|
||||
class InsideFunc():
|
||||
pass
|
||||
class NormalClass (
|
||||
):
|
||||
def func_for_testing(self, first, second):
|
||||
sum = first + second
|
||||
return sum
|
||||
```
|
||||
|
||||
## Black Differences
|
||||
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -1,18 +1,10 @@
|
||||
-class SimpleClassWithBlankParentheses:
|
||||
- pass
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
|
||||
|
||||
-class ClassWithSpaceParentheses:
|
||||
- first_test_data = 90
|
||||
- second_test_data = 100
|
||||
-
|
||||
- def test_func(self):
|
||||
- return None
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
|
||||
|
||||
-class ClassWithEmptyFunc(object):
|
||||
- def func_with_blank_parentheses():
|
||||
- return 5
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
|
||||
|
||||
def public_func_with_blank_parentheses():
|
||||
@@ -20,11 +12,7 @@
|
||||
|
||||
|
||||
def class_under_the_func_with_blank_parentheses():
|
||||
- class InsideFunc:
|
||||
- pass
|
||||
+ NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
|
||||
|
||||
-class NormalClass:
|
||||
- def func_for_testing(self, first, second):
|
||||
- sum = first + second
|
||||
- return sum
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
|
||||
|
||||
def public_func_with_blank_parentheses():
|
||||
return None
|
||||
|
||||
|
||||
def class_under_the_func_with_blank_parentheses():
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
class SimpleClassWithBlankParentheses:
|
||||
pass
|
||||
|
||||
|
||||
class ClassWithSpaceParentheses:
|
||||
first_test_data = 90
|
||||
second_test_data = 100
|
||||
|
||||
def test_func(self):
|
||||
return None
|
||||
|
||||
|
||||
class ClassWithEmptyFunc(object):
|
||||
def func_with_blank_parentheses():
|
||||
return 5
|
||||
|
||||
|
||||
def public_func_with_blank_parentheses():
|
||||
return None
|
||||
|
||||
|
||||
def class_under_the_func_with_blank_parentheses():
|
||||
class InsideFunc:
|
||||
pass
|
||||
|
||||
|
||||
class NormalClass:
|
||||
def func_for_testing(self, first, second):
|
||||
sum = first + second
|
||||
return sum
|
||||
```
|
||||
|
||||
|
||||
@@ -113,259 +113,257 @@ class ClassWithDecoInitAndVarsAndDocstringWithInner2:
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -1,165 +1,61 @@
|
||||
-class ClassSimplest:
|
||||
- pass
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
|
||||
-class ClassWithSingleField:
|
||||
- a = 1
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
|
||||
|
||||
-class ClassWithJustTheDocstring:
|
||||
class ClassWithJustTheDocstring:
|
||||
- """Just a docstring."""
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
+ "NOT_YET_IMPLEMENTED_STRING"
|
||||
|
||||
|
||||
-class ClassWithInit:
|
||||
- def __init__(self):
|
||||
- pass
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class ClassWithInit:
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
|
||||
-class ClassWithTheDocstringAndInit:
|
||||
class ClassWithTheDocstringAndInit:
|
||||
- """Just a docstring."""
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
+ "NOT_YET_IMPLEMENTED_STRING"
|
||||
|
||||
- def __init__(self):
|
||||
- pass
|
||||
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
|
||||
-class ClassWithInitAndVars:
|
||||
- cls_var = 100
|
||||
|
||||
- def __init__(self):
|
||||
- pass
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
def __init__(self):
|
||||
pass
|
||||
@@ -30,8 +30,7 @@
|
||||
|
||||
|
||||
-class ClassWithInitAndVarsAndDocstring:
|
||||
class ClassWithInitAndVarsAndDocstring:
|
||||
- """Test class"""
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
-
|
||||
+ "NOT_YET_IMPLEMENTED_STRING"
|
||||
cls_var = 100
|
||||
|
||||
- cls_var = 100
|
||||
|
||||
- def __init__(self):
|
||||
- pass
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
def __init__(self):
|
||||
@@ -53,8 +52,7 @@
|
||||
|
||||
|
||||
-class ClassWithDecoInit:
|
||||
- @deco
|
||||
- def __init__(self):
|
||||
- pass
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
|
||||
|
||||
-class ClassWithDecoInitAndVars:
|
||||
- cls_var = 100
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
|
||||
- @deco
|
||||
- def __init__(self):
|
||||
- pass
|
||||
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
|
||||
-class ClassWithDecoInitAndVarsAndDocstring:
|
||||
class ClassWithDecoInitAndVarsAndDocstring:
|
||||
- """Test class"""
|
||||
-
|
||||
+ "NOT_YET_IMPLEMENTED_STRING"
|
||||
cls_var = 100
|
||||
|
||||
- cls_var = 100
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
@deco
|
||||
@@ -69,7 +67,7 @@
|
||||
|
||||
- @deco
|
||||
- def __init__(self):
|
||||
- pass
|
||||
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
|
||||
-class ClassSimplestWithInner:
|
||||
- class Inner:
|
||||
- pass
|
||||
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
|
||||
-class ClassSimplestWithInnerWithDocstring:
|
||||
- class Inner:
|
||||
class ClassSimplestWithInnerWithDocstring:
|
||||
class Inner:
|
||||
- """Just a docstring."""
|
||||
+ "NOT_YET_IMPLEMENTED_STRING"
|
||||
|
||||
- def __init__(self):
|
||||
- pass
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
def __init__(self):
|
||||
pass
|
||||
@@ -83,7 +81,7 @@
|
||||
|
||||
|
||||
-class ClassWithSingleFieldWithInner:
|
||||
- a = 1
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
|
||||
- class Inner:
|
||||
- pass
|
||||
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
|
||||
-class ClassWithJustTheDocstringWithInner:
|
||||
class ClassWithJustTheDocstringWithInner:
|
||||
- """Just a docstring."""
|
||||
+ "NOT_YET_IMPLEMENTED_STRING"
|
||||
|
||||
- class Inner:
|
||||
- pass
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class Inner:
|
||||
pass
|
||||
@@ -108,8 +106,7 @@
|
||||
|
||||
|
||||
-class ClassWithInitWithInner:
|
||||
- class Inner:
|
||||
- pass
|
||||
-
|
||||
- def __init__(self):
|
||||
- pass
|
||||
-
|
||||
-
|
||||
-class ClassWithInitAndVarsWithInner:
|
||||
- cls_var = 100
|
||||
-
|
||||
- class Inner:
|
||||
- pass
|
||||
-
|
||||
- def __init__(self):
|
||||
- pass
|
||||
-
|
||||
-
|
||||
-class ClassWithInitAndVarsAndDocstringWithInner:
|
||||
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
|
||||
+ "NOT_YET_IMPLEMENTED_STRING"
|
||||
cls_var = 100
|
||||
|
||||
class Inner:
|
||||
@@ -140,8 +137,7 @@
|
||||
|
||||
|
||||
-class ClassWithDecoInitAndVarsWithInner:
|
||||
- cls_var = 100
|
||||
-
|
||||
- class Inner:
|
||||
- pass
|
||||
-
|
||||
- @deco
|
||||
- def __init__(self):
|
||||
- pass
|
||||
-
|
||||
-
|
||||
-class ClassWithDecoInitAndVarsAndDocstringWithInner:
|
||||
class ClassWithDecoInitAndVarsAndDocstringWithInner:
|
||||
- """Test class"""
|
||||
-
|
||||
- cls_var = 100
|
||||
-
|
||||
- class Inner:
|
||||
- pass
|
||||
-
|
||||
- @deco
|
||||
- def __init__(self):
|
||||
- pass
|
||||
-
|
||||
-
|
||||
-class ClassWithDecoInitAndVarsAndDocstringWithInner2:
|
||||
+ "NOT_YET_IMPLEMENTED_STRING"
|
||||
cls_var = 100
|
||||
|
||||
class Inner:
|
||||
@@ -153,7 +149,7 @@
|
||||
|
||||
|
||||
class ClassWithDecoInitAndVarsAndDocstringWithInner2:
|
||||
- """Test class"""
|
||||
-
|
||||
- class Inner:
|
||||
- pass
|
||||
-
|
||||
- cls_var = 100
|
||||
-
|
||||
- @deco
|
||||
- def __init__(self):
|
||||
- pass
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
+ "NOT_YET_IMPLEMENTED_STRING"
|
||||
|
||||
class Inner:
|
||||
pass
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class ClassSimplest:
|
||||
pass
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class ClassWithSingleField:
|
||||
a = 1
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class ClassWithJustTheDocstring:
|
||||
"NOT_YET_IMPLEMENTED_STRING"
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class ClassWithInit:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class ClassWithTheDocstringAndInit:
|
||||
"NOT_YET_IMPLEMENTED_STRING"
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class ClassWithInitAndVars:
|
||||
cls_var = 100
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class ClassWithInitAndVarsAndDocstring:
|
||||
"NOT_YET_IMPLEMENTED_STRING"
|
||||
cls_var = 100
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class ClassWithDecoInit:
|
||||
@deco
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class ClassWithDecoInitAndVars:
|
||||
cls_var = 100
|
||||
|
||||
@deco
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class ClassWithDecoInitAndVarsAndDocstring:
|
||||
"NOT_YET_IMPLEMENTED_STRING"
|
||||
cls_var = 100
|
||||
|
||||
@deco
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class ClassSimplestWithInner:
|
||||
class Inner:
|
||||
pass
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class ClassSimplestWithInnerWithDocstring:
|
||||
class Inner:
|
||||
"NOT_YET_IMPLEMENTED_STRING"
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class ClassWithSingleFieldWithInner:
|
||||
a = 1
|
||||
|
||||
class Inner:
|
||||
pass
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class ClassWithJustTheDocstringWithInner:
|
||||
"NOT_YET_IMPLEMENTED_STRING"
|
||||
|
||||
class Inner:
|
||||
pass
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class ClassWithInitWithInner:
|
||||
class Inner:
|
||||
pass
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class ClassWithInitAndVarsWithInner:
|
||||
cls_var = 100
|
||||
|
||||
class Inner:
|
||||
pass
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class ClassWithInitAndVarsAndDocstringWithInner:
|
||||
"NOT_YET_IMPLEMENTED_STRING"
|
||||
cls_var = 100
|
||||
|
||||
class Inner:
|
||||
pass
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
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
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class ClassWithDecoInitAndVarsAndDocstringWithInner:
|
||||
"NOT_YET_IMPLEMENTED_STRING"
|
||||
cls_var = 100
|
||||
|
||||
class Inner:
|
||||
pass
|
||||
|
||||
@deco
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class ClassWithDecoInitAndVarsAndDocstringWithInner2:
|
||||
"NOT_YET_IMPLEMENTED_STRING"
|
||||
|
||||
class Inner:
|
||||
pass
|
||||
|
||||
cls_var = 100
|
||||
|
||||
@deco
|
||||
def __init__(self):
|
||||
pass
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
||||
@@ -178,7 +178,7 @@ if True:
|
||||
|
||||
division_result_tuple = (6 / 2,)
|
||||
-print("foo %r", (foo.bar,))
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
if True:
|
||||
IGNORED_TYPES_FOR_ATTRIBUTE_CHECKING = (
|
||||
@@ -204,9 +204,9 @@ if True:
|
||||
- "Delay": 5,
|
||||
- },
|
||||
- )
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
@@ -259,7 +259,7 @@ for (x,) in (1,), (2,), (3,):
|
||||
[1, 2, 3]
|
||||
|
||||
division_result_tuple = (6 / 2,)
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
if True:
|
||||
IGNORED_TYPES_FOR_ATTRIBUTE_CHECKING = (
|
||||
@@ -268,9 +268,9 @@ if True:
|
||||
)
|
||||
|
||||
if True:
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
||||
@@ -243,19 +243,19 @@ instruction()#comment with bad spacing
|
||||
Cheese,
|
||||
- Cheese("Wensleydale"),
|
||||
- SubBytes(b"spam"),
|
||||
+ NOT_IMPLEMENTED_call(),
|
||||
+ NOT_IMPLEMENTED_call(),
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg),
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg),
|
||||
]
|
||||
|
||||
-if "PYTHON" in os.environ:
|
||||
- add_compiler(compiler_from_env())
|
||||
+if NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
else:
|
||||
# for compiler in compilers.values():
|
||||
# add_compiler(compiler)
|
||||
- add_compiler(compilers[(7.0, 32)])
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
# add_compiler(compilers[(7.1, 64)])
|
||||
|
||||
|
||||
@@ -307,7 +307,7 @@ instruction()#comment with bad spacing
|
||||
-""",
|
||||
- arg3=True,
|
||||
- )
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
############################################################################
|
||||
|
||||
@@ -342,14 +342,14 @@ instruction()#comment with bad spacing
|
||||
- # right
|
||||
- if element is not None
|
||||
- ]
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+ lcomp = [i for i in []]
|
||||
+ lcomp2 = [i for i in []]
|
||||
+ lcomp3 = [i for i in []]
|
||||
while True:
|
||||
if False:
|
||||
continue
|
||||
@@ -141,25 +111,13 @@
|
||||
@@ -141,24 +111,18 @@
|
||||
# and round and round we go
|
||||
|
||||
# let's return
|
||||
@@ -357,7 +357,7 @@ instruction()#comment with bad spacing
|
||||
- syms.simple_stmt,
|
||||
- [Node(statement, result), Leaf(token.NEWLINE, "\n")], # FIXME: \r\n?
|
||||
- )
|
||||
+ return NOT_IMPLEMENTED_call()
|
||||
+ return NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
-CONFIG_FILES = (
|
||||
@@ -370,15 +370,17 @@ instruction()#comment with bad spacing
|
||||
+CONFIG_FILES = [CONFIG_FILE] + SHARED_CONFIG_FILES + USER_CONFIG_FILES # type: Final
|
||||
|
||||
|
||||
-class Test:
|
||||
- def _init_host(self, parsed) -> None:
|
||||
class Test:
|
||||
def _init_host(self, parsed) -> None:
|
||||
- if parsed.hostname is None or not parsed.hostname.strip(): # type: ignore
|
||||
- pass
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
+ if (
|
||||
+ NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right # type: ignore
|
||||
+ or not NOT_IMPLEMENTED_call()
|
||||
+ ):
|
||||
pass
|
||||
|
||||
|
||||
#######################
|
||||
@@ -167,7 +125,7 @@
|
||||
@@ -167,7 +131,7 @@
|
||||
#######################
|
||||
|
||||
|
||||
@@ -434,16 +436,16 @@ not_shareables = [
|
||||
"NOT_YET_IMPLEMENTED_STRING",
|
||||
# user-defined types and objects
|
||||
Cheese,
|
||||
NOT_IMPLEMENTED_call(),
|
||||
NOT_IMPLEMENTED_call(),
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg),
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg),
|
||||
]
|
||||
|
||||
if NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
else:
|
||||
# for compiler in compilers.values():
|
||||
# add_compiler(compiler)
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
# add_compiler(compilers[(7.1, 64)])
|
||||
|
||||
|
||||
@@ -489,11 +491,11 @@ def inline_comments_in_brackets_ruin_everything():
|
||||
]
|
||||
|
||||
# no newline after
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
############################################################################
|
||||
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
lcomp = [i for i in []]
|
||||
lcomp2 = [i for i in []]
|
||||
lcomp3 = [i for i in []]
|
||||
@@ -505,13 +507,19 @@ def inline_comments_in_brackets_ruin_everything():
|
||||
# and round and round we go
|
||||
|
||||
# let's return
|
||||
return NOT_IMPLEMENTED_call()
|
||||
return NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
CONFIG_FILES = [CONFIG_FILE] + SHARED_CONFIG_FILES + USER_CONFIG_FILES # type: Final
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class Test:
|
||||
def _init_host(self, parsed) -> None:
|
||||
if (
|
||||
NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right # type: ignore
|
||||
or not NOT_IMPLEMENTED_call()
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
#######################
|
||||
|
||||
@@ -80,7 +80,7 @@ def func():
|
||||
+ lcomp3 = [i for i in []]
|
||||
# Capture each of the exceptions in the MultiError along with each of their causes and contexts
|
||||
- if isinstance(exc_value, MultiError):
|
||||
+ if NOT_IMPLEMENTED_call():
|
||||
+ if NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
embedded = []
|
||||
for exc in exc_value.exceptions:
|
||||
- if exc not in _seen:
|
||||
@@ -98,7 +98,7 @@ def func():
|
||||
- # This should be left alone (after)
|
||||
- )
|
||||
+ if NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
# everything is fine if the expression isn't nested
|
||||
- traceback.TracebackException.from_exception(
|
||||
@@ -110,7 +110,7 @@ def func():
|
||||
- # shared between sub-exceptions are not omitted
|
||||
- _seen=set(_seen),
|
||||
- )
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
# %%
|
||||
@@ -127,14 +127,14 @@ def func():
|
||||
x = "NOT_YET_IMPLEMENTED_STRING"
|
||||
lcomp3 = [i for i in []]
|
||||
# Capture each of the exceptions in the MultiError along with each of their causes and contexts
|
||||
if NOT_IMPLEMENTED_call():
|
||||
if NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
embedded = []
|
||||
for exc in exc_value.exceptions:
|
||||
if NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
# everything is fine if the expression isn't nested
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
# %%
|
||||
|
||||
@@ -107,7 +107,7 @@ def foo3(list_a, list_b):
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -1,94 +1,22 @@
|
||||
@@ -1,94 +1,28 @@
|
||||
-from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
|
||||
- MyLovelyCompanyTeamProjectComponent, # NOT DRY
|
||||
-)
|
||||
@@ -118,7 +118,7 @@ def foo3(list_a, list_b):
|
||||
+NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||
|
||||
|
||||
-class C:
|
||||
class C:
|
||||
- @pytest.mark.parametrize(
|
||||
- ("post_data", "message"),
|
||||
- [
|
||||
@@ -161,12 +161,14 @@ def foo3(list_a, list_b):
|
||||
- ),
|
||||
- ],
|
||||
- )
|
||||
- def test_fails_invalid_post_data(
|
||||
- self, pyramid_config, db_request, post_data, message
|
||||
- ):
|
||||
+ @NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
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
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+ db_request.POST = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
def foo(list_a, list_b):
|
||||
@@ -195,7 +197,7 @@ def foo3(list_a, list_b):
|
||||
- )
|
||||
- .filter(User.xyz.is_(None))
|
||||
- )
|
||||
+ return NOT_IMPLEMENTED_call()
|
||||
+ return NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
def foo3(list_a, list_b):
|
||||
@@ -206,7 +208,7 @@ def foo3(list_a, list_b):
|
||||
- db.or_(User.field_a.astext.in_(list_a), User.field_b.astext.in_(list_b))
|
||||
- )
|
||||
- .filter(User.xyz.is_(None))
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
)
|
||||
```
|
||||
|
||||
@@ -217,7 +219,13 @@ NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||
NOT_YET_IMPLEMENTED_StmtImportFrom
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class C:
|
||||
@NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
def test_fails_invalid_post_data(
|
||||
self, pyramid_config, db_request, post_data, message
|
||||
):
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
db_request.POST = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
def foo(list_a, list_b):
|
||||
@@ -227,13 +235,13 @@ def foo(list_a, list_b):
|
||||
|
||||
def foo2(list_a, list_b):
|
||||
# Standalone comment reasonably placed.
|
||||
return NOT_IMPLEMENTED_call()
|
||||
return NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
def foo3(list_a, list_b):
|
||||
return (
|
||||
# Standalone comment but weirdly placed.
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
)
|
||||
```
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ if __name__ == "__main__":
|
||||
# This one is properly standalone now.
|
||||
|
||||
-for i in range(100):
|
||||
+for i in NOT_IMPLEMENTED_call():
|
||||
+for i in NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
# first we do this
|
||||
- if i % 33 == 0:
|
||||
+ if NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
|
||||
@@ -107,7 +107,7 @@ if __name__ == "__main__":
|
||||
|
||||
# then we do this
|
||||
- print(i)
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
# and finally we loop around
|
||||
|
||||
-with open(some_temp_file) as f:
|
||||
@@ -132,7 +132,7 @@ if __name__ == "__main__":
|
||||
@deco1
|
||||
# leading 2
|
||||
-@deco2(with_args=True)
|
||||
+@NOT_IMPLEMENTED_call()
|
||||
+@NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
# leading 3
|
||||
@deco3
|
||||
def decorated1():
|
||||
@@ -141,7 +141,7 @@ if __name__ == "__main__":
|
||||
@deco1
|
||||
# leading 2
|
||||
-@deco2(with_args=True)
|
||||
+@NOT_IMPLEMENTED_call()
|
||||
+@NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
# leading function comment
|
||||
def decorated1():
|
||||
...
|
||||
@@ -168,13 +168,13 @@ while True:
|
||||
|
||||
# This one is properly standalone now.
|
||||
|
||||
for i in NOT_IMPLEMENTED_call():
|
||||
for i in NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
# first we do this
|
||||
if NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
|
||||
break
|
||||
|
||||
# then we do this
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
# and finally we loop around
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtWith
|
||||
@@ -196,7 +196,7 @@ def wat():
|
||||
# leading 1
|
||||
@deco1
|
||||
# leading 2
|
||||
@NOT_IMPLEMENTED_call()
|
||||
@NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
# leading 3
|
||||
@deco3
|
||||
def decorated1():
|
||||
@@ -206,7 +206,7 @@ def decorated1():
|
||||
# leading 1
|
||||
@deco1
|
||||
# leading 2
|
||||
@NOT_IMPLEMENTED_call()
|
||||
@NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
# leading function comment
|
||||
def decorated1():
|
||||
...
|
||||
|
||||
@@ -169,12 +169,12 @@ aaaaaaaaaaaaa, bbbbbbbbb = map(list, map(itertools.chain.from_iterable, zip(*ite
|
||||
- 0.0789,
|
||||
- a[-1], # type: ignore
|
||||
- )
|
||||
+ c = NOT_IMPLEMENTED_call()
|
||||
+ c = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
- c = call(
|
||||
- "aaaaaaaa", "aaaaaaaa", "aaaaaaaa", "aaaaaaaa", "aaaaaaaa", "aaaaaaaa", "aaaaaaaa" # type: ignore
|
||||
- )
|
||||
+ c = NOT_IMPLEMENTED_call()
|
||||
+ c = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
-result = ( # aaa
|
||||
@@ -194,10 +194,10 @@ aaaaaaaaaaaaa, bbbbbbbbb = map(list, map(itertools.chain.from_iterable, zip(*ite
|
||||
- foo,
|
||||
- [AAAAAAAAAAAAAAAAAAAAAAA, AAAAAAAAAAAAAAAAAAAAAAA, AAAAAAAAAAAAAAAAAAAAAAA, BBBBBBBBBBBB], # type: ignore
|
||||
-)
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
-aaaaaaaaaaaaa, bbbbbbbbb = map(list, map(itertools.chain.from_iterable, zip(*items))) # type: ignore[arg-type]
|
||||
+aaaaaaaaaaaaa, bbbbbbbbb = NOT_IMPLEMENTED_call() # type: ignore[arg-type]
|
||||
+aaaaaaaaaaaaa, bbbbbbbbb = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg) # type: ignore[arg-type]
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
@@ -292,9 +292,9 @@ def f(
|
||||
def func(
|
||||
a=some_list[0], # type: int
|
||||
): # type: () -> int
|
||||
c = NOT_IMPLEMENTED_call()
|
||||
c = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
c = NOT_IMPLEMENTED_call()
|
||||
c = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
result = "NOT_YET_IMPLEMENTED_STRING" # aaa
|
||||
@@ -306,9 +306,9 @@ AAAAAAAAAAAAA = (
|
||||
+ AAAAAAAAAAAAA
|
||||
) # type: ignore
|
||||
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
aaaaaaaaaaaaa, bbbbbbbbb = NOT_IMPLEMENTED_call() # type: ignore[arg-type]
|
||||
aaaaaaaaaaaaa, bbbbbbbbb = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg) # type: ignore[arg-type]
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
||||
@@ -152,65 +152,43 @@ def bar():
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -30,8 +30,7 @@
|
||||
@@ -44,7 +44,7 @@
|
||||
|
||||
|
||||
# This comment should be split from the statement above by two lines.
|
||||
-class MyClass:
|
||||
- pass
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
|
||||
|
||||
some = statement
|
||||
@@ -39,17 +38,14 @@
|
||||
|
||||
|
||||
# This should be split from the above by two lines
|
||||
-class MyClassWithComplexLeadingComments:
|
||||
- pass
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
|
||||
|
||||
-class ClassWithDocstring:
|
||||
class ClassWithDocstring:
|
||||
- """A docstring."""
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
+ "NOT_YET_IMPLEMENTED_STRING"
|
||||
|
||||
|
||||
# Leading comment after a class with just a docstring
|
||||
-class MyClassAfterAnotherClassWithDocstring:
|
||||
- pass
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
|
||||
|
||||
some = statement
|
||||
@@ -59,7 +55,7 @@
|
||||
@@ -59,7 +59,7 @@
|
||||
@deco1
|
||||
# leading 2
|
||||
# leading 2 extra
|
||||
-@deco2(with_args=True)
|
||||
+@NOT_IMPLEMENTED_call()
|
||||
+@NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
# leading 3
|
||||
@deco3
|
||||
# leading 4
|
||||
@@ -73,7 +69,7 @@
|
||||
@@ -73,7 +73,7 @@
|
||||
# leading 1
|
||||
@deco1
|
||||
# leading 2
|
||||
-@deco2(with_args=True)
|
||||
+@NOT_IMPLEMENTED_call()
|
||||
+@NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
# leading 3 that already has an empty line
|
||||
@deco3
|
||||
@@ -88,7 +84,7 @@
|
||||
@@ -88,7 +88,7 @@
|
||||
# leading 1
|
||||
@deco1
|
||||
# leading 2
|
||||
-@deco2(with_args=True)
|
||||
+@NOT_IMPLEMENTED_call()
|
||||
+@NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
# leading 3
|
||||
@deco3
|
||||
|
||||
@@ -106,7 +102,6 @@
|
||||
@@ -106,7 +106,6 @@
|
||||
# Another leading comment
|
||||
def another_inline():
|
||||
pass
|
||||
@@ -218,7 +196,7 @@ def bar():
|
||||
else:
|
||||
# More leading comments
|
||||
def inline_after_else():
|
||||
@@ -121,18 +116,13 @@
|
||||
@@ -121,7 +120,6 @@
|
||||
# Another leading comment
|
||||
def another_top_level_quote_inline_inline():
|
||||
pass
|
||||
@@ -226,18 +204,6 @@ def bar():
|
||||
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.
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
@@ -275,7 +241,8 @@ some = statement
|
||||
|
||||
|
||||
# This comment should be split from the statement above by two lines.
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class MyClass:
|
||||
pass
|
||||
|
||||
|
||||
some = statement
|
||||
@@ -283,14 +250,17 @@ some = statement
|
||||
|
||||
|
||||
# This should be split from the above by two lines
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class MyClassWithComplexLeadingComments:
|
||||
pass
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class ClassWithDocstring:
|
||||
"NOT_YET_IMPLEMENTED_STRING"
|
||||
|
||||
|
||||
# Leading comment after a class with just a docstring
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class MyClassAfterAnotherClassWithDocstring:
|
||||
pass
|
||||
|
||||
|
||||
some = statement
|
||||
@@ -300,7 +270,7 @@ some = statement
|
||||
@deco1
|
||||
# leading 2
|
||||
# leading 2 extra
|
||||
@NOT_IMPLEMENTED_call()
|
||||
@NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
# leading 3
|
||||
@deco3
|
||||
# leading 4
|
||||
@@ -314,7 +284,7 @@ some = statement
|
||||
# leading 1
|
||||
@deco1
|
||||
# leading 2
|
||||
@NOT_IMPLEMENTED_call()
|
||||
@NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
# leading 3 that already has an empty line
|
||||
@deco3
|
||||
@@ -329,7 +299,7 @@ some = statement
|
||||
# leading 1
|
||||
@deco1
|
||||
# leading 2
|
||||
@NOT_IMPLEMENTED_call()
|
||||
@NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
# leading 3
|
||||
@deco3
|
||||
|
||||
@@ -367,7 +337,11 @@ else:
|
||||
pass
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class MyClass:
|
||||
# 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.
|
||||
|
||||
@@ -47,7 +47,7 @@ def function(a:int=42):
|
||||
result = 1 # type: ignore
|
||||
result = 1 # This comment is talking about type: ignore
|
||||
-square = Square(4) # type: Optional[Square]
|
||||
+square = NOT_IMPLEMENTED_call() # type: Optional[Square]
|
||||
+square = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg) # type: Optional[Square]
|
||||
|
||||
|
||||
def function(a: int = 42):
|
||||
@@ -71,7 +71,7 @@ result = (1,) # Another one
|
||||
|
||||
result = 1 # type: ignore
|
||||
result = 1 # This comment is talking about type: ignore
|
||||
square = NOT_IMPLEMENTED_call() # type: Optional[Square]
|
||||
square = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg) # type: Optional[Square]
|
||||
|
||||
|
||||
def function(a: int = 42):
|
||||
|
||||
@@ -114,16 +114,16 @@ async def wat():
|
||||
# Has many lines. Many, many lines.
|
||||
# Many, many, many lines.
|
||||
-"""Module docstring.
|
||||
-
|
||||
+"NOT_YET_IMPLEMENTED_STRING"
|
||||
|
||||
-Possibly also many, many lines.
|
||||
-"""
|
||||
+"NOT_YET_IMPLEMENTED_STRING"
|
||||
+NOT_YET_IMPLEMENTED_StmtImport
|
||||
+NOT_YET_IMPLEMENTED_StmtImport
|
||||
|
||||
-import os.path
|
||||
-import sys
|
||||
+NOT_YET_IMPLEMENTED_StmtImport
|
||||
+NOT_YET_IMPLEMENTED_StmtImport
|
||||
|
||||
-
|
||||
-import a
|
||||
-from b.c import X # some noqa comment
|
||||
+NOT_YET_IMPLEMENTED_StmtImport
|
||||
@@ -137,7 +137,7 @@ async def wat():
|
||||
|
||||
|
||||
# Some comment before a function.
|
||||
@@ -30,67 +24,50 @@
|
||||
@@ -30,25 +24,26 @@
|
||||
|
||||
|
||||
def function(default=None):
|
||||
@@ -166,42 +166,43 @@ async def wat():
|
||||
# Explains why we use global state.
|
||||
-GLOBAL_STATE = {"a": a(1), "b": a(2), "c": a(3)}
|
||||
+GLOBAL_STATE = {
|
||||
+ "NOT_YET_IMPLEMENTED_STRING": NOT_IMPLEMENTED_call(),
|
||||
+ "NOT_YET_IMPLEMENTED_STRING": NOT_IMPLEMENTED_call(),
|
||||
+ "NOT_YET_IMPLEMENTED_STRING": NOT_IMPLEMENTED_call(),
|
||||
+ "NOT_YET_IMPLEMENTED_STRING": NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg),
|
||||
+ "NOT_YET_IMPLEMENTED_STRING": NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg),
|
||||
+ "NOT_YET_IMPLEMENTED_STRING": NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg),
|
||||
+}
|
||||
|
||||
|
||||
# Another comment!
|
||||
# This time two lines.
|
||||
@@ -56,7 +51,7 @@
|
||||
|
||||
|
||||
-class Foo:
|
||||
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
|
||||
+ "NOT_YET_IMPLEMENTED_STRING"
|
||||
|
||||
#: Doc comment for class attribute Foo.bar.
|
||||
#: It can have multiple lines.
|
||||
@@ -65,32 +60,31 @@
|
||||
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
|
||||
+ "NOT_YET_IMPLEMENTED_STRING"
|
||||
|
||||
def __init__(self):
|
||||
#: Doc comment for instance attribute qux.
|
||||
self.qux = 3
|
||||
|
||||
self.spam = 4
|
||||
- """Docstring for instance attribute spam."""
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
+ "NOT_YET_IMPLEMENTED_STRING"
|
||||
|
||||
|
||||
#' <h1>This is pweave!</h1>
|
||||
|
||||
|
||||
-@fast(really=True)
|
||||
+@NOT_IMPLEMENTED_call()
|
||||
+@NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
async def wat():
|
||||
# This comment, for some reason \
|
||||
# contains a trailing backslash.
|
||||
@@ -211,7 +212,7 @@ async def wat():
|
||||
# Comment after ending a block.
|
||||
if result:
|
||||
- print("A OK", file=sys.stdout)
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
# Comment between things.
|
||||
- print()
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
@@ -269,9 +270,9 @@ def function(default=None):
|
||||
|
||||
# Explains why we use global state.
|
||||
GLOBAL_STATE = {
|
||||
"NOT_YET_IMPLEMENTED_STRING": NOT_IMPLEMENTED_call(),
|
||||
"NOT_YET_IMPLEMENTED_STRING": NOT_IMPLEMENTED_call(),
|
||||
"NOT_YET_IMPLEMENTED_STRING": NOT_IMPLEMENTED_call(),
|
||||
"NOT_YET_IMPLEMENTED_STRING": NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg),
|
||||
"NOT_YET_IMPLEMENTED_STRING": NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg),
|
||||
"NOT_YET_IMPLEMENTED_STRING": NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg),
|
||||
}
|
||||
|
||||
|
||||
@@ -279,20 +280,37 @@ GLOBAL_STATE = {
|
||||
# This time two lines.
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class Foo:
|
||||
"NOT_YET_IMPLEMENTED_STRING"
|
||||
|
||||
#: 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
|
||||
"NOT_YET_IMPLEMENTED_STRING"
|
||||
|
||||
def __init__(self):
|
||||
#: Doc comment for instance attribute qux.
|
||||
self.qux = 3
|
||||
|
||||
self.spam = 4
|
||||
"NOT_YET_IMPLEMENTED_STRING"
|
||||
|
||||
|
||||
#' <h1>This is pweave!</h1>
|
||||
|
||||
|
||||
@NOT_IMPLEMENTED_call()
|
||||
@NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
async def wat():
|
||||
# This comment, for some reason \
|
||||
# contains a trailing backslash.
|
||||
NOT_YET_IMPLEMENTED_StmtAsyncWith # Some more comments
|
||||
# Comment after ending a block.
|
||||
if result:
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
# Comment between things.
|
||||
NOT_IMPLEMENTED_call()
|
||||
|
||||
|
||||
@@ -194,9 +194,9 @@ class C:
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -1,181 +1 @@
|
||||
-class C:
|
||||
- def test(self) -> None:
|
||||
@@ -1,181 +1,46 @@
|
||||
class C:
|
||||
def test(self) -> None:
|
||||
- with patch("black.out", print):
|
||||
- self.assertEqual(
|
||||
- unstyle(str(report)), "1 file reformatted, 1 file failed to reformat."
|
||||
@@ -239,23 +239,38 @@ class C:
|
||||
- return (
|
||||
- 'Utterly failed doctest test for %s\n File "%s", line %s, in %s\n\n%s'
|
||||
- % (test.name, test.filename, lineno, lname, err)
|
||||
- )
|
||||
-
|
||||
- def omitting_trailers(self) -> None:
|
||||
+ NOT_YET_IMPLEMENTED_StmtWith
|
||||
+ xxxxxxxxxxxxxxxx = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+ return "NOT_YET_IMPLEMENTED_STRING" % (
|
||||
+ 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
|
||||
- ]
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)[OneLevelIndex]
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)[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:
|
||||
+ assignment = NOT_IMPLEMENTED_call() and another.rule.ending_with.index[123]
|
||||
|
||||
def easy_asserts(self) -> None:
|
||||
- assert {
|
||||
- key1: value1,
|
||||
- key2: value2,
|
||||
@@ -267,7 +282,8 @@ class C:
|
||||
- key8: value8,
|
||||
- key9: value9,
|
||||
- } == expected, "Not what we expected"
|
||||
-
|
||||
+ NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
- assert expected == {
|
||||
- key1: value1,
|
||||
- key2: value2,
|
||||
@@ -279,7 +295,8 @@ class C:
|
||||
- key8: value8,
|
||||
- key9: value9,
|
||||
- }, "Not what we expected"
|
||||
-
|
||||
+ NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
- assert expected == {
|
||||
- key1: value1,
|
||||
- key2: value2,
|
||||
@@ -291,8 +308,9 @@ class C:
|
||||
- key8: value8,
|
||||
- key9: value9,
|
||||
- }
|
||||
-
|
||||
- def tricky_asserts(self) -> None:
|
||||
+ NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
def tricky_asserts(self) -> None:
|
||||
- assert {
|
||||
- key1: value1,
|
||||
- key2: value2,
|
||||
@@ -306,7 +324,8 @@ class C:
|
||||
- } == expected(
|
||||
- value, is_going_to_be="too long to fit in a single line", srsly=True
|
||||
- ), "Not what we expected"
|
||||
-
|
||||
+ NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
- assert {
|
||||
- key1: value1,
|
||||
- key2: value2,
|
||||
@@ -320,7 +339,8 @@ class C:
|
||||
- } == expected, (
|
||||
- "Not what we expected and the message is too long to fit in one line"
|
||||
- )
|
||||
-
|
||||
+ NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
- assert expected(
|
||||
- value, is_going_to_be="too long to fit in a single line", srsly=True
|
||||
- ) == {
|
||||
@@ -334,7 +354,8 @@ class C:
|
||||
- key8: value8,
|
||||
- key9: value9,
|
||||
- }, "Not what we expected"
|
||||
-
|
||||
+ NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
- assert expected == {
|
||||
- key1: value1,
|
||||
- key2: value2,
|
||||
@@ -349,7 +370,8 @@ class C:
|
||||
- "Not what we expected and the message is too long to fit in one line"
|
||||
- " because it's too long"
|
||||
- )
|
||||
-
|
||||
+ NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
- dis_c_instance_method = """\
|
||||
- %3d 0 LOAD_FAST 1 (x)
|
||||
- 2 LOAD_CONST 1 (1)
|
||||
@@ -360,8 +382,11 @@ class C:
|
||||
- 12 RETURN_VALUE
|
||||
- """ % (
|
||||
- _C.__init__.__code__.co_firstlineno + 1,
|
||||
- )
|
||||
-
|
||||
+ dis_c_instance_method = "NOT_YET_IMPLEMENTED_STRING" % (
|
||||
+ _C.__init__.__code__.co_firstlineno
|
||||
+ + 1,
|
||||
)
|
||||
|
||||
- assert (
|
||||
- expectedexpectedexpectedexpectedexpectedexpectedexpectedexpectedexpect
|
||||
- == {
|
||||
@@ -376,13 +401,58 @@ class C:
|
||||
- key9: value9,
|
||||
- }
|
||||
- )
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
+ NOT_YET_IMPLEMENTED_StmtAssert
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class C:
|
||||
def test(self) -> None:
|
||||
NOT_YET_IMPLEMENTED_StmtWith
|
||||
xxxxxxxxxxxxxxxx = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
return "NOT_YET_IMPLEMENTED_STRING" % (
|
||||
test.name,
|
||||
test.filename,
|
||||
lineno,
|
||||
lname,
|
||||
err,
|
||||
)
|
||||
|
||||
def omitting_trailers(self) -> None:
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)[OneLevelIndex]
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)[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 = NOT_IMPLEMENTED_call() and another.rule.ending_with.index[123]
|
||||
|
||||
def easy_asserts(self) -> None:
|
||||
NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
def tricky_asserts(self) -> None:
|
||||
NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
dis_c_instance_method = "NOT_YET_IMPLEMENTED_STRING" % (
|
||||
_C.__init__.__code__.co_firstlineno
|
||||
+ 1,
|
||||
)
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtAssert
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
||||
@@ -194,9 +194,9 @@ class C:
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -1,181 +1 @@
|
||||
-class C:
|
||||
- def test(self) -> None:
|
||||
@@ -1,181 +1,46 @@
|
||||
class C:
|
||||
def test(self) -> None:
|
||||
- with patch("black.out", print):
|
||||
- self.assertEqual(
|
||||
- unstyle(str(report)), "1 file reformatted, 1 file failed to reformat."
|
||||
@@ -239,23 +239,38 @@ class C:
|
||||
- return (
|
||||
- 'Utterly failed doctest test for %s\n File "%s", line %s, in %s\n\n%s'
|
||||
- % (test.name, test.filename, lineno, lname, err)
|
||||
- )
|
||||
-
|
||||
- def omitting_trailers(self) -> None:
|
||||
+ NOT_YET_IMPLEMENTED_StmtWith
|
||||
+ xxxxxxxxxxxxxxxx = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+ return "NOT_YET_IMPLEMENTED_STRING" % (
|
||||
+ 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
|
||||
- ]
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)[OneLevelIndex]
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)[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:
|
||||
+ assignment = NOT_IMPLEMENTED_call() and another.rule.ending_with.index[123]
|
||||
|
||||
def easy_asserts(self) -> None:
|
||||
- assert {
|
||||
- key1: value1,
|
||||
- key2: value2,
|
||||
@@ -267,7 +282,8 @@ class C:
|
||||
- key8: value8,
|
||||
- key9: value9,
|
||||
- } == expected, "Not what we expected"
|
||||
-
|
||||
+ NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
- assert expected == {
|
||||
- key1: value1,
|
||||
- key2: value2,
|
||||
@@ -279,7 +295,8 @@ class C:
|
||||
- key8: value8,
|
||||
- key9: value9,
|
||||
- }, "Not what we expected"
|
||||
-
|
||||
+ NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
- assert expected == {
|
||||
- key1: value1,
|
||||
- key2: value2,
|
||||
@@ -291,8 +308,9 @@ class C:
|
||||
- key8: value8,
|
||||
- key9: value9,
|
||||
- }
|
||||
-
|
||||
- def tricky_asserts(self) -> None:
|
||||
+ NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
def tricky_asserts(self) -> None:
|
||||
- assert {
|
||||
- key1: value1,
|
||||
- key2: value2,
|
||||
@@ -306,7 +324,8 @@ class C:
|
||||
- } == expected(
|
||||
- value, is_going_to_be="too long to fit in a single line", srsly=True
|
||||
- ), "Not what we expected"
|
||||
-
|
||||
+ NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
- assert {
|
||||
- key1: value1,
|
||||
- key2: value2,
|
||||
@@ -320,7 +339,8 @@ class C:
|
||||
- } == expected, (
|
||||
- "Not what we expected and the message is too long to fit in one line"
|
||||
- )
|
||||
-
|
||||
+ NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
- assert expected(
|
||||
- value, is_going_to_be="too long to fit in a single line", srsly=True
|
||||
- ) == {
|
||||
@@ -334,7 +354,8 @@ class C:
|
||||
- key8: value8,
|
||||
- key9: value9,
|
||||
- }, "Not what we expected"
|
||||
-
|
||||
+ NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
- assert expected == {
|
||||
- key1: value1,
|
||||
- key2: value2,
|
||||
@@ -349,7 +370,8 @@ class C:
|
||||
- "Not what we expected and the message is too long to fit in one line"
|
||||
- " because it's too long"
|
||||
- )
|
||||
-
|
||||
+ NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
- dis_c_instance_method = """\
|
||||
- %3d 0 LOAD_FAST 1 (x)
|
||||
- 2 LOAD_CONST 1 (1)
|
||||
@@ -360,8 +382,11 @@ class C:
|
||||
- 12 RETURN_VALUE
|
||||
- """ % (
|
||||
- _C.__init__.__code__.co_firstlineno + 1,
|
||||
- )
|
||||
-
|
||||
+ dis_c_instance_method = "NOT_YET_IMPLEMENTED_STRING" % (
|
||||
+ _C.__init__.__code__.co_firstlineno
|
||||
+ + 1,
|
||||
)
|
||||
|
||||
- assert (
|
||||
- expectedexpectedexpectedexpectedexpectedexpectedexpectedexpectedexpect
|
||||
- == {
|
||||
@@ -376,13 +401,58 @@ class C:
|
||||
- key9: value9,
|
||||
- }
|
||||
- )
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
+ NOT_YET_IMPLEMENTED_StmtAssert
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class C:
|
||||
def test(self) -> None:
|
||||
NOT_YET_IMPLEMENTED_StmtWith
|
||||
xxxxxxxxxxxxxxxx = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
return "NOT_YET_IMPLEMENTED_STRING" % (
|
||||
test.name,
|
||||
test.filename,
|
||||
lineno,
|
||||
lname,
|
||||
err,
|
||||
)
|
||||
|
||||
def omitting_trailers(self) -> None:
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)[OneLevelIndex]
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)[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 = NOT_IMPLEMENTED_call() and another.rule.ending_with.index[123]
|
||||
|
||||
def easy_asserts(self) -> None:
|
||||
NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
def tricky_asserts(self) -> None:
|
||||
NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
dis_c_instance_method = "NOT_YET_IMPLEMENTED_STRING" % (
|
||||
_C.__init__.__code__.co_firstlineno
|
||||
+ 1,
|
||||
)
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtAssert
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
||||
@@ -17,12 +17,12 @@ class ClassWithDocstring:
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -1,4 +1,3 @@
|
||||
@@ -1,4 +1,4 @@
|
||||
# Make sure when the file ends with class's docstring,
|
||||
# It doesn't add extra blank lines.
|
||||
-class ClassWithDocstring:
|
||||
class ClassWithDocstring:
|
||||
- """A docstring."""
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
+ "NOT_YET_IMPLEMENTED_STRING"
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
@@ -30,7 +30,8 @@ class ClassWithDocstring:
|
||||
```py
|
||||
# Make sure when the file ends with class's docstring,
|
||||
# It doesn't add extra blank lines.
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class ClassWithDocstring:
|
||||
"NOT_YET_IMPLEMENTED_STRING"
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
||||
@@ -234,18 +234,19 @@ def stable_quote_normalization_with_immediate_inner_single_quote(self):
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -1,219 +1,149 @@
|
||||
-class MyClass:
|
||||
@@ -1,219 +1,154 @@
|
||||
class MyClass:
|
||||
- """Multiline
|
||||
- class docstring
|
||||
- """
|
||||
-
|
||||
- def method(self):
|
||||
+ "NOT_YET_IMPLEMENTED_STRING"
|
||||
|
||||
def method(self):
|
||||
- """Multiline
|
||||
- method docstring
|
||||
- """
|
||||
- pass
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
+ "NOT_YET_IMPLEMENTED_STRING"
|
||||
pass
|
||||
|
||||
|
||||
def foo():
|
||||
@@ -396,12 +397,12 @@ def stable_quote_normalization_with_immediate_inner_single_quote(self):
|
||||
- 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
|
||||
- """
|
||||
+ "NOT_YET_IMPLEMENTED_STRING"
|
||||
|
||||
- line ends with some tabs
|
||||
- """
|
||||
|
||||
-
|
||||
def docstring_with_inline_tabs_and_tab_indentation():
|
||||
- """hey
|
||||
-
|
||||
@@ -494,7 +495,12 @@ def stable_quote_normalization_with_immediate_inner_single_quote(self):
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class MyClass:
|
||||
"NOT_YET_IMPLEMENTED_STRING"
|
||||
|
||||
def method(self):
|
||||
"NOT_YET_IMPLEMENTED_STRING"
|
||||
pass
|
||||
|
||||
|
||||
def foo():
|
||||
|
||||
@@ -137,7 +137,7 @@ def g():
|
||||
if not prev:
|
||||
- prevp = preceding_leaf(p)
|
||||
- if not prevp or prevp.type in OPENING_BRACKETS:
|
||||
+ prevp = NOT_IMPLEMENTED_call()
|
||||
+ prevp = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+ if not prevp or NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
|
||||
return NO
|
||||
|
||||
@@ -199,7 +199,7 @@ def g():
|
||||
prev = leaf.prev_sibling
|
||||
if not prev:
|
||||
- prevp = preceding_leaf(p)
|
||||
+ prevp = NOT_IMPLEMENTED_call()
|
||||
+ prevp = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
- if not prevp or prevp.type in OPENING_BRACKETS:
|
||||
+ if not prevp or NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
|
||||
@@ -245,7 +245,7 @@ def f():
|
||||
|
||||
prev = leaf.prev_sibling
|
||||
if not prev:
|
||||
prevp = NOT_IMPLEMENTED_call()
|
||||
prevp = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
if not prevp or NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
|
||||
return NO
|
||||
|
||||
@@ -283,7 +283,7 @@ def g():
|
||||
|
||||
prev = leaf.prev_sibling
|
||||
if not prev:
|
||||
prevp = NOT_IMPLEMENTED_call()
|
||||
prevp = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
if not prevp or NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
|
||||
# Start of the line or a bracketed expression.
|
||||
|
||||
@@ -431,18 +431,18 @@ last_call()
|
||||
+NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
|
||||
+NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_IMPLEMENTED_call() # note: no trailing comma pre-3.6
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg) # note: no trailing comma pre-3.6
|
||||
+NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
lukasz.langa.pl
|
||||
-call.me(maybe)
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
(1).real
|
||||
(1.0).real
|
||||
....__class__
|
||||
@@ -454,9 +454,6 @@ last_call()
|
||||
- int,
|
||||
- float,
|
||||
- dict[str, int],
|
||||
-]
|
||||
-very_long_variable_name_filters: t.List[
|
||||
- t.Tuple[str, t.Union[str, t.List[t.Optional[str]]]],
|
||||
+ (
|
||||
+ str,
|
||||
+ int,
|
||||
@@ -464,6 +461,9 @@ last_call()
|
||||
+ dict[str, int],
|
||||
+ )
|
||||
]
|
||||
-very_long_variable_name_filters: t.List[
|
||||
- t.Tuple[str, t.Union[str, t.List[t.Optional[str]]]],
|
||||
-]
|
||||
-xxxx_xxxxx_xxxx_xxx: Callable[..., List[SomeClass]] = classmethod( # type: ignore
|
||||
- sync(async_xxxx_xxx_xxxx_xxxxx_xxxx_xxx.__func__)
|
||||
-)
|
||||
@@ -494,7 +494,7 @@ last_call()
|
||||
numpy[0, :]
|
||||
numpy[:, i]
|
||||
numpy[0, :2]
|
||||
@@ -171,62 +158,58 @@
|
||||
@@ -171,62 +158,59 @@
|
||||
numpy[1 : c + 1, c]
|
||||
numpy[-(c + 1) :, d]
|
||||
numpy[:, l[-2]]
|
||||
@@ -541,7 +541,8 @@ last_call()
|
||||
+ "NOT_YET_IMPLEMENTED_STRING": "NOT_YET_IMPLEMENTED_STRING",
|
||||
+ "NOT_YET_IMPLEMENTED_STRING": "NOT_YET_IMPLEMENTED_STRING",
|
||||
+ "NOT_YET_IMPLEMENTED_STRING": NOT_IMPLEMENTED_call(),
|
||||
+ "NOT_YET_IMPLEMENTED_STRING": NOT_IMPLEMENTED_call() + NOT_IMPLEMENTED_call(),
|
||||
+ "NOT_YET_IMPLEMENTED_STRING": NOT_IMPLEMENTED_call()
|
||||
+ + NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg),
|
||||
+ "NOT_YET_IMPLEMENTED_STRING": 1,
|
||||
+ "NOT_YET_IMPLEMENTED_STRING": 1,
|
||||
**kwargs,
|
||||
@@ -555,16 +556,19 @@ last_call()
|
||||
-g = 1, *"ten"
|
||||
-what_is_up_with_those_new_coord_names = (coord_names + set(vars_to_create)) + set(
|
||||
- vars_to_remove
|
||||
+e = NOT_IMPLEMENTED_call()
|
||||
+e = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+f = 1, NOT_YET_IMPLEMENTED_ExprStarred
|
||||
+g = 1, NOT_YET_IMPLEMENTED_ExprStarred
|
||||
+what_is_up_with_those_new_coord_names = (
|
||||
+ (coord_names + NOT_IMPLEMENTED_call())
|
||||
+ + NOT_IMPLEMENTED_call()
|
||||
+ (coord_names + NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg))
|
||||
+ + NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
)
|
||||
-what_is_up_with_those_new_coord_names = (coord_names | set(vars_to_create)) - set(
|
||||
- vars_to_remove
|
||||
-)
|
||||
+what_is_up_with_those_new_coord_names = (
|
||||
+ (coord_names | NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg))
|
||||
+ - NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
)
|
||||
-result = (
|
||||
- session.query(models.Customer.id)
|
||||
- .filter(
|
||||
@@ -582,10 +586,7 @@ last_call()
|
||||
- models.Customer.id.asc(),
|
||||
- )
|
||||
- .all()
|
||||
+what_is_up_with_those_new_coord_names = (
|
||||
+ (coord_names | NOT_IMPLEMENTED_call())
|
||||
+ - NOT_IMPLEMENTED_call()
|
||||
)
|
||||
-)
|
||||
-Ø = set()
|
||||
-authors.łukasz.say_thanks()
|
||||
+result = NOT_IMPLEMENTED_call()
|
||||
@@ -595,7 +596,7 @@ last_call()
|
||||
mapping = {
|
||||
A: 0.25 * (10.0 / 12),
|
||||
B: 0.1 * (10.0 / 12),
|
||||
@@ -236,31 +219,29 @@
|
||||
@@ -236,31 +220,29 @@
|
||||
|
||||
|
||||
def gen():
|
||||
@@ -611,7 +612,7 @@ last_call()
|
||||
|
||||
async def f():
|
||||
- await some.complicated[0].call(with_args=(True or (1 is not 1)))
|
||||
+ await NOT_IMPLEMENTED_call()
|
||||
+ await NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
-print(*[] or [1])
|
||||
@@ -622,9 +623,9 @@ last_call()
|
||||
- force=False
|
||||
-), "Short message"
|
||||
-assert parens is TooMany
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+NOT_YET_IMPLEMENTED_StmtAssert
|
||||
+NOT_YET_IMPLEMENTED_StmtAssert
|
||||
+NOT_YET_IMPLEMENTED_StmtAssert
|
||||
@@ -640,12 +641,12 @@ last_call()
|
||||
...
|
||||
for j in 1 + (2 + 3):
|
||||
...
|
||||
@@ -272,28 +253,16 @@
|
||||
@@ -272,28 +254,16 @@
|
||||
addr_proto,
|
||||
addr_canonname,
|
||||
addr_sockaddr,
|
||||
-) in socket.getaddrinfo("google.com", "http"):
|
||||
+) in NOT_IMPLEMENTED_call():
|
||||
+) in NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
pass
|
||||
-a = (
|
||||
- aaaa.bbbb.cccc.dddd.eeee.ffff.gggg.hhhh.iiii.jjjj.kkkk.llll.mmmm.nnnn.oooo.pppp
|
||||
@@ -677,7 +678,7 @@ last_call()
|
||||
):
|
||||
return True
|
||||
if (
|
||||
@@ -327,13 +296,18 @@
|
||||
@@ -327,13 +297,18 @@
|
||||
):
|
||||
return True
|
||||
if (
|
||||
@@ -699,7 +700,7 @@ last_call()
|
||||
^ aaaaaaaa.i << aaaaaaaa.k >> aaaaaaaa.l**aaaaaaaa.m // aaaaaaaa.n
|
||||
):
|
||||
return True
|
||||
@@ -341,7 +315,8 @@
|
||||
@@ -341,7 +316,8 @@
|
||||
~aaaaaaaaaaaaaaaa.a
|
||||
+ aaaaaaaaaaaaaaaa.b
|
||||
- aaaaaaaaaaaaaaaa.c * aaaaaaaaaaaaaaaa.d @ aaaaaaaaaaaaaaaa.e
|
||||
@@ -709,7 +710,7 @@ last_call()
|
||||
^ aaaaaaaaaaaaaaaa.i
|
||||
<< aaaaaaaaaaaaaaaa.k
|
||||
>> aaaaaaaaaaaaaaaa.l**aaaaaaaaaaaaaaaa.m // aaaaaaaaaaaaaaaa.n
|
||||
@@ -366,5 +341,5 @@
|
||||
@@ -366,5 +342,5 @@
|
||||
^ bbbb.a & aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
^ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
)
|
||||
@@ -827,17 +828,17 @@ NOT_YET_IMPLEMENTED_ExprSetComp
|
||||
NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
|
||||
NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call() # note: no trailing comma pre-3.6
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg) # note: no trailing comma pre-3.6
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
lukasz.langa.pl
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
(1).real
|
||||
(1.0).real
|
||||
....__class__
|
||||
@@ -909,7 +910,8 @@ SomeName
|
||||
"NOT_YET_IMPLEMENTED_STRING": "NOT_YET_IMPLEMENTED_STRING",
|
||||
"NOT_YET_IMPLEMENTED_STRING": "NOT_YET_IMPLEMENTED_STRING",
|
||||
"NOT_YET_IMPLEMENTED_STRING": NOT_IMPLEMENTED_call(),
|
||||
"NOT_YET_IMPLEMENTED_STRING": NOT_IMPLEMENTED_call() + NOT_IMPLEMENTED_call(),
|
||||
"NOT_YET_IMPLEMENTED_STRING": NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg),
|
||||
"NOT_YET_IMPLEMENTED_STRING": 1,
|
||||
"NOT_YET_IMPLEMENTED_STRING": 1,
|
||||
**kwargs,
|
||||
@@ -918,16 +920,16 @@ a = (1,)
|
||||
b = (1,)
|
||||
c = 1
|
||||
d = (1,) + a + (2,)
|
||||
e = NOT_IMPLEMENTED_call()
|
||||
e = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
f = 1, NOT_YET_IMPLEMENTED_ExprStarred
|
||||
g = 1, NOT_YET_IMPLEMENTED_ExprStarred
|
||||
what_is_up_with_those_new_coord_names = (
|
||||
(coord_names + NOT_IMPLEMENTED_call())
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
(coord_names + NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg))
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
)
|
||||
what_is_up_with_those_new_coord_names = (
|
||||
(coord_names | NOT_IMPLEMENTED_call())
|
||||
- NOT_IMPLEMENTED_call()
|
||||
(coord_names | NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg))
|
||||
- NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
)
|
||||
result = NOT_IMPLEMENTED_call()
|
||||
result = NOT_IMPLEMENTED_call()
|
||||
@@ -949,12 +951,12 @@ def gen():
|
||||
|
||||
|
||||
async def f():
|
||||
await NOT_IMPLEMENTED_call()
|
||||
await NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
NOT_YET_IMPLEMENTED_StmtAssert
|
||||
NOT_YET_IMPLEMENTED_StmtAssert
|
||||
NOT_YET_IMPLEMENTED_StmtAssert
|
||||
@@ -976,7 +978,7 @@ for (
|
||||
addr_proto,
|
||||
addr_canonname,
|
||||
addr_sockaddr,
|
||||
) in NOT_IMPLEMENTED_call():
|
||||
) in NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
pass
|
||||
a = NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
|
||||
a = NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
|
||||
|
||||
@@ -73,7 +73,7 @@ def test_calculate_fades():
|
||||
- ('stuff', 'in')
|
||||
- ],
|
||||
-])
|
||||
+@NOT_IMPLEMENTED_call()
|
||||
+@NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
def test_fader(test):
|
||||
pass
|
||||
|
||||
@@ -122,7 +122,7 @@ TmEx = 2
|
||||
# Test data:
|
||||
# Position, Volume, State, TmSt/TmEx/None, [call, [arg1...]]
|
||||
|
||||
@NOT_IMPLEMENTED_call()
|
||||
@NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
def test_fader(test):
|
||||
pass
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ def f(): pass
|
||||
- 1, 2,
|
||||
- 3, 4,
|
||||
-])
|
||||
+@NOT_IMPLEMENTED_call()
|
||||
+@NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
# fmt: on
|
||||
def f():
|
||||
pass
|
||||
@@ -46,7 +46,7 @@ def f(): pass
|
||||
- 4,
|
||||
- ]
|
||||
-)
|
||||
+@NOT_IMPLEMENTED_call()
|
||||
+@NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
def f():
|
||||
pass
|
||||
```
|
||||
@@ -55,13 +55,13 @@ def f(): pass
|
||||
|
||||
```py
|
||||
# fmt: off
|
||||
@NOT_IMPLEMENTED_call()
|
||||
@NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
# fmt: on
|
||||
def f():
|
||||
pass
|
||||
|
||||
|
||||
@NOT_IMPLEMENTED_call()
|
||||
@NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
def f():
|
||||
pass
|
||||
```
|
||||
|
||||
@@ -109,7 +109,7 @@ elif unformatted:
|
||||
- ] # Includes an formatted indentation.
|
||||
- },
|
||||
-)
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
# Regression test for https://github.com/psf/black/issues/2015.
|
||||
@@ -123,18 +123,18 @@ elif unformatted:
|
||||
- + path,
|
||||
- check=True,
|
||||
-)
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
# Regression test for https://github.com/psf/black/issues/3026.
|
||||
def test_func():
|
||||
# yapf: disable
|
||||
- if unformatted( args ):
|
||||
+ if NOT_IMPLEMENTED_call():
|
||||
+ if NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
return True
|
||||
# yapf: enable
|
||||
elif b:
|
||||
@@ -39,49 +21,29 @@
|
||||
@@ -39,12 +21,12 @@
|
||||
# Regression test for https://github.com/psf/black/issues/2567.
|
||||
if True:
|
||||
# fmt: off
|
||||
@@ -142,50 +142,54 @@ elif unformatted:
|
||||
- # fmt: on
|
||||
- print ( "This won't be formatted" )
|
||||
- print ( "This won't be formatted either" )
|
||||
+ for _ in NOT_IMPLEMENTED_call():
|
||||
+ for _ in NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
+ # fmt: on
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
else:
|
||||
- print("This will be formatted")
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
# Regression test for https://github.com/psf/black/issues/3184.
|
||||
-class A:
|
||||
- async def call(param):
|
||||
- if param:
|
||||
- # fmt: off
|
||||
@@ -52,29 +34,27 @@
|
||||
async def call(param):
|
||||
if param:
|
||||
# fmt: off
|
||||
- if param[0:4] in (
|
||||
- "ABCD", "EFGH"
|
||||
- ) :
|
||||
- # fmt: on
|
||||
+ if NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
|
||||
# fmt: on
|
||||
- print ( "This won't be formatted" )
|
||||
-
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
- elif param[0:4] in ("ZZZZ",):
|
||||
- print ( "This won't be formatted either" )
|
||||
-
|
||||
+ elif NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
- print("This will be formatted")
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
# Regression test for https://github.com/psf/black/issues/2985.
|
||||
-class Named(t.Protocol):
|
||||
- # fmt: off
|
||||
- @property
|
||||
class Named(t.Protocol):
|
||||
# fmt: off
|
||||
@property
|
||||
- def this_wont_be_formatted ( self ) -> str: ...
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
+ def this_wont_be_formatted(self) -> str:
|
||||
+ ...
|
||||
|
||||
|
||||
-class Factory(t.Protocol):
|
||||
- def this_will_be_formatted(self, **kwargs) -> Named:
|
||||
- ...
|
||||
class Factory(t.Protocol):
|
||||
def this_will_be_formatted(self, **kwargs) -> Named:
|
||||
...
|
||||
-
|
||||
- # fmt: on
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
# fmt: on
|
||||
|
||||
|
||||
# Regression test for https://github.com/psf/black/issues/3436.
|
||||
@@ -82,6 +62,6 @@
|
||||
if x:
|
||||
return x
|
||||
# fmt: off
|
||||
@@ -200,17 +204,17 @@ elif unformatted:
|
||||
|
||||
```py
|
||||
# Regression test for https://github.com/psf/black/issues/3129.
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
# Regression test for https://github.com/psf/black/issues/2015.
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
# Regression test for https://github.com/psf/black/issues/3026.
|
||||
def test_func():
|
||||
# yapf: disable
|
||||
if NOT_IMPLEMENTED_call():
|
||||
if NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
return True
|
||||
# yapf: enable
|
||||
elif b:
|
||||
@@ -222,23 +226,41 @@ def test_func():
|
||||
# Regression test for https://github.com/psf/black/issues/2567.
|
||||
if True:
|
||||
# fmt: off
|
||||
for _ in NOT_IMPLEMENTED_call():
|
||||
for _ in NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
# fmt: on
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
else:
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
# Regression test for https://github.com/psf/black/issues/3184.
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class A:
|
||||
async def call(param):
|
||||
if param:
|
||||
# fmt: off
|
||||
if NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
|
||||
# fmt: on
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
elif NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
# Regression test for https://github.com/psf/black/issues/2985.
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class Named(t.Protocol):
|
||||
# fmt: off
|
||||
@property
|
||||
def this_wont_be_formatted(self) -> str:
|
||||
...
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class Factory(t.Protocol):
|
||||
def this_will_be_formatted(self, **kwargs) -> Named:
|
||||
...
|
||||
# fmt: on
|
||||
|
||||
|
||||
# Regression test for https://github.com/psf/black/issues/3436.
|
||||
|
||||
@@ -241,10 +241,10 @@ d={'a':1,
|
||||
+ NOT_YET_IMPLEMENTED_StmtRaise
|
||||
+ if False:
|
||||
+ ...
|
||||
+ for i in NOT_IMPLEMENTED_call():
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ for i in NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+ continue
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+ return None
|
||||
+
|
||||
+
|
||||
@@ -255,7 +255,7 @@ d={'a':1,
|
||||
- await asyncio.sleep(1)
|
||||
+ "NOT_YET_IMPLEMENTED_STRING"
|
||||
+ NOT_YET_IMPLEMENTED_StmtAsyncWith
|
||||
+ await NOT_IMPLEMENTED_call()
|
||||
+ await NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+
|
||||
+
|
||||
@asyncio.coroutine
|
||||
@@ -265,7 +265,7 @@ d={'a':1,
|
||||
-)
|
||||
-def function_signature_stress_test(number:int,no_annotation=None,text:str='default',* ,debug:bool=False,**kwargs) -> str:
|
||||
- return text[number:-1]
|
||||
+@NOT_IMPLEMENTED_call()
|
||||
+@NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+def function_signature_stress_test(
|
||||
+ number: int,
|
||||
+ no_annotation=None,
|
||||
@@ -292,7 +292,7 @@ d={'a':1,
|
||||
+ h="NOT_YET_IMPLEMENTED_STRING",
|
||||
+ i="NOT_YET_IMPLEMENTED_STRING",
|
||||
+):
|
||||
+ offset = NOT_IMPLEMENTED_call()
|
||||
+ offset = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+ NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
|
||||
@@ -312,7 +312,7 @@ d={'a':1,
|
||||
|
||||
|
||||
-def spaces2(result=_core.Value(None)):
|
||||
+def spaces2(result=NOT_IMPLEMENTED_call()):
|
||||
+def spaces2(result=NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)):
|
||||
...
|
||||
|
||||
|
||||
@@ -429,7 +429,7 @@ d={'a':1,
|
||||
- implicit_default=True,
|
||||
- )
|
||||
- )
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
# fmt: off
|
||||
- a = (
|
||||
- unnecessary_bracket()
|
||||
@@ -460,7 +460,7 @@ d={'a':1,
|
||||
- re.MULTILINE|re.VERBOSE
|
||||
- # fmt: on
|
||||
- )
|
||||
+ _type_comment_re = NOT_IMPLEMENTED_call()
|
||||
+ _type_comment_re = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
def single_literal_yapf_disable():
|
||||
@@ -496,7 +496,7 @@ d={'a':1,
|
||||
- # fmt: on
|
||||
- xxxxxxxxxx_xxxxxxxxxxx_xxxxxxx_xxxxxxxxx=5,
|
||||
-)
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
# fmt: off
|
||||
-yield 'hello'
|
||||
+NOT_YET_IMPLEMENTED_ExprYield
|
||||
@@ -536,21 +536,21 @@ def func_no_args():
|
||||
NOT_YET_IMPLEMENTED_StmtRaise
|
||||
if False:
|
||||
...
|
||||
for i in NOT_IMPLEMENTED_call():
|
||||
NOT_IMPLEMENTED_call()
|
||||
for i in NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
continue
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
return None
|
||||
|
||||
|
||||
async def coroutine(arg, exec=False):
|
||||
"NOT_YET_IMPLEMENTED_STRING"
|
||||
NOT_YET_IMPLEMENTED_StmtAsyncWith
|
||||
await NOT_IMPLEMENTED_call()
|
||||
await NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
@NOT_IMPLEMENTED_call()
|
||||
@NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
def function_signature_stress_test(
|
||||
number: int,
|
||||
no_annotation=None,
|
||||
@@ -574,7 +574,7 @@ def spaces(
|
||||
h="NOT_YET_IMPLEMENTED_STRING",
|
||||
i="NOT_YET_IMPLEMENTED_STRING",
|
||||
):
|
||||
offset = NOT_IMPLEMENTED_call()
|
||||
offset = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
|
||||
@@ -592,7 +592,7 @@ def spaces_types(
|
||||
...
|
||||
|
||||
|
||||
def spaces2(result=NOT_IMPLEMENTED_call()):
|
||||
def spaces2(result=NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)):
|
||||
...
|
||||
|
||||
|
||||
@@ -674,11 +674,11 @@ def on_and_off_broken():
|
||||
|
||||
def long_lines():
|
||||
if True:
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
# fmt: off
|
||||
a = NOT_IMPLEMENTED_call()
|
||||
# fmt: on
|
||||
_type_comment_re = NOT_IMPLEMENTED_call()
|
||||
_type_comment_re = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
def single_literal_yapf_disable():
|
||||
@@ -686,7 +686,7 @@ def single_literal_yapf_disable():
|
||||
BAZ = {(1, 2, 3, 4), (5, 6, 7, 8), (9, 10, 11, 12)} # yapf: disable
|
||||
|
||||
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
# fmt: off
|
||||
NOT_YET_IMPLEMENTED_ExprYield
|
||||
# No formatting to the end of the file
|
||||
|
||||
@@ -33,10 +33,10 @@ else:
|
||||
+ and NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
|
||||
):
|
||||
- print("I'm good!")
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
else:
|
||||
- print("I'm bad")
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
@@ -48,9 +48,9 @@ if (
|
||||
and NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right # fmt: skip
|
||||
and NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
|
||||
):
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
else:
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
||||
@@ -18,19 +18,23 @@ class A:
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -1,5 +1 @@
|
||||
-class A:
|
||||
- def f(self):
|
||||
@@ -1,5 +1,5 @@
|
||||
class A:
|
||||
def f(self):
|
||||
- for line in range(10):
|
||||
- if True:
|
||||
- pass # fmt: skip
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
+ for line in NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
if True:
|
||||
pass # fmt: skip
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class A:
|
||||
def f(self):
|
||||
for line in NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
if True:
|
||||
pass # fmt: skip
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
||||
@@ -75,12 +75,12 @@ async def test_async_with():
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -1,62 +1,47 @@
|
||||
@@ -1,62 +1,54 @@
|
||||
# Make sure a leading comment is not removed.
|
||||
-def some_func( unformatted, args ): # fmt: skip
|
||||
- print("I am some_func")
|
||||
+def some_func(unformatted, args): # fmt: skip
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
return 0
|
||||
# Make sure this comment is not removed.
|
||||
|
||||
@@ -90,48 +90,53 @@ async def test_async_with():
|
||||
- print("I am some_async_func")
|
||||
- await asyncio.sleep(1)
|
||||
+async def some_async_func(unformatted, args): # fmt: skip
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ await NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+ await NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
# 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
|
||||
+class SomeClass(Unformatted, SuperClasses): # fmt: skip
|
||||
+ def some_method(self, unformatted, args): # fmt: skip
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
return 0
|
||||
|
||||
- async def some_async_method( self, unformatted, args ): # fmt: skip
|
||||
- print("I am some_async_method")
|
||||
- await asyncio.sleep(1)
|
||||
+ async def some_async_method(self, unformatted, args): # fmt: skip
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+ await NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
-
|
||||
# Make sure a leading comment is not removed.
|
||||
-if unformatted_call( args ): # fmt: skip
|
||||
- print("First branch")
|
||||
+if NOT_IMPLEMENTED_call(): # fmt: skip
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+if NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg): # fmt: skip
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
# Make sure this is not removed.
|
||||
-elif another_unformatted_call( args ): # fmt: skip
|
||||
- print("Second branch")
|
||||
-else : # fmt: skip
|
||||
- print("Last branch")
|
||||
+elif NOT_IMPLEMENTED_call(): # fmt: skip
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+elif NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg): # fmt: skip
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+else: # fmt: skip
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
-while some_condition( unformatted, args ): # fmt: skip
|
||||
- print("Do something")
|
||||
+while NOT_IMPLEMENTED_call(): # fmt: skip
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+while NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg): # fmt: skip
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
-for i in some_iter( unformatted, args ): # fmt: skip
|
||||
- print("Do something")
|
||||
+for i in NOT_IMPLEMENTED_call(): # fmt: skip
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+for i in NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg): # fmt: skip
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
async def test_async_for():
|
||||
@@ -165,37 +170,44 @@ async def test_async_with():
|
||||
```py
|
||||
# Make sure a leading comment is not removed.
|
||||
def some_func(unformatted, args): # fmt: skip
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
return 0
|
||||
# Make sure this comment is not removed.
|
||||
|
||||
|
||||
# Make sure a leading comment is not removed.
|
||||
async def some_async_func(unformatted, args): # fmt: skip
|
||||
NOT_IMPLEMENTED_call()
|
||||
await NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
await NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
# Make sure a leading comment is not removed.
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class SomeClass(Unformatted, SuperClasses): # fmt: skip
|
||||
def some_method(self, unformatted, args): # fmt: skip
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
return 0
|
||||
|
||||
async def some_async_method(self, unformatted, args): # fmt: skip
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
await NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
# Make sure a leading comment is not removed.
|
||||
if NOT_IMPLEMENTED_call(): # fmt: skip
|
||||
NOT_IMPLEMENTED_call()
|
||||
if NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg): # fmt: skip
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
# Make sure this is not removed.
|
||||
elif NOT_IMPLEMENTED_call(): # fmt: skip
|
||||
NOT_IMPLEMENTED_call()
|
||||
elif NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg): # fmt: skip
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
else: # fmt: skip
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
while NOT_IMPLEMENTED_call(): # fmt: skip
|
||||
NOT_IMPLEMENTED_call()
|
||||
while NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg): # fmt: skip
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
for i in NOT_IMPLEMENTED_call(): # fmt: skip
|
||||
NOT_IMPLEMENTED_call()
|
||||
for i in NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg): # fmt: skip
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
async def test_async_for():
|
||||
|
||||
@@ -66,7 +66,7 @@ with hmm_but_this_should_get_two_preceding_newlines():
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -2,64 +2,39 @@
|
||||
@@ -2,64 +2,41 @@
|
||||
a,
|
||||
**kwargs,
|
||||
) -> A:
|
||||
@@ -82,8 +82,8 @@ with hmm_but_this_should_get_two_preceding_newlines():
|
||||
- **kwargs,
|
||||
- )
|
||||
+ NOT_YET_IMPLEMENTED_StmtWith
|
||||
+ NOT_IMPLEMENTED_call() # negate top
|
||||
+ return NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg) # negate top
|
||||
+ return NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
def g():
|
||||
@@ -94,7 +94,7 @@ with hmm_but_this_should_get_two_preceding_newlines():
|
||||
pass
|
||||
|
||||
- print("Inner defs should breathe a little.")
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
def h():
|
||||
@@ -102,7 +102,7 @@ with hmm_but_this_should_get_two_preceding_newlines():
|
||||
pass
|
||||
|
||||
- print("Inner defs should breathe a little.")
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
-if os.name == "posix":
|
||||
@@ -129,17 +129,17 @@ with hmm_but_this_should_get_two_preceding_newlines():
|
||||
|
||||
elif False:
|
||||
-
|
||||
- class IHopeYouAreHavingALovelyDay:
|
||||
- def __call__(self):
|
||||
class IHopeYouAreHavingALovelyDay:
|
||||
def __call__(self):
|
||||
- print("i_should_be_followed_by_only_one_newline")
|
||||
-
|
||||
+ NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
else:
|
||||
-
|
||||
def foo():
|
||||
pass
|
||||
|
||||
-
|
||||
|
||||
-with hmm_but_this_should_get_two_preceding_newlines():
|
||||
- pass
|
||||
+NOT_YET_IMPLEMENTED_StmtWith
|
||||
@@ -153,8 +153,8 @@ def f(
|
||||
**kwargs,
|
||||
) -> A:
|
||||
NOT_YET_IMPLEMENTED_StmtWith
|
||||
NOT_IMPLEMENTED_call() # negate top
|
||||
return NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg) # negate top
|
||||
return NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
def g():
|
||||
@@ -163,14 +163,14 @@ def g():
|
||||
def inner():
|
||||
pass
|
||||
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
def h():
|
||||
def inner():
|
||||
pass
|
||||
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
if NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
|
||||
@@ -182,7 +182,9 @@ elif NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
|
||||
NOT_YET_IMPLEMENTED_StmtTry
|
||||
|
||||
elif False:
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class IHopeYouAreHavingALovelyDay:
|
||||
def __call__(self):
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
else:
|
||||
def foo():
|
||||
pass
|
||||
|
||||
@@ -136,11 +136,11 @@ def __await__(): return (yield)
|
||||
...
|
||||
- for i in range(10):
|
||||
- print(i)
|
||||
+ for i in NOT_IMPLEMENTED_call():
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ for i in NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
continue
|
||||
- exec("new-style exec", {}, {})
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
return None
|
||||
|
||||
|
||||
@@ -151,12 +151,12 @@ def __await__(): return (yield)
|
||||
- await asyncio.sleep(1)
|
||||
+ "NOT_YET_IMPLEMENTED_STRING"
|
||||
+ NOT_YET_IMPLEMENTED_StmtAsyncWith
|
||||
+ await NOT_IMPLEMENTED_call()
|
||||
+ await NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
-@some_decorator(with_args=True, many_args=[1, 2, 3])
|
||||
+@NOT_IMPLEMENTED_call()
|
||||
+@NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
def function_signature_stress_test(
|
||||
number: int,
|
||||
no_annotation=None,
|
||||
@@ -184,7 +184,7 @@ def __await__(): return (yield)
|
||||
+ h="NOT_YET_IMPLEMENTED_STRING",
|
||||
+ i="NOT_YET_IMPLEMENTED_STRING",
|
||||
+):
|
||||
+ offset = NOT_IMPLEMENTED_call()
|
||||
+ offset = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+ NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ def __await__(): return (yield)
|
||||
|
||||
-def spaces2(result=_core.Value(None)):
|
||||
- assert fut is self._read_fut, (fut, self._read_fut)
|
||||
+def spaces2(result=NOT_IMPLEMENTED_call()):
|
||||
+def spaces2(result=NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)):
|
||||
+ NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
|
||||
@@ -263,9 +263,9 @@ def __await__(): return (yield)
|
||||
- """,
|
||||
- re.MULTILINE | re.VERBOSE,
|
||||
- )
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ _type_comment_re = NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+ _type_comment_re = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
def trailing_comma():
|
||||
@@ -309,21 +309,21 @@ def func_no_args():
|
||||
NOT_YET_IMPLEMENTED_StmtRaise
|
||||
if False:
|
||||
...
|
||||
for i in NOT_IMPLEMENTED_call():
|
||||
NOT_IMPLEMENTED_call()
|
||||
for i in NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
continue
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
return None
|
||||
|
||||
|
||||
async def coroutine(arg, exec=False):
|
||||
"NOT_YET_IMPLEMENTED_STRING"
|
||||
NOT_YET_IMPLEMENTED_StmtAsyncWith
|
||||
await NOT_IMPLEMENTED_call()
|
||||
await NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
@NOT_IMPLEMENTED_call()
|
||||
@NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
def function_signature_stress_test(
|
||||
number: int,
|
||||
no_annotation=None,
|
||||
@@ -346,7 +346,7 @@ def spaces(
|
||||
h="NOT_YET_IMPLEMENTED_STRING",
|
||||
i="NOT_YET_IMPLEMENTED_STRING",
|
||||
):
|
||||
offset = NOT_IMPLEMENTED_call()
|
||||
offset = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
|
||||
@@ -364,7 +364,7 @@ def spaces_types(
|
||||
...
|
||||
|
||||
|
||||
def spaces2(result=NOT_IMPLEMENTED_call()):
|
||||
def spaces2(result=NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)):
|
||||
NOT_YET_IMPLEMENTED_StmtAssert
|
||||
|
||||
|
||||
@@ -374,9 +374,9 @@ def example(session):
|
||||
|
||||
def long_lines():
|
||||
if True:
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call()
|
||||
_type_comment_re = NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
_type_comment_re = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
def trailing_comma():
|
||||
|
||||
@@ -106,8 +106,8 @@ some_module.some_function(
|
||||
- call2(
|
||||
- arg=[1, 2, 3],
|
||||
- )
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
x = {
|
||||
- "a": 1,
|
||||
- "b": 2,
|
||||
@@ -161,7 +161,7 @@ some_module.some_function(
|
||||
- this_shouldn_t_get_a_trailing_comma_too
|
||||
- )
|
||||
-):
|
||||
+def func() -> NOT_IMPLEMENTED_call():
|
||||
+def func() -> NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
pass
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ some_module.some_function(
|
||||
- this_shouldn_t_get_a_trailing_comma_too
|
||||
- )
|
||||
-):
|
||||
+def func() -> NOT_IMPLEMENTED_call():
|
||||
+def func() -> NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
pass
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ some_module.some_function(
|
||||
-some_module.some_function(
|
||||
- argument1, (one_element_tuple,), argument4, argument5, argument6
|
||||
-)
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
# Inner trailing comma causes outer to explode
|
||||
-some_module.some_function(
|
||||
@@ -191,7 +191,7 @@ some_module.some_function(
|
||||
- argument5,
|
||||
- argument6,
|
||||
-)
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
@@ -223,8 +223,8 @@ def f2(
|
||||
def f(
|
||||
a: int = 1,
|
||||
):
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
x = {
|
||||
"NOT_YET_IMPLEMENTED_STRING": 1,
|
||||
"NOT_YET_IMPLEMENTED_STRING": 2,
|
||||
@@ -257,19 +257,19 @@ def some_method_with_a_really_long_name(
|
||||
pass
|
||||
|
||||
|
||||
def func() -> NOT_IMPLEMENTED_call():
|
||||
def func() -> NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
pass
|
||||
|
||||
|
||||
def func() -> NOT_IMPLEMENTED_call():
|
||||
def func() -> NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
pass
|
||||
|
||||
|
||||
# Make sure inner one-element tuple won't explode
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
# Inner trailing comma causes outer to explode
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
||||
@@ -87,7 +87,7 @@ return np.divide(
|
||||
-e = lazy(lambda **kwargs: 5)
|
||||
-f = f() ** 5
|
||||
+d = 5 ** f["NOT_YET_IMPLEMENTED_STRING"]
|
||||
+e = NOT_IMPLEMENTED_call()
|
||||
+e = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+f = NOT_IMPLEMENTED_call() ** 5
|
||||
g = a.b**c.d
|
||||
-h = 5 ** funcs.f()
|
||||
@@ -106,7 +106,7 @@ return np.divide(
|
||||
-p = {(k, k**2): v**2 for k, v in pairs}
|
||||
-q = [10**i for i in range(6)]
|
||||
+n = NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
|
||||
+o = NOT_IMPLEMENTED_call()
|
||||
+o = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+p = {NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value for key, value in NOT_IMPLEMENTED_dict}
|
||||
+q = [i for i in []]
|
||||
r = x**y
|
||||
@@ -119,7 +119,7 @@ return np.divide(
|
||||
-e = lazy(lambda **kwargs: 5)
|
||||
-f = f() ** 5.0
|
||||
+d = 5.0 ** f["NOT_YET_IMPLEMENTED_STRING"]
|
||||
+e = NOT_IMPLEMENTED_call()
|
||||
+e = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+f = NOT_IMPLEMENTED_call() ** 5.0
|
||||
g = a.b**c.d
|
||||
-h = 5.0 ** funcs.f()
|
||||
@@ -138,7 +138,7 @@ return np.divide(
|
||||
-p = {(k, k**2): v**2.0 for k, v in pairs}
|
||||
-q = [10.5**i for i in range(6)]
|
||||
+n = NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
|
||||
+o = NOT_IMPLEMENTED_call()
|
||||
+o = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+p = {NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value for key, value in NOT_IMPLEMENTED_dict}
|
||||
+q = [i for i in []]
|
||||
|
||||
@@ -151,13 +151,13 @@ return np.divide(
|
||||
- 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]
|
||||
- )
|
||||
+if NOT_IMPLEMENTED_call():
|
||||
+ return NOT_IMPLEMENTED_call()
|
||||
+if NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
+ return NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
-return np.divide(
|
||||
- where=view.sum_of_weights_of_weight_long**2 > view.sum_of_weights_squared, # type: ignore
|
||||
-)
|
||||
+return NOT_IMPLEMENTED_call()
|
||||
+return NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
@@ -180,7 +180,7 @@ a = 5**~4
|
||||
b = 5 ** NOT_IMPLEMENTED_call()
|
||||
c = -(5**2)
|
||||
d = 5 ** f["NOT_YET_IMPLEMENTED_STRING"]
|
||||
e = NOT_IMPLEMENTED_call()
|
||||
e = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
f = NOT_IMPLEMENTED_call() ** 5
|
||||
g = a.b**c.d
|
||||
h = 5 ** NOT_IMPLEMENTED_call()
|
||||
@@ -190,7 +190,7 @@ k = [i for i in []]
|
||||
l = NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
|
||||
m = [([2**63], [1, 2**63])]
|
||||
n = NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
|
||||
o = NOT_IMPLEMENTED_call()
|
||||
o = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
p = {NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value for key, value in NOT_IMPLEMENTED_dict}
|
||||
q = [i for i in []]
|
||||
r = x**y
|
||||
@@ -199,7 +199,7 @@ a = 5.0**~4.0
|
||||
b = 5.0 ** NOT_IMPLEMENTED_call()
|
||||
c = -(5.0**2.0)
|
||||
d = 5.0 ** f["NOT_YET_IMPLEMENTED_STRING"]
|
||||
e = NOT_IMPLEMENTED_call()
|
||||
e = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
f = NOT_IMPLEMENTED_call() ** 5.0
|
||||
g = a.b**c.d
|
||||
h = 5.0 ** NOT_IMPLEMENTED_call()
|
||||
@@ -209,16 +209,16 @@ k = [i for i in []]
|
||||
l = NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
|
||||
m = [([2.0**63.0], [1.0, 2**63.0])]
|
||||
n = NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
|
||||
o = NOT_IMPLEMENTED_call()
|
||||
o = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
p = {NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value for key, value in NOT_IMPLEMENTED_dict}
|
||||
q = [i for i in []]
|
||||
|
||||
|
||||
# WE SHOULD DEFINITELY NOT EAT THESE COMMENTS (https://github.com/psf/black/issues/2873)
|
||||
if NOT_IMPLEMENTED_call():
|
||||
return NOT_IMPLEMENTED_call()
|
||||
if NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
return NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
return NOT_IMPLEMENTED_call()
|
||||
return NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
||||
@@ -25,7 +25,7 @@ xxxxxxxxx_yyy_zzzzzzzz[xx.xxxxxx(x_yyy_zzzzzz.xxxxx[0]), x_yyy_zzzzzz.xxxxxx(xxx
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -9,13 +9,8 @@
|
||||
@@ -9,13 +9,10 @@
|
||||
m2,
|
||||
),
|
||||
third_value,
|
||||
@@ -33,14 +33,14 @@ xxxxxxxxx_yyy_zzzzzzzz[xx.xxxxxx(x_yyy_zzzzzz.xxxxx[0]), x_yyy_zzzzzz.xxxxxx(xxx
|
||||
- arg1,
|
||||
- arg2,
|
||||
-)
|
||||
+) = NOT_IMPLEMENTED_call()
|
||||
+) = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
# 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.
|
||||
-xxxxxxxxx_yyy_zzzzzzzz[
|
||||
xxxxxxxxx_yyy_zzzzzzzz[
|
||||
- xx.xxxxxx(x_yyy_zzzzzz.xxxxx[0]), x_yyy_zzzzzz.xxxxxx(xxxx=1)
|
||||
-] = 1
|
||||
+xxxxxxxxx_yyy_zzzzzzzz[NOT_IMPLEMENTED_call(), NOT_IMPLEMENTED_call()] = 1
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg), NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
] = 1
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
@@ -57,11 +57,13 @@ xxxxxxxxx_yyy_zzzzzzzz[xx.xxxxxx(x_yyy_zzzzzz.xxxxx[0]), x_yyy_zzzzzz.xxxxxx(xxx
|
||||
m2,
|
||||
),
|
||||
third_value,
|
||||
) = NOT_IMPLEMENTED_call()
|
||||
) = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
# 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.
|
||||
xxxxxxxxx_yyy_zzzzzzzz[NOT_IMPLEMENTED_call(), NOT_IMPLEMENTED_call()] = 1
|
||||
xxxxxxxxx_yyy_zzzzzzzz[
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg), NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
] = 1
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
||||
@@ -102,23 +102,23 @@ async def main():
|
||||
# Control example
|
||||
async def main():
|
||||
- await asyncio.sleep(1)
|
||||
+ await NOT_IMPLEMENTED_call()
|
||||
+ await NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
# Remove brackets for short coroutine/task
|
||||
async def main():
|
||||
- await asyncio.sleep(1)
|
||||
+ await (NOT_IMPLEMENTED_call())
|
||||
+ await (NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg))
|
||||
|
||||
|
||||
async def main():
|
||||
- await asyncio.sleep(1)
|
||||
+ await (NOT_IMPLEMENTED_call())
|
||||
+ await (NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg))
|
||||
|
||||
|
||||
async def main():
|
||||
- await asyncio.sleep(1)
|
||||
+ await (NOT_IMPLEMENTED_call())
|
||||
+ await (NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg))
|
||||
|
||||
|
||||
# Check comments
|
||||
@@ -126,7 +126,7 @@ async def main():
|
||||
- await asyncio.sleep(1) # Hello
|
||||
+ (
|
||||
+ await # Hello
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+ )
|
||||
|
||||
|
||||
@@ -134,14 +134,14 @@ async def main():
|
||||
- await asyncio.sleep(1) # Hello
|
||||
+ (
|
||||
+ await (
|
||||
+ NOT_IMPLEMENTED_call() # Hello
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg) # Hello
|
||||
+ )
|
||||
+ )
|
||||
|
||||
|
||||
async def main():
|
||||
- await asyncio.sleep(1) # Hello
|
||||
+ await (NOT_IMPLEMENTED_call()) # Hello
|
||||
+ await (NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)) # Hello
|
||||
|
||||
|
||||
# Long lines
|
||||
@@ -155,7 +155,7 @@ async def main():
|
||||
- asyncio.sleep(1),
|
||||
- asyncio.sleep(1),
|
||||
- )
|
||||
+ await NOT_IMPLEMENTED_call()
|
||||
+ await NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
# Same as above but with magic trailing comma in function
|
||||
@@ -169,13 +169,13 @@ async def main():
|
||||
- asyncio.sleep(1),
|
||||
- asyncio.sleep(1),
|
||||
- )
|
||||
+ await NOT_IMPLEMENTED_call()
|
||||
+ await NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
# Cr@zY Br@ck3Tz
|
||||
async def main():
|
||||
- await black(1)
|
||||
+ await (NOT_IMPLEMENTED_call())
|
||||
+ await (NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg))
|
||||
|
||||
|
||||
# Keep brackets around non power operations and nested awaits
|
||||
@@ -184,7 +184,7 @@ async def main():
|
||||
|
||||
async def main():
|
||||
- await (await asyncio.sleep(1))
|
||||
+ await (await NOT_IMPLEMENTED_call())
|
||||
+ await (await NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg))
|
||||
|
||||
|
||||
# It's awaits all the way down...
|
||||
@@ -198,12 +198,12 @@ async def main():
|
||||
|
||||
async def main():
|
||||
- await (await asyncio.sleep(1))
|
||||
+ await (await (NOT_IMPLEMENTED_call()))
|
||||
+ await (await (NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)))
|
||||
|
||||
|
||||
async def main():
|
||||
- await (await (await (await (await asyncio.sleep(1)))))
|
||||
+ await (await (await (await (await (NOT_IMPLEMENTED_call())))))
|
||||
+ await (await (await (await (await (NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg))))))
|
||||
|
||||
|
||||
async def main():
|
||||
@@ -219,55 +219,55 @@ NOT_YET_IMPLEMENTED_StmtImport
|
||||
|
||||
# Control example
|
||||
async def main():
|
||||
await NOT_IMPLEMENTED_call()
|
||||
await NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
# Remove brackets for short coroutine/task
|
||||
async def main():
|
||||
await (NOT_IMPLEMENTED_call())
|
||||
await (NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg))
|
||||
|
||||
|
||||
async def main():
|
||||
await (NOT_IMPLEMENTED_call())
|
||||
await (NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg))
|
||||
|
||||
|
||||
async def main():
|
||||
await (NOT_IMPLEMENTED_call())
|
||||
await (NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg))
|
||||
|
||||
|
||||
# Check comments
|
||||
async def main():
|
||||
(
|
||||
await # Hello
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
)
|
||||
|
||||
|
||||
async def main():
|
||||
(
|
||||
await (
|
||||
NOT_IMPLEMENTED_call() # Hello
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg) # Hello
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
async def main():
|
||||
await (NOT_IMPLEMENTED_call()) # Hello
|
||||
await (NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)) # Hello
|
||||
|
||||
|
||||
# Long lines
|
||||
async def main():
|
||||
await NOT_IMPLEMENTED_call()
|
||||
await NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
# Same as above but with magic trailing comma in function
|
||||
async def main():
|
||||
await NOT_IMPLEMENTED_call()
|
||||
await NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
# Cr@zY Br@ck3Tz
|
||||
async def main():
|
||||
await (NOT_IMPLEMENTED_call())
|
||||
await (NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg))
|
||||
|
||||
|
||||
# Keep brackets around non power operations and nested awaits
|
||||
@@ -276,7 +276,7 @@ async def main():
|
||||
|
||||
|
||||
async def main():
|
||||
await (await NOT_IMPLEMENTED_call())
|
||||
await (await NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg))
|
||||
|
||||
|
||||
# It's awaits all the way down...
|
||||
@@ -289,11 +289,11 @@ async def main():
|
||||
|
||||
|
||||
async def main():
|
||||
await (await (NOT_IMPLEMENTED_call()))
|
||||
await (await (NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)))
|
||||
|
||||
|
||||
async def main():
|
||||
await (await (await (await (await (NOT_IMPLEMENTED_call())))))
|
||||
await (await (await (await (await (NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg))))))
|
||||
|
||||
|
||||
async def main():
|
||||
|
||||
@@ -37,13 +37,13 @@ for (((((k, v))))) in d.items():
|
||||
-for k, v in d.items():
|
||||
- print(k, v)
|
||||
+for k, v in NOT_IMPLEMENTED_call():
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
# Don't touch tuple brackets after `in`
|
||||
for module in (core, _unicodefun):
|
||||
- if hasattr(module, "_verify_python3_env"):
|
||||
- module._verify_python3_env = lambda: None
|
||||
+ if NOT_IMPLEMENTED_call():
|
||||
+ if NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
+ module._verify_python3_env = lambda x: True
|
||||
|
||||
# Brackets remain for long for loop lines
|
||||
@@ -53,7 +53,7 @@ for (((((k, v))))) in d.items():
|
||||
-) in d.items():
|
||||
- print(k, v)
|
||||
+) in NOT_IMPLEMENTED_call():
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
-for (
|
||||
- k,
|
||||
@@ -63,13 +63,13 @@ for (((((k, v))))) in d.items():
|
||||
-):
|
||||
- print(k, v)
|
||||
+for k, v in NOT_IMPLEMENTED_call():
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
# Test deeply nested brackets
|
||||
-for k, v in d.items():
|
||||
- print(k, v)
|
||||
+for k, v in NOT_IMPLEMENTED_call():
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
@@ -77,11 +77,11 @@ for (((((k, v))))) in d.items():
|
||||
```py
|
||||
# Only remove tuple brackets after `for`
|
||||
for k, v in NOT_IMPLEMENTED_call():
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
# Don't touch tuple brackets after `in`
|
||||
for module in (core, _unicodefun):
|
||||
if NOT_IMPLEMENTED_call():
|
||||
if NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
module._verify_python3_env = lambda x: True
|
||||
|
||||
# Brackets remain for long for loop lines
|
||||
@@ -89,14 +89,14 @@ 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 NOT_IMPLEMENTED_call():
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
for k, v in NOT_IMPLEMENTED_call():
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
# Test deeply nested brackets
|
||||
for k, v in NOT_IMPLEMENTED_call():
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
||||
@@ -121,72 +121,72 @@ with open("/path/to/file.txt", mode="r") as read_file:
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -1,78 +1,72 @@
|
||||
@@ -1,78 +1,74 @@
|
||||
-import random
|
||||
+NOT_YET_IMPLEMENTED_StmtImport
|
||||
|
||||
|
||||
def foo1():
|
||||
- print("The newline above me should be deleted!")
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
def foo2():
|
||||
- print("All the newlines above me should be deleted!")
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
def foo3():
|
||||
- print("No newline above me!")
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
- print("There is a newline above me, and that's OK!")
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
def foo4():
|
||||
# There is a comment here
|
||||
|
||||
- print("The newline above me should not be deleted!")
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
-class Foo:
|
||||
- def bar(self):
|
||||
class Foo:
|
||||
def bar(self):
|
||||
- print("The newline above me should be deleted!")
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
-for i in range(5):
|
||||
- print(f"{i}) The line above me should be removed!")
|
||||
+for i in NOT_IMPLEMENTED_call():
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+for i in NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
-for i in range(5):
|
||||
- print(f"{i}) The lines above me should be removed!")
|
||||
+for i in NOT_IMPLEMENTED_call():
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+for i in NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
-for i in range(5):
|
||||
- for j in range(7):
|
||||
- print(f"{i}) The lines above me should be removed!")
|
||||
+for i in NOT_IMPLEMENTED_call():
|
||||
+ for j in NOT_IMPLEMENTED_call():
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+for i in NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
+ for j in NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
-if random.randint(0, 3) == 0:
|
||||
- print("The new line above me is about to be removed!")
|
||||
+if NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
-if random.randint(0, 3) == 0:
|
||||
- print("The new lines above me is about to be removed!")
|
||||
+if NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
-if random.randint(0, 3) == 0:
|
||||
@@ -194,23 +194,23 @@ with open("/path/to/file.txt", mode="r") as read_file:
|
||||
- print("Two lines above me are about to be removed!")
|
||||
+if NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
|
||||
+ if NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
while True:
|
||||
- print("The newline above me should be deleted!")
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
while True:
|
||||
- print("The newlines above me should be deleted!")
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
while True:
|
||||
while False:
|
||||
- print("The newlines above me should be deleted!")
|
||||
+ NOT_IMPLEMENTED_call()
|
||||
+ NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
-with open("/path/to/file.txt", mode="w") as file:
|
||||
@@ -236,65 +236,67 @@ NOT_YET_IMPLEMENTED_StmtImport
|
||||
|
||||
|
||||
def foo1():
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
def foo2():
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
def foo3():
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
def foo4():
|
||||
# There is a comment here
|
||||
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class Foo:
|
||||
def bar(self):
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
for i in NOT_IMPLEMENTED_call():
|
||||
NOT_IMPLEMENTED_call()
|
||||
for i in NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
for i in NOT_IMPLEMENTED_call():
|
||||
NOT_IMPLEMENTED_call()
|
||||
for i in NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
for i in NOT_IMPLEMENTED_call():
|
||||
for j in NOT_IMPLEMENTED_call():
|
||||
NOT_IMPLEMENTED_call()
|
||||
for i in NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
for j in NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
if NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
if NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
if NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
|
||||
if NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
while True:
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
while True:
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
while True:
|
||||
while False:
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtWith
|
||||
|
||||
@@ -91,10 +91,10 @@ func(
|
||||
|
||||
# Trailing commas in multiple chained non-nested parens.
|
||||
-zero(one).two(three).four(five)
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
-func1(arg1).func2(arg2).func3(arg3).func4(arg4).func5(arg5)
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
-(a, b, c, d) = func1(arg1) and func2(arg2)
|
||||
+(
|
||||
@@ -102,10 +102,10 @@ func(
|
||||
+ b,
|
||||
+ c,
|
||||
+ d,
|
||||
+) = NOT_IMPLEMENTED_call() and NOT_IMPLEMENTED_call()
|
||||
+) = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg) and NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
-func(argument1, (one, two), argument4, argument5, argument6)
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
@@ -134,18 +134,18 @@ set_of_types = {tuple[(int,)]}
|
||||
small_tuple = (1,)
|
||||
|
||||
# Trailing commas in multiple chained non-nested parens.
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
(
|
||||
a,
|
||||
b,
|
||||
c,
|
||||
d,
|
||||
) = NOT_IMPLEMENTED_call() and NOT_IMPLEMENTED_call()
|
||||
) = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg) and NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
||||
@@ -76,7 +76,7 @@ x[
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -4,30 +4,30 @@
|
||||
@@ -4,30 +4,35 @@
|
||||
slice[d::d]
|
||||
slice[0]
|
||||
slice[-1]
|
||||
@@ -113,11 +113,16 @@ x[
|
||||
ham[lower:upper], ham[lower:upper:], ham[lower::step]
|
||||
# ham[lower+offset : upper+offset]
|
||||
-ham[: upper_fn(x) : step_fn(x)], ham[:: step_fn(x)]
|
||||
+ham[ : NOT_IMPLEMENTED_call() : NOT_IMPLEMENTED_call()], ham[ :: NOT_IMPLEMENTED_call()]
|
||||
+(
|
||||
+ ham[
|
||||
+ : NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg) : NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+ ],
|
||||
+ ham[ :: NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)],
|
||||
+)
|
||||
ham[lower + offset : upper + offset]
|
||||
|
||||
slice[::, ::]
|
||||
@@ -50,10 +50,14 @@
|
||||
@@ -50,10 +55,14 @@
|
||||
slice[
|
||||
# A
|
||||
1
|
||||
@@ -169,7 +174,12 @@ async def f():
|
||||
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]
|
||||
# ham[lower+offset : upper+offset]
|
||||
ham[ : NOT_IMPLEMENTED_call() : NOT_IMPLEMENTED_call()], ham[ :: NOT_IMPLEMENTED_call()]
|
||||
(
|
||||
ham[
|
||||
: NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg) : NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
],
|
||||
ham[ :: NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)],
|
||||
)
|
||||
ham[lower + offset : upper + offset]
|
||||
|
||||
slice[::, ::]
|
||||
|
||||
@@ -42,7 +42,7 @@ assert (
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -2,57 +2,24 @@
|
||||
@@ -2,20 +2,10 @@
|
||||
(
|
||||
()
|
||||
<< 0
|
||||
@@ -65,16 +65,16 @@ assert (
|
||||
|
||||
importA
|
||||
0
|
||||
0 ^ 0 #
|
||||
@@ -24,35 +14,15 @@
|
||||
|
||||
|
||||
-class A:
|
||||
- def foo(self):
|
||||
class A:
|
||||
def foo(self):
|
||||
- for _ in range(10):
|
||||
- aaaaaaaaaaaaaaaaaaa = bbbbbbbbbbbbbbb.cccccccccc(
|
||||
- xxxxxxxxxxxx
|
||||
- ) # pylint: disable=no-member
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
+ for _ in NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
+ aaaaaaaaaaaaaaaaaaa = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
def test(self, othr):
|
||||
@@ -126,7 +126,10 @@ importA
|
||||
0 ^ 0 #
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class A:
|
||||
def foo(self):
|
||||
for _ in NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg):
|
||||
aaaaaaaaaaaaaaaaaaa = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
def test(self, othr):
|
||||
|
||||
@@ -38,12 +38,15 @@ class A:
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -1,34 +1,12 @@
|
||||
@@ -1,34 +1,25 @@
|
||||
-if e1234123412341234.winerror not in (
|
||||
- _winapi.ERROR_SEM_TIMEOUT,
|
||||
- _winapi.ERROR_PIPE_BUSY,
|
||||
-) or _check_timeout(t):
|
||||
+if NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right or NOT_IMPLEMENTED_call():
|
||||
+if (
|
||||
+ NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
|
||||
+ or NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
+):
|
||||
pass
|
||||
|
||||
if x:
|
||||
@@ -55,45 +58,63 @@ class A:
|
||||
- )
|
||||
- + 1
|
||||
- )
|
||||
+ new_id = NOT_IMPLEMENTED_call() + 1
|
||||
+ new_id = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg) + 1
|
||||
|
||||
|
||||
-class X:
|
||||
- def get_help_text(self):
|
||||
class X:
|
||||
def get_help_text(self):
|
||||
- return ngettext(
|
||||
- "Your password must contain at least %(min_length)d character.",
|
||||
- "Your password must contain at least %(min_length)d characters.",
|
||||
- self.min_length,
|
||||
- ) % {"min_length": self.min_length}
|
||||
+NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
+ return NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg) % {
|
||||
+ "NOT_YET_IMPLEMENTED_STRING": self.min_length,
|
||||
+ }
|
||||
|
||||
|
||||
-class A:
|
||||
- def b(self):
|
||||
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
|
||||
+ if (
|
||||
+ self.connection.mysql_is_mariadb
|
||||
+ and NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
|
||||
+ ):
|
||||
pass
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
if NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right or NOT_IMPLEMENTED_call():
|
||||
if (
|
||||
NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
|
||||
or NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
):
|
||||
pass
|
||||
|
||||
if x:
|
||||
if y:
|
||||
new_id = NOT_IMPLEMENTED_call() + 1
|
||||
new_id = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg) + 1
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class X:
|
||||
def get_help_text(self):
|
||||
return NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg) % {
|
||||
"NOT_YET_IMPLEMENTED_STRING": self.min_length,
|
||||
}
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class A:
|
||||
def b(self):
|
||||
if (
|
||||
self.connection.mysql_is_mariadb
|
||||
and NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
|
||||
):
|
||||
pass
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
||||
@@ -30,7 +30,7 @@ if True:
|
||||
- + "qweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqwegqweasdzxcqweasdzxc.",
|
||||
- "qweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqwe",
|
||||
- ) % {"reported_username": reported_username, "report_reason": report_reason}
|
||||
+ return NOT_IMPLEMENTED_call() % {
|
||||
+ return NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg) % {
|
||||
+ "NOT_YET_IMPLEMENTED_STRING": reported_username,
|
||||
+ "NOT_YET_IMPLEMENTED_STRING": report_reason,
|
||||
+ }
|
||||
@@ -42,7 +42,7 @@ if True:
|
||||
if True:
|
||||
if True:
|
||||
if True:
|
||||
return NOT_IMPLEMENTED_call() % {
|
||||
return NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg) % {
|
||||
"NOT_YET_IMPLEMENTED_STRING": reported_username,
|
||||
"NOT_YET_IMPLEMENTED_STRING": report_reason,
|
||||
}
|
||||
|
||||
@@ -54,18 +54,18 @@ assert xxxxxxxxx.xxxxxxxxx.xxxxxxxxx(
|
||||
-).four(
|
||||
- five,
|
||||
-)
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
-func1(arg1).func2(
|
||||
- arg2,
|
||||
-).func3(arg3).func4(
|
||||
- arg4,
|
||||
-).func5(arg5)
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
# Inner one-element tuple shouldn't explode
|
||||
-func1(arg1).func2(arg1, (one_tuple,)).func3(arg3)
|
||||
+NOT_IMPLEMENTED_call()
|
||||
+NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
(
|
||||
a,
|
||||
@@ -75,7 +75,7 @@ assert xxxxxxxxx.xxxxxxxxx.xxxxxxxxx(
|
||||
-) = func1(
|
||||
- arg1
|
||||
-) and func2(arg2)
|
||||
+) = NOT_IMPLEMENTED_call() and NOT_IMPLEMENTED_call()
|
||||
+) = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg) and NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
# Example from https://github.com/psf/black/issues/3229
|
||||
@@ -86,7 +86,7 @@ assert xxxxxxxxx.xxxxxxxxx.xxxxxxxxx(
|
||||
- },
|
||||
- api_key=api_key,
|
||||
- )["extensions"]["sdk"]["token"]
|
||||
+ return NOT_IMPLEMENTED_call()["NOT_YET_IMPLEMENTED_STRING"][
|
||||
+ return NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)["NOT_YET_IMPLEMENTED_STRING"][
|
||||
+ "NOT_YET_IMPLEMENTED_STRING"
|
||||
+ ][
|
||||
+ "NOT_YET_IMPLEMENTED_STRING"
|
||||
@@ -113,24 +113,24 @@ assert xxxxxxxxx.xxxxxxxxx.xxxxxxxxx(
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
# Inner one-element tuple shouldn't explode
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
(
|
||||
a,
|
||||
b,
|
||||
c,
|
||||
d,
|
||||
) = NOT_IMPLEMENTED_call() and NOT_IMPLEMENTED_call()
|
||||
) = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg) and NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
# Example from https://github.com/psf/black/issues/3229
|
||||
def refresh_token(self, device_family, refresh_token, api_key):
|
||||
return NOT_IMPLEMENTED_call()["NOT_YET_IMPLEMENTED_STRING"][
|
||||
return NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)["NOT_YET_IMPLEMENTED_STRING"][
|
||||
"NOT_YET_IMPLEMENTED_STRING"
|
||||
][
|
||||
"NOT_YET_IMPLEMENTED_STRING"
|
||||
|
||||
@@ -29,7 +29,7 @@ this_will_be_wrapped_in_parens, = struct.unpack(b"12345678901234567890")
|
||||
|
||||
# This is as well.
|
||||
-(this_will_be_wrapped_in_parens,) = struct.unpack(b"12345678901234567890")
|
||||
+(this_will_be_wrapped_in_parens,) = NOT_IMPLEMENTED_call()
|
||||
+(this_will_be_wrapped_in_parens,) = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
-(a,) = call()
|
||||
+(a,) = NOT_IMPLEMENTED_call()
|
||||
@@ -47,7 +47,7 @@ this_will_be_wrapped_in_parens, = struct.unpack(b"12345678901234567890")
|
||||
) = 1, 2, 3
|
||||
|
||||
# This is as well.
|
||||
(this_will_be_wrapped_in_parens,) = NOT_IMPLEMENTED_call()
|
||||
(this_will_be_wrapped_in_parens,) = NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
(a,) = NOT_IMPLEMENTED_call()
|
||||
```
|
||||
|
||||
@@ -214,7 +214,7 @@ if (
|
||||
|
||||
|
||||
# Black breaks the right side first for the following expressions:
|
||||
aaaaaaaaaaaaaa + NOT_IMPLEMENTED_call()
|
||||
aaaaaaaaaaaaaa + NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
aaaaaaaaaaaaaa + [
|
||||
bbbbbbbbbbbbbbbbbbbbbb,
|
||||
ccccccccccccccccccccc,
|
||||
|
||||
@@ -54,6 +54,14 @@ mapping = {
|
||||
C: 0.1 * (10.0 / 12),
|
||||
D: 0.1 * (10.0 / 12),
|
||||
}
|
||||
|
||||
# Regression test for formatter panic with comment after parenthesized dict value
|
||||
# Originally found in https://github.com/bolucat/Firefox/blob/636a717ef025c16434997dc89e42351ef740ee6b/testing/marionette/client/marionette_driver/geckoinstance.py#L109
|
||||
a = {
|
||||
1: (2),
|
||||
# comment
|
||||
3: True,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -112,6 +120,14 @@ mapping = {
|
||||
C: 0.1 * (10.0 / 12),
|
||||
D: 0.1 * (10.0 / 12),
|
||||
}
|
||||
|
||||
# Regression test for formatter panic with comment after parenthesized dict value
|
||||
# Originally found in https://github.com/bolucat/Firefox/blob/636a717ef025c16434997dc89e42351ef740ee6b/testing/marionette/client/marionette_driver/geckoinstance.py#L109
|
||||
a = {
|
||||
1: (2),
|
||||
# comment
|
||||
3: True,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
---
|
||||
source: crates/ruff_python_formatter/src/lib.rs
|
||||
expression: snapshot
|
||||
---
|
||||
## Input
|
||||
```py
|
||||
class Test(
|
||||
Aaaaaaaaaaaaaaaaa,
|
||||
Bbbbbbbbbbbbbbbb,
|
||||
DDDDDDDDDDDDDDDD,
|
||||
EEEEEEEEEEEEEE,
|
||||
metaclass=meta,
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
class Test((Aaaaaaaaaaaaaaaaa), Bbbbbbbbbbbbbbbb, metaclass=meta):
|
||||
pass
|
||||
|
||||
class Test( # trailing class comment
|
||||
Aaaaaaaaaaaaaaaaa, # trailing comment
|
||||
|
||||
# in between comment
|
||||
|
||||
Bbbbbbbbbbbbbbbb,
|
||||
# another leading comment
|
||||
DDDDDDDDDDDDDDDD,
|
||||
EEEEEEEEEEEEEE,
|
||||
# meta comment
|
||||
metaclass=meta, # trailing meta comment
|
||||
):
|
||||
pass
|
||||
|
||||
class Test((Aaaa)):
|
||||
...
|
||||
|
||||
|
||||
class Test(aaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbb + cccccccccccccccccccccccc + dddddddddddddddddddddd + eeeeeeeee, ffffffffffffffffff, gggggggggggggggggg):
|
||||
pass
|
||||
|
||||
class Test(Aaaa): # trailing comment
|
||||
pass
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Output
|
||||
```py
|
||||
class Test(
|
||||
Aaaaaaaaaaaaaaaaa,
|
||||
Bbbbbbbbbbbbbbbb,
|
||||
DDDDDDDDDDDDDDDD,
|
||||
EEEEEEEEEEEEEE,
|
||||
metaclass=meta,
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
class Test((Aaaaaaaaaaaaaaaaa), Bbbbbbbbbbbbbbbb, metaclass=meta):
|
||||
pass
|
||||
|
||||
|
||||
class Test(
|
||||
# trailing class comment
|
||||
Aaaaaaaaaaaaaaaaa, # trailing comment
|
||||
# in between comment
|
||||
Bbbbbbbbbbbbbbbb,
|
||||
# another leading comment
|
||||
DDDDDDDDDDDDDDDD,
|
||||
EEEEEEEEEEEEEE,
|
||||
# meta comment
|
||||
metaclass=meta, # trailing meta comment
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
class Test((Aaaa)):
|
||||
...
|
||||
|
||||
|
||||
class Test(
|
||||
aaaaaaaaaaaaaaa
|
||||
+ bbbbbbbbbbbbbbbbbbbbbb
|
||||
+ cccccccccccccccccccccccc
|
||||
+ dddddddddddddddddddddd
|
||||
+ eeeeeeeee,
|
||||
ffffffffffffffffff,
|
||||
gggggggggggggggggg,
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
class Test(Aaaa): # trailing comment
|
||||
pass
|
||||
```
|
||||
|
||||
|
||||
@@ -61,16 +61,16 @@ while (
|
||||
else:
|
||||
...
|
||||
|
||||
while NOT_IMPLEMENTED_call() and anotherCondition or aThirdCondition: # comment
|
||||
NOT_IMPLEMENTED_call()
|
||||
while NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg) and anotherCondition or aThirdCondition: # comment
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
|
||||
|
||||
while (
|
||||
NOT_IMPLEMENTED_call() # trailing some condition
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg) # trailing some condition
|
||||
and anotherCondition
|
||||
or aThirdCondition # trailing third condition
|
||||
): # comment
|
||||
NOT_IMPLEMENTED_call()
|
||||
NOT_IMPLEMENTED_call(NOT_IMPLEMENTED_arg)
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -52,7 +52,10 @@ b = 20
|
||||
|
||||
|
||||
# Adds two lines after `b`
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class Test:
|
||||
def a(self):
|
||||
pass
|
||||
# trailing comment
|
||||
|
||||
|
||||
# two lines before, one line after
|
||||
|
||||
@@ -1,12 +1,138 @@
|
||||
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use rustpython_parser::ast::StmtClassDef;
|
||||
use crate::comments::trailing_comments;
|
||||
use crate::expression::parentheses::Parenthesize;
|
||||
use crate::prelude::*;
|
||||
use crate::trivia::{first_non_trivia_token, SimpleTokenizer, Token, TokenKind};
|
||||
use crate::USE_MAGIC_TRAILING_COMMA;
|
||||
use ruff_formatter::{format_args, write};
|
||||
use ruff_text_size::TextRange;
|
||||
use rustpython_parser::ast::{Expr, Keyword, Ranged, StmtClassDef};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtClassDef;
|
||||
|
||||
impl FormatNodeRule<StmtClassDef> for FormatStmtClassDef {
|
||||
fn fmt_fields(&self, item: &StmtClassDef, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
write!(f, [not_yet_implemented(item)])
|
||||
let StmtClassDef {
|
||||
range: _,
|
||||
name,
|
||||
bases,
|
||||
keywords,
|
||||
body,
|
||||
decorator_list,
|
||||
} = item;
|
||||
|
||||
f.join_with(hard_line_break())
|
||||
.entries(decorator_list.iter().formatted())
|
||||
.finish()?;
|
||||
|
||||
if !decorator_list.is_empty() {
|
||||
hard_line_break().fmt(f)?;
|
||||
}
|
||||
|
||||
write!(f, [text("class"), space(), name.format()])?;
|
||||
|
||||
if !(bases.is_empty() && keywords.is_empty()) {
|
||||
write!(
|
||||
f,
|
||||
[group(&format_args![
|
||||
text("("),
|
||||
soft_block_indent(&FormatInheritanceClause {
|
||||
class_definition: item
|
||||
}),
|
||||
text(")")
|
||||
])]
|
||||
)?;
|
||||
}
|
||||
|
||||
let comments = f.context().comments().clone();
|
||||
let trailing_head_comments = comments.dangling_comments(item);
|
||||
|
||||
write!(
|
||||
f,
|
||||
[
|
||||
text(":"),
|
||||
trailing_comments(trailing_head_comments),
|
||||
block_indent(&body.format())
|
||||
]
|
||||
)
|
||||
}
|
||||
|
||||
fn fmt_dangling_comments(
|
||||
&self,
|
||||
_node: &StmtClassDef,
|
||||
_f: &mut PyFormatter,
|
||||
) -> FormatResult<()> {
|
||||
// handled in fmt_fields
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
struct FormatInheritanceClause<'a> {
|
||||
class_definition: &'a StmtClassDef,
|
||||
}
|
||||
|
||||
impl Format<PyFormatContext<'_>> for FormatInheritanceClause<'_> {
|
||||
fn fmt(&self, f: &mut Formatter<PyFormatContext<'_>>) -> FormatResult<()> {
|
||||
let StmtClassDef {
|
||||
bases,
|
||||
keywords,
|
||||
name,
|
||||
..
|
||||
} = self.class_definition;
|
||||
|
||||
let separator = format_with(|f| write!(f, [text(","), soft_line_break_or_space()]));
|
||||
let source = f.context().contents();
|
||||
|
||||
let mut joiner = f.join_with(&separator);
|
||||
|
||||
if let Some((first, rest)) = bases.split_first() {
|
||||
// Manually handle parentheses for the first expression because the logic in `FormatExpr`
|
||||
// doesn't know that it should disregard the parentheses of the inheritance clause.
|
||||
// ```python
|
||||
// class Test(A) # A is not parenthesized, the parentheses belong to the inheritance clause
|
||||
// class Test((A)) # A is parenthesized
|
||||
// ```
|
||||
// parentheses from the inheritance clause belong to the expression.
|
||||
let tokenizer = SimpleTokenizer::new(source, TextRange::new(name.end(), first.start()))
|
||||
.skip_trivia();
|
||||
|
||||
let left_paren_count = tokenizer
|
||||
.take_while(|token| token.kind() == TokenKind::LParen)
|
||||
.count();
|
||||
|
||||
// Ignore the first parentheses count
|
||||
let parenthesize = if left_paren_count > 1 {
|
||||
Parenthesize::Always
|
||||
} else {
|
||||
Parenthesize::Never
|
||||
};
|
||||
|
||||
joiner.entry(&first.format().with_options(parenthesize));
|
||||
joiner.entries(rest.iter().formatted());
|
||||
}
|
||||
|
||||
joiner.entries(keywords.iter().formatted()).finish()?;
|
||||
|
||||
if_group_breaks(&text(",")).fmt(f)?;
|
||||
|
||||
if USE_MAGIC_TRAILING_COMMA {
|
||||
let last_end = keywords
|
||||
.last()
|
||||
.map(Keyword::end)
|
||||
.or_else(|| bases.last().map(Expr::end))
|
||||
.unwrap();
|
||||
|
||||
if matches!(
|
||||
first_non_trivia_token(last_end, f.context().contents()),
|
||||
Some(Token {
|
||||
kind: TokenKind::Comma,
|
||||
..
|
||||
})
|
||||
) {
|
||||
hard_line_break().fmt(f)?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,7 +252,8 @@ one_leading_newline = 10
|
||||
no_leading_newline = 30
|
||||
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class InTheMiddle:
|
||||
pass
|
||||
|
||||
|
||||
trailing_statement = 1
|
||||
@@ -283,7 +284,8 @@ two_leading_newlines = 20
|
||||
one_leading_newline = 10
|
||||
no_leading_newline = 30
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtClassDef
|
||||
class InTheMiddle:
|
||||
pass
|
||||
|
||||
trailing_statement = 1
|
||||
|
||||
|
||||
@@ -22,15 +22,45 @@
|
||||
--crater: #f0dfdf;
|
||||
}
|
||||
|
||||
[data-md-color-scheme="ruff"] {
|
||||
[data-md-color-scheme="astral-light"] {
|
||||
--md-default-bg-color--dark: var(--black);
|
||||
--md-primary-fg-color: var(--galaxy);
|
||||
--md-typeset-a-color: var(--flare);
|
||||
--md-accent-fg-color: var(--cosmic);
|
||||
}
|
||||
|
||||
/*[data-md-color-scheme="slate"] {*/
|
||||
/* --md-primary-fg-color: var(--galaxy);*/
|
||||
/* --md-typeset-a-color: var(--cosmic);*/
|
||||
/* --md-accent-fg-color: var(--white);*/
|
||||
/*}*/
|
||||
[data-md-color-scheme="astral-dark"] {
|
||||
--md-default-bg-color: var(--galaxy);
|
||||
--md-default-fg-color: var(--white);
|
||||
--md-default-fg-color--light: var(--white);
|
||||
--md-default-fg-color--lighter: var(--white);
|
||||
--md-primary-fg-color: var(--space);
|
||||
--md-primary-bg-color: var(--white);
|
||||
--md-accent-fg-color: var(--radiate);
|
||||
|
||||
--md-typeset-color: var(--white);
|
||||
--md-typeset-a-color: var(--radiate);
|
||||
--md-typeset-mark-color: var(--sun);
|
||||
|
||||
--md-code-fg-color: var(--white);
|
||||
--md-code-bg-color: var(--space);
|
||||
|
||||
--md-code-hl-comment-color: var(--asteroid);
|
||||
--md-code-hl-punctuation-color: var(--asteroid);
|
||||
--md-code-hl-generic-color: var(--supernova);
|
||||
--md-code-hl-variable-color: var(--starlight);
|
||||
--md-code-hl-string-color: var(--radiate);
|
||||
--md-code-hl-keyword-color: var(--supernova);
|
||||
--md-code-hl-operator-color: var(--supernova);
|
||||
--md-code-hl-number-color: var(--electron);
|
||||
--md-code-hl-special-color: var(--electron);
|
||||
--md-code-hl-function-color: var(--neutron);
|
||||
--md-code-hl-constant-color: var(--radiate);
|
||||
--md-code-hl-name-color: var(--md-code-fg-color);
|
||||
|
||||
--md-typeset-del-color: hsla(6, 90%, 60%, 0.15);
|
||||
--md-typeset-ins-color: hsla(150, 90%, 44%, 0.15);
|
||||
|
||||
--md-typeset-table-color: hsla(0, 0%, 100%, 0.12);
|
||||
--md-typeset-table-color--light: hsla(0, 0%, 100%, 0.035);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ def sum_even_numbers(numbers: List[int]) -> int:
|
||||
return sum(num for num in numbers if num % 2 == 0)
|
||||
```
|
||||
|
||||
To start, we'll install Ruff through PyPI (or with our [preferred package manager](installation.md)):
|
||||
To start, we'll install Ruff through PyPI (or with your [preferred package manager](installation.md)):
|
||||
|
||||
```shell
|
||||
> pip install ruff
|
||||
@@ -242,7 +242,7 @@ This tutorial has focused on Ruff's command-line interface, but Ruff can also be
|
||||
```yaml
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
# Ruff version.
|
||||
rev: v0.0.274
|
||||
rev: v0.0.275
|
||||
hooks:
|
||||
- id: ruff
|
||||
```
|
||||
|
||||
@@ -22,7 +22,7 @@ Ruff can also be used as a [pre-commit](https://pre-commit.com) hook:
|
||||
```yaml
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
# Ruff version.
|
||||
rev: v0.0.274
|
||||
rev: v0.0.275
|
||||
hooks:
|
||||
- id: ruff
|
||||
```
|
||||
@@ -32,7 +32,7 @@ Or, to enable autofix:
|
||||
```yaml
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
# Ruff version.
|
||||
rev: v0.0.274
|
||||
rev: v0.0.275
|
||||
hooks:
|
||||
- id: ruff
|
||||
args: [ --fix, --exit-non-zero-on-fix ]
|
||||
|
||||
@@ -14,14 +14,12 @@ theme:
|
||||
- content.code.copy
|
||||
palette:
|
||||
- media: "(prefers-color-scheme: light)"
|
||||
scheme: ruff
|
||||
primary: red
|
||||
scheme: astral-light
|
||||
toggle:
|
||||
icon: material/weather-sunny
|
||||
name: Switch to dark mode
|
||||
- media: "(prefers-color-scheme: dark)"
|
||||
scheme: slate
|
||||
primary: deep-purple
|
||||
scheme: astral-dark
|
||||
toggle:
|
||||
icon: material/weather-night
|
||||
name: Switch to light mode
|
||||
|
||||
@@ -5,7 +5,7 @@ build-backend = "maturin"
|
||||
|
||||
[project]
|
||||
name = "ruff"
|
||||
version = "0.0.274"
|
||||
version = "0.0.275"
|
||||
description = "An extremely fast Python linter, written in Rust."
|
||||
authors = [{ name = "Charlie Marsh", email = "charlie.r.marsh@gmail.com" }]
|
||||
maintainers = [{ name = "Charlie Marsh", email = "charlie.r.marsh@gmail.com" }]
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ Example usage:
|
||||
--url https://pypi.org/project/flake8-pie/
|
||||
--prefix PIE
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ Example usage:
|
||||
--code 807 \
|
||||
--linter flake8-pie
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import subprocess
|
||||
|
||||
@@ -1,17 +1,22 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Check code snippets in docs are formatted by black."""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import re
|
||||
import textwrap
|
||||
from collections.abc import Sequence
|
||||
from pathlib import Path
|
||||
from re import Match
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import black
|
||||
from black.mode import Mode, TargetVersion
|
||||
from black.parsing import InvalidInput
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Sequence
|
||||
|
||||
TARGET_VERSIONS = ["py37", "py38", "py39", "py310", "py311"]
|
||||
SNIPPED_RE = re.compile(
|
||||
r"(?P<before>^(?P<indent> *)```\s*python\n)"
|
||||
|
||||
@@ -44,11 +44,11 @@ class Repository(NamedTuple):
|
||||
async def clone(self: Self, checkout_dir: Path) -> AsyncIterator[Path]:
|
||||
"""Shallow clone this repository to a temporary directory."""
|
||||
if checkout_dir.exists():
|
||||
logger.debug(f"Reusing {self.org}/{self.repo}")
|
||||
logger.debug(f"Reusing {self.org}:{self.repo}")
|
||||
yield Path(checkout_dir)
|
||||
return
|
||||
|
||||
logger.debug(f"Cloning {self.org}/{self.repo}")
|
||||
logger.debug(f"Cloning {self.org}:{self.repo}")
|
||||
git_command = [
|
||||
"git",
|
||||
"clone",
|
||||
@@ -177,18 +177,17 @@ async def compare(
|
||||
"""Check a specific repository against two versions of ruff."""
|
||||
removed, added = set(), set()
|
||||
|
||||
# Allows to keep the checkouts locations
|
||||
# By the default, the git clone are transient, but if the user provides a
|
||||
# directory for permanent storage we keep it there
|
||||
if checkouts:
|
||||
checkout_parent = checkouts.joinpath(repo.org)
|
||||
# Don't create the repodir itself, we need that for checking for existing
|
||||
# clones
|
||||
checkout_parent.mkdir(exist_ok=True, parents=True)
|
||||
location_context = nullcontext(checkout_parent)
|
||||
location_context = nullcontext(checkouts)
|
||||
else:
|
||||
location_context = tempfile.TemporaryDirectory()
|
||||
|
||||
with location_context as checkout_parent:
|
||||
checkout_dir = Path(checkout_parent).joinpath(repo.repo)
|
||||
assert ":" not in repo.org
|
||||
assert ":" not in repo.repo
|
||||
checkout_dir = Path(checkout_parent).joinpath(f"{repo.org}:{repo.repo}")
|
||||
async with repo.clone(checkout_dir) as path:
|
||||
try:
|
||||
async with asyncio.TaskGroup() as tg:
|
||||
@@ -284,8 +283,19 @@ async def main(
|
||||
|
||||
logger.debug(f"Checking {len(repositories)} projects")
|
||||
|
||||
# https://stackoverflow.com/a/61478547/3549270
|
||||
# Otherwise doing 3k repositories can take >8GB RAM
|
||||
semaphore = asyncio.Semaphore(50)
|
||||
|
||||
async def limited_parallelism(coroutine): # noqa: ANN
|
||||
async with semaphore:
|
||||
return await coroutine
|
||||
|
||||
results = await asyncio.gather(
|
||||
*[compare(ruff1, ruff2, repo, checkouts) for repo in repositories.values()],
|
||||
*[
|
||||
limited_parallelism(compare(ruff1, ruff2, repo, checkouts))
|
||||
for repo in repositories.values()
|
||||
],
|
||||
return_exceptions=True,
|
||||
)
|
||||
|
||||
@@ -433,6 +443,8 @@ if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
if args.checkouts:
|
||||
args.checkouts.mkdir(exist_ok=True, parents=True)
|
||||
main_task = asyncio.ensure_future(
|
||||
main(
|
||||
ruff1=args.ruff1,
|
||||
|
||||
@@ -3,13 +3,14 @@ panics, autofix errors and similar problems.
|
||||
|
||||
It's a less elaborate, more hacky version of check_ecosystem.py
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from subprocess import CalledProcessError
|
||||
from typing import NamedTuple, Optional
|
||||
from typing import NamedTuple
|
||||
|
||||
from tqdm import tqdm
|
||||
|
||||
@@ -19,7 +20,7 @@ class Repository(NamedTuple):
|
||||
|
||||
org: str
|
||||
repo: str
|
||||
ref: Optional[str]
|
||||
ref: str | None
|
||||
|
||||
|
||||
def main() -> None:
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user