From 006a96f5a8b0d3c6b399dfdc5dbb2c01ebf68d52 Mon Sep 17 00:00:00 2001 From: Jonathan Plasse <13716151+JonathanPlasse@users.noreply.github.com> Date: Thu, 16 Mar 2023 11:21:47 +0100 Subject: [PATCH] Fix incomplete snapshots --- ...es__flake8_pytest_style__tests__PT018.snap | 150 ++++++++++++ ...ke8_simplify__tests__SIM102_SIM102.py.snap | 46 ++++ ...ke8_simplify__tests__SIM103_SIM103.py.snap | 26 +++ ...ke8_simplify__tests__SIM108_SIM108.py.snap | 52 +++++ ...ke8_simplify__tests__SIM110_SIM110.py.snap | 26 +++ ...ke8_simplify__tests__SIM110_SIM111.py.snap | 26 +++ ...ke8_simplify__tests__SIM117_SIM117.py.snap | 46 ++++ ...ke8_simplify__tests__SIM222_SIM222.py.snap | 20 ++ ...ts__tests__ban_parent_imports_package.snap | 40 ---- ...les__pycodestyle__tests__E731_E731.py.snap | 13 ++ ...__rules__pydocstyle__tests__D200_D.py.snap | 26 +++ ...ules__pyflakes__tests__F401_F401_0.py.snap | 20 ++ ..._rules__pyflakes__tests__F601_F601.py.snap | 78 +++++++ ..._rules__pyflakes__tests__F602_F602.py.snap | 78 +++++++ ...ules__pyflakes__tests__F841_F841_0.py.snap | 118 ++++++++++ ...ules__pyflakes__tests__F841_F841_1.py.snap | 52 +++++ ...ules__pyflakes__tests__F841_F841_3.py.snap | 78 +++++++ ...lakes__tests__f841_dummy_variable_rgx.snap | 39 ++++ ...__pyflakes__tests__future_annotations.snap | 13 ++ ...ff__rules__pyupgrade__tests__UP007.py.snap | 20 ++ ...__rules__pyupgrade__tests__UP031_0.py.snap | 20 ++ ...ff__rules__pyupgrade__tests__UP034.py.snap | 60 +++++ ...ff__rules__pyupgrade__tests__UP035.py.snap | 216 ++++++++++++++++++ ..._rules__ruff__tests__RUF005_RUF005.py.snap | 20 ++ .../ruff__rules__ruff__tests__ruf100_0.snap | 178 +++++++++++++++ crates/ruff/src/test.rs | 20 +- crates/ruff_diagnostics/src/diagnostic.rs | 4 +- 27 files changed, 1435 insertions(+), 50 deletions(-) diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT018.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT018.snap index 72d397571263c8..09e48dee514cc8 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT018.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT018.snap @@ -62,6 +62,26 @@ expression: diagnostics row: 17 column: 0 parent: ~ +- kind: + name: CompositeAssertion + body: Assertion should be broken down into multiple parts + suggestion: Break down assertion into multiple parts + fixable: true + location: + row: 16 + column: 4 + end_location: + row: 16 + column: 39 + fix: + content: " assert something\n assert something_else\n" + location: + row: 16 + column: 0 + end_location: + row: 17 + column: 0 + parent: ~ - kind: name: CompositeAssertion body: Assertion should be broken down into multiple parts @@ -254,4 +274,134 @@ expression: diagnostics column: 5 fix: ~ parent: ~ +- kind: + name: CompositeAssertion + body: Assertion should be broken down into multiple parts + suggestion: Break down assertion into multiple parts + fixable: true + location: + row: 37 + column: 4 + end_location: + row: 37 + column: 20 + fix: ~ + parent: ~ +- kind: + name: CompositeAssertion + body: Assertion should be broken down into multiple parts + suggestion: Break down assertion into multiple parts + fixable: true + location: + row: 38 + column: 4 + end_location: + row: 38 + column: 20 + fix: ~ + parent: ~ +- kind: + name: CompositeAssertion + body: Assertion should be broken down into multiple parts + suggestion: ~ + fixable: false + location: + row: 40 + column: 4 + end_location: + row: 40 + column: 56 + fix: ~ + parent: ~ +- kind: + name: CompositeAssertion + body: Assertion should be broken down into multiple parts + suggestion: ~ + fixable: false + location: + row: 41 + column: 4 + end_location: + row: 41 + column: 80 + fix: ~ + parent: ~ +- kind: + name: CompositeAssertion + body: Assertion should be broken down into multiple parts + suggestion: ~ + fixable: false + location: + row: 41 + column: 4 + end_location: + row: 41 + column: 56 + fix: ~ + parent: ~ +- kind: + name: CompositeAssertion + body: Assertion should be broken down into multiple parts + suggestion: ~ + fixable: false + location: + row: 42 + column: 4 + end_location: + row: 42 + column: 80 + fix: ~ + parent: ~ +- kind: + name: CompositeAssertion + body: Assertion should be broken down into multiple parts + suggestion: ~ + fixable: false + location: + row: 43 + column: 4 + end_location: + row: 43 + column: 64 + fix: ~ + parent: ~ +- kind: + name: CompositeAssertion + body: Assertion should be broken down into multiple parts + suggestion: ~ + fixable: false + location: + row: 44 + column: 4 + end_location: + row: 44 + column: 64 + fix: ~ + parent: ~ +- kind: + name: CompositeAssertion + body: Assertion should be broken down into multiple parts + suggestion: Break down assertion into multiple parts + fixable: true + location: + row: 45 + column: 4 + end_location: + row: 51 + column: 5 + fix: ~ + parent: ~ +- kind: + name: CompositeAssertion + body: Assertion should be broken down into multiple parts + suggestion: Break down assertion into multiple parts + fixable: true + location: + row: 46 + column: 4 + end_location: + row: 52 + column: 5 + fix: ~ + parent: ~ diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM102_SIM102.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM102_SIM102.py.snap index 6ddf06a8ec2e1c..3ab87028c39318 100644 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM102_SIM102.py.snap +++ b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM102_SIM102.py.snap @@ -22,6 +22,26 @@ expression: diagnostics row: 5 column: 0 parent: ~ +- kind: + name: CollapsibleIf + body: "Use a single `if` statement instead of nested `if` statements" + suggestion: "Combine `if` statements using `and`" + fixable: true + location: + row: 6 + column: 0 + end_location: + row: 7 + column: 9 + fix: + content: "if a and b and c:\n d\n" + location: + row: 6 + column: 0 + end_location: + row: 9 + column: 0 + parent: ~ - kind: name: CollapsibleIf body: "Use a single `if` statement instead of nested `if` statements" @@ -62,6 +82,32 @@ expression: diagnostics row: 18 column: 0 parent: ~ +- kind: + name: CollapsibleIf + body: "Use a single `if` statement instead of nested `if` statements" + suggestion: ~ + fixable: false + location: + row: 16 + column: 0 + end_location: + row: 18 + column: 9 + fix: ~ + parent: ~ +- kind: + name: CollapsibleIf + body: "Use a single `if` statement instead of nested `if` statements" + suggestion: ~ + fixable: false + location: + row: 17 + column: 0 + end_location: + row: 19 + column: 9 + fix: ~ + parent: ~ - kind: name: CollapsibleIf body: "Use a single `if` statement instead of nested `if` statements" diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM103_SIM103.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM103_SIM103.py.snap index a3b45f234c8f12..eeba8a0ec62b6e 100644 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM103_SIM103.py.snap +++ b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM103_SIM103.py.snap @@ -82,6 +82,19 @@ expression: diagnostics row: 35 column: 24 parent: ~ +- kind: + name: NeedlessBool + body: "Return the condition `a` directly" + suggestion: ~ + fixable: false + location: + row: 45 + column: 4 + end_location: + row: 48 + column: 19 + fix: ~ + parent: ~ - kind: name: NeedlessBool body: "Return the condition `a` directly" @@ -95,6 +108,19 @@ expression: diagnostics column: 19 fix: ~ parent: ~ +- kind: + name: NeedlessBool + body: "Return the condition `a` directly" + suggestion: ~ + fixable: false + location: + row: 71 + column: 4 + end_location: + row: 74 + column: 20 + fix: ~ + parent: ~ - kind: name: NeedlessBool body: "Return the condition `a` directly" diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM108_SIM108.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM108_SIM108.py.snap index 04215fea385288..0a1e2bb94b44b8 100644 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM108_SIM108.py.snap +++ b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM108_SIM108.py.snap @@ -22,6 +22,19 @@ expression: diagnostics row: 5 column: 9 parent: ~ +- kind: + name: UseTernaryOperator + body: "Use ternary operator `abc = x if x > 0 else -x` instead of `if`-`else`-block" + suggestion: ~ + fixable: false + location: + row: 55 + column: 0 + end_location: + row: 60 + column: 12 + fix: ~ + parent: ~ - kind: name: UseTernaryOperator body: "Use ternary operator `abc = x if x > 0 else -x` instead of `if`-`else`-block" @@ -55,6 +68,19 @@ expression: diagnostics row: 85 column: 45 parent: ~ +- kind: + name: UseTernaryOperator + body: "Use ternary operator `exitcode = 0 if True else 1` instead of `if`-`else`-block" + suggestion: ~ + fixable: false + location: + row: 91 + column: 0 + end_location: + row: 94 + column: 16 + fix: ~ + parent: ~ - kind: name: UseTernaryOperator body: "Use ternary operator `exitcode = 0 if True else 1` instead of `if`-`else`-block" @@ -68,6 +94,32 @@ expression: diagnostics column: 16 fix: ~ parent: ~ +- kind: + name: UseTernaryOperator + body: "Use ternary operator `x = 3 if True else 5` instead of `if`-`else`-block" + suggestion: ~ + fixable: false + location: + row: 98 + column: 0 + end_location: + row: 99 + column: 11 + fix: ~ + parent: ~ +- kind: + name: UseTernaryOperator + body: "Use ternary operator `x = 3 if True else 5` instead of `if`-`else`-block" + suggestion: ~ + fixable: false + location: + row: 103 + column: 0 + end_location: + row: 106 + column: 9 + fix: ~ + parent: ~ - kind: name: UseTernaryOperator body: "Use ternary operator `x = 3 if True else 5` instead of `if`-`else`-block" diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM110_SIM110.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM110_SIM110.py.snap index 684aa45103afa2..f6ed711250dba0 100644 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM110_SIM110.py.snap +++ b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM110_SIM110.py.snap @@ -142,6 +142,32 @@ expression: diagnostics row: 87 column: 19 parent: ~ +- kind: + name: ReimplementedBuiltin + body: "Use `return any(check(x) for x in iterable)` instead of `for` loop" + suggestion: "Replace with `return any(check(x) for x in iterable)`" + fixable: true + location: + row: 99 + column: 4 + end_location: + row: 101 + column: 23 + fix: ~ + parent: ~ +- kind: + name: ReimplementedBuiltin + body: "Use `return all(not check(x) for x in iterable)` instead of `for` loop" + suggestion: "Replace with `return all(not check(x) for x in iterable)`" + fixable: true + location: + row: 109 + column: 4 + end_location: + row: 111 + column: 24 + fix: ~ + parent: ~ - kind: name: ReimplementedBuiltin body: "Use `return any(check(x) for x in iterable)` instead of `for` loop" diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM110_SIM111.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM110_SIM111.py.snap index 1123651c15d136..6f79de00254ddf 100644 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM110_SIM111.py.snap +++ b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM110_SIM111.py.snap @@ -142,6 +142,32 @@ expression: diagnostics row: 87 column: 19 parent: ~ +- kind: + name: ReimplementedBuiltin + body: "Use `return any(check(x) for x in iterable)` instead of `for` loop" + suggestion: "Replace with `return any(check(x) for x in iterable)`" + fixable: true + location: + row: 99 + column: 4 + end_location: + row: 101 + column: 23 + fix: ~ + parent: ~ +- kind: + name: ReimplementedBuiltin + body: "Use `return all(not check(x) for x in iterable)` instead of `for` loop" + suggestion: "Replace with `return all(not check(x) for x in iterable)`" + fixable: true + location: + row: 109 + column: 4 + end_location: + row: 111 + column: 24 + fix: ~ + parent: ~ - kind: name: ReimplementedBuiltin body: "Use `return any(check(x) for x in iterable)` instead of `for` loop" diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM117_SIM117.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM117_SIM117.py.snap index fb6a3e4d08d6ab..09ad5fc1ddb919 100644 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM117_SIM117.py.snap +++ b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM117_SIM117.py.snap @@ -22,6 +22,26 @@ expression: diagnostics row: 5 column: 0 parent: ~ +- kind: + name: MultipleWithStatements + body: "Use a single `with` statement with multiple contexts instead of nested `with` statements" + suggestion: "Combine `with` statements" + fixable: true + location: + row: 6 + column: 0 + end_location: + row: 7 + column: 13 + fix: + content: "with A(), B(), C():\n print(\"hello\")\n" + location: + row: 6 + column: 0 + end_location: + row: 9 + column: 0 + parent: ~ - kind: name: MultipleWithStatements body: "Use a single `with` statement with multiple contexts instead of nested `with` statements" @@ -42,6 +62,32 @@ expression: diagnostics row: 11 column: 0 parent: ~ +- kind: + name: MultipleWithStatements + body: "Use a single `with` statement with multiple contexts instead of nested `with` statements" + suggestion: ~ + fixable: false + location: + row: 10 + column: 0 + end_location: + row: 12 + column: 18 + fix: ~ + parent: ~ +- kind: + name: MultipleWithStatements + body: "Use a single `with` statement with multiple contexts instead of nested `with` statements" + suggestion: ~ + fixable: false + location: + row: 11 + column: 0 + end_location: + row: 13 + column: 18 + fix: ~ + parent: ~ - kind: name: MultipleWithStatements body: "Use a single `with` statement with multiple contexts instead of nested `with` statements" diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM222_SIM222.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM222_SIM222.py.snap index 07487fd799eefc..628543a95c6538 100644 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM222_SIM222.py.snap +++ b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM222_SIM222.py.snap @@ -42,6 +42,26 @@ expression: diagnostics row: 4 column: 19 parent: ~ +- kind: + name: ExprOrTrue + body: "Use `True` instead of `... or True`" + suggestion: "Replace with `True`" + fixable: true + location: + row: 7 + column: 9 + end_location: + row: 7 + column: 13 + fix: + content: "True" + location: + row: 7 + column: 3 + end_location: + row: 7 + column: 14 + parent: ~ - kind: name: ExprOrTrue body: "Use `True` instead of `... or True`" diff --git a/crates/ruff/src/rules/flake8_tidy_imports/snapshots/ruff__rules__flake8_tidy_imports__relative_imports__tests__ban_parent_imports_package.snap b/crates/ruff/src/rules/flake8_tidy_imports/snapshots/ruff__rules__flake8_tidy_imports__relative_imports__tests__ban_parent_imports_package.snap index 868124bf766e87..0079f39870d38e 100644 --- a/crates/ruff/src/rules/flake8_tidy_imports/snapshots/ruff__rules__flake8_tidy_imports__relative_imports__tests__ban_parent_imports_package.snap +++ b/crates/ruff/src/rules/flake8_tidy_imports/snapshots/ruff__rules__flake8_tidy_imports__relative_imports__tests__ban_parent_imports_package.snap @@ -35,46 +35,6 @@ expression: diagnostics row: 6 column: 55 parent: ~ -- kind: - name: RelativeImports - body: Relative imports from parent modules are banned - suggestion: Replace relative imports from parent modules with absolute imports - fixable: true - location: - row: 6 - column: 0 - end_location: - row: 6 - column: 55 - fix: - content: "from my_package.sublib.protocol import commands, definitions, responses" - location: - row: 6 - column: 0 - end_location: - row: 6 - column: 55 - parent: ~ -- kind: - name: RelativeImports - body: Relative imports from parent modules are banned - suggestion: Replace relative imports from parent modules with absolute imports - fixable: true - location: - row: 6 - column: 0 - end_location: - row: 6 - column: 55 - fix: - content: "from my_package.sublib.protocol import commands, definitions, responses" - location: - row: 6 - column: 0 - end_location: - row: 6 - column: 55 - parent: ~ - kind: name: RelativeImports body: Relative imports from parent modules are banned diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E731_E731.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E731_E731.py.snap index a19ce0c7ab7d0d..406852d7d25441 100644 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E731_E731.py.snap +++ b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E731_E731.py.snap @@ -115,4 +115,17 @@ expression: diagnostics column: 23 fix: ~ parent: ~ +- kind: + name: LambdaAssignment + body: "Do not assign a `lambda` expression, use a `def`" + suggestion: ~ + fixable: false + location: + row: 19 + column: 4 + end_location: + row: 19 + column: 23 + fix: ~ + parent: ~ diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D200_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D200_D.py.snap index 3e4d58a38679c6..44be96b8a1da9d 100644 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D200_D.py.snap +++ b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D200_D.py.snap @@ -62,6 +62,19 @@ expression: diagnostics row: 608 column: 7 parent: ~ +- kind: + name: FitsOnOneLine + body: One-line docstring should fit on one line + suggestion: Reformat to one line + fixable: true + location: + row: 609 + column: 4 + end_location: + row: 611 + column: 7 + fix: ~ + parent: ~ - kind: name: FitsOnOneLine body: One-line docstring should fit on one line @@ -75,6 +88,19 @@ expression: diagnostics column: 7 fix: ~ parent: ~ +- kind: + name: FitsOnOneLine + body: One-line docstring should fit on one line + suggestion: Reformat to one line + fixable: true + location: + row: 618 + column: 4 + end_location: + row: 620 + column: 14 + fix: ~ + parent: ~ - kind: name: FitsOnOneLine body: One-line docstring should fit on one line diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_0.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_0.py.snap index bf44e0e586158a..d6d9df711e6f41 100644 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_0.py.snap +++ b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_0.py.snap @@ -44,6 +44,26 @@ expression: diagnostics parent: row: 4 column: 0 +- kind: + name: UnusedImport + body: "`logging.config` imported but unused" + suggestion: "Remove unused import: `logging.config`" + fixable: true + location: + row: 10 + column: 7 + end_location: + row: 10 + column: 21 + fix: + content: "" + location: + row: 10 + column: 0 + end_location: + row: 11 + column: 0 + parent: ~ - kind: name: UnusedImport body: "`logging.handlers` imported but unused" diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F601_F601.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F601_F601.py.snap index f47ed6f68a164e..f8875fae5de5fe 100644 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F601_F601.py.snap +++ b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F601_F601.py.snap @@ -87,6 +87,19 @@ expression: diagnostics row: 18 column: 10 parent: ~ +- kind: + name: MultiValueRepeatedKeyLiteral + body: "Dictionary key literal `\"a\"` repeated" + suggestion: ~ + fixable: false + location: + row: 22 + column: 4 + end_location: + row: 22 + column: 7 + fix: ~ + parent: ~ - kind: name: MultiValueRepeatedKeyLiteral body: "Dictionary key literal `\"a\"` repeated" @@ -146,6 +159,32 @@ expression: diagnostics column: 7 fix: ~ parent: ~ +- kind: + name: MultiValueRepeatedKeyLiteral + body: "Dictionary key literal `\"a\"` repeated" + suggestion: ~ + fixable: false + location: + row: 29 + column: 4 + end_location: + row: 29 + column: 7 + fix: ~ + parent: ~ +- kind: + name: MultiValueRepeatedKeyLiteral + body: "Dictionary key literal `\"a\"` repeated" + suggestion: ~ + fixable: false + location: + row: 30 + column: 4 + end_location: + row: 30 + column: 7 + fix: ~ + parent: ~ - kind: name: MultiValueRepeatedKeyLiteral body: "Dictionary key literal `\"a\"` repeated" @@ -166,6 +205,19 @@ expression: diagnostics row: 31 column: 10 parent: ~ +- kind: + name: MultiValueRepeatedKeyLiteral + body: "Dictionary key literal `\"a\"` repeated" + suggestion: ~ + fixable: false + location: + row: 31 + column: 4 + end_location: + row: 31 + column: 7 + fix: ~ + parent: ~ - kind: name: MultiValueRepeatedKeyLiteral body: "Dictionary key literal `\"a\"` repeated" @@ -205,6 +257,32 @@ expression: diagnostics column: 7 fix: ~ parent: ~ +- kind: + name: MultiValueRepeatedKeyLiteral + body: "Dictionary key literal `\"a\"` repeated" + suggestion: ~ + fixable: false + location: + row: 38 + column: 4 + end_location: + row: 38 + column: 7 + fix: ~ + parent: ~ +- kind: + name: MultiValueRepeatedKeyLiteral + body: "Dictionary key literal `\"a\"` repeated" + suggestion: ~ + fixable: false + location: + row: 40 + column: 4 + end_location: + row: 40 + column: 7 + fix: ~ + parent: ~ - kind: name: MultiValueRepeatedKeyLiteral body: "Dictionary key literal `\"a\"` repeated" diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F602_F602.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F602_F602.py.snap index 305cdf4132fa2c..67fc7d01b5a082 100644 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F602_F602.py.snap +++ b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F602_F602.py.snap @@ -61,6 +61,19 @@ expression: diagnostics row: 13 column: 8 parent: ~ +- kind: + name: MultiValueRepeatedKeyVariable + body: "Dictionary key `a` repeated" + suggestion: ~ + fixable: false + location: + row: 17 + column: 4 + end_location: + row: 17 + column: 5 + fix: ~ + parent: ~ - kind: name: MultiValueRepeatedKeyVariable body: "Dictionary key `a` repeated" @@ -120,6 +133,32 @@ expression: diagnostics column: 5 fix: ~ parent: ~ +- kind: + name: MultiValueRepeatedKeyVariable + body: "Dictionary key `a` repeated" + suggestion: ~ + fixable: false + location: + row: 24 + column: 4 + end_location: + row: 24 + column: 5 + fix: ~ + parent: ~ +- kind: + name: MultiValueRepeatedKeyVariable + body: "Dictionary key `a` repeated" + suggestion: ~ + fixable: false + location: + row: 25 + column: 4 + end_location: + row: 25 + column: 5 + fix: ~ + parent: ~ - kind: name: MultiValueRepeatedKeyVariable body: "Dictionary key `a` repeated" @@ -140,6 +179,19 @@ expression: diagnostics row: 26 column: 8 parent: ~ +- kind: + name: MultiValueRepeatedKeyVariable + body: "Dictionary key `a` repeated" + suggestion: ~ + fixable: false + location: + row: 26 + column: 4 + end_location: + row: 26 + column: 5 + fix: ~ + parent: ~ - kind: name: MultiValueRepeatedKeyVariable body: "Dictionary key `a` repeated" @@ -179,6 +231,19 @@ expression: diagnostics column: 5 fix: ~ parent: ~ +- kind: + name: MultiValueRepeatedKeyVariable + body: "Dictionary key `a` repeated" + suggestion: ~ + fixable: false + location: + row: 33 + column: 4 + end_location: + row: 33 + column: 5 + fix: ~ + parent: ~ - kind: name: MultiValueRepeatedKeyVariable body: "Dictionary key `a` repeated" @@ -199,6 +264,19 @@ expression: diagnostics row: 35 column: 8 parent: ~ +- kind: + name: MultiValueRepeatedKeyVariable + body: "Dictionary key `a` repeated" + suggestion: ~ + fixable: false + location: + row: 35 + column: 4 + end_location: + row: 35 + column: 5 + fix: ~ + parent: ~ - kind: name: MultiValueRepeatedKeyVariable body: "Dictionary key `a` repeated" diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F841_F841_0.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F841_F841_0.py.snap index a25da2b54009cc..9186e688c3152e 100644 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F841_F841_0.py.snap +++ b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F841_F841_0.py.snap @@ -22,6 +22,46 @@ expression: diagnostics row: 3 column: 22 parent: ~ +- kind: + name: UnusedVariable + body: "Local variable `x` is assigned to but never used" + suggestion: "Remove assignment to unused variable `x`" + fixable: true + location: + row: 14 + column: 4 + end_location: + row: 14 + column: 5 + fix: + content: "" + location: + row: 14 + column: 0 + end_location: + row: 15 + column: 0 + parent: ~ +- kind: + name: UnusedVariable + body: "Local variable `y` is assigned to but never used" + suggestion: "Remove assignment to unused variable `y`" + fixable: true + location: + row: 15 + column: 4 + end_location: + row: 15 + column: 5 + fix: + content: pass + location: + row: 15 + column: 4 + end_location: + row: 15 + column: 9 + parent: ~ - kind: name: UnusedVariable body: "Local variable `z` is assigned to but never used" @@ -42,6 +82,58 @@ expression: diagnostics row: 17 column: 0 parent: ~ +- kind: + name: UnusedVariable + body: "Local variable `a` is assigned to but never used" + suggestion: "Remove assignment to unused variable `a`" + fixable: true + location: + row: 18 + column: 5 + end_location: + row: 18 + column: 6 + fix: ~ + parent: ~ +- kind: + name: UnusedVariable + body: "Local variable `b` is assigned to but never used" + suggestion: "Remove assignment to unused variable `b`" + fixable: true + location: + row: 18 + column: 8 + end_location: + row: 18 + column: 9 + fix: ~ + parent: ~ +- kind: + name: UnusedVariable + body: "Local variable `a` is assigned to but never used" + suggestion: "Remove assignment to unused variable `a`" + fixable: true + location: + row: 19 + column: 5 + end_location: + row: 19 + column: 6 + fix: ~ + parent: ~ +- kind: + name: UnusedVariable + body: "Local variable `b` is assigned to but never used" + suggestion: "Remove assignment to unused variable `b`" + fixable: true + location: + row: 19 + column: 8 + end_location: + row: 19 + column: 9 + fix: ~ + parent: ~ - kind: name: UnusedVariable body: "Local variable `foo` is assigned to but never used" @@ -208,6 +300,32 @@ expression: diagnostics row: 115 column: 10 parent: ~ +- kind: + name: UnusedVariable + body: "Local variable `y` is assigned to but never used" + suggestion: "Remove assignment to unused variable `y`" + fixable: true + location: + row: 118 + column: 13 + end_location: + row: 118 + column: 14 + fix: ~ + parent: ~ +- kind: + name: UnusedVariable + body: "Local variable `y` is assigned to but never used" + suggestion: "Remove assignment to unused variable `y`" + fixable: true + location: + row: 119 + column: 13 + end_location: + row: 119 + column: 14 + fix: ~ + parent: ~ - kind: name: UnusedVariable body: "Local variable `y` is assigned to but never used" diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F841_F841_1.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F841_F841_1.py.snap index b5a9eb03e0d3eb..027cfce398bb7c 100644 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F841_F841_1.py.snap +++ b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F841_F841_1.py.snap @@ -28,6 +28,32 @@ expression: diagnostics column: 8 fix: ~ parent: ~ +- kind: + name: UnusedVariable + body: "Local variable `x` is assigned to but never used" + suggestion: "Remove assignment to unused variable `x`" + fixable: true + location: + row: 16 + column: 5 + end_location: + row: 16 + column: 6 + fix: ~ + parent: ~ +- kind: + name: UnusedVariable + body: "Local variable `y` is assigned to but never used" + suggestion: "Remove assignment to unused variable `y`" + fixable: true + location: + row: 16 + column: 8 + end_location: + row: 16 + column: 9 + fix: ~ + parent: ~ - kind: name: UnusedVariable body: "Local variable `coords` is assigned to but never used" @@ -68,6 +94,32 @@ expression: diagnostics row: 20 column: 13 parent: ~ +- kind: + name: UnusedVariable + body: "Local variable `x` is assigned to but never used" + suggestion: "Remove assignment to unused variable `x`" + fixable: true + location: + row: 20 + column: 5 + end_location: + row: 20 + column: 6 + fix: ~ + parent: ~ +- kind: + name: UnusedVariable + body: "Local variable `y` is assigned to but never used" + suggestion: "Remove assignment to unused variable `y`" + fixable: true + location: + row: 20 + column: 8 + end_location: + row: 20 + column: 9 + fix: ~ + parent: ~ - kind: name: UnusedVariable body: "Local variable `a` is assigned to but never used" diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F841_F841_3.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F841_F841_3.py.snap index ef855b950c52d0..e3a2ba09eb4601 100644 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F841_F841_3.py.snap +++ b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F841_F841_3.py.snap @@ -162,6 +162,84 @@ expression: diagnostics row: 27 column: 47 parent: ~ +- kind: + name: UnusedVariable + body: "Local variable `x1` is assigned to but never used" + suggestion: "Remove assignment to unused variable `x1`" + fixable: true + location: + row: 28 + column: 5 + end_location: + row: 28 + column: 7 + fix: ~ + parent: ~ +- kind: + name: UnusedVariable + body: "Local variable `y1` is assigned to but never used" + suggestion: "Remove assignment to unused variable `y1`" + fixable: true + location: + row: 28 + column: 9 + end_location: + row: 28 + column: 11 + fix: ~ + parent: ~ +- kind: + name: UnusedVariable + body: "Local variable `x2` is assigned to but never used" + suggestion: "Remove assignment to unused variable `x2`" + fixable: true + location: + row: 29 + column: 5 + end_location: + row: 29 + column: 7 + fix: ~ + parent: ~ +- kind: + name: UnusedVariable + body: "Local variable `y2` is assigned to but never used" + suggestion: "Remove assignment to unused variable `y2`" + fixable: true + location: + row: 29 + column: 9 + end_location: + row: 29 + column: 11 + fix: ~ + parent: ~ +- kind: + name: UnusedVariable + body: "Local variable `x3` is assigned to but never used" + suggestion: "Remove assignment to unused variable `x3`" + fixable: true + location: + row: 30 + column: 5 + end_location: + row: 30 + column: 7 + fix: ~ + parent: ~ +- kind: + name: UnusedVariable + body: "Local variable `y3` is assigned to but never used" + suggestion: "Remove assignment to unused variable `y3`" + fixable: true + location: + row: 30 + column: 9 + end_location: + row: 30 + column: 11 + fix: ~ + parent: ~ - kind: name: UnusedVariable body: "Local variable `x1` is assigned to but never used" diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__f841_dummy_variable_rgx.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__f841_dummy_variable_rgx.snap index 51757829ed1182..d0b68ec11ec7da 100644 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__f841_dummy_variable_rgx.snap +++ b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__f841_dummy_variable_rgx.snap @@ -42,6 +42,32 @@ expression: diagnostics row: 21 column: 0 parent: ~ +- kind: + name: UnusedVariable + body: "Local variable `a` is assigned to but never used" + suggestion: "Remove assignment to unused variable `a`" + fixable: true + location: + row: 20 + column: 5 + end_location: + row: 20 + column: 6 + fix: ~ + parent: ~ +- kind: + name: UnusedVariable + body: "Local variable `b` is assigned to but never used" + suggestion: "Remove assignment to unused variable `b`" + fixable: true + location: + row: 20 + column: 8 + end_location: + row: 20 + column: 9 + fix: ~ + parent: ~ - kind: name: UnusedVariable body: "Local variable `a` is assigned to but never used" @@ -248,6 +274,19 @@ expression: diagnostics row: 115 column: 10 parent: ~ +- kind: + name: UnusedVariable + body: "Local variable `y` is assigned to but never used" + suggestion: "Remove assignment to unused variable `y`" + fixable: true + location: + row: 118 + column: 13 + end_location: + row: 118 + column: 14 + fix: ~ + parent: ~ - kind: name: UnusedVariable body: "Local variable `y` is assigned to but never used" diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__future_annotations.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__future_annotations.snap index 2702ad271096b5..66eee76ed57ad2 100644 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__future_annotations.snap +++ b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__future_annotations.snap @@ -24,6 +24,19 @@ expression: diagnostics parent: row: 6 column: 0 +- kind: + name: UndefinedName + body: "Undefined name `Bar`" + suggestion: ~ + fixable: false + location: + row: 25 + column: 18 + end_location: + row: 25 + column: 21 + fix: ~ + parent: ~ - kind: name: UndefinedName body: "Undefined name `Bar`" diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP007.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP007.py.snap index 5c9997de7c865a..82c190d357a735 100644 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP007.py.snap +++ b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP007.py.snap @@ -62,6 +62,26 @@ expression: diagnostics row: 14 column: 45 parent: ~ +- kind: + name: TypingUnion + body: "Use `X | Y` for type annotations" + suggestion: "Convert to `X | Y`" + fixable: true + location: + row: 14 + column: 21 + end_location: + row: 14 + column: 40 + fix: + content: float | bytes + location: + row: 14 + column: 21 + end_location: + row: 14 + column: 40 + parent: ~ - kind: name: TypingUnion body: "Use `X | Y` for type annotations" diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP031_0.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP031_0.py.snap index 5fc3d25dc6eb58..a6c4891fb90121 100644 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP031_0.py.snap +++ b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP031_0.py.snap @@ -122,6 +122,26 @@ expression: diagnostics row: 12 column: 32 parent: ~ +- kind: + name: PrintfStringFormatting + body: Use format specifiers instead of percent format + suggestion: Replace with format specifiers + fixable: true + location: + row: 12 + column: 18 + end_location: + row: 12 + column: 36 + fix: + content: "\"{}\".format(\"nested\")" + location: + row: 12 + column: 18 + end_location: + row: 12 + column: 36 + parent: ~ - kind: name: PrintfStringFormatting body: Use format specifiers instead of percent format diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP034.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP034.py.snap index 11131316f68d9b..8a700ea1e494f7 100644 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP034.py.snap +++ b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP034.py.snap @@ -62,6 +62,26 @@ expression: diagnostics row: 8 column: 15 parent: ~ +- kind: + name: ExtraneousParentheses + body: Avoid extraneous parentheses + suggestion: Remove extraneous parentheses + fixable: true + location: + row: 8 + column: 6 + end_location: + row: 8 + column: 13 + fix: + content: "\"foo\"" + location: + row: 8 + column: 6 + end_location: + row: 8 + column: 13 + parent: ~ - kind: name: ExtraneousParentheses body: Avoid extraneous parentheses @@ -82,6 +102,46 @@ expression: diagnostics row: 11 column: 13 parent: ~ +- kind: + name: ExtraneousParentheses + body: Avoid extraneous parentheses + suggestion: Remove extraneous parentheses + fixable: true + location: + row: 11 + column: 6 + end_location: + row: 11 + column: 11 + fix: + content: (1) + location: + row: 11 + column: 6 + end_location: + row: 11 + column: 11 + parent: ~ +- kind: + name: ExtraneousParentheses + body: Avoid extraneous parentheses + suggestion: Remove extraneous parentheses + fixable: true + location: + row: 11 + column: 6 + end_location: + row: 11 + column: 9 + fix: + content: "1" + location: + row: 11 + column: 6 + end_location: + row: 11 + column: 9 + parent: ~ - kind: name: ExtraneousParentheses body: Avoid extraneous parentheses diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP035.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP035.py.snap index 441079428fa403..fb96ba7212b387 100644 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP035.py.snap +++ b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP035.py.snap @@ -394,4 +394,220 @@ expression: diagnostics column: 21 fix: ~ parent: ~ +- kind: + name: DeprecatedImport + body: "Import from `collections` instead: `OrderedDict`" + suggestion: "Import from `collections`" + fixable: true + location: + row: 50 + column: 0 + end_location: + row: 50 + column: 81 + fix: + content: "from typing import Match, Pattern, List, AbstractSet, ContextManager\nfrom collections import OrderedDict" + location: + row: 50 + column: 0 + end_location: + row: 50 + column: 81 + parent: ~ +- kind: + name: DeprecatedImport + body: "Import from `re` instead: `Match`, `Pattern`" + suggestion: "Import from `re`" + fixable: true + location: + row: 50 + column: 0 + end_location: + row: 50 + column: 81 + fix: + content: "from typing import List, OrderedDict, AbstractSet, ContextManager\nfrom re import Match, Pattern" + location: + row: 50 + column: 0 + end_location: + row: 50 + column: 81 + parent: ~ +- kind: + name: DeprecatedImport + body: "`typing.List` is deprecated, use `list` instead" + suggestion: ~ + fixable: false + location: + row: 50 + column: 0 + end_location: + row: 50 + column: 81 + fix: ~ + parent: ~ +- kind: + name: DeprecatedImport + body: "`typing.AbstractSet` is deprecated, use `collections.abc.Set` instead" + suggestion: ~ + fixable: false + location: + row: 50 + column: 0 + end_location: + row: 50 + column: 81 + fix: ~ + parent: ~ +- kind: + name: DeprecatedImport + body: "`typing.ContextManager` is deprecated, use `contextlib.AbstractContextManager` instead" + suggestion: ~ + fixable: false + location: + row: 50 + column: 0 + end_location: + row: 50 + column: 81 + fix: ~ + parent: ~ +- kind: + name: DeprecatedImport + body: "Import from `re` instead: `Match`, `Pattern`" + suggestion: "Import from `re`" + fixable: true + location: + row: 50 + column: 0 + end_location: + row: 50 + column: 68 + fix: + content: "from typing import List, AbstractSet, ContextManager\nfrom re import Match, Pattern" + location: + row: 50 + column: 0 + end_location: + row: 50 + column: 68 + parent: ~ +- kind: + name: DeprecatedImport + body: "`typing.List` is deprecated, use `list` instead" + suggestion: ~ + fixable: false + location: + row: 50 + column: 0 + end_location: + row: 50 + column: 68 + fix: ~ + parent: ~ +- kind: + name: DeprecatedImport + body: "`typing.AbstractSet` is deprecated, use `collections.abc.Set` instead" + suggestion: ~ + fixable: false + location: + row: 50 + column: 0 + end_location: + row: 50 + column: 68 + fix: ~ + parent: ~ +- kind: + name: DeprecatedImport + body: "`typing.ContextManager` is deprecated, use `contextlib.AbstractContextManager` instead" + suggestion: ~ + fixable: false + location: + row: 50 + column: 0 + end_location: + row: 50 + column: 68 + fix: ~ + parent: ~ +- kind: + name: DeprecatedImport + body: "`typing.List` is deprecated, use `list` instead" + suggestion: ~ + fixable: false + location: + row: 50 + column: 0 + end_location: + row: 50 + column: 52 + fix: ~ + parent: ~ +- kind: + name: DeprecatedImport + body: "`typing.AbstractSet` is deprecated, use `collections.abc.Set` instead" + suggestion: ~ + fixable: false + location: + row: 50 + column: 0 + end_location: + row: 50 + column: 52 + fix: ~ + parent: ~ +- kind: + name: DeprecatedImport + body: "`typing.ContextManager` is deprecated, use `contextlib.AbstractContextManager` instead" + suggestion: ~ + fixable: false + location: + row: 50 + column: 0 + end_location: + row: 50 + column: 52 + fix: ~ + parent: ~ +- kind: + name: DeprecatedImport + body: "Import from `collections.abc` instead: `Mapping`" + suggestion: ~ + fixable: false + location: + row: 53 + column: 9 + end_location: + row: 54 + column: 21 + fix: ~ + parent: ~ +- kind: + name: DeprecatedImport + body: "Import from `collections.abc` instead: `Mapping`" + suggestion: ~ + fixable: false + location: + row: 54 + column: 9 + end_location: + row: 55 + column: 21 + fix: ~ + parent: ~ +- kind: + name: DeprecatedImport + body: "Import from `collections.abc` instead: `Mapping`" + suggestion: ~ + fixable: false + location: + row: 55 + column: 9 + end_location: + row: 56 + column: 21 + fix: ~ + parent: ~ diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF005_RUF005.py.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF005_RUF005.py.snap index ebc36dfecbcbe5..286f23045b0cbb 100644 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF005_RUF005.py.snap +++ b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF005_RUF005.py.snap @@ -162,6 +162,26 @@ expression: diagnostics row: 20 column: 30 parent: ~ +- kind: + name: UnpackInsteadOfConcatenatingToCollectionLiteral + body: "Consider `[\"a\", \"b\", \"c\", *eggs, *list((\"yes\", \"no\", \"pants\", *zoob))]` instead of concatenation" + suggestion: "Replace with `[\"a\", \"b\", \"c\", *eggs, *list((\"yes\", \"no\", \"pants\", *zoob))]`" + fixable: true + location: + row: 20 + column: 8 + end_location: + row: 20 + column: 68 + fix: + content: "[\"a\", \"b\", \"c\", *eggs, *list((\"yes\", \"no\", \"pants\", *zoob))]" + location: + row: 20 + column: 8 + end_location: + row: 20 + column: 68 + parent: ~ - kind: name: UnpackInsteadOfConcatenatingToCollectionLiteral body: "Consider `(\"yes\", \"no\", \"pants\", *zoob)` instead of concatenation" diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__ruf100_0.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__ruf100_0.snap index cd7486d195d8bc..a52e1d6cf8ad32 100644 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__ruf100_0.snap +++ b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__ruf100_0.snap @@ -22,6 +22,26 @@ expression: diagnostics row: 9 column: 17 parent: ~ +- kind: + name: UnusedVariable + body: "Local variable `d` is assigned to but never used" + suggestion: "Remove assignment to unused variable `d`" + fixable: true + location: + row: 13 + column: 4 + end_location: + row: 13 + column: 5 + fix: + content: "" + location: + row: 13 + column: 0 + end_location: + row: 14 + column: 0 + parent: ~ - kind: name: UnusedNOQA body: "Unused `noqa` directive (unused: `E501`)" @@ -42,6 +62,26 @@ expression: diagnostics row: 13 column: 23 parent: ~ +- kind: + name: UnusedVariable + body: "Local variable `d` is assigned to but never used" + suggestion: "Remove assignment to unused variable `d`" + fixable: true + location: + row: 16 + column: 4 + end_location: + row: 16 + column: 5 + fix: + content: "" + location: + row: 16 + column: 0 + end_location: + row: 17 + column: 0 + parent: ~ - kind: name: UnusedNOQA body: "Unused `noqa` directive (unused: `F841`, `E501`)" @@ -62,6 +102,26 @@ expression: diagnostics row: 16 column: 29 parent: ~ +- kind: + name: UnusedVariable + body: "Local variable `d` is assigned to but never used" + suggestion: "Remove assignment to unused variable `d`" + fixable: true + location: + row: 19 + column: 4 + end_location: + row: 19 + column: 5 + fix: + content: "" + location: + row: 19 + column: 0 + end_location: + row: 20 + column: 0 + parent: ~ - kind: name: UnusedNOQA body: "Unused `noqa` directive (unused: `F841`, `W191`; non-enabled: `F821`)" @@ -82,6 +142,26 @@ expression: diagnostics row: 19 column: 35 parent: ~ +- kind: + name: UnusedVariable + body: "Local variable `d` is assigned to but never used" + suggestion: "Remove assignment to unused variable `d`" + fixable: true + location: + row: 22 + column: 4 + end_location: + row: 22 + column: 5 + fix: + content: "" + location: + row: 22 + column: 0 + end_location: + row: 23 + column: 0 + parent: ~ - kind: name: UnusedNOQA body: "Unused `noqa` directive (unused: `F841`; unknown: `V101`)" @@ -102,6 +182,26 @@ expression: diagnostics row: 22 column: 29 parent: ~ +- kind: + name: UnusedVariable + body: "Local variable `d` is assigned to but never used" + suggestion: "Remove assignment to unused variable `d`" + fixable: true + location: + row: 26 + column: 4 + end_location: + row: 26 + column: 5 + fix: + content: "" + location: + row: 26 + column: 0 + end_location: + row: 27 + column: 0 + parent: ~ - kind: name: UnusedNOQA body: "Unused `noqa` directive (unused: `E501`)" @@ -222,6 +322,32 @@ expression: diagnostics row: 71 column: 11 parent: ~ +- kind: + name: LineTooLong + body: Line too long (89 > 88 characters) + suggestion: ~ + fixable: false + location: + row: 83 + column: 88 + end_location: + row: 83 + column: 89 + fix: ~ + parent: ~ +- kind: + name: LineTooLong + body: Line too long (89 > 88 characters) + suggestion: ~ + fixable: false + location: + row: 84 + column: 88 + end_location: + row: 84 + column: 89 + fix: ~ + parent: ~ - kind: name: UnusedImport body: "`shelve` imported but unused" @@ -242,6 +368,58 @@ expression: diagnostics row: 86 column: 0 parent: ~ +- kind: + name: LineTooLong + body: Line too long (89 > 88 characters) + suggestion: ~ + fixable: false + location: + row: 85 + column: 88 + end_location: + row: 85 + column: 89 + fix: ~ + parent: ~ +- kind: + name: LineTooLong + body: Line too long (89 > 88 characters) + suggestion: ~ + fixable: false + location: + row: 86 + column: 88 + end_location: + row: 86 + column: 89 + fix: ~ + parent: ~ +- kind: + name: LineTooLong + body: Line too long (89 > 88 characters) + suggestion: ~ + fixable: false + location: + row: 87 + column: 88 + end_location: + row: 87 + column: 89 + fix: ~ + parent: ~ +- kind: + name: LineTooLong + body: Line too long (89 > 88 characters) + suggestion: ~ + fixable: false + location: + row: 88 + column: 88 + end_location: + row: 88 + column: 89 + fix: ~ + parent: ~ - kind: name: LineTooLong body: Line too long (103 > 88 characters) diff --git a/crates/ruff/src/test.rs b/crates/ruff/src/test.rs index b6758e9d5c79d4..c5c97d0ba7ff78 100644 --- a/crates/ruff/src/test.rs +++ b/crates/ruff/src/test.rs @@ -23,6 +23,9 @@ pub fn test_resource_path(path: impl AsRef) -> std::path::PathBuf { /// asserts that autofixes converge after 10 iterations. pub fn test_path(path: impl AsRef, settings: &Settings) -> Result> { let path = test_resource_path("fixtures").join(path); + let package = path + .parent() + .and_then(|parent| detect_package_root(parent, &settings.namespace_packages)); let contents = std::fs::read_to_string(&path)?; let tokens: Vec = ruff_rustpython::tokenize(&contents); let locator = Locator::new(&contents); @@ -31,12 +34,10 @@ pub fn test_path(path: impl AsRef, settings: &Settings) -> Result, settings: &Settings) -> Result, settings: &Settings) -> Result = ruff_rustpython::tokenize(&contents); let locator = Locator::new(&contents); @@ -69,7 +72,7 @@ pub fn test_path(path: impl AsRef, settings: &Settings) -> Result, settings: &Settings) -> Result, settings: &Settings) -> Result