diff --git a/crates/ruff/src/lib.rs b/crates/ruff/src/lib.rs index 8ba057cefc2bd..c8a056a6dc7ea 100644 --- a/crates/ruff/src/lib.rs +++ b/crates/ruff/src/lib.rs @@ -287,6 +287,9 @@ pub fn check(args: CheckCommand, global_options: GlobalConfigArgs) -> Result Result<()> { | = help: Remove unused import: `os` + 1 |-import os + Found 1 error. [*] 1 fixable with the `--fix` option. @@ -1523,7 +1551,10 @@ fn check_hints_hidden_unsafe_fixes() { exit_code: 1 ----- stdout ----- -:1:1: RUF901 [*] Hey this is a stable test rule with a safe fix. + 1 |+# fix from stable-test-rule-safe-fix + -:1:1: RUF902 Hey this is a stable test rule with an unsafe fix. + Found 2 errors. [*] 1 fixable with the `--fix` option (1 hidden fix can be enabled with the `--unsafe-fixes` option). @@ -1541,6 +1572,7 @@ fn check_hints_hidden_unsafe_fixes_with_no_safe_fixes() { exit_code: 1 ----- stdout ----- -:1:1: RUF902 Hey this is a stable test rule with an unsafe fix. + Found 1 error. No fixes available (1 hidden fix can be enabled with the `--unsafe-fixes` option). @@ -1559,7 +1591,10 @@ fn check_no_hint_for_hidden_unsafe_fixes_when_disabled() { exit_code: 1 ----- stdout ----- -:1:1: RUF901 [*] Hey this is a stable test rule with a safe fix. + 1 |+# fix from stable-test-rule-safe-fix + -:1:1: RUF902 Hey this is a stable test rule with an unsafe fix. + Found 2 errors. [*] 1 fixable with the --fix option. @@ -1579,6 +1614,7 @@ fn check_no_hint_for_hidden_unsafe_fixes_with_no_safe_fixes_when_disabled() { exit_code: 1 ----- stdout ----- -:1:1: RUF902 Hey this is a stable test rule with an unsafe fix. + Found 1 error. ----- stderr ----- @@ -1596,7 +1632,10 @@ fn check_shows_unsafe_fixes_with_opt_in() { exit_code: 1 ----- stdout ----- -:1:1: RUF901 [*] Hey this is a stable test rule with a safe fix. + 1 |+# fix from stable-test-rule-safe-fix + -:1:1: RUF902 [*] Hey this is a stable test rule with an unsafe fix. + Found 2 errors. [*] 2 fixable with the --fix option. @@ -1618,6 +1657,7 @@ fn fix_applies_safe_fixes_by_default() { ----- stderr ----- -:1:1: RUF902 Hey this is a stable test rule with an unsafe fix. + Found 2 errors (1 fixed, 1 remaining). No fixes available (1 hidden fix can be enabled with the `--unsafe-fixes` option). "###); @@ -1655,6 +1695,7 @@ fn fix_does_not_apply_display_only_fixes() { def add_to_list(item, some_list=[]): ... ----- stderr ----- -:1:1: RUF903 Hey this is a stable test rule with a display only fix. + Found 1 error. "###); } @@ -1673,6 +1714,7 @@ fn fix_does_not_apply_display_only_fixes_with_unsafe_fixes_enabled() { def add_to_list(item, some_list=[]): ... ----- stderr ----- -:1:1: RUF903 Hey this is a stable test rule with a display only fix. + Found 1 error. "###); } @@ -1690,6 +1732,7 @@ fn fix_only_unsafe_fixes_available() { ----- stderr ----- -:1:1: RUF902 Hey this is a stable test rule with an unsafe fix. + Found 1 error. No fixes available (1 hidden fix can be enabled with the `--unsafe-fixes` option). "###); @@ -1826,7 +1869,9 @@ extend-unsafe-fixes = ["RUF901"] exit_code: 1 ----- stdout ----- -:1:1: RUF901 Hey this is a stable test rule with a safe fix. + -:1:1: RUF902 Hey this is a stable test rule with an unsafe fix. + Found 2 errors. No fixes available (2 hidden fixes can be enabled with the `--unsafe-fixes` option). @@ -1858,7 +1903,11 @@ extend-safe-fixes = ["RUF902"] exit_code: 1 ----- stdout ----- -:1:1: RUF901 [*] Hey this is a stable test rule with a safe fix. + 1 |+# fix from stable-test-rule-safe-fix + -:1:1: RUF902 [*] Hey this is a stable test rule with an unsafe fix. + 1 |+# fix from stable-test-rule-unsafe-fix + Found 2 errors. [*] 2 fixable with the `--fix` option. @@ -1892,7 +1941,10 @@ extend-safe-fixes = ["RUF902"] exit_code: 1 ----- stdout ----- -:1:1: RUF901 [*] Hey this is a stable test rule with a safe fix. + 1 |+# fix from stable-test-rule-safe-fix + -:1:1: RUF902 Hey this is a stable test rule with an unsafe fix. + Found 2 errors. [*] 1 fixable with the `--fix` option (1 hidden fix can be enabled with the `--unsafe-fixes` option). @@ -1929,8 +1981,15 @@ extend-safe-fixes = ["RUF9"] ----- stdout ----- -:1:1: RUF900 Hey this is a stable test rule. -:1:1: RUF901 Hey this is a stable test rule with a safe fix. + -:1:1: RUF902 [*] Hey this is a stable test rule with an unsafe fix. + 1 |+# fix from stable-test-rule-unsafe-fix + 1 2 | x = {'a': 1, 'a': 1} + 2 3 | print(('foo')) + 3 4 | print(str('foo')) + -:1:1: RUF903 Hey this is a stable test rule with a display only fix. + -:1:1: RUF920 Hey this is a deprecated test rule. -:1:1: RUF921 Hey this is another deprecated test rule. -:1:1: RUF950 Hey this is a test rule that was redirected from another. @@ -2039,6 +2098,7 @@ select = ["RUF017"] | = help: Replace with `functools.reduce` + Found 1 error. No fixes available (1 hidden fix can be enabled with the `--unsafe-fixes` option). diff --git a/crates/ruff_linter/src/message/diff.rs b/crates/ruff_linter/src/message/diff.rs index e3b3d99290c82..4eefc37baf74b 100644 --- a/crates/ruff_linter/src/message/diff.rs +++ b/crates/ruff_linter/src/message/diff.rs @@ -36,6 +36,16 @@ impl<'a> Diff<'a> { impl Display for Diff<'_> { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + // TODO: Instead of hard-coding this in, the `TextEmitter` should be + // handling it. See https://github.com/astral-sh/ruff/issues/12597 for + // further discussion. + if matches!( + self.fix.applicability(), + Applicability::Unsafe | Applicability::DisplayOnly + ) { + return Ok(()); + } + // TODO(dhruvmanila): Add support for Notebook cells once it's user-facing let mut output = String::with_capacity(self.source_code.source_text().len()); let mut last_end = TextSize::default(); @@ -53,14 +63,6 @@ impl Display for Diff<'_> { let diff = TextDiff::from_lines(self.source_code.source_text(), &output); - let message = match self.fix.applicability() { - // TODO(zanieb): Adjust this messaging once it's user-facing - Applicability::Safe => "Safe fix", - Applicability::Unsafe => "Unsafe fix", - Applicability::DisplayOnly => "Display-only fix", - }; - writeln!(f, "ℹ {}", message.blue())?; - let (largest_old, largest_new) = diff .ops() .last() diff --git a/crates/ruff_linter/src/rules/eradicate/snapshots/ruff_linter__rules__eradicate__tests__ERA001_ERA001.py.snap b/crates/ruff_linter/src/rules/eradicate/snapshots/ruff_linter__rules__eradicate__tests__ERA001_ERA001.py.snap index 7dc46d961fda6..b239a923143df 100644 --- a/crates/ruff_linter/src/rules/eradicate/snapshots/ruff_linter__rules__eradicate__tests__ERA001_ERA001.py.snap +++ b/crates/ruff_linter/src/rules/eradicate/snapshots/ruff_linter__rules__eradicate__tests__ERA001_ERA001.py.snap @@ -10,11 +10,6 @@ ERA001.py:1:1: ERA001 Found commented-out code | = help: Remove commented-out code -ℹ Display-only fix -1 |-#import os -2 1 | # from foo import junk -3 2 | #a = 3 -4 3 | a = 4 ERA001.py:2:1: ERA001 Found commented-out code | @@ -26,12 +21,6 @@ ERA001.py:2:1: ERA001 Found commented-out code | = help: Remove commented-out code -ℹ Display-only fix -1 1 | #import os -2 |-# from foo import junk -3 2 | #a = 3 -4 3 | a = 4 -5 4 | #foo(1, 2, 3) ERA001.py:3:1: ERA001 Found commented-out code | @@ -44,13 +33,6 @@ ERA001.py:3:1: ERA001 Found commented-out code | = help: Remove commented-out code -ℹ Display-only fix -1 1 | #import os -2 2 | # from foo import junk -3 |-#a = 3 -4 3 | a = 4 -5 4 | #foo(1, 2, 3) -6 5 | ERA001.py:5:1: ERA001 Found commented-out code | @@ -63,14 +45,6 @@ ERA001.py:5:1: ERA001 Found commented-out code | = help: Remove commented-out code -ℹ Display-only fix -2 2 | # from foo import junk -3 3 | #a = 3 -4 4 | a = 4 -5 |-#foo(1, 2, 3) -6 5 | -7 6 | def foo(x, y, z): -8 7 | content = 1 # print('hello') ERA001.py:13:5: ERA001 Found commented-out code | @@ -82,14 +56,6 @@ ERA001.py:13:5: ERA001 Found commented-out code | = help: Remove commented-out code -ℹ Display-only fix -10 10 | -11 11 | # This is a real comment. -12 12 | # # This is a (nested) comment. -13 |- #return True -14 13 | return False -15 14 | -16 15 | #import os # noqa: ERA001 ERA001.py:21:5: ERA001 Found commented-out code | @@ -100,14 +66,6 @@ ERA001.py:21:5: ERA001 Found commented-out code | = help: Remove commented-out code -ℹ Display-only fix -18 18 | -19 19 | class A(): -20 20 | pass -21 |- # b = c -22 21 | -23 22 | -24 23 | dictionary = { ERA001.py:26:5: ERA001 Found commented-out code | @@ -120,14 +78,6 @@ ERA001.py:26:5: ERA001 Found commented-out code | = help: Remove commented-out code -ℹ Display-only fix -23 23 | -24 24 | dictionary = { -25 25 | # "key1": 123, # noqa: ERA001 -26 |- # "key2": 456, -27 26 | # "key3": 789, # test -28 27 | } -29 28 | ERA001.py:27:5: ERA001 Found commented-out code | @@ -139,14 +89,6 @@ ERA001.py:27:5: ERA001 Found commented-out code | = help: Remove commented-out code -ℹ Display-only fix -24 24 | dictionary = { -25 25 | # "key1": 123, # noqa: ERA001 -26 26 | # "key2": 456, -27 |- # "key3": 789, # test -28 27 | } -29 28 | -30 29 | #import os # noqa ERA001.py:32:1: ERA001 Found commented-out code | @@ -159,14 +101,6 @@ ERA001.py:32:1: ERA001 Found commented-out code | = help: Remove commented-out code -ℹ Display-only fix -29 29 | -30 30 | #import os # noqa -31 31 | -32 |-# case 1: -33 32 | # try: -34 33 | # try: # with comment -35 34 | # try: print() ERA001.py:33:1: ERA001 Found commented-out code | @@ -178,14 +112,6 @@ ERA001.py:33:1: ERA001 Found commented-out code | = help: Remove commented-out code -ℹ Display-only fix -30 30 | #import os # noqa -31 31 | -32 32 | # case 1: -33 |-# try: -34 33 | # try: # with comment -35 34 | # try: print() -36 35 | # except: ERA001.py:34:1: ERA001 Found commented-out code | @@ -198,14 +124,6 @@ ERA001.py:34:1: ERA001 Found commented-out code | = help: Remove commented-out code -ℹ Display-only fix -31 31 | -32 32 | # case 1: -33 33 | # try: -34 |-# try: # with comment -35 34 | # try: print() -36 35 | # except: -37 36 | # except Foo: ERA001.py:35:1: ERA001 Found commented-out code | @@ -218,14 +136,6 @@ ERA001.py:35:1: ERA001 Found commented-out code | = help: Remove commented-out code -ℹ Display-only fix -32 32 | # case 1: -33 33 | # try: -34 34 | # try: # with comment -35 |-# try: print() -36 35 | # except: -37 36 | # except Foo: -38 37 | # except Exception as e: print(e) ERA001.py:36:1: ERA001 Found commented-out code | @@ -238,14 +148,6 @@ ERA001.py:36:1: ERA001 Found commented-out code | = help: Remove commented-out code -ℹ Display-only fix -33 33 | # try: -34 34 | # try: # with comment -35 35 | # try: print() -36 |-# except: -37 36 | # except Foo: -38 37 | # except Exception as e: print(e) -39 38 | ERA001.py:37:1: ERA001 Found commented-out code | @@ -257,14 +159,6 @@ ERA001.py:37:1: ERA001 Found commented-out code | = help: Remove commented-out code -ℹ Display-only fix -34 34 | # try: # with comment -35 35 | # try: print() -36 36 | # except: -37 |-# except Foo: -38 37 | # except Exception as e: print(e) -39 38 | -40 39 | ERA001.py:38:1: ERA001 Found commented-out code | @@ -275,14 +169,6 @@ ERA001.py:38:1: ERA001 Found commented-out code | = help: Remove commented-out code -ℹ Display-only fix -35 35 | # try: print() -36 36 | # except: -37 37 | # except Foo: -38 |-# except Exception as e: print(e) -39 38 | -40 39 | -41 40 | # Script tag without an opening tag (Error) ERA001.py:44:1: ERA001 Found commented-out code | @@ -294,14 +180,6 @@ ERA001.py:44:1: ERA001 Found commented-out code | = help: Remove commented-out code -ℹ Display-only fix -41 41 | # Script tag without an opening tag (Error) -42 42 | -43 43 | # requires-python = ">=3.11" -44 |-# dependencies = [ -45 44 | # "requests<3", -46 45 | # "rich", -47 46 | # ] ERA001.py:47:1: ERA001 Found commented-out code | @@ -312,12 +190,3 @@ ERA001.py:47:1: ERA001 Found commented-out code 48 | # /// | = help: Remove commented-out code - -ℹ Display-only fix -44 44 | # dependencies = [ -45 45 | # "requests<3", -46 46 | # "rich", -47 |-# ] -48 47 | # /// -49 48 | -50 49 | # Script tag (OK) diff --git a/crates/ruff_linter/src/rules/fastapi/snapshots/ruff_linter__rules__fastapi__tests__fast-api-non-annotated-dependency_FAST002.py.snap b/crates/ruff_linter/src/rules/fastapi/snapshots/ruff_linter__rules__fastapi__tests__fast-api-non-annotated-dependency_FAST002.py.snap index 0651f5f7005c4..56f0b57549cb1 100644 --- a/crates/ruff_linter/src/rules/fastapi/snapshots/ruff_linter__rules__fastapi__tests__fast-api-non-annotated-dependency_FAST002.py.snap +++ b/crates/ruff_linter/src/rules/fastapi/snapshots/ruff_linter__rules__fastapi__tests__fast-api-non-annotated-dependency_FAST002.py.snap @@ -12,23 +12,6 @@ FAST002.py:24:5: FAST002 [*] FastAPI dependency without `Annotated` | = help: Replace with `Annotated` -ℹ Unsafe fix -12 12 | Security, -13 13 | ) -14 14 | from pydantic import BaseModel - 15 |+from typing import Annotated -15 16 | -16 17 | app = FastAPI() -17 18 | router = APIRouter() --------------------------------------------------------------------------------- -21 22 | -22 23 | @app.get("/items/") -23 24 | def get_items( -24 |- current_user: User = Depends(get_current_user), - 25 |+ current_user: Annotated[User, Depends(get_current_user)], -25 26 | some_security_param: str = Security(get_oauth2_user), -26 27 | ): -27 28 | pass FAST002.py:25:5: FAST002 [*] FastAPI dependency without `Annotated` | @@ -41,23 +24,6 @@ FAST002.py:25:5: FAST002 [*] FastAPI dependency without `Annotated` | = help: Replace with `Annotated` -ℹ Unsafe fix -12 12 | Security, -13 13 | ) -14 14 | from pydantic import BaseModel - 15 |+from typing import Annotated -15 16 | -16 17 | app = FastAPI() -17 18 | router = APIRouter() --------------------------------------------------------------------------------- -22 23 | @app.get("/items/") -23 24 | def get_items( -24 25 | current_user: User = Depends(get_current_user), -25 |- some_security_param: str = Security(get_oauth2_user), - 26 |+ some_security_param: Annotated[str, Security(get_oauth2_user)], -26 27 | ): -27 28 | pass -28 29 | FAST002.py:32:5: FAST002 [*] FastAPI dependency without `Annotated` | @@ -70,23 +36,6 @@ FAST002.py:32:5: FAST002 [*] FastAPI dependency without `Annotated` | = help: Replace with `Annotated` -ℹ Unsafe fix -12 12 | Security, -13 13 | ) -14 14 | from pydantic import BaseModel - 15 |+from typing import Annotated -15 16 | -16 17 | app = FastAPI() -17 18 | router = APIRouter() --------------------------------------------------------------------------------- -29 30 | -30 31 | @app.post("/stuff/") -31 32 | def do_stuff( -32 |- some_query_param: str | None = Query(default=None), - 33 |+ some_query_param: Annotated[str | None, Query(default=None)], -33 34 | some_path_param: str = Path(), -34 35 | some_body_param: str = Body("foo"), -35 36 | some_cookie_param: str = Cookie(), FAST002.py:33:5: FAST002 [*] FastAPI dependency without `Annotated` | @@ -99,23 +48,6 @@ FAST002.py:33:5: FAST002 [*] FastAPI dependency without `Annotated` | = help: Replace with `Annotated` -ℹ Unsafe fix -12 12 | Security, -13 13 | ) -14 14 | from pydantic import BaseModel - 15 |+from typing import Annotated -15 16 | -16 17 | app = FastAPI() -17 18 | router = APIRouter() --------------------------------------------------------------------------------- -30 31 | @app.post("/stuff/") -31 32 | def do_stuff( -32 33 | some_query_param: str | None = Query(default=None), -33 |- some_path_param: str = Path(), - 34 |+ some_path_param: Annotated[str, Path()], -34 35 | some_body_param: str = Body("foo"), -35 36 | some_cookie_param: str = Cookie(), -36 37 | some_header_param: int = Header(default=5), FAST002.py:34:5: FAST002 [*] FastAPI dependency without `Annotated` | @@ -128,23 +60,6 @@ FAST002.py:34:5: FAST002 [*] FastAPI dependency without `Annotated` | = help: Replace with `Annotated` -ℹ Unsafe fix -12 12 | Security, -13 13 | ) -14 14 | from pydantic import BaseModel - 15 |+from typing import Annotated -15 16 | -16 17 | app = FastAPI() -17 18 | router = APIRouter() --------------------------------------------------------------------------------- -31 32 | def do_stuff( -32 33 | some_query_param: str | None = Query(default=None), -33 34 | some_path_param: str = Path(), -34 |- some_body_param: str = Body("foo"), - 35 |+ some_body_param: Annotated[str, Body("foo")], -35 36 | some_cookie_param: str = Cookie(), -36 37 | some_header_param: int = Header(default=5), -37 38 | some_file_param: UploadFile = File(), FAST002.py:35:5: FAST002 [*] FastAPI dependency without `Annotated` | @@ -157,23 +72,6 @@ FAST002.py:35:5: FAST002 [*] FastAPI dependency without `Annotated` | = help: Replace with `Annotated` -ℹ Unsafe fix -12 12 | Security, -13 13 | ) -14 14 | from pydantic import BaseModel - 15 |+from typing import Annotated -15 16 | -16 17 | app = FastAPI() -17 18 | router = APIRouter() --------------------------------------------------------------------------------- -32 33 | some_query_param: str | None = Query(default=None), -33 34 | some_path_param: str = Path(), -34 35 | some_body_param: str = Body("foo"), -35 |- some_cookie_param: str = Cookie(), - 36 |+ some_cookie_param: Annotated[str, Cookie()], -36 37 | some_header_param: int = Header(default=5), -37 38 | some_file_param: UploadFile = File(), -38 39 | some_form_param: str = Form(), FAST002.py:36:5: FAST002 [*] FastAPI dependency without `Annotated` | @@ -186,23 +84,6 @@ FAST002.py:36:5: FAST002 [*] FastAPI dependency without `Annotated` | = help: Replace with `Annotated` -ℹ Unsafe fix -12 12 | Security, -13 13 | ) -14 14 | from pydantic import BaseModel - 15 |+from typing import Annotated -15 16 | -16 17 | app = FastAPI() -17 18 | router = APIRouter() --------------------------------------------------------------------------------- -33 34 | some_path_param: str = Path(), -34 35 | some_body_param: str = Body("foo"), -35 36 | some_cookie_param: str = Cookie(), -36 |- some_header_param: int = Header(default=5), - 37 |+ some_header_param: Annotated[int, Header(default=5)], -37 38 | some_file_param: UploadFile = File(), -38 39 | some_form_param: str = Form(), -39 40 | ): FAST002.py:37:5: FAST002 [*] FastAPI dependency without `Annotated` | @@ -215,23 +96,6 @@ FAST002.py:37:5: FAST002 [*] FastAPI dependency without `Annotated` | = help: Replace with `Annotated` -ℹ Unsafe fix -12 12 | Security, -13 13 | ) -14 14 | from pydantic import BaseModel - 15 |+from typing import Annotated -15 16 | -16 17 | app = FastAPI() -17 18 | router = APIRouter() --------------------------------------------------------------------------------- -34 35 | some_body_param: str = Body("foo"), -35 36 | some_cookie_param: str = Cookie(), -36 37 | some_header_param: int = Header(default=5), -37 |- some_file_param: UploadFile = File(), - 38 |+ some_file_param: Annotated[UploadFile, File()], -38 39 | some_form_param: str = Form(), -39 40 | ): -40 41 | # do stuff FAST002.py:38:5: FAST002 [*] FastAPI dependency without `Annotated` | @@ -243,21 +107,3 @@ FAST002.py:38:5: FAST002 [*] FastAPI dependency without `Annotated` 40 | # do stuff | = help: Replace with `Annotated` - -ℹ Unsafe fix -12 12 | Security, -13 13 | ) -14 14 | from pydantic import BaseModel - 15 |+from typing import Annotated -15 16 | -16 17 | app = FastAPI() -17 18 | router = APIRouter() --------------------------------------------------------------------------------- -35 36 | some_cookie_param: str = Cookie(), -36 37 | some_header_param: int = Header(default=5), -37 38 | some_file_param: UploadFile = File(), -38 |- some_form_param: str = Form(), - 39 |+ some_form_param: Annotated[str, Form()], -39 40 | ): -40 41 | # do stuff -41 42 | pass diff --git a/crates/ruff_linter/src/rules/fastapi/snapshots/ruff_linter__rules__fastapi__tests__fast-api-redundant-response-model_FAST001.py.snap b/crates/ruff_linter/src/rules/fastapi/snapshots/ruff_linter__rules__fastapi__tests__fast-api-redundant-response-model_FAST001.py.snap index 84b582e502da7..22fc250cde580 100644 --- a/crates/ruff_linter/src/rules/fastapi/snapshots/ruff_linter__rules__fastapi__tests__fast-api-redundant-response-model_FAST001.py.snap +++ b/crates/ruff_linter/src/rules/fastapi/snapshots/ruff_linter__rules__fastapi__tests__fast-api-redundant-response-model_FAST001.py.snap @@ -10,15 +10,6 @@ FAST001.py:17:22: FAST001 [*] FastAPI route with redundant `response_model` argu | = help: Remove argument -ℹ Unsafe fix -14 14 | # Errors -15 15 | -16 16 | -17 |-@app.post("/items/", response_model=Item) - 17 |+@app.post("/items/") -18 18 | async def create_item(item: Item) -> Item: -19 19 | return item -20 20 | FAST001.py:22:22: FAST001 [*] FastAPI route with redundant `response_model` argument | @@ -29,15 +20,6 @@ FAST001.py:22:22: FAST001 [*] FastAPI route with redundant `response_model` argu | = help: Remove argument -ℹ Unsafe fix -19 19 | return item -20 20 | -21 21 | -22 |-@app.post("/items/", response_model=list[Item]) - 22 |+@app.post("/items/") -23 23 | async def create_item(item: Item) -> list[Item]: -24 24 | return item -25 25 | FAST001.py:27:22: FAST001 [*] FastAPI route with redundant `response_model` argument | @@ -48,15 +30,6 @@ FAST001.py:27:22: FAST001 [*] FastAPI route with redundant `response_model` argu | = help: Remove argument -ℹ Unsafe fix -24 24 | return item -25 25 | -26 26 | -27 |-@app.post("/items/", response_model=List[Item]) - 27 |+@app.post("/items/") -28 28 | async def create_item(item: Item) -> List[Item]: -29 29 | return item -30 30 | FAST001.py:32:22: FAST001 [*] FastAPI route with redundant `response_model` argument | @@ -67,15 +40,6 @@ FAST001.py:32:22: FAST001 [*] FastAPI route with redundant `response_model` argu | = help: Remove argument -ℹ Unsafe fix -29 29 | return item -30 30 | -31 31 | -32 |-@app.post("/items/", response_model=Dict[str, Item]) - 32 |+@app.post("/items/") -33 33 | async def create_item(item: Item) -> Dict[str, Item]: -34 34 | return item -35 35 | FAST001.py:37:22: FAST001 [*] FastAPI route with redundant `response_model` argument | @@ -86,15 +50,6 @@ FAST001.py:37:22: FAST001 [*] FastAPI route with redundant `response_model` argu | = help: Remove argument -ℹ Unsafe fix -34 34 | return item -35 35 | -36 36 | -37 |-@app.post("/items/", response_model=str) - 37 |+@app.post("/items/") -38 38 | async def create_item(item: Item) -> str: -39 39 | return item -40 40 | FAST001.py:42:21: FAST001 [*] FastAPI route with redundant `response_model` argument | @@ -105,15 +60,6 @@ FAST001.py:42:21: FAST001 [*] FastAPI route with redundant `response_model` argu | = help: Remove argument -ℹ Unsafe fix -39 39 | return item -40 40 | -41 41 | -42 |-@app.get("/items/", response_model=Item) - 42 |+@app.get("/items/") -43 43 | async def create_item(item: Item) -> Item: -44 44 | return item -45 45 | FAST001.py:47:21: FAST001 [*] FastAPI route with redundant `response_model` argument | @@ -124,15 +70,6 @@ FAST001.py:47:21: FAST001 [*] FastAPI route with redundant `response_model` argu | = help: Remove argument -ℹ Unsafe fix -44 44 | return item -45 45 | -46 46 | -47 |-@app.get("/items/", response_model=Item) - 47 |+@app.get("/items/") -48 48 | @app.post("/items/", response_model=Item) -49 49 | async def create_item(item: Item) -> Item: -50 50 | return item FAST001.py:48:22: FAST001 [*] FastAPI route with redundant `response_model` argument | @@ -144,15 +81,6 @@ FAST001.py:48:22: FAST001 [*] FastAPI route with redundant `response_model` argu | = help: Remove argument -ℹ Unsafe fix -45 45 | -46 46 | -47 47 | @app.get("/items/", response_model=Item) -48 |-@app.post("/items/", response_model=Item) - 48 |+@app.post("/items/") -49 49 | async def create_item(item: Item) -> Item: -50 50 | return item -51 51 | FAST001.py:53:24: FAST001 [*] FastAPI route with redundant `response_model` argument | @@ -162,13 +90,3 @@ FAST001.py:53:24: FAST001 [*] FastAPI route with redundant `response_model` argu 55 | return item | = help: Remove argument - -ℹ Unsafe fix -50 50 | return item -51 51 | -52 52 | -53 |-@router.get("/items/", response_model=Item) - 53 |+@router.get("/items/") -54 54 | async def create_item(item: Item) -> Item: -55 55 | return item -56 56 | diff --git a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__auto_return_type.snap b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__auto_return_type.snap index c2be32c1fa995..18467e0cf9ebd 100644 --- a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__auto_return_type.snap +++ b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__auto_return_type.snap @@ -9,12 +9,6 @@ auto_return_type.py:1:5: ANN201 [*] Missing return type annotation for public fu | = help: Add return type annotation: `int` -ℹ Unsafe fix -1 |-def func(): - 1 |+def func() -> int: -2 2 | return 1 -3 3 | -4 4 | auto_return_type.py:5:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -24,15 +18,6 @@ auto_return_type.py:5:5: ANN201 [*] Missing return type annotation for public fu | = help: Add return type annotation: `float` -ℹ Unsafe fix -2 2 | return 1 -3 3 | -4 4 | -5 |-def func(): - 5 |+def func() -> float: -6 6 | return 1.5 -7 7 | -8 8 | auto_return_type.py:9:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -43,15 +28,6 @@ auto_return_type.py:9:5: ANN201 [*] Missing return type annotation for public fu | = help: Add return type annotation: `float` -ℹ Unsafe fix -6 6 | return 1.5 -7 7 | -8 8 | -9 |-def func(x: int): - 9 |+def func(x: int) -> float: -10 10 | if x > 0: -11 11 | return 1 -12 12 | else: auto_return_type.py:16:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -61,15 +37,6 @@ auto_return_type.py:16:5: ANN201 [*] Missing return type annotation for public f | = help: Add return type annotation: `bool` -ℹ Unsafe fix -13 13 | return 1.5 -14 14 | -15 15 | -16 |-def func(): - 16 |+def func() -> bool: -17 17 | return True -18 18 | -19 19 | auto_return_type.py:20:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -80,15 +47,6 @@ auto_return_type.py:20:5: ANN201 [*] Missing return type annotation for public f | = help: Add return type annotation: `None` -ℹ Unsafe fix -17 17 | return True -18 18 | -19 19 | -20 |-def func(x: int): - 20 |+def func(x: int) -> None: -21 21 | if x > 0: -22 22 | return None -23 23 | else: auto_return_type.py:27:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -98,15 +56,6 @@ auto_return_type.py:27:5: ANN201 [*] Missing return type annotation for public f | = help: Add return type annotation: `str | float` -ℹ Unsafe fix -24 24 | return -25 25 | -26 26 | -27 |-def func(x: int): - 27 |+def func(x: int) -> str | float: -28 28 | return 1 or 2.5 if x > 0 else 1.5 or "str" -29 29 | -30 30 | auto_return_type.py:31:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -116,15 +65,6 @@ auto_return_type.py:31:5: ANN201 [*] Missing return type annotation for public f | = help: Add return type annotation: `str | float` -ℹ Unsafe fix -28 28 | return 1 or 2.5 if x > 0 else 1.5 or "str" -29 29 | -30 30 | -31 |-def func(x: int): - 31 |+def func(x: int) -> str | float: -32 32 | return 1 + 2.5 if x > 0 else 1.5 or "str" -33 33 | -34 34 | auto_return_type.py:35:5: ANN201 Missing return type annotation for public function `func` | @@ -152,15 +92,6 @@ auto_return_type.py:45:5: ANN201 [*] Missing return type annotation for public f | = help: Add return type annotation: `int` -ℹ Unsafe fix -42 42 | return {"foo": 1} -43 43 | -44 44 | -45 |-def func(x: int): - 45 |+def func(x: int) -> int: -46 46 | if not x: -47 47 | return 1 -48 48 | else: auto_return_type.py:52:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -171,15 +102,6 @@ auto_return_type.py:52:5: ANN201 [*] Missing return type annotation for public f | = help: Add return type annotation: `int | None` -ℹ Unsafe fix -49 49 | return True -50 50 | -51 51 | -52 |-def func(x: int): - 52 |+def func(x: int) -> int | None: -53 53 | if not x: -54 54 | return 1 -55 55 | else: auto_return_type.py:59:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -190,15 +112,6 @@ auto_return_type.py:59:5: ANN201 [*] Missing return type annotation for public f | = help: Add return type annotation: `str | int | None` -ℹ Unsafe fix -56 56 | return None -57 57 | -58 58 | -59 |-def func(x: int): - 59 |+def func(x: int) -> str | int | None: -60 60 | if not x: -61 61 | return 1 -62 62 | elif x > 5: auto_return_type.py:68:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -209,15 +122,6 @@ auto_return_type.py:68:5: ANN201 [*] Missing return type annotation for public f | = help: Add return type annotation: `int | None` -ℹ Unsafe fix -65 65 | return None -66 66 | -67 67 | -68 |-def func(x: int): - 68 |+def func(x: int) -> int | None: -69 69 | if x: -70 70 | return 1 -71 71 | auto_return_type.py:73:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -227,15 +131,6 @@ auto_return_type.py:73:5: ANN201 [*] Missing return type annotation for public f | = help: Add return type annotation: `None` -ℹ Unsafe fix -70 70 | return 1 -71 71 | -72 72 | -73 |-def func(): - 73 |+def func() -> None: -74 74 | x = 1 -75 75 | -76 76 | auto_return_type.py:77:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -246,15 +141,6 @@ auto_return_type.py:77:5: ANN201 [*] Missing return type annotation for public f | = help: Add return type annotation: `int | None` -ℹ Unsafe fix -74 74 | x = 1 -75 75 | -76 76 | -77 |-def func(x: int): - 77 |+def func(x: int) -> int | None: -78 78 | if x > 0: -79 79 | return 1 -80 80 | auto_return_type.py:82:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -265,15 +151,6 @@ auto_return_type.py:82:5: ANN201 [*] Missing return type annotation for public f | = help: Add return type annotation: `str | int | None` -ℹ Unsafe fix -79 79 | return 1 -80 80 | -81 81 | -82 |-def func(x: int): - 82 |+def func(x: int) -> str | int | None: -83 83 | match x: -84 84 | case [1, 2, 3]: -85 85 | return 1 auto_return_type.py:90:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -284,15 +161,6 @@ auto_return_type.py:90:5: ANN201 [*] Missing return type annotation for public f | = help: Add return type annotation: `int | None` -ℹ Unsafe fix -87 87 | return "foo" -88 88 | -89 89 | -90 |-def func(x: int): - 90 |+def func(x: int) -> int | None: -91 91 | for i in range(5): -92 92 | if i > 0: -93 93 | return 1 auto_return_type.py:96:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -303,15 +171,6 @@ auto_return_type.py:96:5: ANN201 [*] Missing return type annotation for public f | = help: Add return type annotation: `int` -ℹ Unsafe fix -93 93 | return 1 -94 94 | -95 95 | -96 |-def func(x: int): - 96 |+def func(x: int) -> int: -97 97 | for i in range(5): -98 98 | if i > 0: -99 99 | return 1 auto_return_type.py:104:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -322,15 +181,6 @@ auto_return_type.py:104:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `int | None` -ℹ Unsafe fix -101 101 | return 4 -102 102 | -103 103 | -104 |-def func(x: int): - 104 |+def func(x: int) -> int | None: -105 105 | for i in range(5): -106 106 | if i > 0: -107 107 | break auto_return_type.py:112:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -341,15 +191,6 @@ auto_return_type.py:112:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `int | None` -ℹ Unsafe fix -109 109 | return 4 -110 110 | -111 111 | -112 |-def func(x: int): - 112 |+def func(x: int) -> int | None: -113 113 | try: -114 114 | pass -115 115 | except: auto_return_type.py:119:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -360,15 +201,6 @@ auto_return_type.py:119:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `int` -ℹ Unsafe fix -116 116 | return 1 -117 117 | -118 118 | -119 |-def func(x: int): - 119 |+def func(x: int) -> int: -120 120 | try: -121 121 | pass -122 122 | except: auto_return_type.py:128:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -379,15 +211,6 @@ auto_return_type.py:128:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `int` -ℹ Unsafe fix -125 125 | return 2 -126 126 | -127 127 | -128 |-def func(x: int): - 128 |+def func(x: int) -> int: -129 129 | try: -130 130 | pass -131 131 | except: auto_return_type.py:137:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -398,15 +221,6 @@ auto_return_type.py:137:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `int | None` -ℹ Unsafe fix -134 134 | return 2 -135 135 | -136 136 | -137 |-def func(x: int): - 137 |+def func(x: int) -> int | None: -138 138 | try: -139 139 | return 1 -140 140 | except: auto_return_type.py:146:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -417,15 +231,6 @@ auto_return_type.py:146:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `int | None` -ℹ Unsafe fix -143 143 | pass -144 144 | -145 145 | -146 |-def func(x: int): - 146 |+def func(x: int) -> int | None: -147 147 | while x > 0: -148 148 | break -149 149 | return 1 auto_return_type.py:158:9: ANN201 Missing return type annotation for public function `method` | @@ -485,15 +290,6 @@ auto_return_type.py:180:9: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `float` -ℹ Unsafe fix -177 177 | pass -178 178 | -179 179 | @abstractmethod -180 |- def method(self): - 180 |+ def method(self) -> float: -181 181 | if self.x > 0: -182 182 | return 1 -183 183 | else: auto_return_type.py:187:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -504,15 +300,6 @@ auto_return_type.py:187:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `int | None` -ℹ Unsafe fix -184 184 | return 1.5 -185 185 | -186 186 | -187 |-def func(x: int): - 187 |+def func(x: int) -> int | None: -188 188 | try: -189 189 | pass -190 190 | except: auto_return_type.py:194:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -523,15 +310,6 @@ auto_return_type.py:194:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `int` -ℹ Unsafe fix -191 191 | return 2 -192 192 | -193 193 | -194 |-def func(x: int): - 194 |+def func(x: int) -> int: -195 195 | try: -196 196 | pass -197 197 | except: auto_return_type.py:203:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -542,23 +320,6 @@ auto_return_type.py:203:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `Never` -ℹ Unsafe fix -151 151 | -152 152 | import abc -153 153 | from abc import abstractmethod - 154 |+from typing import Never -154 155 | -155 156 | -156 157 | class Foo(abc.ABC): --------------------------------------------------------------------------------- -200 201 | return 3 -201 202 | -202 203 | -203 |-def func(x: int): - 204 |+def func(x: int) -> Never: -204 205 | if not x: -205 206 | raise ValueError -206 207 | else: auto_return_type.py:210:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -569,15 +330,6 @@ auto_return_type.py:210:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `int` -ℹ Unsafe fix -207 207 | raise TypeError -208 208 | -209 209 | -210 |-def func(x: int): - 210 |+def func(x: int) -> int: -211 211 | if not x: -212 212 | raise ValueError -213 213 | else: auto_return_type.py:234:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -588,15 +340,6 @@ auto_return_type.py:234:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `int` -ℹ Unsafe fix -231 231 | return i -232 232 | -233 233 | -234 |-def func(x: int): - 234 |+def func(x: int) -> int: -235 235 | if not x: -236 236 | return 1 -237 237 | raise ValueError auto_return_type.py:240:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -607,15 +350,6 @@ auto_return_type.py:240:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `int` -ℹ Unsafe fix -237 237 | raise ValueError -238 238 | -239 239 | -240 |-def func(x: int): - 240 |+def func(x: int) -> int: -241 241 | if not x: -242 242 | return 1 -243 243 | else: auto_return_type.py:248:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -626,15 +360,6 @@ auto_return_type.py:248:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `int | None` -ℹ Unsafe fix -245 245 | raise ValueError -246 246 | -247 247 | -248 |-def func(): - 248 |+def func() -> int | None: -249 249 | try: -250 250 | raise ValueError -251 251 | except: auto_return_type.py:255:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -645,15 +370,6 @@ auto_return_type.py:255:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `int | None` -ℹ Unsafe fix -252 252 | return 2 -253 253 | -254 254 | -255 |-def func(): - 255 |+def func() -> int | None: -256 256 | try: -257 257 | return 1 -258 258 | except: auto_return_type.py:262:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -664,15 +380,6 @@ auto_return_type.py:262:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `int` -ℹ Unsafe fix -259 259 | pass -260 260 | -261 261 | -262 |-def func(x: int): - 262 |+def func(x: int) -> int: -263 263 | for _ in range(3): -264 264 | if x > 0: -265 265 | return 1 auto_return_type.py:269:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -683,15 +390,6 @@ auto_return_type.py:269:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `None` -ℹ Unsafe fix -266 266 | raise ValueError -267 267 | -268 268 | -269 |-def func(x: int): - 269 |+def func(x: int) -> None: -270 270 | if x > 5: -271 271 | raise ValueError -272 272 | else: auto_return_type.py:276:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -702,15 +400,6 @@ auto_return_type.py:276:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `None` -ℹ Unsafe fix -273 273 | pass -274 274 | -275 275 | -276 |-def func(x: int): - 276 |+def func(x: int) -> None: -277 277 | if x > 5: -278 278 | raise ValueError -279 279 | elif x > 10: auto_return_type.py:283:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -721,15 +410,6 @@ auto_return_type.py:283:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `int | None` -ℹ Unsafe fix -280 280 | pass -281 281 | -282 282 | -283 |-def func(x: int): - 283 |+def func(x: int) -> int | None: -284 284 | if x > 5: -285 285 | raise ValueError -286 286 | elif x > 10: auto_return_type.py:290:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -740,15 +420,6 @@ auto_return_type.py:290:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `int` -ℹ Unsafe fix -287 287 | return 5 -288 288 | -289 289 | -290 |-def func(): - 290 |+def func() -> int: -291 291 | try: -292 292 | return 5 -293 293 | except: auto_return_type.py:299:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -758,15 +429,3 @@ auto_return_type.py:299:5: ANN201 [*] Missing return type annotation for public 301 | case [1, 2, 3]: | = help: Add return type annotation: `str | int` - -ℹ Unsafe fix -296 296 | raise ValueError -297 297 | -298 298 | -299 |-def func(x: int): - 299 |+def func(x: int) -> str | int: -300 300 | match x: -301 301 | case [1, 2, 3]: -302 302 | return 1 - - diff --git a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__auto_return_type_py38.snap b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__auto_return_type_py38.snap index 4cb5bbfb615fa..a21fad875b9d3 100644 --- a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__auto_return_type_py38.snap +++ b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__auto_return_type_py38.snap @@ -9,12 +9,6 @@ auto_return_type.py:1:5: ANN201 [*] Missing return type annotation for public fu | = help: Add return type annotation: `int` -ℹ Unsafe fix -1 |-def func(): - 1 |+def func() -> int: -2 2 | return 1 -3 3 | -4 4 | auto_return_type.py:5:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -24,15 +18,6 @@ auto_return_type.py:5:5: ANN201 [*] Missing return type annotation for public fu | = help: Add return type annotation: `float` -ℹ Unsafe fix -2 2 | return 1 -3 3 | -4 4 | -5 |-def func(): - 5 |+def func() -> float: -6 6 | return 1.5 -7 7 | -8 8 | auto_return_type.py:9:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -43,15 +28,6 @@ auto_return_type.py:9:5: ANN201 [*] Missing return type annotation for public fu | = help: Add return type annotation: `float` -ℹ Unsafe fix -6 6 | return 1.5 -7 7 | -8 8 | -9 |-def func(x: int): - 9 |+def func(x: int) -> float: -10 10 | if x > 0: -11 11 | return 1 -12 12 | else: auto_return_type.py:16:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -61,15 +37,6 @@ auto_return_type.py:16:5: ANN201 [*] Missing return type annotation for public f | = help: Add return type annotation: `bool` -ℹ Unsafe fix -13 13 | return 1.5 -14 14 | -15 15 | -16 |-def func(): - 16 |+def func() -> bool: -17 17 | return True -18 18 | -19 19 | auto_return_type.py:20:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -80,15 +47,6 @@ auto_return_type.py:20:5: ANN201 [*] Missing return type annotation for public f | = help: Add return type annotation: `None` -ℹ Unsafe fix -17 17 | return True -18 18 | -19 19 | -20 |-def func(x: int): - 20 |+def func(x: int) -> None: -21 21 | if x > 0: -22 22 | return None -23 23 | else: auto_return_type.py:27:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -98,20 +56,6 @@ auto_return_type.py:27:5: ANN201 [*] Missing return type annotation for public f | = help: Add return type annotation: `Union[str | float]` -ℹ Unsafe fix - 1 |+from typing import Union -1 2 | def func(): -2 3 | return 1 -3 4 | --------------------------------------------------------------------------------- -24 25 | return -25 26 | -26 27 | -27 |-def func(x: int): - 28 |+def func(x: int) -> Union[str | float]: -28 29 | return 1 or 2.5 if x > 0 else 1.5 or "str" -29 30 | -30 31 | auto_return_type.py:31:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -121,20 +65,6 @@ auto_return_type.py:31:5: ANN201 [*] Missing return type annotation for public f | = help: Add return type annotation: `Union[str | float]` -ℹ Unsafe fix - 1 |+from typing import Union -1 2 | def func(): -2 3 | return 1 -3 4 | --------------------------------------------------------------------------------- -28 29 | return 1 or 2.5 if x > 0 else 1.5 or "str" -29 30 | -30 31 | -31 |-def func(x: int): - 32 |+def func(x: int) -> Union[str | float]: -32 33 | return 1 + 2.5 if x > 0 else 1.5 or "str" -33 34 | -34 35 | auto_return_type.py:35:5: ANN201 Missing return type annotation for public function `func` | @@ -162,15 +92,6 @@ auto_return_type.py:45:5: ANN201 [*] Missing return type annotation for public f | = help: Add return type annotation: `int` -ℹ Unsafe fix -42 42 | return {"foo": 1} -43 43 | -44 44 | -45 |-def func(x: int): - 45 |+def func(x: int) -> int: -46 46 | if not x: -47 47 | return 1 -48 48 | else: auto_return_type.py:52:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -181,20 +102,6 @@ auto_return_type.py:52:5: ANN201 [*] Missing return type annotation for public f | = help: Add return type annotation: `Optional[int]` -ℹ Unsafe fix - 1 |+from typing import Optional -1 2 | def func(): -2 3 | return 1 -3 4 | --------------------------------------------------------------------------------- -49 50 | return True -50 51 | -51 52 | -52 |-def func(x: int): - 53 |+def func(x: int) -> Optional[int]: -53 54 | if not x: -54 55 | return 1 -55 56 | else: auto_return_type.py:59:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -205,20 +112,6 @@ auto_return_type.py:59:5: ANN201 [*] Missing return type annotation for public f | = help: Add return type annotation: `Union[str | int | None]` -ℹ Unsafe fix - 1 |+from typing import Union -1 2 | def func(): -2 3 | return 1 -3 4 | --------------------------------------------------------------------------------- -56 57 | return None -57 58 | -58 59 | -59 |-def func(x: int): - 60 |+def func(x: int) -> Union[str | int | None]: -60 61 | if not x: -61 62 | return 1 -62 63 | elif x > 5: auto_return_type.py:68:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -229,20 +122,6 @@ auto_return_type.py:68:5: ANN201 [*] Missing return type annotation for public f | = help: Add return type annotation: `Optional[int]` -ℹ Unsafe fix - 1 |+from typing import Optional -1 2 | def func(): -2 3 | return 1 -3 4 | --------------------------------------------------------------------------------- -65 66 | return None -66 67 | -67 68 | -68 |-def func(x: int): - 69 |+def func(x: int) -> Optional[int]: -69 70 | if x: -70 71 | return 1 -71 72 | auto_return_type.py:73:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -252,15 +131,6 @@ auto_return_type.py:73:5: ANN201 [*] Missing return type annotation for public f | = help: Add return type annotation: `None` -ℹ Unsafe fix -70 70 | return 1 -71 71 | -72 72 | -73 |-def func(): - 73 |+def func() -> None: -74 74 | x = 1 -75 75 | -76 76 | auto_return_type.py:77:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -271,20 +141,6 @@ auto_return_type.py:77:5: ANN201 [*] Missing return type annotation for public f | = help: Add return type annotation: `Optional[int]` -ℹ Unsafe fix - 1 |+from typing import Optional -1 2 | def func(): -2 3 | return 1 -3 4 | --------------------------------------------------------------------------------- -74 75 | x = 1 -75 76 | -76 77 | -77 |-def func(x: int): - 78 |+def func(x: int) -> Optional[int]: -78 79 | if x > 0: -79 80 | return 1 -80 81 | auto_return_type.py:82:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -295,20 +151,6 @@ auto_return_type.py:82:5: ANN201 [*] Missing return type annotation for public f | = help: Add return type annotation: `Union[str | int | None]` -ℹ Unsafe fix - 1 |+from typing import Union -1 2 | def func(): -2 3 | return 1 -3 4 | --------------------------------------------------------------------------------- -79 80 | return 1 -80 81 | -81 82 | -82 |-def func(x: int): - 83 |+def func(x: int) -> Union[str | int | None]: -83 84 | match x: -84 85 | case [1, 2, 3]: -85 86 | return 1 auto_return_type.py:90:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -319,20 +161,6 @@ auto_return_type.py:90:5: ANN201 [*] Missing return type annotation for public f | = help: Add return type annotation: `Optional[int]` -ℹ Unsafe fix - 1 |+from typing import Optional -1 2 | def func(): -2 3 | return 1 -3 4 | --------------------------------------------------------------------------------- -87 88 | return "foo" -88 89 | -89 90 | -90 |-def func(x: int): - 91 |+def func(x: int) -> Optional[int]: -91 92 | for i in range(5): -92 93 | if i > 0: -93 94 | return 1 auto_return_type.py:96:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -343,15 +171,6 @@ auto_return_type.py:96:5: ANN201 [*] Missing return type annotation for public f | = help: Add return type annotation: `int` -ℹ Unsafe fix -93 93 | return 1 -94 94 | -95 95 | -96 |-def func(x: int): - 96 |+def func(x: int) -> int: -97 97 | for i in range(5): -98 98 | if i > 0: -99 99 | return 1 auto_return_type.py:104:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -362,20 +181,6 @@ auto_return_type.py:104:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `Optional[int]` -ℹ Unsafe fix - 1 |+from typing import Optional -1 2 | def func(): -2 3 | return 1 -3 4 | --------------------------------------------------------------------------------- -101 102 | return 4 -102 103 | -103 104 | -104 |-def func(x: int): - 105 |+def func(x: int) -> Optional[int]: -105 106 | for i in range(5): -106 107 | if i > 0: -107 108 | break auto_return_type.py:112:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -386,20 +191,6 @@ auto_return_type.py:112:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `Optional[int]` -ℹ Unsafe fix - 1 |+from typing import Optional -1 2 | def func(): -2 3 | return 1 -3 4 | --------------------------------------------------------------------------------- -109 110 | return 4 -110 111 | -111 112 | -112 |-def func(x: int): - 113 |+def func(x: int) -> Optional[int]: -113 114 | try: -114 115 | pass -115 116 | except: auto_return_type.py:119:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -410,15 +201,6 @@ auto_return_type.py:119:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `int` -ℹ Unsafe fix -116 116 | return 1 -117 117 | -118 118 | -119 |-def func(x: int): - 119 |+def func(x: int) -> int: -120 120 | try: -121 121 | pass -122 122 | except: auto_return_type.py:128:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -429,15 +211,6 @@ auto_return_type.py:128:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `int` -ℹ Unsafe fix -125 125 | return 2 -126 126 | -127 127 | -128 |-def func(x: int): - 128 |+def func(x: int) -> int: -129 129 | try: -130 130 | pass -131 131 | except: auto_return_type.py:137:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -448,20 +221,6 @@ auto_return_type.py:137:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `Optional[int]` -ℹ Unsafe fix - 1 |+from typing import Optional -1 2 | def func(): -2 3 | return 1 -3 4 | --------------------------------------------------------------------------------- -134 135 | return 2 -135 136 | -136 137 | -137 |-def func(x: int): - 138 |+def func(x: int) -> Optional[int]: -138 139 | try: -139 140 | return 1 -140 141 | except: auto_return_type.py:146:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -472,20 +231,6 @@ auto_return_type.py:146:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `Optional[int]` -ℹ Unsafe fix - 1 |+from typing import Optional -1 2 | def func(): -2 3 | return 1 -3 4 | --------------------------------------------------------------------------------- -143 144 | pass -144 145 | -145 146 | -146 |-def func(x: int): - 147 |+def func(x: int) -> Optional[int]: -147 148 | while x > 0: -148 149 | break -149 150 | return 1 auto_return_type.py:158:9: ANN201 Missing return type annotation for public function `method` | @@ -545,15 +290,6 @@ auto_return_type.py:180:9: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `float` -ℹ Unsafe fix -177 177 | pass -178 178 | -179 179 | @abstractmethod -180 |- def method(self): - 180 |+ def method(self) -> float: -181 181 | if self.x > 0: -182 182 | return 1 -183 183 | else: auto_return_type.py:187:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -564,23 +300,6 @@ auto_return_type.py:187:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `Optional[int]` -ℹ Unsafe fix -151 151 | -152 152 | import abc -153 153 | from abc import abstractmethod - 154 |+from typing import Optional -154 155 | -155 156 | -156 157 | class Foo(abc.ABC): --------------------------------------------------------------------------------- -184 185 | return 1.5 -185 186 | -186 187 | -187 |-def func(x: int): - 188 |+def func(x: int) -> Optional[int]: -188 189 | try: -189 190 | pass -190 191 | except: auto_return_type.py:194:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -591,15 +310,6 @@ auto_return_type.py:194:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `int` -ℹ Unsafe fix -191 191 | return 2 -192 192 | -193 193 | -194 |-def func(x: int): - 194 |+def func(x: int) -> int: -195 195 | try: -196 196 | pass -197 197 | except: auto_return_type.py:203:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -610,23 +320,6 @@ auto_return_type.py:203:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `NoReturn` -ℹ Unsafe fix -151 151 | -152 152 | import abc -153 153 | from abc import abstractmethod - 154 |+from typing import NoReturn -154 155 | -155 156 | -156 157 | class Foo(abc.ABC): --------------------------------------------------------------------------------- -200 201 | return 3 -201 202 | -202 203 | -203 |-def func(x: int): - 204 |+def func(x: int) -> NoReturn: -204 205 | if not x: -205 206 | raise ValueError -206 207 | else: auto_return_type.py:210:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -637,15 +330,6 @@ auto_return_type.py:210:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `int` -ℹ Unsafe fix -207 207 | raise TypeError -208 208 | -209 209 | -210 |-def func(x: int): - 210 |+def func(x: int) -> int: -211 211 | if not x: -212 212 | raise ValueError -213 213 | else: auto_return_type.py:234:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -656,15 +340,6 @@ auto_return_type.py:234:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `int` -ℹ Unsafe fix -231 231 | return i -232 232 | -233 233 | -234 |-def func(x: int): - 234 |+def func(x: int) -> int: -235 235 | if not x: -236 236 | return 1 -237 237 | raise ValueError auto_return_type.py:240:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -675,15 +350,6 @@ auto_return_type.py:240:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `int` -ℹ Unsafe fix -237 237 | raise ValueError -238 238 | -239 239 | -240 |-def func(x: int): - 240 |+def func(x: int) -> int: -241 241 | if not x: -242 242 | return 1 -243 243 | else: auto_return_type.py:248:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -694,24 +360,6 @@ auto_return_type.py:248:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `Optional[int]` -ℹ Unsafe fix -214 214 | return 1 -215 215 | -216 216 | -217 |-from typing import overload - 217 |+from typing import overload, Optional -218 218 | -219 219 | -220 220 | @overload --------------------------------------------------------------------------------- -245 245 | raise ValueError -246 246 | -247 247 | -248 |-def func(): - 248 |+def func() -> Optional[int]: -249 249 | try: -250 250 | raise ValueError -251 251 | except: auto_return_type.py:255:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -722,24 +370,6 @@ auto_return_type.py:255:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `Optional[int]` -ℹ Unsafe fix -214 214 | return 1 -215 215 | -216 216 | -217 |-from typing import overload - 217 |+from typing import overload, Optional -218 218 | -219 219 | -220 220 | @overload --------------------------------------------------------------------------------- -252 252 | return 2 -253 253 | -254 254 | -255 |-def func(): - 255 |+def func() -> Optional[int]: -256 256 | try: -257 257 | return 1 -258 258 | except: auto_return_type.py:262:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -750,15 +380,6 @@ auto_return_type.py:262:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `int` -ℹ Unsafe fix -259 259 | pass -260 260 | -261 261 | -262 |-def func(x: int): - 262 |+def func(x: int) -> int: -263 263 | for _ in range(3): -264 264 | if x > 0: -265 265 | return 1 auto_return_type.py:269:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -769,15 +390,6 @@ auto_return_type.py:269:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `None` -ℹ Unsafe fix -266 266 | raise ValueError -267 267 | -268 268 | -269 |-def func(x: int): - 269 |+def func(x: int) -> None: -270 270 | if x > 5: -271 271 | raise ValueError -272 272 | else: auto_return_type.py:276:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -788,15 +400,6 @@ auto_return_type.py:276:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `None` -ℹ Unsafe fix -273 273 | pass -274 274 | -275 275 | -276 |-def func(x: int): - 276 |+def func(x: int) -> None: -277 277 | if x > 5: -278 278 | raise ValueError -279 279 | elif x > 10: auto_return_type.py:283:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -807,24 +410,6 @@ auto_return_type.py:283:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `Optional[int]` -ℹ Unsafe fix -214 214 | return 1 -215 215 | -216 216 | -217 |-from typing import overload - 217 |+from typing import overload, Optional -218 218 | -219 219 | -220 220 | @overload --------------------------------------------------------------------------------- -280 280 | pass -281 281 | -282 282 | -283 |-def func(x: int): - 283 |+def func(x: int) -> Optional[int]: -284 284 | if x > 5: -285 285 | raise ValueError -286 286 | elif x > 10: auto_return_type.py:290:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -835,15 +420,6 @@ auto_return_type.py:290:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `int` -ℹ Unsafe fix -287 287 | return 5 -288 288 | -289 289 | -290 |-def func(): - 290 |+def func() -> int: -291 291 | try: -292 292 | return 5 -293 293 | except: auto_return_type.py:299:5: ANN201 [*] Missing return type annotation for public function `func` | @@ -853,24 +429,3 @@ auto_return_type.py:299:5: ANN201 [*] Missing return type annotation for public 301 | case [1, 2, 3]: | = help: Add return type annotation: `Union[str | int]` - -ℹ Unsafe fix -214 214 | return 1 -215 215 | -216 216 | -217 |-from typing import overload - 217 |+from typing import overload, Union -218 218 | -219 219 | -220 220 | @overload --------------------------------------------------------------------------------- -296 296 | raise ValueError -297 297 | -298 298 | -299 |-def func(x: int): - 299 |+def func(x: int) -> Union[str | int]: -300 300 | match x: -301 301 | case [1, 2, 3]: -302 302 | return 1 - - diff --git a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__defaults.snap b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__defaults.snap index 9be33117659ce..2b38d11ca830d 100644 --- a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__defaults.snap +++ b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__defaults.snap @@ -10,15 +10,6 @@ annotation_presence.py:5:5: ANN201 [*] Missing return type annotation for public | = help: Add return type annotation: `None` -ℹ Unsafe fix -2 2 | from typing_extensions import override -3 3 | -4 4 | # Error -5 |-def foo(a, b): - 5 |+def foo(a, b) -> None: -6 6 | pass -7 7 | -8 8 | annotation_presence.py:5:9: ANN001 Missing type annotation for function argument `a` | @@ -45,15 +36,6 @@ annotation_presence.py:10:5: ANN201 [*] Missing return type annotation for publi | = help: Add return type annotation: `None` -ℹ Unsafe fix -7 7 | -8 8 | -9 9 | # Error -10 |-def foo(a: int, b): - 10 |+def foo(a: int, b) -> None: -11 11 | pass -12 12 | -13 13 | annotation_presence.py:10:17: ANN001 Missing type annotation for function argument `b` | @@ -80,15 +62,6 @@ annotation_presence.py:20:5: ANN201 [*] Missing return type annotation for publi | = help: Add return type annotation: `None` -ℹ Unsafe fix -17 17 | -18 18 | -19 19 | # Error -20 |-def foo(a: int, b: int): - 20 |+def foo(a: int, b: int) -> None: -21 21 | pass -22 22 | -23 23 | annotation_presence.py:25:5: ANN201 [*] Missing return type annotation for public function `foo` | @@ -99,15 +72,6 @@ annotation_presence.py:25:5: ANN201 [*] Missing return type annotation for publi | = help: Add return type annotation: `None` -ℹ Unsafe fix -22 22 | -23 23 | -24 24 | # Error -25 |-def foo(): - 25 |+def foo() -> None: -26 26 | pass -27 27 | -28 28 | annotation_presence.py:45:12: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` | @@ -296,15 +260,6 @@ annotation_presence.py:159:9: ANN204 [*] Missing return type annotation for spec | = help: Add return type annotation: `None` -ℹ Unsafe fix -156 156 | -157 157 | class Foo: -158 158 | @decorator() -159 |- def __init__(self: "Foo", foo: int): - 159 |+ def __init__(self: "Foo", foo: int) -> None: -160 160 | ... -161 161 | -162 162 | annotation_presence.py:165:9: ANN204 [*] Missing return type annotation for special method `__init__` | @@ -316,13 +271,6 @@ annotation_presence.py:165:9: ANN204 [*] Missing return type annotation for spec | = help: Add return type annotation: `None` -ℹ Unsafe fix -162 162 | -163 163 | # Regression test for: https://github.com/astral-sh/ruff/issues/7711 -164 164 | class Class: -165 |- def __init__(self): - 165 |+ def __init__(self) -> None: -166 166 | print(f"{self.attr=}") annotation_presence.py:165:18: ANN101 Missing type annotation for `self` in method | @@ -332,5 +280,3 @@ annotation_presence.py:165:18: ANN101 Missing type annotation for `self` in meth | ^^^^ ANN101 166 | print(f"{self.attr=}") | - - diff --git a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__ignore_fully_untyped.snap b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__ignore_fully_untyped.snap index d806d641b4caa..cdbde7a18e225 100644 --- a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__ignore_fully_untyped.snap +++ b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__ignore_fully_untyped.snap @@ -9,15 +9,6 @@ ignore_fully_untyped.py:24:5: ANN201 [*] Missing return type annotation for publ | = help: Add return type annotation: `None` -ℹ Unsafe fix -21 21 | pass -22 22 | -23 23 | -24 |-def error_partially_typed_1(a: int, b): - 24 |+def error_partially_typed_1(a: int, b) -> None: -25 25 | pass -26 26 | -27 27 | ignore_fully_untyped.py:24:37: ANN001 Missing type annotation for function argument `b` | @@ -41,15 +32,6 @@ ignore_fully_untyped.py:32:5: ANN201 [*] Missing return type annotation for publ | = help: Add return type annotation: `None` -ℹ Unsafe fix -29 29 | pass -30 30 | -31 31 | -32 |-def error_partially_typed_3(a: int, b: int): - 32 |+def error_partially_typed_3(a: int, b: int) -> None: -33 33 | pass -34 34 | -35 35 | ignore_fully_untyped.py:43:9: ANN201 [*] Missing return type annotation for public function `error_typed_self` | @@ -60,13 +42,3 @@ ignore_fully_untyped.py:43:9: ANN201 [*] Missing return type annotation for publ 44 | pass | = help: Add return type annotation: `None` - -ℹ Unsafe fix -40 40 | def ok_untyped_method(self): -41 41 | pass -42 42 | -43 |- def error_typed_self(self: X): - 43 |+ def error_typed_self(self: X) -> None: -44 44 | pass - - diff --git a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__mypy_init_return.snap b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__mypy_init_return.snap index f25fc530bc8cf..c7206cc46fe3c 100644 --- a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__mypy_init_return.snap +++ b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__mypy_init_return.snap @@ -11,15 +11,6 @@ mypy_init_return.py:5:9: ANN204 [*] Missing return type annotation for special m | = help: Add return type annotation: `None` -ℹ Unsafe fix -2 2 | -3 3 | # Error -4 4 | class Foo: -5 |- def __init__(self): - 5 |+ def __init__(self) -> None: -6 6 | ... -7 7 | -8 8 | mypy_init_return.py:11:9: ANN204 [*] Missing return type annotation for special method `__init__` | @@ -31,15 +22,6 @@ mypy_init_return.py:11:9: ANN204 [*] Missing return type annotation for special | = help: Add return type annotation: `None` -ℹ Unsafe fix -8 8 | -9 9 | # Error -10 10 | class Foo: -11 |- def __init__(self, foo): - 11 |+ def __init__(self, foo) -> None: -12 12 | ... -13 13 | -14 14 | mypy_init_return.py:40:5: ANN202 [*] Missing return type annotation for private function `__init__` | @@ -50,15 +32,6 @@ mypy_init_return.py:40:5: ANN202 [*] Missing return type annotation for private | = help: Add return type annotation: `None` -ℹ Unsafe fix -37 37 | -38 38 | -39 39 | # Error -40 |-def __init__(self, foo: int): - 40 |+def __init__(self, foo: int) -> None: -41 41 | ... -42 42 | -43 43 | mypy_init_return.py:47:9: ANN204 [*] Missing return type annotation for special method `__init__` | @@ -69,13 +42,3 @@ mypy_init_return.py:47:9: ANN204 [*] Missing return type annotation for special 48 | ... | = help: Add return type annotation: `None` - -ℹ Unsafe fix -44 44 | # Error – used to be ok for a moment since the mere presence -45 45 | # of a vararg falsely indicated that the function has a typed argument. -46 46 | class Foo: -47 |- def __init__(self, *arg): - 47 |+ def __init__(self, *arg) -> None: -48 48 | ... - - diff --git a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__simple_magic_methods.snap b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__simple_magic_methods.snap index 29f85e2af8423..eaeceed86279b 100644 --- a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__simple_magic_methods.snap +++ b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__simple_magic_methods.snap @@ -10,13 +10,6 @@ simple_magic_methods.py:2:9: ANN204 [*] Missing return type annotation for speci | = help: Add return type annotation: `str` -ℹ Unsafe fix -1 1 | class Foo: -2 |- def __str__(self): - 2 |+ def __str__(self) -> str: -3 3 | ... -4 4 | -5 5 | def __repr__(self): simple_magic_methods.py:5:9: ANN204 [*] Missing return type annotation for special method `__repr__` | @@ -28,15 +21,6 @@ simple_magic_methods.py:5:9: ANN204 [*] Missing return type annotation for speci | = help: Add return type annotation: `str` -ℹ Unsafe fix -2 2 | def __str__(self): -3 3 | ... -4 4 | -5 |- def __repr__(self): - 5 |+ def __repr__(self) -> str: -6 6 | ... -7 7 | -8 8 | def __len__(self): simple_magic_methods.py:8:9: ANN204 [*] Missing return type annotation for special method `__len__` | @@ -48,15 +32,6 @@ simple_magic_methods.py:8:9: ANN204 [*] Missing return type annotation for speci | = help: Add return type annotation: `int` -ℹ Unsafe fix -5 5 | def __repr__(self): -6 6 | ... -7 7 | -8 |- def __len__(self): - 8 |+ def __len__(self) -> int: -9 9 | ... -10 10 | -11 11 | def __length_hint__(self): simple_magic_methods.py:11:9: ANN204 [*] Missing return type annotation for special method `__length_hint__` | @@ -68,15 +43,6 @@ simple_magic_methods.py:11:9: ANN204 [*] Missing return type annotation for spec | = help: Add return type annotation: `int` -ℹ Unsafe fix -8 8 | def __len__(self): -9 9 | ... -10 10 | -11 |- def __length_hint__(self): - 11 |+ def __length_hint__(self) -> int: -12 12 | ... -13 13 | -14 14 | def __init__(self): simple_magic_methods.py:14:9: ANN204 [*] Missing return type annotation for special method `__init__` | @@ -88,15 +54,6 @@ simple_magic_methods.py:14:9: ANN204 [*] Missing return type annotation for spec | = help: Add return type annotation: `None` -ℹ Unsafe fix -11 11 | def __length_hint__(self): -12 12 | ... -13 13 | -14 |- def __init__(self): - 14 |+ def __init__(self) -> None: -15 15 | ... -16 16 | -17 17 | def __del__(self): simple_magic_methods.py:17:9: ANN204 [*] Missing return type annotation for special method `__del__` | @@ -108,15 +65,6 @@ simple_magic_methods.py:17:9: ANN204 [*] Missing return type annotation for spec | = help: Add return type annotation: `None` -ℹ Unsafe fix -14 14 | def __init__(self): -15 15 | ... -16 16 | -17 |- def __del__(self): - 17 |+ def __del__(self) -> None: -18 18 | ... -19 19 | -20 20 | def __bool__(self): simple_magic_methods.py:20:9: ANN204 [*] Missing return type annotation for special method `__bool__` | @@ -128,15 +76,6 @@ simple_magic_methods.py:20:9: ANN204 [*] Missing return type annotation for spec | = help: Add return type annotation: `bool` -ℹ Unsafe fix -17 17 | def __del__(self): -18 18 | ... -19 19 | -20 |- def __bool__(self): - 20 |+ def __bool__(self) -> bool: -21 21 | ... -22 22 | -23 23 | def __bytes__(self): simple_magic_methods.py:23:9: ANN204 [*] Missing return type annotation for special method `__bytes__` | @@ -148,15 +87,6 @@ simple_magic_methods.py:23:9: ANN204 [*] Missing return type annotation for spec | = help: Add return type annotation: `bytes` -ℹ Unsafe fix -20 20 | def __bool__(self): -21 21 | ... -22 22 | -23 |- def __bytes__(self): - 23 |+ def __bytes__(self) -> bytes: -24 24 | ... -25 25 | -26 26 | def __format__(self, format_spec): simple_magic_methods.py:26:9: ANN204 [*] Missing return type annotation for special method `__format__` | @@ -168,15 +98,6 @@ simple_magic_methods.py:26:9: ANN204 [*] Missing return type annotation for spec | = help: Add return type annotation: `str` -ℹ Unsafe fix -23 23 | def __bytes__(self): -24 24 | ... -25 25 | -26 |- def __format__(self, format_spec): - 26 |+ def __format__(self, format_spec) -> str: -27 27 | ... -28 28 | -29 29 | def __contains__(self, item): simple_magic_methods.py:29:9: ANN204 [*] Missing return type annotation for special method `__contains__` | @@ -188,15 +109,6 @@ simple_magic_methods.py:29:9: ANN204 [*] Missing return type annotation for spec | = help: Add return type annotation: `bool` -ℹ Unsafe fix -26 26 | def __format__(self, format_spec): -27 27 | ... -28 28 | -29 |- def __contains__(self, item): - 29 |+ def __contains__(self, item) -> bool: -30 30 | ... -31 31 | -32 32 | def __complex__(self): simple_magic_methods.py:32:9: ANN204 [*] Missing return type annotation for special method `__complex__` | @@ -208,15 +120,6 @@ simple_magic_methods.py:32:9: ANN204 [*] Missing return type annotation for spec | = help: Add return type annotation: `complex` -ℹ Unsafe fix -29 29 | def __contains__(self, item): -30 30 | ... -31 31 | -32 |- def __complex__(self): - 32 |+ def __complex__(self) -> complex: -33 33 | ... -34 34 | -35 35 | def __int__(self): simple_magic_methods.py:35:9: ANN204 [*] Missing return type annotation for special method `__int__` | @@ -228,15 +131,6 @@ simple_magic_methods.py:35:9: ANN204 [*] Missing return type annotation for spec | = help: Add return type annotation: `int` -ℹ Unsafe fix -32 32 | def __complex__(self): -33 33 | ... -34 34 | -35 |- def __int__(self): - 35 |+ def __int__(self) -> int: -36 36 | ... -37 37 | -38 38 | def __float__(self): simple_magic_methods.py:38:9: ANN204 [*] Missing return type annotation for special method `__float__` | @@ -248,15 +142,6 @@ simple_magic_methods.py:38:9: ANN204 [*] Missing return type annotation for spec | = help: Add return type annotation: `float` -ℹ Unsafe fix -35 35 | def __int__(self): -36 36 | ... -37 37 | -38 |- def __float__(self): - 38 |+ def __float__(self) -> float: -39 39 | ... -40 40 | -41 41 | def __index__(self): simple_magic_methods.py:41:9: ANN204 [*] Missing return type annotation for special method `__index__` | @@ -267,13 +152,3 @@ simple_magic_methods.py:41:9: ANN204 [*] Missing return type annotation for spec 42 | ... | = help: Add return type annotation: `int` - -ℹ Unsafe fix -38 38 | def __float__(self): -39 39 | ... -40 40 | -41 |- def __index__(self): - 41 |+ def __index__(self) -> int: -42 42 | ... - - diff --git a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__suppress_none_returning.snap b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__suppress_none_returning.snap index 07d875aa50649..1245be261340a 100644 --- a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__suppress_none_returning.snap +++ b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__suppress_none_returning.snap @@ -10,15 +10,6 @@ suppress_none_returning.py:45:5: ANN201 [*] Missing return type annotation for p | = help: Add return type annotation: `bool` -ℹ Unsafe fix -42 42 | -43 43 | -44 44 | # Error -45 |-def foo(): - 45 |+def foo() -> bool: -46 46 | return True -47 47 | -48 48 | suppress_none_returning.py:50:5: ANN201 [*] Missing return type annotation for public function `foo` | @@ -30,15 +21,6 @@ suppress_none_returning.py:50:5: ANN201 [*] Missing return type annotation for p | = help: Add return type annotation: `bool | None` -ℹ Unsafe fix -47 47 | -48 48 | -49 49 | # Error -50 |-def foo(): - 50 |+def foo() -> bool | None: -51 51 | a = 2 + 2 -52 52 | if a == 4: -53 53 | return True suppress_none_returning.py:59:9: ANN001 Missing type annotation for function argument `a` | @@ -47,5 +29,3 @@ suppress_none_returning.py:59:9: ANN001 Missing type annotation for function arg | ^ ANN001 60 | a = 2 + 2 | - - diff --git a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC105_ASYNC105.py.snap b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC105_ASYNC105.py.snap index 1595cdc008549..2006488826278 100644 --- a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC105_ASYNC105.py.snap +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC105_ASYNC105.py.snap @@ -11,15 +11,6 @@ ASYNC105.py:30:5: ASYNC105 [*] Call to `trio.aclose_forcefully` is not immediate | = help: Add `await` -ℹ Unsafe fix -27 27 | await trio.lowlevel.wait_writable(foo) -28 28 | -29 29 | # ASYNC105 -30 |- trio.aclose_forcefully(foo) - 30 |+ await trio.aclose_forcefully(foo) -31 31 | trio.open_file(foo) -32 32 | trio.open_ssl_over_tcp_listeners(foo, foo) -33 33 | trio.open_ssl_over_tcp_stream(foo, foo) ASYNC105.py:31:5: ASYNC105 [*] Call to `trio.open_file` is not immediately awaited | @@ -32,15 +23,6 @@ ASYNC105.py:31:5: ASYNC105 [*] Call to `trio.open_file` is not immediately await | = help: Add `await` -ℹ Unsafe fix -28 28 | -29 29 | # ASYNC105 -30 30 | trio.aclose_forcefully(foo) -31 |- trio.open_file(foo) - 31 |+ await trio.open_file(foo) -32 32 | trio.open_ssl_over_tcp_listeners(foo, foo) -33 33 | trio.open_ssl_over_tcp_stream(foo, foo) -34 34 | trio.open_tcp_listeners(foo) ASYNC105.py:32:5: ASYNC105 [*] Call to `trio.open_ssl_over_tcp_listeners` is not immediately awaited | @@ -53,15 +35,6 @@ ASYNC105.py:32:5: ASYNC105 [*] Call to `trio.open_ssl_over_tcp_listeners` is not | = help: Add `await` -ℹ Unsafe fix -29 29 | # ASYNC105 -30 30 | trio.aclose_forcefully(foo) -31 31 | trio.open_file(foo) -32 |- trio.open_ssl_over_tcp_listeners(foo, foo) - 32 |+ await trio.open_ssl_over_tcp_listeners(foo, foo) -33 33 | trio.open_ssl_over_tcp_stream(foo, foo) -34 34 | trio.open_tcp_listeners(foo) -35 35 | trio.open_tcp_stream(foo, foo) ASYNC105.py:33:5: ASYNC105 [*] Call to `trio.open_ssl_over_tcp_stream` is not immediately awaited | @@ -74,15 +47,6 @@ ASYNC105.py:33:5: ASYNC105 [*] Call to `trio.open_ssl_over_tcp_stream` is not im | = help: Add `await` -ℹ Unsafe fix -30 30 | trio.aclose_forcefully(foo) -31 31 | trio.open_file(foo) -32 32 | trio.open_ssl_over_tcp_listeners(foo, foo) -33 |- trio.open_ssl_over_tcp_stream(foo, foo) - 33 |+ await trio.open_ssl_over_tcp_stream(foo, foo) -34 34 | trio.open_tcp_listeners(foo) -35 35 | trio.open_tcp_stream(foo, foo) -36 36 | trio.open_unix_socket(foo) ASYNC105.py:34:5: ASYNC105 [*] Call to `trio.open_tcp_listeners` is not immediately awaited | @@ -95,15 +59,6 @@ ASYNC105.py:34:5: ASYNC105 [*] Call to `trio.open_tcp_listeners` is not immediat | = help: Add `await` -ℹ Unsafe fix -31 31 | trio.open_file(foo) -32 32 | trio.open_ssl_over_tcp_listeners(foo, foo) -33 33 | trio.open_ssl_over_tcp_stream(foo, foo) -34 |- trio.open_tcp_listeners(foo) - 34 |+ await trio.open_tcp_listeners(foo) -35 35 | trio.open_tcp_stream(foo, foo) -36 36 | trio.open_unix_socket(foo) -37 37 | trio.run_process(foo) ASYNC105.py:35:5: ASYNC105 [*] Call to `trio.open_tcp_stream` is not immediately awaited | @@ -116,15 +71,6 @@ ASYNC105.py:35:5: ASYNC105 [*] Call to `trio.open_tcp_stream` is not immediately | = help: Add `await` -ℹ Unsafe fix -32 32 | trio.open_ssl_over_tcp_listeners(foo, foo) -33 33 | trio.open_ssl_over_tcp_stream(foo, foo) -34 34 | trio.open_tcp_listeners(foo) -35 |- trio.open_tcp_stream(foo, foo) - 35 |+ await trio.open_tcp_stream(foo, foo) -36 36 | trio.open_unix_socket(foo) -37 37 | trio.run_process(foo) -38 38 | trio.serve_listeners(foo, foo) ASYNC105.py:36:5: ASYNC105 [*] Call to `trio.open_unix_socket` is not immediately awaited | @@ -137,15 +83,6 @@ ASYNC105.py:36:5: ASYNC105 [*] Call to `trio.open_unix_socket` is not immediatel | = help: Add `await` -ℹ Unsafe fix -33 33 | trio.open_ssl_over_tcp_stream(foo, foo) -34 34 | trio.open_tcp_listeners(foo) -35 35 | trio.open_tcp_stream(foo, foo) -36 |- trio.open_unix_socket(foo) - 36 |+ await trio.open_unix_socket(foo) -37 37 | trio.run_process(foo) -38 38 | trio.serve_listeners(foo, foo) -39 39 | trio.serve_ssl_over_tcp(foo, foo, foo) ASYNC105.py:37:5: ASYNC105 [*] Call to `trio.run_process` is not immediately awaited | @@ -158,15 +95,6 @@ ASYNC105.py:37:5: ASYNC105 [*] Call to `trio.run_process` is not immediately awa | = help: Add `await` -ℹ Unsafe fix -34 34 | trio.open_tcp_listeners(foo) -35 35 | trio.open_tcp_stream(foo, foo) -36 36 | trio.open_unix_socket(foo) -37 |- trio.run_process(foo) - 37 |+ await trio.run_process(foo) -38 38 | trio.serve_listeners(foo, foo) -39 39 | trio.serve_ssl_over_tcp(foo, foo, foo) -40 40 | trio.serve_tcp(foo, foo) ASYNC105.py:38:5: ASYNC105 [*] Call to `trio.serve_listeners` is not immediately awaited | @@ -179,15 +107,6 @@ ASYNC105.py:38:5: ASYNC105 [*] Call to `trio.serve_listeners` is not immediately | = help: Add `await` -ℹ Unsafe fix -35 35 | trio.open_tcp_stream(foo, foo) -36 36 | trio.open_unix_socket(foo) -37 37 | trio.run_process(foo) -38 |- trio.serve_listeners(foo, foo) - 38 |+ await trio.serve_listeners(foo, foo) -39 39 | trio.serve_ssl_over_tcp(foo, foo, foo) -40 40 | trio.serve_tcp(foo, foo) -41 41 | trio.sleep(foo) ASYNC105.py:39:5: ASYNC105 [*] Call to `trio.serve_ssl_over_tcp` is not immediately awaited | @@ -200,15 +119,6 @@ ASYNC105.py:39:5: ASYNC105 [*] Call to `trio.serve_ssl_over_tcp` is not immediat | = help: Add `await` -ℹ Unsafe fix -36 36 | trio.open_unix_socket(foo) -37 37 | trio.run_process(foo) -38 38 | trio.serve_listeners(foo, foo) -39 |- trio.serve_ssl_over_tcp(foo, foo, foo) - 39 |+ await trio.serve_ssl_over_tcp(foo, foo, foo) -40 40 | trio.serve_tcp(foo, foo) -41 41 | trio.sleep(foo) -42 42 | trio.sleep_forever() ASYNC105.py:40:5: ASYNC105 [*] Call to `trio.serve_tcp` is not immediately awaited | @@ -221,15 +131,6 @@ ASYNC105.py:40:5: ASYNC105 [*] Call to `trio.serve_tcp` is not immediately await | = help: Add `await` -ℹ Unsafe fix -37 37 | trio.run_process(foo) -38 38 | trio.serve_listeners(foo, foo) -39 39 | trio.serve_ssl_over_tcp(foo, foo, foo) -40 |- trio.serve_tcp(foo, foo) - 40 |+ await trio.serve_tcp(foo, foo) -41 41 | trio.sleep(foo) -42 42 | trio.sleep_forever() -43 43 | trio.sleep_until(foo) ASYNC105.py:41:5: ASYNC105 [*] Call to `trio.sleep` is not immediately awaited | @@ -242,15 +143,6 @@ ASYNC105.py:41:5: ASYNC105 [*] Call to `trio.sleep` is not immediately awaited | = help: Add `await` -ℹ Unsafe fix -38 38 | trio.serve_listeners(foo, foo) -39 39 | trio.serve_ssl_over_tcp(foo, foo, foo) -40 40 | trio.serve_tcp(foo, foo) -41 |- trio.sleep(foo) - 41 |+ await trio.sleep(foo) -42 42 | trio.sleep_forever() -43 43 | trio.sleep_until(foo) -44 44 | trio.lowlevel.cancel_shielded_checkpoint() ASYNC105.py:42:5: ASYNC105 [*] Call to `trio.sleep_forever` is not immediately awaited | @@ -263,15 +155,6 @@ ASYNC105.py:42:5: ASYNC105 [*] Call to `trio.sleep_forever` is not immediately a | = help: Add `await` -ℹ Unsafe fix -39 39 | trio.serve_ssl_over_tcp(foo, foo, foo) -40 40 | trio.serve_tcp(foo, foo) -41 41 | trio.sleep(foo) -42 |- trio.sleep_forever() - 42 |+ await trio.sleep_forever() -43 43 | trio.sleep_until(foo) -44 44 | trio.lowlevel.cancel_shielded_checkpoint() -45 45 | trio.lowlevel.checkpoint() ASYNC105.py:44:5: ASYNC105 [*] Call to `trio.lowlevel.cancel_shielded_checkpoint` is not immediately awaited | @@ -284,15 +167,6 @@ ASYNC105.py:44:5: ASYNC105 [*] Call to `trio.lowlevel.cancel_shielded_checkpoint | = help: Add `await` -ℹ Unsafe fix -41 41 | trio.sleep(foo) -42 42 | trio.sleep_forever() -43 43 | trio.sleep_until(foo) -44 |- trio.lowlevel.cancel_shielded_checkpoint() - 44 |+ await trio.lowlevel.cancel_shielded_checkpoint() -45 45 | trio.lowlevel.checkpoint() -46 46 | trio.lowlevel.checkpoint_if_cancelled() -47 47 | trio.lowlevel.open_process() ASYNC105.py:45:5: ASYNC105 [*] Call to `trio.lowlevel.checkpoint` is not immediately awaited | @@ -305,15 +179,6 @@ ASYNC105.py:45:5: ASYNC105 [*] Call to `trio.lowlevel.checkpoint` is not immedia | = help: Add `await` -ℹ Unsafe fix -42 42 | trio.sleep_forever() -43 43 | trio.sleep_until(foo) -44 44 | trio.lowlevel.cancel_shielded_checkpoint() -45 |- trio.lowlevel.checkpoint() - 45 |+ await trio.lowlevel.checkpoint() -46 46 | trio.lowlevel.checkpoint_if_cancelled() -47 47 | trio.lowlevel.open_process() -48 48 | trio.lowlevel.permanently_detach_coroutine_object(foo) ASYNC105.py:46:5: ASYNC105 [*] Call to `trio.lowlevel.checkpoint_if_cancelled` is not immediately awaited | @@ -326,15 +191,6 @@ ASYNC105.py:46:5: ASYNC105 [*] Call to `trio.lowlevel.checkpoint_if_cancelled` i | = help: Add `await` -ℹ Unsafe fix -43 43 | trio.sleep_until(foo) -44 44 | trio.lowlevel.cancel_shielded_checkpoint() -45 45 | trio.lowlevel.checkpoint() -46 |- trio.lowlevel.checkpoint_if_cancelled() - 46 |+ await trio.lowlevel.checkpoint_if_cancelled() -47 47 | trio.lowlevel.open_process() -48 48 | trio.lowlevel.permanently_detach_coroutine_object(foo) -49 49 | trio.lowlevel.reattach_detached_coroutine_object(foo, foo) ASYNC105.py:47:5: ASYNC105 [*] Call to `trio.lowlevel.open_process` is not immediately awaited | @@ -347,15 +203,6 @@ ASYNC105.py:47:5: ASYNC105 [*] Call to `trio.lowlevel.open_process` is not immed | = help: Add `await` -ℹ Unsafe fix -44 44 | trio.lowlevel.cancel_shielded_checkpoint() -45 45 | trio.lowlevel.checkpoint() -46 46 | trio.lowlevel.checkpoint_if_cancelled() -47 |- trio.lowlevel.open_process() - 47 |+ await trio.lowlevel.open_process() -48 48 | trio.lowlevel.permanently_detach_coroutine_object(foo) -49 49 | trio.lowlevel.reattach_detached_coroutine_object(foo, foo) -50 50 | trio.lowlevel.temporarily_detach_coroutine_object(foo) ASYNC105.py:48:5: ASYNC105 [*] Call to `trio.lowlevel.permanently_detach_coroutine_object` is not immediately awaited | @@ -368,15 +215,6 @@ ASYNC105.py:48:5: ASYNC105 [*] Call to `trio.lowlevel.permanently_detach_corouti | = help: Add `await` -ℹ Unsafe fix -45 45 | trio.lowlevel.checkpoint() -46 46 | trio.lowlevel.checkpoint_if_cancelled() -47 47 | trio.lowlevel.open_process() -48 |- trio.lowlevel.permanently_detach_coroutine_object(foo) - 48 |+ await trio.lowlevel.permanently_detach_coroutine_object(foo) -49 49 | trio.lowlevel.reattach_detached_coroutine_object(foo, foo) -50 50 | trio.lowlevel.temporarily_detach_coroutine_object(foo) -51 51 | trio.lowlevel.wait_readable(foo) ASYNC105.py:49:5: ASYNC105 [*] Call to `trio.lowlevel.reattach_detached_coroutine_object` is not immediately awaited | @@ -389,15 +227,6 @@ ASYNC105.py:49:5: ASYNC105 [*] Call to `trio.lowlevel.reattach_detached_coroutin | = help: Add `await` -ℹ Unsafe fix -46 46 | trio.lowlevel.checkpoint_if_cancelled() -47 47 | trio.lowlevel.open_process() -48 48 | trio.lowlevel.permanently_detach_coroutine_object(foo) -49 |- trio.lowlevel.reattach_detached_coroutine_object(foo, foo) - 49 |+ await trio.lowlevel.reattach_detached_coroutine_object(foo, foo) -50 50 | trio.lowlevel.temporarily_detach_coroutine_object(foo) -51 51 | trio.lowlevel.wait_readable(foo) -52 52 | trio.lowlevel.wait_task_rescheduled(foo) ASYNC105.py:50:5: ASYNC105 [*] Call to `trio.lowlevel.temporarily_detach_coroutine_object` is not immediately awaited | @@ -410,15 +239,6 @@ ASYNC105.py:50:5: ASYNC105 [*] Call to `trio.lowlevel.temporarily_detach_corouti | = help: Add `await` -ℹ Unsafe fix -47 47 | trio.lowlevel.open_process() -48 48 | trio.lowlevel.permanently_detach_coroutine_object(foo) -49 49 | trio.lowlevel.reattach_detached_coroutine_object(foo, foo) -50 |- trio.lowlevel.temporarily_detach_coroutine_object(foo) - 50 |+ await trio.lowlevel.temporarily_detach_coroutine_object(foo) -51 51 | trio.lowlevel.wait_readable(foo) -52 52 | trio.lowlevel.wait_task_rescheduled(foo) -53 53 | trio.lowlevel.wait_writable(foo) ASYNC105.py:51:5: ASYNC105 [*] Call to `trio.lowlevel.wait_readable` is not immediately awaited | @@ -431,15 +251,6 @@ ASYNC105.py:51:5: ASYNC105 [*] Call to `trio.lowlevel.wait_readable` is not imme | = help: Add `await` -ℹ Unsafe fix -48 48 | trio.lowlevel.permanently_detach_coroutine_object(foo) -49 49 | trio.lowlevel.reattach_detached_coroutine_object(foo, foo) -50 50 | trio.lowlevel.temporarily_detach_coroutine_object(foo) -51 |- trio.lowlevel.wait_readable(foo) - 51 |+ await trio.lowlevel.wait_readable(foo) -52 52 | trio.lowlevel.wait_task_rescheduled(foo) -53 53 | trio.lowlevel.wait_writable(foo) -54 54 | ASYNC105.py:52:5: ASYNC105 [*] Call to `trio.lowlevel.wait_task_rescheduled` is not immediately awaited | @@ -451,15 +262,6 @@ ASYNC105.py:52:5: ASYNC105 [*] Call to `trio.lowlevel.wait_task_rescheduled` is | = help: Add `await` -ℹ Unsafe fix -49 49 | trio.lowlevel.reattach_detached_coroutine_object(foo, foo) -50 50 | trio.lowlevel.temporarily_detach_coroutine_object(foo) -51 51 | trio.lowlevel.wait_readable(foo) -52 |- trio.lowlevel.wait_task_rescheduled(foo) - 52 |+ await trio.lowlevel.wait_task_rescheduled(foo) -53 53 | trio.lowlevel.wait_writable(foo) -54 54 | -55 55 | async with await trio.open_file(foo): # Ok ASYNC105.py:53:5: ASYNC105 [*] Call to `trio.lowlevel.wait_writable` is not immediately awaited | @@ -472,15 +274,6 @@ ASYNC105.py:53:5: ASYNC105 [*] Call to `trio.lowlevel.wait_writable` is not imme | = help: Add `await` -ℹ Unsafe fix -50 50 | trio.lowlevel.temporarily_detach_coroutine_object(foo) -51 51 | trio.lowlevel.wait_readable(foo) -52 52 | trio.lowlevel.wait_task_rescheduled(foo) -53 |- trio.lowlevel.wait_writable(foo) - 53 |+ await trio.lowlevel.wait_writable(foo) -54 54 | -55 55 | async with await trio.open_file(foo): # Ok -56 56 | pass ASYNC105.py:58:16: ASYNC105 [*] Call to `trio.open_file` is not immediately awaited | @@ -492,15 +285,6 @@ ASYNC105.py:58:16: ASYNC105 [*] Call to `trio.open_file` is not immediately awai | = help: Add `await` -ℹ Unsafe fix -55 55 | async with await trio.open_file(foo): # Ok -56 56 | pass -57 57 | -58 |- async with trio.open_file(foo): # ASYNC105 - 58 |+ async with await trio.open_file(foo): # ASYNC105 -59 59 | pass -60 60 | -61 61 | ASYNC105.py:64:5: ASYNC105 Call to `trio.open_file` is not immediately awaited | diff --git a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC115_ASYNC115.py.snap b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC115_ASYNC115.py.snap index 71d341d400af1..1c03be15c47b0 100644 --- a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC115_ASYNC115.py.snap +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC115_ASYNC115.py.snap @@ -12,7 +12,6 @@ ASYNC115.py:5:11: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio | = help: Replace with `trio.lowlevel.checkpoint()` -ℹ Safe fix 2 2 | import trio 3 3 | from trio import sleep 4 4 | @@ -33,7 +32,6 @@ ASYNC115.py:11:5: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio | = help: Replace with `trio.lowlevel.checkpoint()` -ℹ Safe fix 8 8 | await trio.sleep(...) # OK 9 9 | await trio.sleep() # OK 10 10 | @@ -54,7 +52,6 @@ ASYNC115.py:17:5: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio | = help: Replace with `trio.lowlevel.checkpoint()` -ℹ Safe fix 14 14 | trio.sleep(1) # OK 15 15 | time.sleep(0) # OK 16 16 | @@ -73,7 +70,6 @@ ASYNC115.py:48:14: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `tri | = help: Replace with `trio.lowlevel.checkpoint()` -ℹ Safe fix 45 45 | def func(): 46 46 | import trio 47 47 | @@ -91,7 +87,6 @@ ASYNC115.py:55:5: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio | = help: Replace with `trio.lowlevel.checkpoint()` -ℹ Safe fix 48 48 | trio.run(trio.sleep(0)) # ASYNC115 49 49 | 50 50 | @@ -114,7 +109,6 @@ ASYNC115.py:59:11: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `tri | = help: Replace with `trio.lowlevel.checkpoint()` -ℹ Safe fix 48 48 | trio.run(trio.sleep(0)) # ASYNC115 49 49 | 50 50 | diff --git a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC116_ASYNC116.py.snap b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC116_ASYNC116.py.snap index 83b6209e1dfd1..cbeadf9386794 100644 --- a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC116_ASYNC116.py.snap +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC116_ASYNC116.py.snap @@ -11,15 +11,6 @@ ASYNC116.py:11:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usu | = help: Replace with `trio.sleep_forever()` -ℹ Unsafe fix -8 8 | import trio -9 9 | -10 10 | # These examples are probably not meant to ever wake up: -11 |- await trio.sleep(100000) # error: 116, "async" - 11 |+ await trio.sleep_forever() # error: 116, "async" -12 12 | -13 13 | # 'inf literal' overflow trick -14 14 | await trio.sleep(1e999) # error: 116, "async" ASYNC116.py:14:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` | @@ -31,15 +22,6 @@ ASYNC116.py:14:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usu | = help: Replace with `trio.sleep_forever()` -ℹ Unsafe fix -11 11 | await trio.sleep(100000) # error: 116, "async" -12 12 | -13 13 | # 'inf literal' overflow trick -14 |- await trio.sleep(1e999) # error: 116, "async" - 14 |+ await trio.sleep_forever() # error: 116, "async" -15 15 | -16 16 | await trio.sleep(86399) -17 17 | await trio.sleep(86400) ASYNC116.py:18:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` | @@ -51,15 +33,6 @@ ASYNC116.py:18:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usu | = help: Replace with `trio.sleep_forever()` -ℹ Unsafe fix -15 15 | -16 16 | await trio.sleep(86399) -17 17 | await trio.sleep(86400) -18 |- await trio.sleep(86400.01) # error: 116, "async" - 18 |+ await trio.sleep_forever() # error: 116, "async" -19 19 | await trio.sleep(86401) # error: 116, "async" -20 20 | -21 21 | await trio.sleep(-1) # will raise a runtime error ASYNC116.py:19:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` | @@ -72,15 +45,6 @@ ASYNC116.py:19:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usu | = help: Replace with `trio.sleep_forever()` -ℹ Unsafe fix -16 16 | await trio.sleep(86399) -17 17 | await trio.sleep(86400) -18 18 | await trio.sleep(86400.01) # error: 116, "async" -19 |- await trio.sleep(86401) # error: 116, "async" - 19 |+ await trio.sleep_forever() # error: 116, "async" -20 20 | -21 21 | await trio.sleep(-1) # will raise a runtime error -22 22 | await trio.sleep(0) # handled by different check ASYNC116.py:48:5: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` | @@ -92,15 +56,6 @@ ASYNC116.py:48:5: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usua | = help: Replace with `trio.sleep_forever()` -ℹ Unsafe fix -45 45 | import trio -46 46 | -47 47 | # does not require the call to be awaited, nor in an async fun -48 |- trio.sleep(86401) # error: 116, "async" - 48 |+ trio.sleep_forever() # error: 116, "async" -49 49 | # also checks that we don't break visit_Call -50 50 | trio.run(trio.sleep(86401)) # error: 116, "async" -51 51 | ASYNC116.py:50:14: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` | @@ -111,15 +66,6 @@ ASYNC116.py:50:14: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usu | = help: Replace with `trio.sleep_forever()` -ℹ Unsafe fix -47 47 | # does not require the call to be awaited, nor in an async fun -48 48 | trio.sleep(86401) # error: 116, "async" -49 49 | # also checks that we don't break visit_Call -50 |- trio.run(trio.sleep(86401)) # error: 116, "async" - 50 |+ trio.run(trio.sleep_forever()) # error: 116, "async" -51 51 | -52 52 | -53 53 | async def import_from_trio(): ASYNC116.py:57:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` | @@ -128,21 +74,3 @@ ASYNC116.py:57:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usu | ^^^^^^^^^^^^ ASYNC116 | = help: Replace with `trio.sleep_forever()` - -ℹ Unsafe fix -2 2 | # ASYNCIO_NO_ERROR - no asyncio.sleep_forever, so check intentionally doesn't trigger. -3 3 | import math -4 4 | from math import inf - 5 |+from trio import sleep_forever -5 6 | -6 7 | -7 8 | async def import_trio(): --------------------------------------------------------------------------------- -54 55 | from trio import sleep -55 56 | -56 57 | # catch from import -57 |- await sleep(86401) # error: 116, "async" - 58 |+ await sleep_forever() # error: 116, "async" -58 59 | -59 60 | -60 61 | async def import_anyio(): diff --git a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__preview__ASYNC115_ASYNC115.py.snap b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__preview__ASYNC115_ASYNC115.py.snap index 3e40da955dd3e..c60b9de90e2f4 100644 --- a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__preview__ASYNC115_ASYNC115.py.snap +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__preview__ASYNC115_ASYNC115.py.snap @@ -12,7 +12,6 @@ ASYNC115.py:5:11: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio | = help: Replace with `trio.lowlevel.checkpoint()` -ℹ Safe fix 2 2 | import trio 3 3 | from trio import sleep 4 4 | @@ -33,7 +32,6 @@ ASYNC115.py:11:5: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio | = help: Replace with `trio.lowlevel.checkpoint()` -ℹ Safe fix 8 8 | await trio.sleep(...) # OK 9 9 | await trio.sleep() # OK 10 10 | @@ -54,7 +52,6 @@ ASYNC115.py:17:5: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio | = help: Replace with `trio.lowlevel.checkpoint()` -ℹ Safe fix 14 14 | trio.sleep(1) # OK 15 15 | time.sleep(0) # OK 16 16 | @@ -73,7 +70,6 @@ ASYNC115.py:48:14: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `tri | = help: Replace with `trio.lowlevel.checkpoint()` -ℹ Safe fix 45 45 | def func(): 46 46 | import trio 47 47 | @@ -91,7 +87,6 @@ ASYNC115.py:55:5: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio | = help: Replace with `trio.lowlevel.checkpoint()` -ℹ Safe fix 48 48 | trio.run(trio.sleep(0)) # ASYNC115 49 49 | 50 50 | @@ -114,7 +109,6 @@ ASYNC115.py:59:11: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `tri | = help: Replace with `trio.lowlevel.checkpoint()` -ℹ Safe fix 48 48 | trio.run(trio.sleep(0)) # ASYNC115 49 49 | 50 50 | @@ -144,7 +138,6 @@ ASYNC115.py:85:11: ASYNC115 [*] Use `asyncio.lowlevel.checkpoint()` instead of ` | = help: Replace with `asyncio.lowlevel.checkpoint()` -ℹ Safe fix 49 49 | 50 50 | 51 51 | from trio import Event, sleep @@ -173,7 +166,6 @@ ASYNC115.py:91:5: ASYNC115 [*] Use `asyncio.lowlevel.checkpoint()` instead of `a | = help: Replace with `asyncio.lowlevel.checkpoint()` -ℹ Safe fix 49 49 | 50 50 | 51 51 | from trio import Event, sleep @@ -202,7 +194,6 @@ ASYNC115.py:97:5: ASYNC115 [*] Use `asyncio.lowlevel.checkpoint()` instead of `a | = help: Replace with `asyncio.lowlevel.checkpoint()` -ℹ Safe fix 49 49 | 50 50 | 51 51 | from trio import Event, sleep @@ -229,7 +220,6 @@ ASYNC115.py:128:15: ASYNC115 [*] Use `asyncio.lowlevel.checkpoint()` instead of | = help: Replace with `asyncio.lowlevel.checkpoint()` -ℹ Safe fix 49 49 | 50 50 | 51 51 | from trio import Event, sleep diff --git a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__preview__ASYNC116_ASYNC116.py.snap b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__preview__ASYNC116_ASYNC116.py.snap index 3421bd0105a7d..0fcc8aee96f53 100644 --- a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__preview__ASYNC116_ASYNC116.py.snap +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__preview__ASYNC116_ASYNC116.py.snap @@ -11,15 +11,6 @@ ASYNC116.py:11:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usu | = help: Replace with `trio.sleep_forever()` -ℹ Unsafe fix -8 8 | import trio -9 9 | -10 10 | # These examples are probably not meant to ever wake up: -11 |- await trio.sleep(100000) # error: 116, "async" - 11 |+ await trio.sleep_forever() # error: 116, "async" -12 12 | -13 13 | # 'inf literal' overflow trick -14 14 | await trio.sleep(1e999) # error: 116, "async" ASYNC116.py:14:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` | @@ -31,15 +22,6 @@ ASYNC116.py:14:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usu | = help: Replace with `trio.sleep_forever()` -ℹ Unsafe fix -11 11 | await trio.sleep(100000) # error: 116, "async" -12 12 | -13 13 | # 'inf literal' overflow trick -14 |- await trio.sleep(1e999) # error: 116, "async" - 14 |+ await trio.sleep_forever() # error: 116, "async" -15 15 | -16 16 | await trio.sleep(86399) -17 17 | await trio.sleep(86400) ASYNC116.py:18:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` | @@ -51,15 +33,6 @@ ASYNC116.py:18:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usu | = help: Replace with `trio.sleep_forever()` -ℹ Unsafe fix -15 15 | -16 16 | await trio.sleep(86399) -17 17 | await trio.sleep(86400) -18 |- await trio.sleep(86400.01) # error: 116, "async" - 18 |+ await trio.sleep_forever() # error: 116, "async" -19 19 | await trio.sleep(86401) # error: 116, "async" -20 20 | -21 21 | await trio.sleep(-1) # will raise a runtime error ASYNC116.py:19:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` | @@ -72,15 +45,6 @@ ASYNC116.py:19:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usu | = help: Replace with `trio.sleep_forever()` -ℹ Unsafe fix -16 16 | await trio.sleep(86399) -17 17 | await trio.sleep(86400) -18 18 | await trio.sleep(86400.01) # error: 116, "async" -19 |- await trio.sleep(86401) # error: 116, "async" - 19 |+ await trio.sleep_forever() # error: 116, "async" -20 20 | -21 21 | await trio.sleep(-1) # will raise a runtime error -22 22 | await trio.sleep(0) # handled by different check ASYNC116.py:48:5: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` | @@ -92,15 +56,6 @@ ASYNC116.py:48:5: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usua | = help: Replace with `trio.sleep_forever()` -ℹ Unsafe fix -45 45 | import trio -46 46 | -47 47 | # does not require the call to be awaited, nor in an async fun -48 |- trio.sleep(86401) # error: 116, "async" - 48 |+ trio.sleep_forever() # error: 116, "async" -49 49 | # also checks that we don't break visit_Call -50 50 | trio.run(trio.sleep(86401)) # error: 116, "async" -51 51 | ASYNC116.py:50:14: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` | @@ -111,15 +66,6 @@ ASYNC116.py:50:14: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usu | = help: Replace with `trio.sleep_forever()` -ℹ Unsafe fix -47 47 | # does not require the call to be awaited, nor in an async fun -48 48 | trio.sleep(86401) # error: 116, "async" -49 49 | # also checks that we don't break visit_Call -50 |- trio.run(trio.sleep(86401)) # error: 116, "async" - 50 |+ trio.run(trio.sleep_forever()) # error: 116, "async" -51 51 | -52 52 | -53 53 | async def import_from_trio(): ASYNC116.py:57:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` | @@ -129,23 +75,6 @@ ASYNC116.py:57:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usu | = help: Replace with `trio.sleep_forever()` -ℹ Unsafe fix -2 2 | # ASYNCIO_NO_ERROR - no asyncio.sleep_forever, so check intentionally doesn't trigger. -3 3 | import math -4 4 | from math import inf - 5 |+from trio import sleep_forever -5 6 | -6 7 | -7 8 | async def import_trio(): --------------------------------------------------------------------------------- -54 55 | from trio import sleep -55 56 | -56 57 | # catch from import -57 |- await sleep(86401) # error: 116, "async" - 58 |+ await sleep_forever() # error: 116, "async" -58 59 | -59 60 | -60 61 | async def import_anyio(): ASYNC116.py:64:11: ASYNC116 [*] `asyncio.sleep()` with >24 hour interval should usually be `asyncio.sleep_forever()` | @@ -157,23 +86,6 @@ ASYNC116.py:64:11: ASYNC116 [*] `asyncio.sleep()` with >24 hour interval should | = help: Replace with `asyncio.sleep_forever()` -ℹ Unsafe fix -2 2 | # ASYNCIO_NO_ERROR - no asyncio.sleep_forever, so check intentionally doesn't trigger. -3 3 | import math -4 4 | from math import inf - 5 |+from asyncio import sleep_forever -5 6 | -6 7 | -7 8 | async def import_trio(): --------------------------------------------------------------------------------- -61 62 | import anyio -62 63 | -63 64 | # These examples are probably not meant to ever wake up: -64 |- await anyio.sleep(100000) # error: 116, "async" - 65 |+ await sleep_forever() # error: 116, "async" -65 66 | -66 67 | # 'inf literal' overflow trick -67 68 | await anyio.sleep(1e999) # error: 116, "async" ASYNC116.py:67:11: ASYNC116 [*] `asyncio.sleep()` with >24 hour interval should usually be `asyncio.sleep_forever()` | @@ -185,23 +97,6 @@ ASYNC116.py:67:11: ASYNC116 [*] `asyncio.sleep()` with >24 hour interval should | = help: Replace with `asyncio.sleep_forever()` -ℹ Unsafe fix -2 2 | # ASYNCIO_NO_ERROR - no asyncio.sleep_forever, so check intentionally doesn't trigger. -3 3 | import math -4 4 | from math import inf - 5 |+from asyncio import sleep_forever -5 6 | -6 7 | -7 8 | async def import_trio(): --------------------------------------------------------------------------------- -64 65 | await anyio.sleep(100000) # error: 116, "async" -65 66 | -66 67 | # 'inf literal' overflow trick -67 |- await anyio.sleep(1e999) # error: 116, "async" - 68 |+ await sleep_forever() # error: 116, "async" -68 69 | -69 70 | await anyio.sleep(86399) -70 71 | await anyio.sleep(86400) ASYNC116.py:71:11: ASYNC116 [*] `asyncio.sleep()` with >24 hour interval should usually be `asyncio.sleep_forever()` | @@ -213,23 +108,6 @@ ASYNC116.py:71:11: ASYNC116 [*] `asyncio.sleep()` with >24 hour interval should | = help: Replace with `asyncio.sleep_forever()` -ℹ Unsafe fix -2 2 | # ASYNCIO_NO_ERROR - no asyncio.sleep_forever, so check intentionally doesn't trigger. -3 3 | import math -4 4 | from math import inf - 5 |+from asyncio import sleep_forever -5 6 | -6 7 | -7 8 | async def import_trio(): --------------------------------------------------------------------------------- -68 69 | -69 70 | await anyio.sleep(86399) -70 71 | await anyio.sleep(86400) -71 |- await anyio.sleep(86400.01) # error: 116, "async" - 72 |+ await sleep_forever() # error: 116, "async" -72 73 | await anyio.sleep(86401) # error: 116, "async" -73 74 | -74 75 | await anyio.sleep(-1) # will raise a runtime error ASYNC116.py:72:11: ASYNC116 [*] `asyncio.sleep()` with >24 hour interval should usually be `asyncio.sleep_forever()` | @@ -242,23 +120,6 @@ ASYNC116.py:72:11: ASYNC116 [*] `asyncio.sleep()` with >24 hour interval should | = help: Replace with `asyncio.sleep_forever()` -ℹ Unsafe fix -2 2 | # ASYNCIO_NO_ERROR - no asyncio.sleep_forever, so check intentionally doesn't trigger. -3 3 | import math -4 4 | from math import inf - 5 |+from asyncio import sleep_forever -5 6 | -6 7 | -7 8 | async def import_trio(): --------------------------------------------------------------------------------- -69 70 | await anyio.sleep(86399) -70 71 | await anyio.sleep(86400) -71 72 | await anyio.sleep(86400.01) # error: 116, "async" -72 |- await anyio.sleep(86401) # error: 116, "async" - 73 |+ await sleep_forever() # error: 116, "async" -73 74 | -74 75 | await anyio.sleep(-1) # will raise a runtime error -75 76 | await anyio.sleep(0) # handled by different check ASYNC116.py:101:5: ASYNC116 [*] `asyncio.sleep()` with >24 hour interval should usually be `asyncio.sleep_forever()` | @@ -270,23 +131,6 @@ ASYNC116.py:101:5: ASYNC116 [*] `asyncio.sleep()` with >24 hour interval should | = help: Replace with `asyncio.sleep_forever()` -ℹ Unsafe fix -2 2 | # ASYNCIO_NO_ERROR - no asyncio.sleep_forever, so check intentionally doesn't trigger. -3 3 | import math -4 4 | from math import inf - 5 |+from asyncio import sleep_forever -5 6 | -6 7 | -7 8 | async def import_trio(): --------------------------------------------------------------------------------- -98 99 | import anyio -99 100 | -100 101 | # does not require the call to be awaited, nor in an async fun -101 |- anyio.sleep(86401) # error: 116, "async" - 102 |+ sleep_forever() # error: 116, "async" -102 103 | # also checks that we don't break visit_Call -103 104 | anyio.run(anyio.sleep(86401)) # error: 116, "async" -104 105 | ASYNC116.py:103:15: ASYNC116 [*] `asyncio.sleep()` with >24 hour interval should usually be `asyncio.sleep_forever()` | @@ -297,23 +141,6 @@ ASYNC116.py:103:15: ASYNC116 [*] `asyncio.sleep()` with >24 hour interval should | = help: Replace with `asyncio.sleep_forever()` -ℹ Unsafe fix -2 2 | # ASYNCIO_NO_ERROR - no asyncio.sleep_forever, so check intentionally doesn't trigger. -3 3 | import math -4 4 | from math import inf - 5 |+from asyncio import sleep_forever -5 6 | -6 7 | -7 8 | async def import_trio(): --------------------------------------------------------------------------------- -100 101 | # does not require the call to be awaited, nor in an async fun -101 102 | anyio.sleep(86401) # error: 116, "async" -102 103 | # also checks that we don't break visit_Call -103 |- anyio.run(anyio.sleep(86401)) # error: 116, "async" - 104 |+ anyio.run(sleep_forever()) # error: 116, "async" -104 105 | -105 106 | -106 107 | async def import_from_anyio(): ASYNC116.py:110:11: ASYNC116 [*] `asyncio.sleep()` with >24 hour interval should usually be `asyncio.sleep_forever()` | @@ -322,18 +149,3 @@ ASYNC116.py:110:11: ASYNC116 [*] `asyncio.sleep()` with >24 hour interval should | ^^^^^^^^^^^^ ASYNC116 | = help: Replace with `asyncio.sleep_forever()` - -ℹ Unsafe fix -2 2 | # ASYNCIO_NO_ERROR - no asyncio.sleep_forever, so check intentionally doesn't trigger. -3 3 | import math -4 4 | from math import inf - 5 |+from asyncio import sleep_forever -5 6 | -6 7 | -7 8 | async def import_trio(): --------------------------------------------------------------------------------- -107 108 | from anyio import sleep -108 109 | -109 110 | # catch from import -110 |- await sleep(86401) # error: 116, "async" - 111 |+ await sleep_forever() # error: 116, "async" diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B004_B004.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B004_B004.py.snap index da4177d024b9f..01071da0364b7 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B004_B004.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B004_B004.py.snap @@ -12,7 +12,6 @@ B004.py:3:8: B004 [*] Using `hasattr(x, "__call__")` to test if x is callable is | = help: Replace with `callable()` -ℹ Safe fix 1 1 | def this_is_a_bug(): 2 2 | o = object() 3 |- if hasattr(o, "__call__"): @@ -42,7 +41,6 @@ B004.py:12:8: B004 [*] Using `hasattr(x, "__call__")` to test if x is callable i | = help: Replace with `callable()` -ℹ Safe fix 9 9 | def still_a_bug(): 10 10 | import builtins 11 11 | o = object() @@ -72,7 +70,6 @@ B004.py:24:8: B004 [*] Using `hasattr(x, "__call__")` to test if x is callable i | = help: Replace with `callable()` -ℹ Safe fix 1 |+import builtins 1 2 | def this_is_a_bug(): 2 3 | o = object() diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_1.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_1.py.snap index 1456ef463102a..460c35027560b 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_1.py.snap @@ -11,11 +11,3 @@ B006_1.py:3:22: B006 [*] Do not use mutable data structures for argument default 5 | """ | = help: Replace with `None`; initialize within function - -ℹ Unsafe fix -1 1 | # Docstring followed by a newline -2 2 | -3 |-def foobar(foor, bar={}): - 3 |+def foobar(foor, bar=None): -4 4 | """ -5 5 | """ diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_2.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_2.py.snap index c050ac73b7212..26103aa42e38e 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_2.py.snap @@ -11,12 +11,3 @@ B006_2.py:4:22: B006 [*] Do not use mutable data structures for argument default 6 | """ | = help: Replace with `None`; initialize within function - -ℹ Unsafe fix -1 1 | # Docstring followed by whitespace with no newline -2 2 | # Regression test for https://github.com/astral-sh/ruff/issues/7155 -3 3 | -4 |-def foobar(foor, bar={}): - 4 |+def foobar(foor, bar=None): -5 5 | """ -6 6 | """ diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_3.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_3.py.snap index 583e51b5a7cd7..2fd83184d6f07 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_3.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_3.py.snap @@ -9,12 +9,3 @@ B006_3.py:4:22: B006 [*] Do not use mutable data structures for argument default 6 | """ | = help: Replace with `None`; initialize within function - -ℹ Unsafe fix -1 1 | # Docstring with no newline -2 2 | -3 3 | -4 |-def foobar(foor, bar={}): - 4 |+def foobar(foor, bar=None): -5 5 | """ -6 6 | """ diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_4.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_4.py.snap index 2494c15ac42ef..ecec719296ef1 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_4.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_4.py.snap @@ -9,16 +9,3 @@ B006_4.py:7:26: B006 [*] Do not use mutable data structures for argument default 8 | print(a) | = help: Replace with `None`; initialize within function - -ℹ Unsafe fix -4 4 | -5 5 | -6 6 | class FormFeedIndent: -7 |- def __init__(self, a=[]): - 7 |+ def __init__(self, a=None): - 8 |+ if a is None: - 9 |+ a = [] -8 10 | print(a) -9 11 | - - diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_5.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_5.py.snap index 24ad24f06b524..a191efa5d825f 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_5.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_5.py.snap @@ -9,18 +9,6 @@ B006_5.py:5:49: B006 [*] Do not use mutable data structures for argument default | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -2 2 | # https://github.com/astral-sh/ruff/issues/7616 -3 3 | -4 4 | -5 |-def import_module_wrong(value: dict[str, str] = {}): - 5 |+def import_module_wrong(value: dict[str, str] = None): -6 6 | import os - 7 |+ if value is None: - 8 |+ value = {} -7 9 | -8 10 | -9 11 | def import_module_with_values_wrong(value: dict[str, str] = {}): B006_5.py:9:61: B006 [*] Do not use mutable data structures for argument defaults | @@ -30,19 +18,6 @@ B006_5.py:9:61: B006 [*] Do not use mutable data structures for argument default | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -6 6 | import os -7 7 | -8 8 | -9 |-def import_module_with_values_wrong(value: dict[str, str] = {}): - 9 |+def import_module_with_values_wrong(value: dict[str, str] = None): -10 10 | import os -11 11 | - 12 |+ if value is None: - 13 |+ value = {} -12 14 | return 2 -13 15 | -14 16 | B006_5.py:15:50: B006 [*] Do not use mutable data structures for argument defaults | @@ -53,20 +28,6 @@ B006_5.py:15:50: B006 [*] Do not use mutable data structures for argument defaul | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -12 12 | return 2 -13 13 | -14 14 | -15 |-def import_modules_wrong(value: dict[str, str] = {}): - 15 |+def import_modules_wrong(value: dict[str, str] = None): -16 16 | import os -17 17 | import sys -18 18 | import itertools - 19 |+ if value is None: - 20 |+ value = {} -19 21 | -20 22 | -21 23 | def from_import_module_wrong(value: dict[str, str] = {}): B006_5.py:21:54: B006 [*] Do not use mutable data structures for argument defaults | @@ -76,18 +37,6 @@ B006_5.py:21:54: B006 [*] Do not use mutable data structures for argument defaul | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -18 18 | import itertools -19 19 | -20 20 | -21 |-def from_import_module_wrong(value: dict[str, str] = {}): - 21 |+def from_import_module_wrong(value: dict[str, str] = None): -22 22 | from os import path - 23 |+ if value is None: - 24 |+ value = {} -23 25 | -24 26 | -25 27 | def from_imports_module_wrong(value: dict[str, str] = {}): B006_5.py:25:55: B006 [*] Do not use mutable data structures for argument defaults | @@ -98,19 +47,6 @@ B006_5.py:25:55: B006 [*] Do not use mutable data structures for argument defaul | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -22 22 | from os import path -23 23 | -24 24 | -25 |-def from_imports_module_wrong(value: dict[str, str] = {}): - 25 |+def from_imports_module_wrong(value: dict[str, str] = None): -26 26 | from os import path -27 27 | from sys import version_info - 28 |+ if value is None: - 29 |+ value = {} -28 30 | -29 31 | -30 32 | def import_and_from_imports_module_wrong(value: dict[str, str] = {}): B006_5.py:30:66: B006 [*] Do not use mutable data structures for argument defaults | @@ -121,19 +57,6 @@ B006_5.py:30:66: B006 [*] Do not use mutable data structures for argument defaul | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -27 27 | from sys import version_info -28 28 | -29 29 | -30 |-def import_and_from_imports_module_wrong(value: dict[str, str] = {}): - 30 |+def import_and_from_imports_module_wrong(value: dict[str, str] = None): -31 31 | import os -32 32 | from sys import version_info - 33 |+ if value is None: - 34 |+ value = {} -33 35 | -34 36 | -35 37 | def import_docstring_module_wrong(value: dict[str, str] = {}): B006_5.py:35:59: B006 [*] Do not use mutable data structures for argument defaults | @@ -144,19 +67,6 @@ B006_5.py:35:59: B006 [*] Do not use mutable data structures for argument defaul | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -32 32 | from sys import version_info -33 33 | -34 34 | -35 |-def import_docstring_module_wrong(value: dict[str, str] = {}): - 35 |+def import_docstring_module_wrong(value: dict[str, str] = None): -36 36 | """Docstring""" -37 37 | import os - 38 |+ if value is None: - 39 |+ value = {} -38 40 | -39 41 | -40 42 | def import_module_wrong(value: dict[str, str] = {}): B006_5.py:40:49: B006 [*] Do not use mutable data structures for argument defaults | @@ -167,19 +77,6 @@ B006_5.py:40:49: B006 [*] Do not use mutable data structures for argument defaul | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -37 37 | import os -38 38 | -39 39 | -40 |-def import_module_wrong(value: dict[str, str] = {}): - 40 |+def import_module_wrong(value: dict[str, str] = None): -41 41 | """Docstring""" -42 42 | import os; import sys - 43 |+ if value is None: - 44 |+ value = {} -43 45 | -44 46 | -45 47 | def import_module_wrong(value: dict[str, str] = {}): B006_5.py:45:49: B006 [*] Do not use mutable data structures for argument defaults | @@ -190,18 +87,6 @@ B006_5.py:45:49: B006 [*] Do not use mutable data structures for argument defaul | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -42 42 | import os; import sys -43 43 | -44 44 | -45 |-def import_module_wrong(value: dict[str, str] = {}): - 45 |+def import_module_wrong(value: dict[str, str] = None): -46 46 | """Docstring""" - 47 |+ if value is None: - 48 |+ value = {} -47 49 | import os; import sys; x = 1 -48 50 | -49 51 | B006_5.py:50:49: B006 [*] Do not use mutable data structures for argument defaults | @@ -212,19 +97,6 @@ B006_5.py:50:49: B006 [*] Do not use mutable data structures for argument defaul | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -47 47 | import os; import sys; x = 1 -48 48 | -49 49 | -50 |-def import_module_wrong(value: dict[str, str] = {}): - 50 |+def import_module_wrong(value: dict[str, str] = None): -51 51 | """Docstring""" -52 52 | import os; import sys - 53 |+ if value is None: - 54 |+ value = {} -53 55 | -54 56 | -55 57 | def import_module_wrong(value: dict[str, str] = {}): B006_5.py:55:49: B006 [*] Do not use mutable data structures for argument defaults | @@ -234,18 +106,6 @@ B006_5.py:55:49: B006 [*] Do not use mutable data structures for argument defaul | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -52 52 | import os; import sys -53 53 | -54 54 | -55 |-def import_module_wrong(value: dict[str, str] = {}): - 55 |+def import_module_wrong(value: dict[str, str] = None): -56 56 | import os; import sys - 57 |+ if value is None: - 58 |+ value = {} -57 59 | -58 60 | -59 61 | def import_module_wrong(value: dict[str, str] = {}): B006_5.py:59:49: B006 [*] Do not use mutable data structures for argument defaults | @@ -255,17 +115,6 @@ B006_5.py:59:49: B006 [*] Do not use mutable data structures for argument defaul | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -56 56 | import os; import sys -57 57 | -58 58 | -59 |-def import_module_wrong(value: dict[str, str] = {}): - 59 |+def import_module_wrong(value: dict[str, str] = None): - 60 |+ if value is None: - 61 |+ value = {} -60 62 | import os; import sys; x = 1 -61 63 | -62 64 | B006_5.py:63:49: B006 [*] Do not use mutable data structures for argument defaults | @@ -275,18 +124,6 @@ B006_5.py:63:49: B006 [*] Do not use mutable data structures for argument defaul | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -60 60 | import os; import sys; x = 1 -61 61 | -62 62 | -63 |-def import_module_wrong(value: dict[str, str] = {}): - 63 |+def import_module_wrong(value: dict[str, str] = None): -64 64 | import os; import sys - 65 |+ if value is None: - 66 |+ value = {} -65 67 | -66 68 | -67 69 | def import_module_wrong(value: dict[str, str] = {}): import os B006_5.py:67:49: B006 Do not use mutable data structures for argument defaults | @@ -309,5 +146,3 @@ B006_5.py:73:49: B006 Do not use mutable data structures for argument defaults 74 | import os | = help: Replace with `None`; initialize within function - - diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_6.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_6.py.snap index 032ad0e13259d..f5d16539b70a5 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_6.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_6.py.snap @@ -10,16 +10,3 @@ B006_6.py:4:22: B006 [*] Do not use mutable data structures for argument default 5 | import os | = help: Replace with `None`; initialize within function - -ℹ Unsafe fix -1 1 | # Import followed by whitespace with no newline -2 2 | # Same as B006_2.py, but import instead of docstring -3 3 | -4 |-def foobar(foor, bar={}): -5 |- import os - 4 |+def foobar(foor, bar=None): - 5 |+ import os - 6 |+ if bar is None: - 7 |+ bar = {} - - diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_7.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_7.py.snap index 05fdbd20f189d..474740752b6bd 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_7.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_7.py.snap @@ -10,16 +10,3 @@ B006_7.py:4:22: B006 [*] Do not use mutable data structures for argument default 5 | import os | = help: Replace with `None`; initialize within function - -ℹ Unsafe fix -1 1 | # Import with no newline -2 2 | # Same as B006_3.py, but import instead of docstring -3 3 | -4 |-def foobar(foor, bar={}): -5 |- import os - 4 |+def foobar(foor, bar=None): - 5 |+ import os - 6 |+ if bar is None: - 7 |+ bar = {} - - diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_8.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_8.py.snap index 866643aa45474..b272c4bd30430 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_8.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_8.py.snap @@ -9,12 +9,6 @@ B006_8.py:1:19: B006 [*] Do not use mutable data structures for argument default | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -1 |-def foo(a: list = []): - 1 |+def foo(a: list = None): -2 2 | raise NotImplementedError("") -3 3 | -4 4 | B006_8.py:5:19: B006 [*] Do not use mutable data structures for argument defaults | @@ -25,15 +19,6 @@ B006_8.py:5:19: B006 [*] Do not use mutable data structures for argument default | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -2 2 | raise NotImplementedError("") -3 3 | -4 4 | -5 |-def bar(a: dict = {}): - 5 |+def bar(a: dict = None): -6 6 | """ This one also has a docstring""" -7 7 | raise NotImplementedError("and has some text in here") -8 8 | B006_8.py:10:19: B006 [*] Do not use mutable data structures for argument defaults | @@ -44,18 +29,6 @@ B006_8.py:10:19: B006 [*] Do not use mutable data structures for argument defaul | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -7 7 | raise NotImplementedError("and has some text in here") -8 8 | -9 9 | -10 |-def baz(a: list = []): - 10 |+def baz(a: list = None): -11 11 | """This one raises a different exception""" - 12 |+ if a is None: - 13 |+ a = [] -12 14 | raise IndexError() -13 15 | -14 16 | B006_8.py:15:19: B006 [*] Do not use mutable data structures for argument defaults | @@ -65,15 +38,6 @@ B006_8.py:15:19: B006 [*] Do not use mutable data structures for argument defaul | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -12 12 | raise IndexError() -13 13 | -14 14 | -15 |-def qux(a: list = []): - 15 |+def qux(a: list = None): -16 16 | raise NotImplementedError -17 17 | -18 18 | B006_8.py:19:20: B006 [*] Do not use mutable data structures for argument defaults | @@ -82,11 +46,3 @@ B006_8.py:19:20: B006 [*] Do not use mutable data structures for argument defaul 20 | raise NotImplemented | = help: Replace with `None`; initialize within function - -ℹ Unsafe fix -16 16 | raise NotImplementedError -17 17 | -18 18 | -19 |-def quux(a: list = []): - 19 |+def quux(a: list = None): -20 20 | raise NotImplemented diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_B008.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_B008.py.snap index 5627954be4cd2..472e1f674ad4d 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_B008.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_B008.py.snap @@ -9,15 +9,6 @@ B006_B008.py:63:25: B006 [*] Do not use mutable data structures for argument def | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -60 60 | # Flag mutable literals/comprehensions -61 61 | -62 62 | -63 |-def this_is_wrong(value=[1, 2, 3]): - 63 |+def this_is_wrong(value=None): -64 64 | ... -65 65 | -66 66 | B006_B008.py:67:30: B006 [*] Do not use mutable data structures for argument defaults | @@ -27,15 +18,6 @@ B006_B008.py:67:30: B006 [*] Do not use mutable data structures for argument def | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -64 64 | ... -65 65 | -66 66 | -67 |-def this_is_also_wrong(value={}): - 67 |+def this_is_also_wrong(value=None): -68 68 | ... -69 69 | -70 70 | B006_B008.py:73:52: B006 [*] Do not use mutable data structures for argument defaults | @@ -47,15 +29,6 @@ B006_B008.py:73:52: B006 [*] Do not use mutable data structures for argument def | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -70 70 | -71 71 | class Foo: -72 72 | @staticmethod -73 |- def this_is_also_wrong_and_more_indented(value={}): - 73 |+ def this_is_also_wrong_and_more_indented(value=None): -74 74 | pass -75 75 | -76 76 | B006_B008.py:77:31: B006 [*] Do not use mutable data structures for argument defaults | @@ -68,17 +41,6 @@ B006_B008.py:77:31: B006 [*] Do not use mutable data structures for argument def | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -74 74 | pass -75 75 | -76 76 | -77 |-def multiline_arg_wrong(value={ -78 |- -79 |-}): - 77 |+def multiline_arg_wrong(value=None): -80 78 | ... -81 79 | -82 80 | def single_line_func_wrong(value = {}): ... B006_B008.py:82:36: B006 Do not use mutable data structures for argument defaults | @@ -97,15 +59,6 @@ B006_B008.py:85:20: B006 [*] Do not use mutable data structures for argument def | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -82 82 | def single_line_func_wrong(value = {}): ... -83 83 | -84 84 | -85 |-def and_this(value=set()): - 85 |+def and_this(value=None): -86 86 | ... -87 87 | -88 88 | B006_B008.py:89:20: B006 [*] Do not use mutable data structures for argument defaults | @@ -115,15 +68,6 @@ B006_B008.py:89:20: B006 [*] Do not use mutable data structures for argument def | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -86 86 | ... -87 87 | -88 88 | -89 |-def this_too(value=collections.OrderedDict()): - 89 |+def this_too(value=None): -90 90 | ... -91 91 | -92 92 | B006_B008.py:93:32: B006 [*] Do not use mutable data structures for argument defaults | @@ -133,15 +77,6 @@ B006_B008.py:93:32: B006 [*] Do not use mutable data structures for argument def | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -90 90 | ... -91 91 | -92 92 | -93 |-async def async_this_too(value=collections.defaultdict()): - 93 |+async def async_this_too(value=None): -94 94 | ... -95 95 | -96 96 | B006_B008.py:97:26: B006 [*] Do not use mutable data structures for argument defaults | @@ -151,15 +86,6 @@ B006_B008.py:97:26: B006 [*] Do not use mutable data structures for argument def | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -94 94 | ... -95 95 | -96 96 | -97 |-def dont_forget_me(value=collections.deque()): - 97 |+def dont_forget_me(value=None): -98 98 | ... -99 99 | -100 100 | B006_B008.py:102:46: B006 [*] Do not use mutable data structures for argument defaults | @@ -170,15 +96,6 @@ B006_B008.py:102:46: B006 [*] Do not use mutable data structures for argument de | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -99 99 | -100 100 | -101 101 | # N.B. we're also flagging the function call in the comprehension -102 |-def list_comprehension_also_not_okay(default=[i**2 for i in range(3)]): - 102 |+def list_comprehension_also_not_okay(default=None): -103 103 | pass -104 104 | -105 105 | B006_B008.py:106:46: B006 [*] Do not use mutable data structures for argument defaults | @@ -188,15 +105,6 @@ B006_B008.py:106:46: B006 [*] Do not use mutable data structures for argument de | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -103 103 | pass -104 104 | -105 105 | -106 |-def dict_comprehension_also_not_okay(default={i: i**2 for i in range(3)}): - 106 |+def dict_comprehension_also_not_okay(default=None): -107 107 | pass -108 108 | -109 109 | B006_B008.py:110:45: B006 [*] Do not use mutable data structures for argument defaults | @@ -206,15 +114,6 @@ B006_B008.py:110:45: B006 [*] Do not use mutable data structures for argument de | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -107 107 | pass -108 108 | -109 109 | -110 |-def set_comprehension_also_not_okay(default={i**2 for i in range(3)}): - 110 |+def set_comprehension_also_not_okay(default=None): -111 111 | pass -112 112 | -113 113 | B006_B008.py:114:33: B006 [*] Do not use mutable data structures for argument defaults | @@ -224,15 +123,6 @@ B006_B008.py:114:33: B006 [*] Do not use mutable data structures for argument de | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -111 111 | pass -112 112 | -113 113 | -114 |-def kwonlyargs_mutable(*, value=[]): - 114 |+def kwonlyargs_mutable(*, value=None): -115 115 | ... -116 116 | -117 117 | B006_B008.py:239:20: B006 [*] Do not use mutable data structures for argument defaults | @@ -244,15 +134,6 @@ B006_B008.py:239:20: B006 [*] Do not use mutable data structures for argument de | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -236 236 | -237 237 | # B006 and B008 -238 238 | # We should handle arbitrary nesting of these B008. -239 |-def nested_combo(a=[float(3), dt.datetime.now()]): - 239 |+def nested_combo(a=None): -240 240 | pass -241 241 | -242 242 | B006_B008.py:276:27: B006 [*] Do not use mutable data structures for argument defaults | @@ -264,15 +145,6 @@ B006_B008.py:276:27: B006 [*] Do not use mutable data structures for argument de | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -273 273 | -274 274 | -275 275 | def mutable_annotations( -276 |- a: list[int] | None = [], - 276 |+ a: list[int] | None = None, -277 277 | b: Optional[Dict[int, int]] = {}, -278 278 | c: Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), -279 279 | d: typing_extensions.Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), B006_B008.py:277:35: B006 [*] Do not use mutable data structures for argument defaults | @@ -285,15 +157,6 @@ B006_B008.py:277:35: B006 [*] Do not use mutable data structures for argument de | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -274 274 | -275 275 | def mutable_annotations( -276 276 | a: list[int] | None = [], -277 |- b: Optional[Dict[int, int]] = {}, - 277 |+ b: Optional[Dict[int, int]] = None, -278 278 | c: Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), -279 279 | d: typing_extensions.Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), -280 280 | ): B006_B008.py:278:62: B006 [*] Do not use mutable data structures for argument defaults | @@ -306,15 +169,6 @@ B006_B008.py:278:62: B006 [*] Do not use mutable data structures for argument de | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -275 275 | def mutable_annotations( -276 276 | a: list[int] | None = [], -277 277 | b: Optional[Dict[int, int]] = {}, -278 |- c: Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), - 278 |+ c: Annotated[Union[Set[str], abc.Sized], "annotation"] = None, -279 279 | d: typing_extensions.Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), -280 280 | ): -281 281 | pass B006_B008.py:279:80: B006 [*] Do not use mutable data structures for argument defaults | @@ -327,15 +181,6 @@ B006_B008.py:279:80: B006 [*] Do not use mutable data structures for argument de | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -276 276 | a: list[int] | None = [], -277 277 | b: Optional[Dict[int, int]] = {}, -278 278 | c: Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), -279 |- d: typing_extensions.Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), - 279 |+ d: typing_extensions.Annotated[Union[Set[str], abc.Sized], "annotation"] = None, -280 280 | ): -281 281 | pass -282 282 | B006_B008.py:284:52: B006 [*] Do not use mutable data structures for argument defaults | @@ -345,15 +190,6 @@ B006_B008.py:284:52: B006 [*] Do not use mutable data structures for argument de | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -281 281 | pass -282 282 | -283 283 | -284 |-def single_line_func_wrong(value: dict[str, str] = {}): - 284 |+def single_line_func_wrong(value: dict[str, str] = None): -285 285 | """Docstring""" -286 286 | -287 287 | B006_B008.py:288:52: B006 [*] Do not use mutable data structures for argument defaults | @@ -364,15 +200,6 @@ B006_B008.py:288:52: B006 [*] Do not use mutable data structures for argument de | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -285 285 | """Docstring""" -286 286 | -287 287 | -288 |-def single_line_func_wrong(value: dict[str, str] = {}): - 288 |+def single_line_func_wrong(value: dict[str, str] = None): -289 289 | """Docstring""" -290 290 | ... -291 291 | B006_B008.py:293:52: B006 [*] Do not use mutable data structures for argument defaults | @@ -382,15 +209,6 @@ B006_B008.py:293:52: B006 [*] Do not use mutable data structures for argument de | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -290 290 | ... -291 291 | -292 292 | -293 |-def single_line_func_wrong(value: dict[str, str] = {}): - 293 |+def single_line_func_wrong(value: dict[str, str] = None): -294 294 | """Docstring"""; ... -295 295 | -296 296 | B006_B008.py:297:52: B006 [*] Do not use mutable data structures for argument defaults | @@ -401,15 +219,6 @@ B006_B008.py:297:52: B006 [*] Do not use mutable data structures for argument de | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -294 294 | """Docstring"""; ... -295 295 | -296 296 | -297 |-def single_line_func_wrong(value: dict[str, str] = {}): - 297 |+def single_line_func_wrong(value: dict[str, str] = None): -298 298 | """Docstring"""; \ -299 299 | ... -300 300 | B006_B008.py:302:52: B006 [*] Do not use mutable data structures for argument defaults | @@ -422,17 +231,6 @@ B006_B008.py:302:52: B006 [*] Do not use mutable data structures for argument de | = help: Replace with `None`; initialize within function -ℹ Unsafe fix -299 299 | ... -300 300 | -301 301 | -302 |-def single_line_func_wrong(value: dict[str, str] = { -303 |- # This is a comment -304 |-}): - 302 |+def single_line_func_wrong(value: dict[str, str] = None): -305 303 | """Docstring""" -306 304 | -307 305 | B006_B008.py:308:52: B006 Do not use mutable data structures for argument defaults | @@ -450,11 +248,3 @@ B006_B008.py:313:52: B006 [*] Do not use mutable data structures for argument de 314 | """Docstring without newline""" | = help: Replace with `None`; initialize within function - -ℹ Unsafe fix -310 310 | """Docstring""" -311 311 | -312 312 | -313 |-def single_line_func_wrong(value: dict[str, str] = {}): - 313 |+def single_line_func_wrong(value: dict[str, str] = None): -314 314 | """Docstring without newline""" diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B007_B007.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B007_B007.py.snap index 5f36888c89df6..c30babd832ab5 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B007_B007.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B007_B007.py.snap @@ -21,15 +21,6 @@ B007.py:18:13: B007 [*] Loop control variable `k` not used within loop body | = help: Rename unused `k` to `_k` -ℹ Unsafe fix -15 15 | -16 16 | for i in range(10): -17 17 | for j in range(10): -18 |- for k in range(10): # k not used, i and j used transitively - 18 |+ for _k in range(10): # k not used, i and j used transitively -19 19 | print(i + j) -20 20 | -21 21 | B007.py:30:5: B007 Loop control variable `i` not used within loop body | @@ -47,15 +38,6 @@ B007.py:30:13: B007 [*] Loop control variable `k` not used within loop body | = help: Rename unused `k` to `_k` -ℹ Unsafe fix -27 27 | yield i, (j, (k, l)) -28 28 | -29 29 | -30 |-for i, (j, (k, l)) in strange_generator(): # i, k not used - 30 |+for i, (j, (_k, l)) in strange_generator(): # i, k not used -31 31 | print(j, l) -32 32 | -33 33 | FMT = "{foo} {bar}" B007.py:34:10: B007 Loop control variable `bar` may not be used within loop body | @@ -110,15 +92,6 @@ B007.py:52:14: B007 [*] Loop control variable `bar` not used within loop body | = help: Rename unused `bar` to `_bar` -ℹ Unsafe fix -49 49 | -50 50 | def f(): -51 51 | # Fixable. -52 |- for foo, bar, baz in (["1", "2", "3"],): - 52 |+ for foo, _bar, baz in (["1", "2", "3"],): -53 53 | if foo or baz: -54 54 | break -55 55 | B007.py:59:14: B007 Loop control variable `bar` not used within loop body | @@ -142,15 +115,6 @@ B007.py:68:14: B007 [*] Loop control variable `bar` not used within loop body | = help: Rename unused `bar` to `_bar` -ℹ Unsafe fix -65 65 | -66 66 | def f(): -67 67 | # Fixable. -68 |- for foo, bar, baz in (["1", "2", "3"],): - 68 |+ for foo, _bar, baz in (["1", "2", "3"],): -69 69 | if foo or baz: -70 70 | break -71 71 | B007.py:77:14: B007 Loop control variable `bar` not used within loop body | @@ -182,5 +146,3 @@ B007.py:98:5: B007 Loop control variable `line_` not used within loop body | ^^^^^ B007 99 | fp.readline() | - - diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B009_B009_B010.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B009_B009_B010.py.snap index fc00bb4ef9792..4ccfc45f71e27 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B009_B009_B010.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B009_B009_B010.py.snap @@ -11,7 +11,6 @@ B009_B010.py:19:1: B009 [*] Do not call `getattr` with a constant attribute valu | = help: Replace `getattr` with attribute access -ℹ Safe fix 16 16 | getattr(foo, "__123abc") 17 17 | 18 18 | # Invalid usage @@ -32,7 +31,6 @@ B009_B010.py:20:1: B009 [*] Do not call `getattr` with a constant attribute valu | = help: Replace `getattr` with attribute access -ℹ Safe fix 17 17 | 18 18 | # Invalid usage 19 19 | getattr(foo, "bar") @@ -53,7 +51,6 @@ B009_B010.py:21:1: B009 [*] Do not call `getattr` with a constant attribute valu | = help: Replace `getattr` with attribute access -ℹ Safe fix 18 18 | # Invalid usage 19 19 | getattr(foo, "bar") 20 20 | getattr(foo, "_123abc") @@ -74,7 +71,6 @@ B009_B010.py:22:1: B009 [*] Do not call `getattr` with a constant attribute valu | = help: Replace `getattr` with attribute access -ℹ Safe fix 19 19 | getattr(foo, "bar") 20 20 | getattr(foo, "_123abc") 21 21 | getattr(foo, "__123abc__") @@ -95,7 +91,6 @@ B009_B010.py:23:1: B009 [*] Do not call `getattr` with a constant attribute valu | = help: Replace `getattr` with attribute access -ℹ Safe fix 20 20 | getattr(foo, "_123abc") 21 21 | getattr(foo, "__123abc__") 22 22 | getattr(foo, "abc123") @@ -116,7 +111,6 @@ B009_B010.py:24:15: B009 [*] Do not call `getattr` with a constant attribute val | = help: Replace `getattr` with attribute access -ℹ Safe fix 21 21 | getattr(foo, "__123abc__") 22 22 | getattr(foo, "abc123") 23 23 | getattr(foo, r"abc123") @@ -137,7 +131,6 @@ B009_B010.py:25:4: B009 [*] Do not call `getattr` with a constant attribute valu | = help: Replace `getattr` with attribute access -ℹ Safe fix 22 22 | getattr(foo, "abc123") 23 23 | getattr(foo, r"abc123") 24 24 | _ = lambda x: getattr(x, "bar") @@ -158,7 +151,6 @@ B009_B010.py:27:1: B009 [*] Do not call `getattr` with a constant attribute valu | = help: Replace `getattr` with attribute access -ℹ Safe fix 24 24 | _ = lambda x: getattr(x, "bar") 25 25 | if getattr(x, "bar"): 26 26 | pass @@ -179,7 +171,6 @@ B009_B010.py:28:1: B009 [*] Do not call `getattr` with a constant attribute valu | = help: Replace `getattr` with attribute access -ℹ Safe fix 25 25 | if getattr(x, "bar"): 26 26 | pass 27 27 | getattr(1, "real") @@ -200,7 +191,6 @@ B009_B010.py:29:1: B009 [*] Do not call `getattr` with a constant attribute valu | = help: Replace `getattr` with attribute access -ℹ Safe fix 26 26 | pass 27 27 | getattr(1, "real") 28 28 | getattr(1., "real") @@ -221,7 +211,6 @@ B009_B010.py:30:1: B009 [*] Do not call `getattr` with a constant attribute valu | = help: Replace `getattr` with attribute access -ℹ Safe fix 27 27 | getattr(1, "real") 28 28 | getattr(1., "real") 29 29 | getattr(1.0, "real") @@ -242,7 +231,6 @@ B009_B010.py:31:1: B009 [*] Do not call `getattr` with a constant attribute valu | = help: Replace `getattr` with attribute access -ℹ Safe fix 28 28 | getattr(1., "real") 29 29 | getattr(1.0, "real") 30 30 | getattr(1j, "real") @@ -263,7 +251,6 @@ B009_B010.py:32:1: B009 [*] Do not call `getattr` with a constant attribute valu | = help: Replace `getattr` with attribute access -ℹ Safe fix 29 29 | getattr(1.0, "real") 30 30 | getattr(1j, "real") 31 31 | getattr(True, "real") @@ -284,7 +271,6 @@ B009_B010.py:33:1: B009 [*] Do not call `getattr` with a constant attribute valu | = help: Replace `getattr` with attribute access -ℹ Safe fix 30 30 | getattr(1j, "real") 31 31 | getattr(True, "real") 32 32 | getattr(x := 1, "real") @@ -304,7 +290,6 @@ B009_B010.py:34:1: B009 [*] Do not call `getattr` with a constant attribute valu | = help: Replace `getattr` with attribute access -ℹ Safe fix 31 31 | getattr(True, "real") 32 32 | getattr(x := 1, "real") 33 33 | getattr(x + y, "real") @@ -326,7 +311,6 @@ B009_B010.py:58:8: B009 [*] Do not call `getattr` with a constant attribute valu | = help: Replace `getattr` with attribute access -ℹ Safe fix 55 55 | setattr(foo.bar, r"baz", None) 56 56 | 57 57 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722458885 @@ -347,7 +331,6 @@ B009_B010.py:65:1: B009 [*] Do not call `getattr` with a constant attribute valu | = help: Replace `getattr` with attribute access -ℹ Safe fix 62 62 | setattr(*foo, "bar", None) 63 63 | 64 64 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1739800901 @@ -367,7 +350,6 @@ B009_B010.py:69:1: B009 [*] Do not call `getattr` with a constant attribute valu | = help: Replace `getattr` with attribute access -ℹ Safe fix 66 66 | registration.registry, '__name__') 67 67 | 68 68 | import builtins diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B010_B009_B010.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B010_B009_B010.py.snap index cad3fc9306173..19b03198ecdb8 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B010_B009_B010.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B010_B009_B010.py.snap @@ -11,7 +11,6 @@ B009_B010.py:50:1: B010 [*] Do not call `setattr` with a constant attribute valu | = help: Replace `setattr` with assignment -ℹ Safe fix 47 47 | pass 48 48 | 49 49 | # Invalid usage @@ -32,7 +31,6 @@ B009_B010.py:51:1: B010 [*] Do not call `setattr` with a constant attribute valu | = help: Replace `setattr` with assignment -ℹ Safe fix 48 48 | 49 49 | # Invalid usage 50 50 | setattr(foo, "bar", None) @@ -53,7 +51,6 @@ B009_B010.py:52:1: B010 [*] Do not call `setattr` with a constant attribute valu | = help: Replace `setattr` with assignment -ℹ Safe fix 49 49 | # Invalid usage 50 50 | setattr(foo, "bar", None) 51 51 | setattr(foo, "_123abc", None) @@ -74,7 +71,6 @@ B009_B010.py:53:1: B010 [*] Do not call `setattr` with a constant attribute valu | = help: Replace `setattr` with assignment -ℹ Safe fix 50 50 | setattr(foo, "bar", None) 51 51 | setattr(foo, "_123abc", None) 52 52 | setattr(foo, "__123abc__", None) @@ -94,7 +90,6 @@ B009_B010.py:54:1: B010 [*] Do not call `setattr` with a constant attribute valu | = help: Replace `setattr` with assignment -ℹ Safe fix 51 51 | setattr(foo, "_123abc", None) 52 52 | setattr(foo, "__123abc__", None) 53 53 | setattr(foo, "abc123", None) @@ -115,7 +110,6 @@ B009_B010.py:55:1: B010 [*] Do not call `setattr` with a constant attribute valu | = help: Replace `setattr` with assignment -ℹ Safe fix 52 52 | setattr(foo, "__123abc__", None) 53 53 | setattr(foo, "abc123", None) 54 54 | setattr(foo, r"abc123", None) @@ -124,5 +118,3 @@ B009_B010.py:55:1: B010 [*] Do not call `setattr` with a constant attribute valu 56 56 | 57 57 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722458885 58 58 | assert getattr(func, '_rpc')is True - - diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B011_B011.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B011_B011.py.snap index 828397abcea25..51a8dd887b015 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B011_B011.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B011_B011.py.snap @@ -11,14 +11,6 @@ B011.py:8:8: B011 [*] Do not `assert False` (`python -O` removes these calls), r | = help: Replace `assert False` -ℹ Unsafe fix -5 5 | """ -6 6 | -7 7 | assert 1 != 2 -8 |-assert False - 8 |+raise AssertionError() -9 9 | assert 1 != 2, "message" -10 10 | assert False, "message" B011.py:10:8: B011 [*] Do not `assert False` (`python -O` removes these calls), raise `AssertionError()` | @@ -28,12 +20,3 @@ B011.py:10:8: B011 [*] Do not `assert False` (`python -O` removes these calls), | ^^^^^ B011 | = help: Replace `assert False` - -ℹ Unsafe fix -7 7 | assert 1 != 2 -8 8 | assert False -9 9 | assert 1 != 2, "message" -10 |-assert False, "message" - 10 |+raise AssertionError("message") - - diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B013_B013.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B013_B013.py.snap index 658dfd3c7a7c0..262cfe4d49182 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B013_B013.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B013_B013.py.snap @@ -12,7 +12,6 @@ B013.py:5:8: B013 [*] A length-one tuple literal is redundant in exception handl | = help: Replace with `except ValueError` -ℹ Safe fix 2 2 | 3 3 | try: 4 4 | pass @@ -32,7 +31,6 @@ B013.py:13:7: B013 [*] A length-one tuple literal is redundant in exception hand | = help: Replace with `except ValueError` -ℹ Safe fix 10 10 | pass 11 11 | except (*retriable_exceptions,): 12 12 | pass diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B014_B014.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B014_B014.py.snap index c35fb2494dcd8..11a9c258484fa 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B014_B014.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B014_B014.py.snap @@ -12,7 +12,6 @@ B014.py:17:8: B014 [*] Exception handler with duplicate exception: `OSError` | = help: De-duplicate exceptions -ℹ Safe fix 14 14 | 15 15 | try: 16 16 | pass @@ -33,7 +32,6 @@ B014.py:28:8: B014 [*] Exception handler with duplicate exception: `MyError` | = help: De-duplicate exceptions -ℹ Safe fix 25 25 | 26 26 | try: 27 27 | pass @@ -54,7 +52,6 @@ B014.py:49:8: B014 [*] Exception handler with duplicate exception: `re.error` | = help: De-duplicate exceptions -ℹ Safe fix 46 46 | 47 47 | try: 48 48 | pass @@ -74,7 +71,6 @@ B014.py:82:8: B014 [*] Exception handler with duplicate exception: `ValueError` | = help: De-duplicate exceptions -ℹ Safe fix 79 79 | # Regression test for: https://github.com/astral-sh/ruff/issues/6412 80 80 | try: 81 81 | pass @@ -94,12 +90,9 @@ B014.py:89:7: B014 [*] Exception handler with duplicate exception: `re.error` | = help: De-duplicate exceptions -ℹ Safe fix 86 86 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1739801758 87 87 | try: 88 88 | pas 89 |-except(re.error, re.error): 89 |+except re.error: 90 90 | p - - diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B033_B033.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B033_B033.py.snap index 6d468e2683cd3..e87ce710b14d9 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B033_B033.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B033_B033.py.snap @@ -12,7 +12,6 @@ B033.py:4:35: B033 [*] Sets should not contain duplicate item `"value1"` | = help: Remove duplicate item -ℹ Safe fix 1 1 | ### 2 2 | # Errors. 3 3 | ### @@ -33,7 +32,6 @@ B033.py:5:21: B033 [*] Sets should not contain duplicate item `1` | = help: Remove duplicate item -ℹ Safe fix 2 2 | # Errors. 3 3 | ### 4 4 | incorrect_set = {"value1", 23, 5, "value1"} @@ -54,7 +52,6 @@ B033.py:10:5: B033 [*] Sets should not contain duplicate item `"value1"` | = help: Remove duplicate item -ℹ Safe fix 7 7 | "value1", 8 8 | 23, 9 9 | 5, @@ -74,7 +71,6 @@ B033.py:13:21: B033 [*] Sets should not contain duplicate item `1` | = help: Remove duplicate item -ℹ Safe fix 10 10 | "value1", 11 11 | # B033 12 12 | } @@ -95,7 +91,6 @@ B033.py:14:21: B033 [*] Sets should not contain duplicate item `1` | = help: Remove duplicate item -ℹ Safe fix 11 11 | # B033 12 12 | } 13 13 | incorrect_set = {1, 1} @@ -116,7 +111,6 @@ B033.py:15:24: B033 [*] Sets should not contain duplicate item `1` | = help: Remove duplicate item -ℹ Safe fix 12 12 | } 13 13 | incorrect_set = {1, 1} 14 14 | incorrect_set = {1, 1,} @@ -137,7 +131,6 @@ B033.py:16:24: B033 [*] Sets should not contain duplicate item `1` | = help: Remove duplicate item -ℹ Safe fix 13 13 | incorrect_set = {1, 1} 14 14 | incorrect_set = {1, 1,} 15 15 | incorrect_set = {0, 1, 1,} @@ -157,7 +150,6 @@ B033.py:20:5: B033 [*] Sets should not contain duplicate item `1` | = help: Remove duplicate item -ℹ Safe fix 17 17 | incorrect_set = { 18 18 | 0, 19 19 | 1, @@ -165,5 +157,3 @@ B033.py:20:5: B033 [*] Sets should not contain duplicate item `1` 21 20 | } 22 21 | 23 22 | ### - - diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B905.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B905.py.snap index 2e0c24059003d..d012b2da6d806 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B905.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B905.py.snap @@ -11,7 +11,6 @@ B905.py:4:1: B905 [*] `zip()` without an explicit `strict=` parameter | = help: Add explicit `strict=False` -ℹ Safe fix 1 1 | from itertools import count, cycle, repeat 2 2 | 3 3 | # Errors @@ -32,7 +31,6 @@ B905.py:5:1: B905 [*] `zip()` without an explicit `strict=` parameter | = help: Add explicit `strict=False` -ℹ Safe fix 2 2 | 3 3 | # Errors 4 4 | zip() @@ -53,7 +51,6 @@ B905.py:6:1: B905 [*] `zip()` without an explicit `strict=` parameter | = help: Add explicit `strict=False` -ℹ Safe fix 3 3 | # Errors 4 4 | zip() 5 5 | zip(range(3)) @@ -74,7 +71,6 @@ B905.py:7:1: B905 [*] `zip()` without an explicit `strict=` parameter | = help: Add explicit `strict=False` -ℹ Safe fix 4 4 | zip() 5 5 | zip(range(3)) 6 6 | zip("a", "b") @@ -95,7 +91,6 @@ B905.py:7:16: B905 [*] `zip()` without an explicit `strict=` parameter | = help: Add explicit `strict=False` -ℹ Safe fix 4 4 | zip() 5 5 | zip(range(3)) 6 6 | zip("a", "b") @@ -115,7 +110,6 @@ B905.py:8:5: B905 [*] `zip()` without an explicit `strict=` parameter | = help: Add explicit `strict=False` -ℹ Safe fix 5 5 | zip(range(3)) 6 6 | zip("a", "b") 7 7 | zip("a", "b", *zip("c")) @@ -136,7 +130,6 @@ B905.py:9:1: B905 [*] `zip()` without an explicit `strict=` parameter | = help: Add explicit `strict=False` -ℹ Safe fix 6 6 | zip("a", "b") 7 7 | zip("a", "b", *zip("c")) 8 8 | zip(zip("a"), strict=False) @@ -155,7 +148,6 @@ B905.py:24:1: B905 [*] `zip()` without an explicit `strict=` parameter | = help: Add explicit `strict=False` -ℹ Safe fix 21 21 | zip([1, 2, 3], repeat(1, times=None)) 22 22 | 23 23 | # Errors (limited iterators). @@ -176,7 +168,6 @@ B905.py:25:1: B905 [*] `zip()` without an explicit `strict=` parameter | = help: Add explicit `strict=False` -ℹ Safe fix 22 22 | 23 23 | # Errors (limited iterators). 24 24 | zip([1, 2, 3], repeat(1, 1)) @@ -195,7 +186,6 @@ B905.py:29:1: B905 [*] `zip()` without an explicit `strict=` parameter | = help: Add explicit `strict=False` -ℹ Safe fix 26 26 | 27 27 | import builtins 28 28 | # Still an error even though it uses the qualified name diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__extend_immutable_calls_arg_annotation.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__extend_immutable_calls_arg_annotation.snap index ff069ea930445..16ca3d8f6d558 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__extend_immutable_calls_arg_annotation.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__extend_immutable_calls_arg_annotation.snap @@ -8,11 +8,3 @@ B006_extended.py:17:55: B006 [*] Do not use mutable data structures for argument 18 | ... | = help: Replace with `None`; initialize within function - -ℹ Unsafe fix -14 14 | ... -15 15 | -16 16 | -17 |-def error_due_to_missing_import(foo: ImmutableTypeA = []): - 17 |+def error_due_to_missing_import(foo: ImmutableTypeA = None): -18 18 | ... diff --git a/crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__COM81.py.snap b/crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__COM81.py.snap index 1955cf08d063f..081880c12cf97 100644 --- a/crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__COM81.py.snap +++ b/crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__COM81.py.snap @@ -12,7 +12,6 @@ COM81.py:4:18: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 1 1 | # ==> bad_function_call.py <== 2 2 | bad_function_call( 3 3 | param1='test', @@ -32,7 +31,6 @@ COM81.py:10:6: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 7 7 | bad_list = [ 8 8 | 1, 9 9 | 2, @@ -53,7 +51,6 @@ COM81.py:16:6: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 13 13 | bad_list_with_comment = [ 14 14 | 1, 15 15 | 2, @@ -72,7 +69,6 @@ COM81.py:23:6: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 20 20 | bad_list_with_extra_empty = [ 21 21 | 1, 22 22 | 2, @@ -159,7 +155,6 @@ COM81.py:70:8: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 67 67 | pass 68 68 | 69 69 | {'foo': foo}['foo']( @@ -178,7 +173,6 @@ COM81.py:78:8: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 75 75 | ) 76 76 | 77 77 | (foo)( @@ -197,7 +191,6 @@ COM81.py:86:8: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 83 83 | ) 84 84 | 85 85 | [foo][0]( @@ -217,7 +210,6 @@ COM81.py:152:6: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 149 149 | 150 150 | # ==> keyword_before_parenth_form/base_bad.py <== 151 151 | from x import ( @@ -237,7 +229,6 @@ COM81.py:158:11: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 155 155 | assert( 156 156 | SyntaxWarning, 157 157 | ThrownHere, @@ -258,7 +249,6 @@ COM81.py:293:15: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 290 290 | 291 291 | # ==> multiline_bad_dict.py <== 292 292 | multiline_bad_dict = { @@ -279,7 +269,6 @@ COM81.py:304:14: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 301 301 | 302 302 | def func_bad( 303 303 | a = 3, @@ -300,7 +289,6 @@ COM81.py:310:14: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 307 307 | 308 308 | # ==> multiline_bad_function_one_param.py <== 309 309 | def func( @@ -319,7 +307,6 @@ COM81.py:316:10: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 313 313 | 314 314 | 315 315 | func( @@ -339,7 +326,6 @@ COM81.py:322:15: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 319 319 | # ==> multiline_bad_or_dict.py <== 320 320 | multiline_bad_or_dict = { 321 321 | "good": True or False, @@ -359,7 +345,6 @@ COM81.py:368:15: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 365 365 | 366 366 | multiline_index_access[ 367 367 | "probably fine", @@ -379,7 +364,6 @@ COM81.py:375:15: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 372 372 | "fine", 373 373 | "fine", 374 374 | : @@ -399,7 +383,6 @@ COM81.py:404:15: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 401 401 | "fine", 402 402 | "fine" 403 403 | : @@ -419,7 +402,6 @@ COM81.py:432:15: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 429 429 | "fine" 430 430 | : 431 431 | "fine", @@ -439,7 +421,6 @@ COM81.py:485:21: COM819 [*] Trailing comma prohibited | = help: Remove trailing comma -ℹ Safe fix 482 482 | ) 483 483 | 484 484 | # ==> prohibited.py <== @@ -460,7 +441,6 @@ COM81.py:487:13: COM819 [*] Trailing comma prohibited | = help: Remove trailing comma -ℹ Safe fix 484 484 | # ==> prohibited.py <== 485 485 | foo = ['a', 'b', 'c',] 486 486 | @@ -480,7 +460,6 @@ COM81.py:489:18: COM819 [*] Trailing comma prohibited | = help: Remove trailing comma -ℹ Safe fix 486 486 | 487 487 | bar = { a: b,} 488 488 | @@ -501,7 +480,6 @@ COM81.py:494:6: COM819 [*] Trailing comma prohibited | = help: Remove trailing comma -ℹ Safe fix 491 491 | 492 492 | (0,) 493 493 | @@ -522,7 +500,6 @@ COM81.py:496:21: COM819 [*] Trailing comma prohibited | = help: Remove trailing comma -ℹ Safe fix 493 493 | 494 494 | (0, 1,) 495 495 | @@ -543,7 +520,6 @@ COM81.py:498:13: COM819 [*] Trailing comma prohibited | = help: Remove trailing comma -ℹ Safe fix 495 495 | 496 496 | foo = ['a', 'b', 'c', ] 497 497 | @@ -563,7 +539,6 @@ COM81.py:500:18: COM819 [*] Trailing comma prohibited | = help: Remove trailing comma -ℹ Safe fix 497 497 | 498 498 | bar = { a: b, } 499 499 | @@ -584,7 +559,6 @@ COM81.py:505:6: COM819 [*] Trailing comma prohibited | = help: Remove trailing comma -ℹ Safe fix 502 502 | 503 503 | (0, ) 504 504 | @@ -605,7 +579,6 @@ COM81.py:511:10: COM819 [*] Trailing comma prohibited | = help: Remove trailing comma -ℹ Safe fix 508 508 | 509 509 | image[:,] 510 510 | @@ -626,7 +599,6 @@ COM81.py:513:9: COM819 [*] Trailing comma prohibited | = help: Remove trailing comma -ℹ Safe fix 510 510 | 511 511 | image[:,:,] 512 512 | @@ -647,7 +619,6 @@ COM81.py:519:13: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 516 516 | def function( 517 517 | foo, 518 518 | bar, @@ -668,7 +639,6 @@ COM81.py:526:10: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 523 523 | def function( 524 524 | foo, 525 525 | bar, @@ -689,7 +659,6 @@ COM81.py:534:16: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 531 531 | foo, 532 532 | bar, 533 533 | *args, @@ -709,7 +678,6 @@ COM81.py:541:13: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 538 538 | result = function( 539 539 | foo, 540 540 | bar, @@ -729,7 +697,6 @@ COM81.py:547:24: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 544 544 | result = function( 545 545 | foo, 546 546 | bar, @@ -750,7 +717,6 @@ COM81.py:554:15: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 551 551 | ham, 552 552 | spam, 553 553 | *args, @@ -769,7 +735,6 @@ COM81.py:561:13: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 558 558 | # In python 3.5 if it's not a function def, commas are mandatory. 559 559 | 560 560 | foo( @@ -788,7 +753,6 @@ COM81.py:565:13: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 562 562 | ) 563 563 | 564 564 | { @@ -807,7 +771,6 @@ COM81.py:569:10: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 566 566 | } 567 567 | 568 568 | { @@ -826,7 +789,6 @@ COM81.py:573:10: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 570 570 | } 571 571 | 572 572 | [ @@ -847,7 +809,6 @@ COM81.py:579:10: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 576 576 | def foo( 577 577 | ham, 578 578 | spam, @@ -868,7 +829,6 @@ COM81.py:586:13: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 583 583 | def foo( 584 584 | ham, 585 585 | spam, @@ -889,7 +849,6 @@ COM81.py:594:15: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 591 591 | ham, 592 592 | spam, 593 593 | *args, @@ -909,7 +868,6 @@ COM81.py:623:20: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 620 620 | result = function( 621 621 | foo, 622 622 | bar, @@ -929,7 +887,6 @@ COM81.py:628:42: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 625 625 | 626 626 | # Make sure the COM812 and UP034 rules don't fix simultaneously and cause a syntax error. 627 627 | the_first_one = next( @@ -949,7 +906,6 @@ COM81.py:640:46: COM819 [*] Trailing comma prohibited | = help: Remove trailing comma -ℹ Safe fix 637 637 | ) 638 638 | 639 639 | # F-strings @@ -968,7 +924,6 @@ COM81.py:643:49: COM812 [*] Trailing comma missing | = help: Add trailing comma -ℹ Safe fix 640 640 | kwargs.pop("remove", f"this {trailing_comma}",) 641 641 | 642 642 | raise Exception( diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C400_C400.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C400_C400.py.snap index d64116390469b..599ecd3ecaa0c 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C400_C400.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C400_C400.py.snap @@ -11,13 +11,6 @@ C400.py:2:13: C400 [*] Unnecessary generator (rewrite as a `list` comprehension) | = help: Rewrite as a `list` comprehension -ℹ Unsafe fix -1 1 | # Cannot combine with C416. Should use list comprehension here. -2 |-even_nums = list(2 * x for x in range(3)) - 2 |+even_nums = [2 * x for x in range(3)] -3 3 | odd_nums = list( -4 4 | 2 * x + 1 for x in range(3) -5 5 | ) C400.py:3:12: C400 [*] Unnecessary generator (rewrite as a `list` comprehension) | @@ -31,17 +24,6 @@ C400.py:3:12: C400 [*] Unnecessary generator (rewrite as a `list` comprehension) | = help: Rewrite as a `list` comprehension -ℹ Unsafe fix -1 1 | # Cannot combine with C416. Should use list comprehension here. -2 2 | even_nums = list(2 * x for x in range(3)) -3 |-odd_nums = list( - 3 |+odd_nums = [ -4 4 | 2 * x + 1 for x in range(3) -5 |-) - 5 |+] -6 6 | -7 7 | -8 8 | # Short-circuit case, combine with C416 and should produce x = list(range(3)) C400.py:9:5: C400 [*] Unnecessary generator (rewrite using `list()`) | @@ -53,15 +35,6 @@ C400.py:9:5: C400 [*] Unnecessary generator (rewrite using `list()`) | = help: Rewrite using `list()` -ℹ Unsafe fix -6 6 | -7 7 | -8 8 | # Short-circuit case, combine with C416 and should produce x = list(range(3)) -9 |-x = list(x for x in range(3)) - 9 |+x = list(range(3)) -10 10 | x = list( -11 11 | x for x in range(3) -12 12 | ) C400.py:10:5: C400 [*] Unnecessary generator (rewrite using `list()`) | @@ -77,17 +50,6 @@ C400.py:10:5: C400 [*] Unnecessary generator (rewrite using `list()`) | = help: Rewrite using `list()` -ℹ Unsafe fix -7 7 | -8 8 | # Short-circuit case, combine with C416 and should produce x = list(range(3)) -9 9 | x = list(x for x in range(3)) -10 |-x = list( -11 |- x for x in range(3) -12 |-) - 10 |+x = list(range(3)) -13 11 | -14 12 | # Strip parentheses from inner generators. -15 13 | list((2 * x for x in range(3))) C400.py:15:1: C400 [*] Unnecessary generator (rewrite as a `list` comprehension) | @@ -99,15 +61,6 @@ C400.py:15:1: C400 [*] Unnecessary generator (rewrite as a `list` comprehension) | = help: Rewrite as a `list` comprehension -ℹ Unsafe fix -12 12 | ) -13 13 | -14 14 | # Strip parentheses from inner generators. -15 |-list((2 * x for x in range(3))) - 15 |+[2 * x for x in range(3)] -16 16 | list(((2 * x for x in range(3)))) -17 17 | list((((2 * x for x in range(3))))) -18 18 | C400.py:16:1: C400 [*] Unnecessary generator (rewrite as a `list` comprehension) | @@ -119,15 +72,6 @@ C400.py:16:1: C400 [*] Unnecessary generator (rewrite as a `list` comprehension) | = help: Rewrite as a `list` comprehension -ℹ Unsafe fix -13 13 | -14 14 | # Strip parentheses from inner generators. -15 15 | list((2 * x for x in range(3))) -16 |-list(((2 * x for x in range(3)))) - 16 |+[2 * x for x in range(3)] -17 17 | list((((2 * x for x in range(3))))) -18 18 | -19 19 | # Not built-in list. C400.py:17:1: C400 [*] Unnecessary generator (rewrite as a `list` comprehension) | @@ -139,13 +83,3 @@ C400.py:17:1: C400 [*] Unnecessary generator (rewrite as a `list` comprehension) 19 | # Not built-in list. | = help: Rewrite as a `list` comprehension - -ℹ Unsafe fix -14 14 | # Strip parentheses from inner generators. -15 15 | list((2 * x for x in range(3))) -16 16 | list(((2 * x for x in range(3)))) -17 |-list((((2 * x for x in range(3))))) - 17 |+[2 * x for x in range(3)] -18 18 | -19 19 | # Not built-in list. -20 20 | def list(*args, **kwargs): diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C401_C401.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C401_C401.py.snap index fdde5715682af..4f516e4342046 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C401_C401.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C401_C401.py.snap @@ -11,13 +11,6 @@ C401.py:2:13: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) | = help: Rewrite as a `set` comprehension -ℹ Unsafe fix -1 1 | # Cannot conbime with C416. Should use set comprehension here. -2 |-even_nums = set(2 * x for x in range(3)) - 2 |+even_nums = {2 * x for x in range(3)} -3 3 | odd_nums = set( -4 4 | 2 * x + 1 for x in range(3) -5 5 | ) C401.py:3:12: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) | @@ -32,17 +25,6 @@ C401.py:3:12: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) | = help: Rewrite as a `set` comprehension -ℹ Unsafe fix -1 1 | # Cannot conbime with C416. Should use set comprehension here. -2 2 | even_nums = set(2 * x for x in range(3)) -3 |-odd_nums = set( - 3 |+odd_nums = { -4 4 | 2 * x + 1 for x in range(3) -5 |-) - 5 |+} -6 6 | small_nums = f"{set(a if a < 6 else 0 for a in range(3))}" -7 7 | -8 8 | def f(x): C401.py:6:17: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) | @@ -55,15 +37,6 @@ C401.py:6:17: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) | = help: Rewrite as a `set` comprehension -ℹ Unsafe fix -3 3 | odd_nums = set( -4 4 | 2 * x + 1 for x in range(3) -5 5 | ) -6 |-small_nums = f"{set(a if a < 6 else 0 for a in range(3))}" - 6 |+small_nums = f"{ {a if a < 6 else 0 for a in range(3)} }" -7 7 | -8 8 | def f(x): -9 9 | return x C401.py:11:16: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) | @@ -75,15 +48,6 @@ C401.py:11:16: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) | = help: Rewrite as a `set` comprehension -ℹ Unsafe fix -8 8 | def f(x): -9 9 | return x -10 10 | -11 |-print(f"Hello {set(f(a) for a in 'abc')} World") - 11 |+print(f"Hello { {f(a) for a in 'abc'} } World") -12 12 | print(f"Hello { set(f(a) for a in 'abc') } World") -13 13 | -14 14 | C401.py:12:17: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) | @@ -93,15 +57,6 @@ C401.py:12:17: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) | = help: Rewrite as a `set` comprehension -ℹ Unsafe fix -9 9 | return x -10 10 | -11 11 | print(f"Hello {set(f(a) for a in 'abc')} World") -12 |-print(f"Hello { set(f(a) for a in 'abc') } World") - 12 |+print(f"Hello { {f(a) for a in 'abc'} } World") -13 13 | -14 14 | -15 15 | # Short-circuit case, combine with C416 and should produce x = set(range(3)) C401.py:16:5: C401 [*] Unnecessary generator (rewrite using `set()` | @@ -113,15 +68,6 @@ C401.py:16:5: C401 [*] Unnecessary generator (rewrite using `set()` | = help: Rewrite using `set()` -ℹ Unsafe fix -13 13 | -14 14 | -15 15 | # Short-circuit case, combine with C416 and should produce x = set(range(3)) -16 |-x = set(x for x in range(3)) - 16 |+x = set(range(3)) -17 17 | x = set( -18 18 | x for x in range(3) -19 19 | ) C401.py:17:5: C401 [*] Unnecessary generator (rewrite using `set()` | @@ -137,17 +83,6 @@ C401.py:17:5: C401 [*] Unnecessary generator (rewrite using `set()` | = help: Rewrite using `set()` -ℹ Unsafe fix -14 14 | -15 15 | # Short-circuit case, combine with C416 and should produce x = set(range(3)) -16 16 | x = set(x for x in range(3)) -17 |-x = set( -18 |- x for x in range(3) -19 |-) - 17 |+x = set(range(3)) -20 18 | print(f"Hello {set(a for a in range(3))} World") -21 19 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") -22 20 | print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") C401.py:20:16: C401 [*] Unnecessary generator (rewrite using `set()` | @@ -160,15 +95,6 @@ C401.py:20:16: C401 [*] Unnecessary generator (rewrite using `set()` | = help: Rewrite using `set()` -ℹ Unsafe fix -17 17 | x = set( -18 18 | x for x in range(3) -19 19 | ) -20 |-print(f"Hello {set(a for a in range(3))} World") - 20 |+print(f"Hello {set(range(3))} World") -21 21 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") -22 22 | print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") -23 23 | C401.py:21:10: C401 [*] Unnecessary generator (rewrite using `set()` | @@ -180,15 +106,6 @@ C401.py:21:10: C401 [*] Unnecessary generator (rewrite using `set()` | = help: Rewrite using `set()` -ℹ Unsafe fix -18 18 | x for x in range(3) -19 19 | ) -20 20 | print(f"Hello {set(a for a in range(3))} World") -21 |-print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") - 21 |+print(f"{set('abc') - set(a for a in 'ab')}") -22 22 | print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") -23 23 | -24 24 | C401.py:21:34: C401 [*] Unnecessary generator (rewrite using `set()` | @@ -200,15 +117,6 @@ C401.py:21:34: C401 [*] Unnecessary generator (rewrite using `set()` | = help: Rewrite using `set()` -ℹ Unsafe fix -18 18 | x for x in range(3) -19 19 | ) -20 20 | print(f"Hello {set(a for a in range(3))} World") -21 |-print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") - 21 |+print(f"{set(a for a in 'abc') - set('ab')}") -22 22 | print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") -23 23 | -24 24 | C401.py:22:11: C401 [*] Unnecessary generator (rewrite using `set()` | @@ -219,15 +127,6 @@ C401.py:22:11: C401 [*] Unnecessary generator (rewrite using `set()` | = help: Rewrite using `set()` -ℹ Unsafe fix -19 19 | ) -20 20 | print(f"Hello {set(a for a in range(3))} World") -21 21 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") -22 |-print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") - 22 |+print(f"{ set('abc') - set(a for a in 'ab') }") -23 23 | -24 24 | -25 25 | # Not built-in set. C401.py:22:35: C401 [*] Unnecessary generator (rewrite using `set()` | @@ -237,13 +136,3 @@ C401.py:22:35: C401 [*] Unnecessary generator (rewrite using `set()` | ^^^^^^^^^^^^^^^^^^^^ C401 | = help: Rewrite using `set()` - -ℹ Unsafe fix -19 19 | ) -20 20 | print(f"Hello {set(a for a in range(3))} World") -21 21 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") -22 |-print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") - 22 |+print(f"{ set(a for a in 'abc') - set('ab') }") -23 23 | -24 24 | -25 25 | # Not built-in set. diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C402_C402.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C402_C402.py.snap index 1a79ba66f5baa..adbc120aaa6c8 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C402_C402.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C402_C402.py.snap @@ -10,12 +10,6 @@ C402.py:1:1: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) | = help: Rewrite as a `dict` comprehension -ℹ Unsafe fix -1 |-dict((x, x) for x in range(3)) - 1 |+{x: x for x in range(3)} -2 2 | dict( -3 3 | (x, x) for x in range(3) -4 4 | ) C402.py:2:1: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) | @@ -29,17 +23,6 @@ C402.py:2:1: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) | = help: Rewrite as a `dict` comprehension -ℹ Unsafe fix -1 1 | dict((x, x) for x in range(3)) -2 |-dict( -3 |- (x, x) for x in range(3) -4 |-) - 2 |+{ - 3 |+ x: x for x in range(3) - 4 |+} -5 5 | dict(((x, x) for x in range(3)), z=3) -6 6 | y = f'{dict((x, x) for x in range(3))}' -7 7 | print(f'Hello {dict((x, x) for x in range(3))} World') C402.py:6:8: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) | @@ -52,15 +35,6 @@ C402.py:6:8: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) | = help: Rewrite as a `dict` comprehension -ℹ Unsafe fix -3 3 | (x, x) for x in range(3) -4 4 | ) -5 5 | dict(((x, x) for x in range(3)), z=3) -6 |-y = f'{dict((x, x) for x in range(3))}' - 6 |+y = f'{ {x: x for x in range(3)} }' -7 7 | print(f'Hello {dict((x, x) for x in range(3))} World') -8 8 | print(f"Hello {dict((x, x) for x in 'abc')} World") -9 9 | print(f'Hello {dict((x, x) for x in "abc")} World') C402.py:7:16: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) | @@ -73,15 +47,6 @@ C402.py:7:16: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) | = help: Rewrite as a `dict` comprehension -ℹ Unsafe fix -4 4 | ) -5 5 | dict(((x, x) for x in range(3)), z=3) -6 6 | y = f'{dict((x, x) for x in range(3))}' -7 |-print(f'Hello {dict((x, x) for x in range(3))} World') - 7 |+print(f'Hello { {x: x for x in range(3)} } World') -8 8 | print(f"Hello {dict((x, x) for x in 'abc')} World") -9 9 | print(f'Hello {dict((x, x) for x in "abc")} World') -10 10 | print(f'Hello {dict((x,x) for x in "abc")} World') C402.py:8:16: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) | @@ -94,15 +59,6 @@ C402.py:8:16: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) | = help: Rewrite as a `dict` comprehension -ℹ Unsafe fix -5 5 | dict(((x, x) for x in range(3)), z=3) -6 6 | y = f'{dict((x, x) for x in range(3))}' -7 7 | print(f'Hello {dict((x, x) for x in range(3))} World') -8 |-print(f"Hello {dict((x, x) for x in 'abc')} World") - 8 |+print(f"Hello { {x: x for x in 'abc'} } World") -9 9 | print(f'Hello {dict((x, x) for x in "abc")} World') -10 10 | print(f'Hello {dict((x,x) for x in "abc")} World') -11 11 | C402.py:9:16: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) | @@ -114,15 +70,6 @@ C402.py:9:16: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) | = help: Rewrite as a `dict` comprehension -ℹ Unsafe fix -6 6 | y = f'{dict((x, x) for x in range(3))}' -7 7 | print(f'Hello {dict((x, x) for x in range(3))} World') -8 8 | print(f"Hello {dict((x, x) for x in 'abc')} World") -9 |-print(f'Hello {dict((x, x) for x in "abc")} World') - 9 |+print(f'Hello { {x: x for x in "abc"} } World') -10 10 | print(f'Hello {dict((x,x) for x in "abc")} World') -11 11 | -12 12 | f'{dict((x, x) for x in range(3)) | dict((x, x) for x in range(3))}' C402.py:10:16: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) | @@ -135,15 +82,6 @@ C402.py:10:16: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension | = help: Rewrite as a `dict` comprehension -ℹ Unsafe fix -7 7 | print(f'Hello {dict((x, x) for x in range(3))} World') -8 8 | print(f"Hello {dict((x, x) for x in 'abc')} World") -9 9 | print(f'Hello {dict((x, x) for x in "abc")} World') -10 |-print(f'Hello {dict((x,x) for x in "abc")} World') - 10 |+print(f'Hello { {x: x for x in "abc"} } World') -11 11 | -12 12 | f'{dict((x, x) for x in range(3)) | dict((x, x) for x in range(3))}' -13 13 | f'{ dict((x, x) for x in range(3)) | dict((x, x) for x in range(3)) }' C402.py:12:4: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) | @@ -155,15 +93,6 @@ C402.py:12:4: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) | = help: Rewrite as a `dict` comprehension -ℹ Unsafe fix -9 9 | print(f'Hello {dict((x, x) for x in "abc")} World') -10 10 | print(f'Hello {dict((x,x) for x in "abc")} World') -11 11 | -12 |-f'{dict((x, x) for x in range(3)) | dict((x, x) for x in range(3))}' - 12 |+f'{ {x: x for x in range(3)} | dict((x, x) for x in range(3))}' -13 13 | f'{ dict((x, x) for x in range(3)) | dict((x, x) for x in range(3)) }' -14 14 | -15 15 | def f(x): C402.py:12:37: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) | @@ -175,15 +104,6 @@ C402.py:12:37: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension | = help: Rewrite as a `dict` comprehension -ℹ Unsafe fix -9 9 | print(f'Hello {dict((x, x) for x in "abc")} World') -10 10 | print(f'Hello {dict((x,x) for x in "abc")} World') -11 11 | -12 |-f'{dict((x, x) for x in range(3)) | dict((x, x) for x in range(3))}' - 12 |+f'{dict((x, x) for x in range(3)) | {x: x for x in range(3)} }' -13 13 | f'{ dict((x, x) for x in range(3)) | dict((x, x) for x in range(3)) }' -14 14 | -15 15 | def f(x): C402.py:13:5: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) | @@ -195,15 +115,6 @@ C402.py:13:5: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) | = help: Rewrite as a `dict` comprehension -ℹ Unsafe fix -10 10 | print(f'Hello {dict((x,x) for x in "abc")} World') -11 11 | -12 12 | f'{dict((x, x) for x in range(3)) | dict((x, x) for x in range(3))}' -13 |-f'{ dict((x, x) for x in range(3)) | dict((x, x) for x in range(3)) }' - 13 |+f'{ {x: x for x in range(3)} | dict((x, x) for x in range(3)) }' -14 14 | -15 15 | def f(x): -16 16 | return x C402.py:13:38: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) | @@ -215,15 +126,6 @@ C402.py:13:38: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension | = help: Rewrite as a `dict` comprehension -ℹ Unsafe fix -10 10 | print(f'Hello {dict((x,x) for x in "abc")} World') -11 11 | -12 12 | f'{dict((x, x) for x in range(3)) | dict((x, x) for x in range(3))}' -13 |-f'{ dict((x, x) for x in range(3)) | dict((x, x) for x in range(3)) }' - 13 |+f'{ dict((x, x) for x in range(3)) | {x: x for x in range(3)} }' -14 14 | -15 15 | def f(x): -16 16 | return x C402.py:18:16: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) | @@ -236,15 +138,6 @@ C402.py:18:16: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension | = help: Rewrite as a `dict` comprehension -ℹ Unsafe fix -15 15 | def f(x): -16 16 | return x -17 17 | -18 |-print(f'Hello {dict((x,f(x)) for x in "abc")} World') - 18 |+print(f'Hello { {x: f(x) for x in "abc"} } World') -19 19 | -20 20 | # Regression test for: https://github.com/astral-sh/ruff/issues/7086 -21 21 | dict((k,v)for k,v in d.iteritems() if k in only_args) C402.py:21:1: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) | @@ -255,15 +148,3 @@ C402.py:21:1: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) 23 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722458940 | = help: Rewrite as a `dict` comprehension - -ℹ Unsafe fix -18 18 | print(f'Hello {dict((x,f(x)) for x in "abc")} World') -19 19 | -20 20 | # Regression test for: https://github.com/astral-sh/ruff/issues/7086 -21 |-dict((k,v)for k,v in d.iteritems() if k in only_args) - 21 |+{k: v for k,v in d.iteritems() if k in only_args} -22 22 | -23 23 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722458940 -24 24 | dict((*v, k) for k, v in enumerate(calendar.month_abbr)) - - diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C403_C403.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C403_C403.py.snap index 8b30f0a8e2537..8884aaa82953a 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C403_C403.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C403_C403.py.snap @@ -10,12 +10,6 @@ C403.py:1:5: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` compr | = help: Rewrite as a `set` comprehension -ℹ Unsafe fix -1 |-s = set([x for x in range(3)]) - 1 |+s = {x for x in range(3)} -2 2 | s = set( -3 3 | [x for x in range(3)] -4 4 | ) C403.py:2:5: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension) | @@ -30,17 +24,6 @@ C403.py:2:5: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` compr | = help: Rewrite as a `set` comprehension -ℹ Unsafe fix -1 1 | s = set([x for x in range(3)]) -2 |-s = set( -3 |- [x for x in range(3)] -4 |-) - 2 |+s = { - 3 |+ x for x in range(3) - 4 |+} -5 5 | -6 6 | s = f"{set([x for x in 'ab'])}" -7 7 | s = f'{set([x for x in "ab"])}' C403.py:6:8: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension) | @@ -52,15 +35,6 @@ C403.py:6:8: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` compr | = help: Rewrite as a `set` comprehension -ℹ Unsafe fix -3 3 | [x for x in range(3)] -4 4 | ) -5 5 | -6 |-s = f"{set([x for x in 'ab'])}" - 6 |+s = f"{ {x for x in 'ab'} }" -7 7 | s = f'{set([x for x in "ab"])}' -8 8 | -9 9 | def f(x): C403.py:7:8: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension) | @@ -72,15 +46,6 @@ C403.py:7:8: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` compr | = help: Rewrite as a `set` comprehension -ℹ Unsafe fix -4 4 | ) -5 5 | -6 6 | s = f"{set([x for x in 'ab'])}" -7 |-s = f'{set([x for x in "ab"])}' - 7 |+s = f'{ {x for x in "ab"} }' -8 8 | -9 9 | def f(x): -10 10 | return x C403.py:12:8: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension) | @@ -93,15 +58,6 @@ C403.py:12:8: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comp | = help: Rewrite as a `set` comprehension -ℹ Unsafe fix -9 9 | def f(x): -10 10 | return x -11 11 | -12 |-s = f"{set([f(x) for x in 'ab'])}" - 12 |+s = f"{ {f(x) for x in 'ab'} }" -13 13 | -14 14 | s = f"{ set([x for x in 'ab']) | set([x for x in 'ab']) }" -15 15 | s = f"{set([x for x in 'ab']) | set([x for x in 'ab'])}" C403.py:14:9: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension) | @@ -113,15 +69,6 @@ C403.py:14:9: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comp | = help: Rewrite as a `set` comprehension -ℹ Unsafe fix -11 11 | -12 12 | s = f"{set([f(x) for x in 'ab'])}" -13 13 | -14 |-s = f"{ set([x for x in 'ab']) | set([x for x in 'ab']) }" - 14 |+s = f"{ {x for x in 'ab'} | set([x for x in 'ab']) }" -15 15 | s = f"{set([x for x in 'ab']) | set([x for x in 'ab'])}" -16 16 | -17 17 | s = set( # comment C403.py:14:34: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension) | @@ -133,15 +80,6 @@ C403.py:14:34: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` com | = help: Rewrite as a `set` comprehension -ℹ Unsafe fix -11 11 | -12 12 | s = f"{set([f(x) for x in 'ab'])}" -13 13 | -14 |-s = f"{ set([x for x in 'ab']) | set([x for x in 'ab']) }" - 14 |+s = f"{ set([x for x in 'ab']) | {x for x in 'ab'} }" -15 15 | s = f"{set([x for x in 'ab']) | set([x for x in 'ab'])}" -16 16 | -17 17 | s = set( # comment C403.py:15:8: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension) | @@ -153,15 +91,6 @@ C403.py:15:8: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comp | = help: Rewrite as a `set` comprehension -ℹ Unsafe fix -12 12 | s = f"{set([f(x) for x in 'ab'])}" -13 13 | -14 14 | s = f"{ set([x for x in 'ab']) | set([x for x in 'ab']) }" -15 |-s = f"{set([x for x in 'ab']) | set([x for x in 'ab'])}" - 15 |+s = f"{ {x for x in 'ab'} | set([x for x in 'ab'])}" -16 16 | -17 17 | s = set( # comment -18 18 | [x for x in range(3)] C403.py:15:33: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension) | @@ -173,15 +102,6 @@ C403.py:15:33: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` com | = help: Rewrite as a `set` comprehension -ℹ Unsafe fix -12 12 | s = f"{set([f(x) for x in 'ab'])}" -13 13 | -14 14 | s = f"{ set([x for x in 'ab']) | set([x for x in 'ab']) }" -15 |-s = f"{set([x for x in 'ab']) | set([x for x in 'ab'])}" - 15 |+s = f"{set([x for x in 'ab']) | {x for x in 'ab'} }" -16 16 | -17 17 | s = set( # comment -18 18 | [x for x in range(3)] C403.py:17:5: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension) | @@ -197,19 +117,6 @@ C403.py:17:5: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comp | = help: Rewrite as a `set` comprehension -ℹ Unsafe fix -14 14 | s = f"{ set([x for x in 'ab']) | set([x for x in 'ab']) }" -15 15 | s = f"{set([x for x in 'ab']) | set([x for x in 'ab'])}" -16 16 | -17 |-s = set( # comment -18 |- [x for x in range(3)] -19 |-) - 17 |+s = { # comment - 18 |+ x for x in range(3) - 19 |+} -20 20 | -21 21 | s = set([ # comment -22 22 | x for x in range(3) C403.py:21:5: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension) | @@ -222,15 +129,3 @@ C403.py:21:5: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comp | |__^ C403 | = help: Rewrite as a `set` comprehension - -ℹ Unsafe fix -18 18 | [x for x in range(3)] -19 19 | ) -20 20 | -21 |-s = set([ # comment - 21 |+s = { # comment -22 22 | x for x in range(3) -23 |-]) - 23 |+} - - diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C404_C404.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C404_C404.py.snap index 6ee5af803d1de..1624bbe22f63e 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C404_C404.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C404_C404.py.snap @@ -9,12 +9,6 @@ C404.py:1:1: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comp | = help: Rewrite as a `dict` comprehension -ℹ Unsafe fix -1 |-dict([(i, i) for i in range(3)]) - 1 |+{i: i for i in range(3)} -2 2 | dict([(i, i) for i in range(3)], z=4) -3 3 | -4 4 | def f(x): C404.py:7:4: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) | @@ -27,15 +21,6 @@ C404.py:7:4: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comp | = help: Rewrite as a `dict` comprehension -ℹ Unsafe fix -4 4 | def f(x): -5 5 | return x -6 6 | -7 |-f'{dict([(s,s) for s in "ab"])}' - 7 |+f'{ {s: s for s in "ab"} }' -8 8 | f"{dict([(s,s) for s in 'ab'])}" -9 9 | f"{dict([(s, s) for s in 'ab'])}" -10 10 | f"{dict([(s,f(s)) for s in 'ab'])}" C404.py:8:4: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) | @@ -47,15 +32,6 @@ C404.py:8:4: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comp | = help: Rewrite as a `dict` comprehension -ℹ Unsafe fix -5 5 | return x -6 6 | -7 7 | f'{dict([(s,s) for s in "ab"])}' -8 |-f"{dict([(s,s) for s in 'ab'])}" - 8 |+f"{ {s: s for s in 'ab'} }" -9 9 | f"{dict([(s, s) for s in 'ab'])}" -10 10 | f"{dict([(s,f(s)) for s in 'ab'])}" -11 11 | C404.py:9:4: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) | @@ -67,15 +43,6 @@ C404.py:9:4: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comp | = help: Rewrite as a `dict` comprehension -ℹ Unsafe fix -6 6 | -7 7 | f'{dict([(s,s) for s in "ab"])}' -8 8 | f"{dict([(s,s) for s in 'ab'])}" -9 |-f"{dict([(s, s) for s in 'ab'])}" - 9 |+f"{ {s: s for s in 'ab'} }" -10 10 | f"{dict([(s,f(s)) for s in 'ab'])}" -11 11 | -12 12 | f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}' C404.py:10:4: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) | @@ -88,15 +55,6 @@ C404.py:10:4: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` com | = help: Rewrite as a `dict` comprehension -ℹ Unsafe fix -7 7 | f'{dict([(s,s) for s in "ab"])}' -8 8 | f"{dict([(s,s) for s in 'ab'])}" -9 9 | f"{dict([(s, s) for s in 'ab'])}" -10 |-f"{dict([(s,f(s)) for s in 'ab'])}" - 10 |+f"{ {s: f(s) for s in 'ab'} }" -11 11 | -12 12 | f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}' -13 13 | f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }' C404.py:12:4: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) | @@ -108,15 +66,6 @@ C404.py:12:4: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` com | = help: Rewrite as a `dict` comprehension -ℹ Unsafe fix -9 9 | f"{dict([(s, s) for s in 'ab'])}" -10 10 | f"{dict([(s,f(s)) for s in 'ab'])}" -11 11 | -12 |-f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}' - 12 |+f'{ {s: s for s in "ab"} | dict([(s,s) for s in "ab"])}' -13 13 | f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }' -14 14 | -15 15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 C404.py:12:34: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) | @@ -128,15 +77,6 @@ C404.py:12:34: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` co | = help: Rewrite as a `dict` comprehension -ℹ Unsafe fix -9 9 | f"{dict([(s, s) for s in 'ab'])}" -10 10 | f"{dict([(s,f(s)) for s in 'ab'])}" -11 11 | -12 |-f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}' - 12 |+f'{dict([(s,s) for s in "ab"]) | {s: s for s in "ab"} }' -13 13 | f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }' -14 14 | -15 15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 C404.py:13:5: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) | @@ -148,15 +88,6 @@ C404.py:13:5: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` com | = help: Rewrite as a `dict` comprehension -ℹ Unsafe fix -10 10 | f"{dict([(s,f(s)) for s in 'ab'])}" -11 11 | -12 12 | f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}' -13 |-f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }' - 13 |+f'{ {s: s for s in "ab"} | dict([(s,s) for s in "ab"]) }' -14 14 | -15 15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 -16 16 | saved.append(dict([(k, v)for k,v in list(unique_instance.__dict__.items()) if k in [f.name for f in unique_instance._meta.fields]])) C404.py:13:35: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) | @@ -168,15 +99,6 @@ C404.py:13:35: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` co | = help: Rewrite as a `dict` comprehension -ℹ Unsafe fix -10 10 | f"{dict([(s,f(s)) for s in 'ab'])}" -11 11 | -12 12 | f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}' -13 |-f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }' - 13 |+f'{ dict([(s,s) for s in "ab"]) | {s: s for s in "ab"} }' -14 14 | -15 15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 -16 16 | saved.append(dict([(k, v)for k,v in list(unique_instance.__dict__.items()) if k in [f.name for f in unique_instance._meta.fields]])) C404.py:16:14: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) | @@ -185,12 +107,3 @@ C404.py:16:14: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` co | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C404 | = help: Rewrite as a `dict` comprehension - -ℹ Unsafe fix -13 13 | f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }' -14 14 | -15 15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 -16 |-saved.append(dict([(k, v)for k,v in list(unique_instance.__dict__.items()) if k in [f.name for f in unique_instance._meta.fields]])) - 16 |+saved.append({k: v for k,v in list(unique_instance.__dict__.items()) if k in [f.name for f in unique_instance._meta.fields]}) - - diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C405_C405.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C405_C405.py.snap index 1ab72fff86626..8a02f1636a5fa 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C405_C405.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C405_C405.py.snap @@ -10,12 +10,6 @@ C405.py:1:1: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) | = help: Rewrite as a `set` literal -ℹ Unsafe fix -1 |-set([1, 2]) - 1 |+{1, 2} -2 2 | set((1, 2)) -3 3 | set([]) -4 4 | set(()) C405.py:2:1: C405 [*] Unnecessary `tuple` literal (rewrite as a `set` literal) | @@ -27,13 +21,6 @@ C405.py:2:1: C405 [*] Unnecessary `tuple` literal (rewrite as a `set` literal) | = help: Rewrite as a `set` literal -ℹ Unsafe fix -1 1 | set([1, 2]) -2 |-set((1, 2)) - 2 |+{1, 2} -3 3 | set([]) -4 4 | set(()) -5 5 | set() C405.py:3:1: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) | @@ -46,14 +33,6 @@ C405.py:3:1: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) | = help: Rewrite as a `set` literal -ℹ Unsafe fix -1 1 | set([1, 2]) -2 2 | set((1, 2)) -3 |-set([]) - 3 |+set() -4 4 | set(()) -5 5 | set() -6 6 | set((1,)) C405.py:4:1: C405 [*] Unnecessary `tuple` literal (rewrite as a `set` literal) | @@ -66,16 +45,6 @@ C405.py:4:1: C405 [*] Unnecessary `tuple` literal (rewrite as a `set` literal) | = help: Rewrite as a `set` literal -ℹ Unsafe fix -1 1 | set([1, 2]) -2 2 | set((1, 2)) -3 3 | set([]) -4 |-set(()) -5 4 | set() - 5 |+set() -6 6 | set((1,)) -7 7 | set(( -8 8 | 1, C405.py:6:1: C405 [*] Unnecessary `tuple` literal (rewrite as a `set` literal) | @@ -88,15 +57,6 @@ C405.py:6:1: C405 [*] Unnecessary `tuple` literal (rewrite as a `set` literal) | = help: Rewrite as a `set` literal -ℹ Unsafe fix -3 3 | set([]) -4 4 | set(()) -5 5 | set() -6 |-set((1,)) - 6 |+{1} -7 7 | set(( -8 8 | 1, -9 9 | )) C405.py:7:1: C405 [*] Unnecessary `tuple` literal (rewrite as a `set` literal) | @@ -111,18 +71,6 @@ C405.py:7:1: C405 [*] Unnecessary `tuple` literal (rewrite as a `set` literal) | = help: Rewrite as a `set` literal -ℹ Unsafe fix -4 4 | set(()) -5 5 | set() -6 6 | set((1,)) -7 |-set(( - 7 |+{ -8 8 | 1, -9 |-)) - 9 |+} -10 10 | set([ -11 11 | 1, -12 12 | ]) C405.py:10:1: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) | @@ -137,18 +85,6 @@ C405.py:10:1: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) | = help: Rewrite as a `set` literal -ℹ Unsafe fix -7 7 | set(( -8 8 | 1, -9 9 | )) -10 |-set([ - 10 |+{ -11 11 | 1, -12 |-]) - 12 |+} -13 13 | set( -14 14 | (1,) -15 15 | ) C405.py:13:1: C405 [*] Unnecessary `tuple` literal (rewrite as a `set` literal) | @@ -163,17 +99,6 @@ C405.py:13:1: C405 [*] Unnecessary `tuple` literal (rewrite as a `set` literal) | = help: Rewrite as a `set` literal -ℹ Unsafe fix -10 10 | set([ -11 11 | 1, -12 12 | ]) -13 |-set( -14 |- (1,) -15 |-) - 13 |+{1} -16 14 | set( -17 15 | [1,] -18 16 | ) C405.py:16:1: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) | @@ -188,17 +113,6 @@ C405.py:16:1: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) | = help: Rewrite as a `set` literal -ℹ Unsafe fix -13 13 | set( -14 14 | (1,) -15 15 | ) -16 |-set( -17 |- [1,] -18 |-) - 16 |+{1,} -19 17 | f"{set([1,2,3])}" -20 18 | f"{set(['a', 'b'])}" -21 19 | f'{set(["a", "b"])}' C405.py:19:4: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) | @@ -211,15 +125,6 @@ C405.py:19:4: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) | = help: Rewrite as a `set` literal -ℹ Unsafe fix -16 16 | set( -17 17 | [1,] -18 18 | ) -19 |-f"{set([1,2,3])}" - 19 |+f"{ {1,2,3} }" -20 20 | f"{set(['a', 'b'])}" -21 21 | f'{set(["a", "b"])}' -22 22 | C405.py:20:4: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) | @@ -231,15 +136,6 @@ C405.py:20:4: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) | = help: Rewrite as a `set` literal -ℹ Unsafe fix -17 17 | [1,] -18 18 | ) -19 19 | f"{set([1,2,3])}" -20 |-f"{set(['a', 'b'])}" - 20 |+f"{ {'a', 'b'} }" -21 21 | f'{set(["a", "b"])}' -22 22 | -23 23 | f"{set(['a', 'b']) - set(['a'])}" C405.py:21:4: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) | @@ -252,15 +148,6 @@ C405.py:21:4: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) | = help: Rewrite as a `set` literal -ℹ Unsafe fix -18 18 | ) -19 19 | f"{set([1,2,3])}" -20 20 | f"{set(['a', 'b'])}" -21 |-f'{set(["a", "b"])}' - 21 |+f'{ {"a", "b"} }' -22 22 | -23 23 | f"{set(['a', 'b']) - set(['a'])}" -24 24 | f"{ set(['a', 'b']) - set(['a']) }" C405.py:23:4: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) | @@ -273,15 +160,6 @@ C405.py:23:4: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) | = help: Rewrite as a `set` literal -ℹ Unsafe fix -20 20 | f"{set(['a', 'b'])}" -21 21 | f'{set(["a", "b"])}' -22 22 | -23 |-f"{set(['a', 'b']) - set(['a'])}" - 23 |+f"{ {'a', 'b'} - set(['a'])}" -24 24 | f"{ set(['a', 'b']) - set(['a']) }" -25 25 | f"a {set(['a', 'b']) - set(['a'])} b" -26 26 | f"a { set(['a', 'b']) - set(['a']) } b" C405.py:23:22: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) | @@ -294,15 +172,6 @@ C405.py:23:22: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) | = help: Rewrite as a `set` literal -ℹ Unsafe fix -20 20 | f"{set(['a', 'b'])}" -21 21 | f'{set(["a", "b"])}' -22 22 | -23 |-f"{set(['a', 'b']) - set(['a'])}" - 23 |+f"{set(['a', 'b']) - {'a'} }" -24 24 | f"{ set(['a', 'b']) - set(['a']) }" -25 25 | f"a {set(['a', 'b']) - set(['a'])} b" -26 26 | f"a { set(['a', 'b']) - set(['a']) } b" C405.py:24:5: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) | @@ -314,14 +183,6 @@ C405.py:24:5: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) | = help: Rewrite as a `set` literal -ℹ Unsafe fix -21 21 | f'{set(["a", "b"])}' -22 22 | -23 23 | f"{set(['a', 'b']) - set(['a'])}" -24 |-f"{ set(['a', 'b']) - set(['a']) }" - 24 |+f"{ {'a', 'b'} - set(['a']) }" -25 25 | f"a {set(['a', 'b']) - set(['a'])} b" -26 26 | f"a { set(['a', 'b']) - set(['a']) } b" C405.py:24:23: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) | @@ -333,14 +194,6 @@ C405.py:24:23: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) | = help: Rewrite as a `set` literal -ℹ Unsafe fix -21 21 | f'{set(["a", "b"])}' -22 22 | -23 23 | f"{set(['a', 'b']) - set(['a'])}" -24 |-f"{ set(['a', 'b']) - set(['a']) }" - 24 |+f"{ set(['a', 'b']) - {'a'} }" -25 25 | f"a {set(['a', 'b']) - set(['a'])} b" -26 26 | f"a { set(['a', 'b']) - set(['a']) } b" C405.py:25:6: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) | @@ -352,13 +205,6 @@ C405.py:25:6: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) | = help: Rewrite as a `set` literal -ℹ Unsafe fix -22 22 | -23 23 | f"{set(['a', 'b']) - set(['a'])}" -24 24 | f"{ set(['a', 'b']) - set(['a']) }" -25 |-f"a {set(['a', 'b']) - set(['a'])} b" - 25 |+f"a { {'a', 'b'} - set(['a'])} b" -26 26 | f"a { set(['a', 'b']) - set(['a']) } b" C405.py:25:24: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) | @@ -370,13 +216,6 @@ C405.py:25:24: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) | = help: Rewrite as a `set` literal -ℹ Unsafe fix -22 22 | -23 23 | f"{set(['a', 'b']) - set(['a'])}" -24 24 | f"{ set(['a', 'b']) - set(['a']) }" -25 |-f"a {set(['a', 'b']) - set(['a'])} b" - 25 |+f"a {set(['a', 'b']) - {'a'} } b" -26 26 | f"a { set(['a', 'b']) - set(['a']) } b" C405.py:26:7: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) | @@ -387,12 +226,6 @@ C405.py:26:7: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) | = help: Rewrite as a `set` literal -ℹ Unsafe fix -23 23 | f"{set(['a', 'b']) - set(['a'])}" -24 24 | f"{ set(['a', 'b']) - set(['a']) }" -25 25 | f"a {set(['a', 'b']) - set(['a'])} b" -26 |-f"a { set(['a', 'b']) - set(['a']) } b" - 26 |+f"a { {'a', 'b'} - set(['a']) } b" C405.py:26:25: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) | @@ -402,12 +235,3 @@ C405.py:26:25: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) | ^^^^^^^^^^ C405 | = help: Rewrite as a `set` literal - -ℹ Unsafe fix -23 23 | f"{set(['a', 'b']) - set(['a'])}" -24 24 | f"{ set(['a', 'b']) - set(['a']) }" -25 25 | f"a {set(['a', 'b']) - set(['a'])} b" -26 |-f"a { set(['a', 'b']) - set(['a']) } b" - 26 |+f"a { set(['a', 'b']) - {'a'} } b" - - diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C406_C406.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C406_C406.py.snap index d9847ec6c6178..1109d27ffe143 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C406_C406.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C406_C406.py.snap @@ -10,12 +10,6 @@ C406.py:1:6: C406 [*] Unnecessary `list` literal (rewrite as a `dict` literal) | = help: Rewrite as a `dict` literal -ℹ Unsafe fix -1 |-d1 = dict([(1, 2)]) - 1 |+d1 = {1: 2} -2 2 | d2 = dict(((1, 2),)) -3 3 | d3 = dict([]) -4 4 | d4 = dict(()) C406.py:2:6: C406 [*] Unnecessary `tuple` literal (rewrite as a `dict` literal) | @@ -27,13 +21,6 @@ C406.py:2:6: C406 [*] Unnecessary `tuple` literal (rewrite as a `dict` literal) | = help: Rewrite as a `dict` literal -ℹ Unsafe fix -1 1 | d1 = dict([(1, 2)]) -2 |-d2 = dict(((1, 2),)) - 2 |+d2 = {1: 2,} -3 3 | d3 = dict([]) -4 4 | d4 = dict(()) -5 5 | d5 = dict() C406.py:3:6: C406 [*] Unnecessary `list` literal (rewrite as a `dict` literal) | @@ -46,13 +33,6 @@ C406.py:3:6: C406 [*] Unnecessary `list` literal (rewrite as a `dict` literal) | = help: Rewrite as a `dict` literal -ℹ Unsafe fix -1 1 | d1 = dict([(1, 2)]) -2 2 | d2 = dict(((1, 2),)) -3 |-d3 = dict([]) - 3 |+d3 = {} -4 4 | d4 = dict(()) -5 5 | d5 = dict() C406.py:4:6: C406 [*] Unnecessary `tuple` literal (rewrite as a `dict` literal) | @@ -63,13 +43,3 @@ C406.py:4:6: C406 [*] Unnecessary `tuple` literal (rewrite as a `dict` literal) 5 | d5 = dict() | = help: Rewrite as a `dict` literal - -ℹ Unsafe fix -1 1 | d1 = dict([(1, 2)]) -2 2 | d2 = dict(((1, 2),)) -3 3 | d3 = dict([]) -4 |-d4 = dict(()) - 4 |+d4 = {} -5 5 | d5 = dict() - - diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C408_C408.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C408_C408.py.snap index 6b4414d1b4a87..9a67f24b8424f 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C408_C408.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C408_C408.py.snap @@ -10,12 +10,6 @@ C408.py:1:5: C408 [*] Unnecessary `tuple` call (rewrite as a literal) | = help: Rewrite as a literal -ℹ Unsafe fix -1 |-t = tuple() - 1 |+t = () -2 2 | l = list() -3 3 | d1 = dict() -4 4 | d2 = dict(a=1) C408.py:2:5: C408 [*] Unnecessary `list` call (rewrite as a literal) | @@ -27,13 +21,6 @@ C408.py:2:5: C408 [*] Unnecessary `list` call (rewrite as a literal) | = help: Rewrite as a literal -ℹ Unsafe fix -1 1 | t = tuple() -2 |-l = list() - 2 |+l = [] -3 3 | d1 = dict() -4 4 | d2 = dict(a=1) -5 5 | d3 = dict(**d2) C408.py:3:6: C408 [*] Unnecessary `dict` call (rewrite as a literal) | @@ -46,14 +33,6 @@ C408.py:3:6: C408 [*] Unnecessary `dict` call (rewrite as a literal) | = help: Rewrite as a literal -ℹ Unsafe fix -1 1 | t = tuple() -2 2 | l = list() -3 |-d1 = dict() - 3 |+d1 = {} -4 4 | d2 = dict(a=1) -5 5 | d3 = dict(**d2) -6 6 | C408.py:4:6: C408 [*] Unnecessary `dict` call (rewrite as a literal) | @@ -65,15 +44,6 @@ C408.py:4:6: C408 [*] Unnecessary `dict` call (rewrite as a literal) | = help: Rewrite as a literal -ℹ Unsafe fix -1 1 | t = tuple() -2 2 | l = list() -3 3 | d1 = dict() -4 |-d2 = dict(a=1) - 4 |+d2 = {"a": 1} -5 5 | d3 = dict(**d2) -6 6 | -7 7 | C408.py:14:4: C408 [*] Unnecessary `dict` call (rewrite as a literal) | @@ -86,15 +56,6 @@ C408.py:14:4: C408 [*] Unnecessary `dict` call (rewrite as a literal) | = help: Rewrite as a literal -ℹ Unsafe fix -11 11 | -12 12 | a = list() -13 13 | -14 |-f"{dict(x='y')}" - 14 |+f"{ {'x': 'y'} }" -15 15 | f'{dict(x="y")}' -16 16 | f"{dict()}" -17 17 | f"a {dict()} b" C408.py:15:4: C408 [*] Unnecessary `dict` call (rewrite as a literal) | @@ -106,15 +67,6 @@ C408.py:15:4: C408 [*] Unnecessary `dict` call (rewrite as a literal) | = help: Rewrite as a literal -ℹ Unsafe fix -12 12 | a = list() -13 13 | -14 14 | f"{dict(x='y')}" -15 |-f'{dict(x="y")}' - 15 |+f'{ {"x": "y"} }' -16 16 | f"{dict()}" -17 17 | f"a {dict()} b" -18 18 | C408.py:16:4: C408 [*] Unnecessary `dict` call (rewrite as a literal) | @@ -126,15 +78,6 @@ C408.py:16:4: C408 [*] Unnecessary `dict` call (rewrite as a literal) | = help: Rewrite as a literal -ℹ Unsafe fix -13 13 | -14 14 | f"{dict(x='y')}" -15 15 | f'{dict(x="y")}' -16 |-f"{dict()}" - 16 |+f"{ {} }" -17 17 | f"a {dict()} b" -18 18 | -19 19 | f"{dict(x='y') | dict(y='z')}" C408.py:17:6: C408 [*] Unnecessary `dict` call (rewrite as a literal) | @@ -147,15 +90,6 @@ C408.py:17:6: C408 [*] Unnecessary `dict` call (rewrite as a literal) | = help: Rewrite as a literal -ℹ Unsafe fix -14 14 | f"{dict(x='y')}" -15 15 | f'{dict(x="y")}' -16 16 | f"{dict()}" -17 |-f"a {dict()} b" - 17 |+f"a { {} } b" -18 18 | -19 19 | f"{dict(x='y') | dict(y='z')}" -20 20 | f"{ dict(x='y') | dict(y='z') }" C408.py:19:4: C408 [*] Unnecessary `dict` call (rewrite as a literal) | @@ -168,15 +102,6 @@ C408.py:19:4: C408 [*] Unnecessary `dict` call (rewrite as a literal) | = help: Rewrite as a literal -ℹ Unsafe fix -16 16 | f"{dict()}" -17 17 | f"a {dict()} b" -18 18 | -19 |-f"{dict(x='y') | dict(y='z')}" - 19 |+f"{ {'x': 'y'} | dict(y='z')}" -20 20 | f"{ dict(x='y') | dict(y='z') }" -21 21 | f"a {dict(x='y') | dict(y='z')} b" -22 22 | f"a { dict(x='y') | dict(y='z') } b" C408.py:19:18: C408 [*] Unnecessary `dict` call (rewrite as a literal) | @@ -189,15 +114,6 @@ C408.py:19:18: C408 [*] Unnecessary `dict` call (rewrite as a literal) | = help: Rewrite as a literal -ℹ Unsafe fix -16 16 | f"{dict()}" -17 17 | f"a {dict()} b" -18 18 | -19 |-f"{dict(x='y') | dict(y='z')}" - 19 |+f"{dict(x='y') | {'y': 'z'} }" -20 20 | f"{ dict(x='y') | dict(y='z') }" -21 21 | f"a {dict(x='y') | dict(y='z')} b" -22 22 | f"a { dict(x='y') | dict(y='z') } b" C408.py:20:5: C408 [*] Unnecessary `dict` call (rewrite as a literal) | @@ -209,15 +125,6 @@ C408.py:20:5: C408 [*] Unnecessary `dict` call (rewrite as a literal) | = help: Rewrite as a literal -ℹ Unsafe fix -17 17 | f"a {dict()} b" -18 18 | -19 19 | f"{dict(x='y') | dict(y='z')}" -20 |-f"{ dict(x='y') | dict(y='z') }" - 20 |+f"{ {'x': 'y'} | dict(y='z') }" -21 21 | f"a {dict(x='y') | dict(y='z')} b" -22 22 | f"a { dict(x='y') | dict(y='z') } b" -23 23 | C408.py:20:19: C408 [*] Unnecessary `dict` call (rewrite as a literal) | @@ -229,15 +136,6 @@ C408.py:20:19: C408 [*] Unnecessary `dict` call (rewrite as a literal) | = help: Rewrite as a literal -ℹ Unsafe fix -17 17 | f"a {dict()} b" -18 18 | -19 19 | f"{dict(x='y') | dict(y='z')}" -20 |-f"{ dict(x='y') | dict(y='z') }" - 20 |+f"{ dict(x='y') | {'y': 'z'} }" -21 21 | f"a {dict(x='y') | dict(y='z')} b" -22 22 | f"a { dict(x='y') | dict(y='z') } b" -23 23 | C408.py:21:6: C408 [*] Unnecessary `dict` call (rewrite as a literal) | @@ -249,15 +147,6 @@ C408.py:21:6: C408 [*] Unnecessary `dict` call (rewrite as a literal) | = help: Rewrite as a literal -ℹ Unsafe fix -18 18 | -19 19 | f"{dict(x='y') | dict(y='z')}" -20 20 | f"{ dict(x='y') | dict(y='z') }" -21 |-f"a {dict(x='y') | dict(y='z')} b" - 21 |+f"a { {'x': 'y'} | dict(y='z')} b" -22 22 | f"a { dict(x='y') | dict(y='z') } b" -23 23 | -24 24 | dict( C408.py:21:20: C408 [*] Unnecessary `dict` call (rewrite as a literal) | @@ -269,15 +158,6 @@ C408.py:21:20: C408 [*] Unnecessary `dict` call (rewrite as a literal) | = help: Rewrite as a literal -ℹ Unsafe fix -18 18 | -19 19 | f"{dict(x='y') | dict(y='z')}" -20 20 | f"{ dict(x='y') | dict(y='z') }" -21 |-f"a {dict(x='y') | dict(y='z')} b" - 21 |+f"a {dict(x='y') | {'y': 'z'} } b" -22 22 | f"a { dict(x='y') | dict(y='z') } b" -23 23 | -24 24 | dict( C408.py:22:7: C408 [*] Unnecessary `dict` call (rewrite as a literal) | @@ -290,15 +170,6 @@ C408.py:22:7: C408 [*] Unnecessary `dict` call (rewrite as a literal) | = help: Rewrite as a literal -ℹ Unsafe fix -19 19 | f"{dict(x='y') | dict(y='z')}" -20 20 | f"{ dict(x='y') | dict(y='z') }" -21 21 | f"a {dict(x='y') | dict(y='z')} b" -22 |-f"a { dict(x='y') | dict(y='z') } b" - 22 |+f"a { {'x': 'y'} | dict(y='z') } b" -23 23 | -24 24 | dict( -25 25 | # comment C408.py:22:21: C408 [*] Unnecessary `dict` call (rewrite as a literal) | @@ -311,15 +182,6 @@ C408.py:22:21: C408 [*] Unnecessary `dict` call (rewrite as a literal) | = help: Rewrite as a literal -ℹ Unsafe fix -19 19 | f"{dict(x='y') | dict(y='z')}" -20 20 | f"{ dict(x='y') | dict(y='z') }" -21 21 | f"a {dict(x='y') | dict(y='z')} b" -22 |-f"a { dict(x='y') | dict(y='z') } b" - 22 |+f"a { dict(x='y') | {'y': 'z'} } b" -23 23 | -24 24 | dict( -25 25 | # comment C408.py:24:1: C408 [*] Unnecessary `dict` call (rewrite as a literal) | @@ -334,18 +196,6 @@ C408.py:24:1: C408 [*] Unnecessary `dict` call (rewrite as a literal) | = help: Rewrite as a literal -ℹ Unsafe fix -21 21 | f"a {dict(x='y') | dict(y='z')} b" -22 22 | f"a { dict(x='y') | dict(y='z') } b" -23 23 | -24 |-dict( - 24 |+{ -25 25 | # comment -26 |-) - 26 |+} -27 27 | -28 28 | tuple( # comment -29 29 | ) C408.py:28:1: C408 [*] Unnecessary `tuple` call (rewrite as a literal) | @@ -356,13 +206,3 @@ C408.py:28:1: C408 [*] Unnecessary `tuple` call (rewrite as a literal) | |_^ C408 | = help: Rewrite as a literal - -ℹ Unsafe fix -25 25 | # comment -26 26 | ) -27 27 | -28 |-tuple( # comment - 28 |+( # comment -29 29 | ) - - diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C408_C408.py_allow_dict_calls_with_keyword_arguments.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C408_C408.py_allow_dict_calls_with_keyword_arguments.snap index 59c761f4aa603..fecda9d490fe9 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C408_C408.py_allow_dict_calls_with_keyword_arguments.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C408_C408.py_allow_dict_calls_with_keyword_arguments.snap @@ -10,12 +10,6 @@ C408.py:1:5: C408 [*] Unnecessary `tuple` call (rewrite as a literal) | = help: Rewrite as a literal -ℹ Unsafe fix -1 |-t = tuple() - 1 |+t = () -2 2 | l = list() -3 3 | d1 = dict() -4 4 | d2 = dict(a=1) C408.py:2:5: C408 [*] Unnecessary `list` call (rewrite as a literal) | @@ -27,13 +21,6 @@ C408.py:2:5: C408 [*] Unnecessary `list` call (rewrite as a literal) | = help: Rewrite as a literal -ℹ Unsafe fix -1 1 | t = tuple() -2 |-l = list() - 2 |+l = [] -3 3 | d1 = dict() -4 4 | d2 = dict(a=1) -5 5 | d3 = dict(**d2) C408.py:3:6: C408 [*] Unnecessary `dict` call (rewrite as a literal) | @@ -46,14 +33,6 @@ C408.py:3:6: C408 [*] Unnecessary `dict` call (rewrite as a literal) | = help: Rewrite as a literal -ℹ Unsafe fix -1 1 | t = tuple() -2 2 | l = list() -3 |-d1 = dict() - 3 |+d1 = {} -4 4 | d2 = dict(a=1) -5 5 | d3 = dict(**d2) -6 6 | C408.py:16:4: C408 [*] Unnecessary `dict` call (rewrite as a literal) | @@ -65,15 +44,6 @@ C408.py:16:4: C408 [*] Unnecessary `dict` call (rewrite as a literal) | = help: Rewrite as a literal -ℹ Unsafe fix -13 13 | -14 14 | f"{dict(x='y')}" -15 15 | f'{dict(x="y")}' -16 |-f"{dict()}" - 16 |+f"{ {} }" -17 17 | f"a {dict()} b" -18 18 | -19 19 | f"{dict(x='y') | dict(y='z')}" C408.py:17:6: C408 [*] Unnecessary `dict` call (rewrite as a literal) | @@ -86,15 +56,6 @@ C408.py:17:6: C408 [*] Unnecessary `dict` call (rewrite as a literal) | = help: Rewrite as a literal -ℹ Unsafe fix -14 14 | f"{dict(x='y')}" -15 15 | f'{dict(x="y")}' -16 16 | f"{dict()}" -17 |-f"a {dict()} b" - 17 |+f"a { {} } b" -18 18 | -19 19 | f"{dict(x='y') | dict(y='z')}" -20 20 | f"{ dict(x='y') | dict(y='z') }" C408.py:24:1: C408 [*] Unnecessary `dict` call (rewrite as a literal) | @@ -109,18 +70,6 @@ C408.py:24:1: C408 [*] Unnecessary `dict` call (rewrite as a literal) | = help: Rewrite as a literal -ℹ Unsafe fix -21 21 | f"a {dict(x='y') | dict(y='z')} b" -22 22 | f"a { dict(x='y') | dict(y='z') } b" -23 23 | -24 |-dict( - 24 |+{ -25 25 | # comment -26 |-) - 26 |+} -27 27 | -28 28 | tuple( # comment -29 29 | ) C408.py:28:1: C408 [*] Unnecessary `tuple` call (rewrite as a literal) | @@ -131,13 +80,3 @@ C408.py:28:1: C408 [*] Unnecessary `tuple` call (rewrite as a literal) | |_^ C408 | = help: Rewrite as a literal - -ℹ Unsafe fix -25 25 | # comment -26 26 | ) -27 27 | -28 |-tuple( # comment - 28 |+( # comment -29 29 | ) - - diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C409_C409.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C409_C409.py.snap index e7feb37b081cd..5400d9a1dd2d5 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C409_C409.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C409_C409.py.snap @@ -10,12 +10,6 @@ C409.py:1:6: C409 [*] Unnecessary `list` literal passed to `tuple()` (rewrite as | = help: Rewrite as a `tuple` literal -ℹ Unsafe fix -1 |-t1 = tuple([]) - 1 |+t1 = () -2 2 | t2 = tuple([1, 2]) -3 3 | t3 = tuple((1, 2)) -4 4 | t4 = tuple([ C409.py:2:6: C409 [*] Unnecessary `list` literal passed to `tuple()` (rewrite as a `tuple` literal) | @@ -27,13 +21,6 @@ C409.py:2:6: C409 [*] Unnecessary `list` literal passed to `tuple()` (rewrite as | = help: Rewrite as a `tuple` literal -ℹ Unsafe fix -1 1 | t1 = tuple([]) -2 |-t2 = tuple([1, 2]) - 2 |+t2 = (1, 2) -3 3 | t3 = tuple((1, 2)) -4 4 | t4 = tuple([ -5 5 | 1, C409.py:3:6: C409 [*] Unnecessary `tuple` literal passed to `tuple()` (remove the outer call to `tuple()`) | @@ -46,14 +33,6 @@ C409.py:3:6: C409 [*] Unnecessary `tuple` literal passed to `tuple()` (remove th | = help: Remove outer `tuple` call -ℹ Unsafe fix -1 1 | t1 = tuple([]) -2 2 | t2 = tuple([1, 2]) -3 |-t3 = tuple((1, 2)) - 3 |+t3 = (1, 2) -4 4 | t4 = tuple([ -5 5 | 1, -6 6 | 2 C409.py:4:6: C409 [*] Unnecessary `list` literal passed to `tuple()` (rewrite as a `tuple` literal) | @@ -70,19 +49,6 @@ C409.py:4:6: C409 [*] Unnecessary `list` literal passed to `tuple()` (rewrite as | = help: Rewrite as a `tuple` literal -ℹ Unsafe fix -1 1 | t1 = tuple([]) -2 2 | t2 = tuple([1, 2]) -3 3 | t3 = tuple((1, 2)) -4 |-t4 = tuple([ - 4 |+t4 = ( -5 5 | 1, -6 6 | 2 -7 |-]) - 7 |+) -8 8 | t5 = tuple( -9 9 | (1, 2) -10 10 | ) C409.py:8:6: C409 [*] Unnecessary `tuple` literal passed to `tuple()` (remove the outer call to `tuple()`) | @@ -98,17 +64,6 @@ C409.py:8:6: C409 [*] Unnecessary `tuple` literal passed to `tuple()` (remove th | = help: Remove outer `tuple` call -ℹ Unsafe fix -5 5 | 1, -6 6 | 2 -7 7 | ]) -8 |-t5 = tuple( -9 |- (1, 2) -10 |-) - 8 |+t5 = (1, 2) -11 9 | -12 10 | tuple( # comment -13 11 | [1, 2] C409.py:12:1: C409 [*] Unnecessary `list` literal passed to `tuple()` (rewrite as a `tuple` literal) | @@ -123,17 +78,6 @@ C409.py:12:1: C409 [*] Unnecessary `list` literal passed to `tuple()` (rewrite a | = help: Rewrite as a `tuple` literal -ℹ Unsafe fix -9 9 | (1, 2) -10 10 | ) -11 11 | -12 |-tuple( # comment -13 |- [1, 2] -14 |-) - 12 |+(1, 2) -15 13 | -16 14 | tuple([ # comment -17 15 | 1, 2 C409.py:16:1: C409 [*] Unnecessary `list` literal passed to `tuple()` (rewrite as a `tuple` literal) | @@ -148,18 +92,6 @@ C409.py:16:1: C409 [*] Unnecessary `list` literal passed to `tuple()` (rewrite a | = help: Rewrite as a `tuple` literal -ℹ Unsafe fix -13 13 | [1, 2] -14 14 | ) -15 15 | -16 |-tuple([ # comment - 16 |+( # comment -17 17 | 1, 2 -18 |-]) - 18 |+) -19 19 | -20 20 | tuple(( -21 21 | 1, C409.py:20:1: C409 [*] Unnecessary `tuple` literal passed to `tuple()` (remove the outer call to `tuple()`) | @@ -174,18 +106,6 @@ C409.py:20:1: C409 [*] Unnecessary `tuple` literal passed to `tuple()` (remove t | = help: Remove outer `tuple` call -ℹ Unsafe fix -17 17 | 1, 2 -18 18 | ]) -19 19 | -20 |-tuple(( - 20 |+( -21 21 | 1, -22 |-)) - 22 |+) -23 23 | -24 24 | t6 = tuple([1]) -25 25 | t7 = tuple((1,)) C409.py:24:6: C409 [*] Unnecessary `list` literal passed to `tuple()` (rewrite as a `tuple` literal) | @@ -198,14 +118,6 @@ C409.py:24:6: C409 [*] Unnecessary `list` literal passed to `tuple()` (rewrite a | = help: Rewrite as a `tuple` literal -ℹ Unsafe fix -21 21 | 1, -22 22 | )) -23 23 | -24 |-t6 = tuple([1]) - 24 |+t6 = (1,) -25 25 | t7 = tuple((1,)) -26 26 | t8 = tuple([1,]) C409.py:25:6: C409 [*] Unnecessary `tuple` literal passed to `tuple()` (remove the outer call to `tuple()`) | @@ -216,13 +128,6 @@ C409.py:25:6: C409 [*] Unnecessary `tuple` literal passed to `tuple()` (remove t | = help: Remove outer `tuple` call -ℹ Unsafe fix -22 22 | )) -23 23 | -24 24 | t6 = tuple([1]) -25 |-t7 = tuple((1,)) - 25 |+t7 = (1,) -26 26 | t8 = tuple([1,]) C409.py:26:6: C409 [*] Unnecessary `list` literal passed to `tuple()` (rewrite as a `tuple` literal) | @@ -232,10 +137,3 @@ C409.py:26:6: C409 [*] Unnecessary `list` literal passed to `tuple()` (rewrite a | ^^^^^^^^^^^ C409 | = help: Rewrite as a `tuple` literal - -ℹ Unsafe fix -23 23 | -24 24 | t6 = tuple([1]) -25 25 | t7 = tuple((1,)) -26 |-t8 = tuple([1,]) - 26 |+t8 = (1,) diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C410_C410.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C410_C410.py.snap index 921547ca2dedc..739057be350f4 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C410_C410.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C410_C410.py.snap @@ -10,12 +10,6 @@ C410.py:1:6: C410 [*] Unnecessary `list` literal passed to `list()` (remove the | = help: Remove outer `list` call -ℹ Unsafe fix -1 |-l1 = list([1, 2]) - 1 |+l1 = [1, 2] -2 2 | l2 = list((1, 2)) -3 3 | l3 = list([]) -4 4 | l4 = list(()) C410.py:2:6: C410 [*] Unnecessary `tuple` literal passed to `list()` (rewrite as a `list` literal) | @@ -27,13 +21,6 @@ C410.py:2:6: C410 [*] Unnecessary `tuple` literal passed to `list()` (rewrite as | = help: Rewrite as a `list` literal -ℹ Unsafe fix -1 1 | l1 = list([1, 2]) -2 |-l2 = list((1, 2)) - 2 |+l2 = [1, 2] -3 3 | l3 = list([]) -4 4 | l4 = list(()) -5 5 | C410.py:3:6: C410 [*] Unnecessary `list` literal passed to `list()` (remove the outer call to `list()`) | @@ -45,14 +32,6 @@ C410.py:3:6: C410 [*] Unnecessary `list` literal passed to `list()` (remove the | = help: Remove outer `list` call -ℹ Unsafe fix -1 1 | l1 = list([1, 2]) -2 2 | l2 = list((1, 2)) -3 |-l3 = list([]) - 3 |+l3 = [] -4 4 | l4 = list(()) -5 5 | -6 6 | C410.py:4:6: C410 [*] Unnecessary `tuple` literal passed to `list()` (rewrite as a `list` literal) | @@ -63,15 +42,6 @@ C410.py:4:6: C410 [*] Unnecessary `tuple` literal passed to `list()` (rewrite as | = help: Rewrite as a `list` literal -ℹ Unsafe fix -1 1 | l1 = list([1, 2]) -2 2 | l2 = list((1, 2)) -3 3 | l3 = list([]) -4 |-l4 = list(()) - 4 |+l4 = [] -5 5 | -6 6 | -7 7 | list( # comment C410.py:7:1: C410 [*] Unnecessary `list` literal passed to `list()` (remove the outer call to `list()`) | @@ -84,17 +54,6 @@ C410.py:7:1: C410 [*] Unnecessary `list` literal passed to `list()` (remove the | = help: Remove outer `list` call -ℹ Unsafe fix -4 4 | l4 = list(()) -5 5 | -6 6 | -7 |-list( # comment -8 |- [1, 2] -9 |-) - 7 |+[1, 2] -10 8 | -11 9 | list([ # comment -12 10 | 1, 2 C410.py:11:1: C410 [*] Unnecessary `list` literal passed to `list()` (remove the outer call to `list()`) | @@ -106,15 +65,3 @@ C410.py:11:1: C410 [*] Unnecessary `list` literal passed to `list()` (remove the | |__^ C410 | = help: Remove outer `list` call - -ℹ Unsafe fix -8 8 | [1, 2] -9 9 | ) -10 10 | -11 |-list([ # comment - 11 |+[ # comment -12 12 | 1, 2 -13 |-]) - 13 |+] - - diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C411_C411.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C411_C411.py.snap index 763f99136ea68..1d5612cec40ce 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C411_C411.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C411_C411.py.snap @@ -8,10 +8,3 @@ C411.py:2:1: C411 [*] Unnecessary `list` call (remove the outer call to `list()` | ^^^^^^^^^^^^^^^^^^^^ C411 | = help: Remove outer `list` call - -ℹ Unsafe fix -1 1 | x = [1, 2, 3] -2 |-list([i for i in x]) - 2 |+[i for i in x] - - diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C413_C413.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C413_C413.py.snap index def04f25aea8f..e100579dc65cc 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C413_C413.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C413_C413.py.snap @@ -12,7 +12,6 @@ C413.py:3:1: C413 [*] Unnecessary `list` call around `sorted()` | = help: Remove unnecessary `list` call -ℹ Safe fix 1 1 | x = [2, 3, 1] 2 2 | list(x) 3 |-list(sorted(x)) @@ -32,15 +31,6 @@ C413.py:4:1: C413 [*] Unnecessary `reversed` call around `sorted()` | = help: Remove unnecessary `reversed` call -ℹ Unsafe fix -1 1 | x = [2, 3, 1] -2 2 | list(x) -3 3 | list(sorted(x)) -4 |-reversed(sorted(x)) - 4 |+sorted(x, reverse=True) -5 5 | reversed(sorted(x, key=lambda e: e)) -6 6 | reversed(sorted(x, reverse=True)) -7 7 | reversed(sorted(x, key=lambda e: e, reverse=True)) C413.py:5:1: C413 [*] Unnecessary `reversed` call around `sorted()` | @@ -53,15 +43,6 @@ C413.py:5:1: C413 [*] Unnecessary `reversed` call around `sorted()` | = help: Remove unnecessary `reversed` call -ℹ Unsafe fix -2 2 | list(x) -3 3 | list(sorted(x)) -4 4 | reversed(sorted(x)) -5 |-reversed(sorted(x, key=lambda e: e)) - 5 |+sorted(x, key=lambda e: e, reverse=True) -6 6 | reversed(sorted(x, reverse=True)) -7 7 | reversed(sorted(x, key=lambda e: e, reverse=True)) -8 8 | reversed(sorted(x, reverse=True, key=lambda e: e)) C413.py:6:1: C413 [*] Unnecessary `reversed` call around `sorted()` | @@ -74,15 +55,6 @@ C413.py:6:1: C413 [*] Unnecessary `reversed` call around `sorted()` | = help: Remove unnecessary `reversed` call -ℹ Unsafe fix -3 3 | list(sorted(x)) -4 4 | reversed(sorted(x)) -5 5 | reversed(sorted(x, key=lambda e: e)) -6 |-reversed(sorted(x, reverse=True)) - 6 |+sorted(x, reverse=False) -7 7 | reversed(sorted(x, key=lambda e: e, reverse=True)) -8 8 | reversed(sorted(x, reverse=True, key=lambda e: e)) -9 9 | reversed(sorted(x, reverse=False)) C413.py:7:1: C413 [*] Unnecessary `reversed` call around `sorted()` | @@ -95,15 +67,6 @@ C413.py:7:1: C413 [*] Unnecessary `reversed` call around `sorted()` | = help: Remove unnecessary `reversed` call -ℹ Unsafe fix -4 4 | reversed(sorted(x)) -5 5 | reversed(sorted(x, key=lambda e: e)) -6 6 | reversed(sorted(x, reverse=True)) -7 |-reversed(sorted(x, key=lambda e: e, reverse=True)) - 7 |+sorted(x, key=lambda e: e, reverse=False) -8 8 | reversed(sorted(x, reverse=True, key=lambda e: e)) -9 9 | reversed(sorted(x, reverse=False)) -10 10 | reversed(sorted(x, reverse=x)) C413.py:8:1: C413 [*] Unnecessary `reversed` call around `sorted()` | @@ -116,15 +79,6 @@ C413.py:8:1: C413 [*] Unnecessary `reversed` call around `sorted()` | = help: Remove unnecessary `reversed` call -ℹ Unsafe fix -5 5 | reversed(sorted(x, key=lambda e: e)) -6 6 | reversed(sorted(x, reverse=True)) -7 7 | reversed(sorted(x, key=lambda e: e, reverse=True)) -8 |-reversed(sorted(x, reverse=True, key=lambda e: e)) - 8 |+sorted(x, reverse=False, key=lambda e: e) -9 9 | reversed(sorted(x, reverse=False)) -10 10 | reversed(sorted(x, reverse=x)) -11 11 | reversed(sorted(x, reverse=not x)) C413.py:9:1: C413 [*] Unnecessary `reversed` call around `sorted()` | @@ -137,15 +91,6 @@ C413.py:9:1: C413 [*] Unnecessary `reversed` call around `sorted()` | = help: Remove unnecessary `reversed` call -ℹ Unsafe fix -6 6 | reversed(sorted(x, reverse=True)) -7 7 | reversed(sorted(x, key=lambda e: e, reverse=True)) -8 8 | reversed(sorted(x, reverse=True, key=lambda e: e)) -9 |-reversed(sorted(x, reverse=False)) - 9 |+sorted(x, reverse=True) -10 10 | reversed(sorted(x, reverse=x)) -11 11 | reversed(sorted(x, reverse=not x)) -12 12 | C413.py:10:1: C413 [*] Unnecessary `reversed` call around `sorted()` | @@ -157,15 +102,6 @@ C413.py:10:1: C413 [*] Unnecessary `reversed` call around `sorted()` | = help: Remove unnecessary `reversed` call -ℹ Unsafe fix -7 7 | reversed(sorted(x, key=lambda e: e, reverse=True)) -8 8 | reversed(sorted(x, reverse=True, key=lambda e: e)) -9 9 | reversed(sorted(x, reverse=False)) -10 |-reversed(sorted(x, reverse=x)) - 10 |+sorted(x, reverse=not x) -11 11 | reversed(sorted(x, reverse=not x)) -12 12 | -13 13 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289 C413.py:11:1: C413 [*] Unnecessary `reversed` call around `sorted()` | @@ -178,15 +114,6 @@ C413.py:11:1: C413 [*] Unnecessary `reversed` call around `sorted()` | = help: Remove unnecessary `reversed` call -ℹ Unsafe fix -8 8 | reversed(sorted(x, reverse=True, key=lambda e: e)) -9 9 | reversed(sorted(x, reverse=False)) -10 10 | reversed(sorted(x, reverse=x)) -11 |-reversed(sorted(x, reverse=not x)) - 11 |+sorted(x, reverse=x) -12 12 | -13 13 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289 -14 14 | reversed(sorted(i for i in range(42))) C413.py:14:1: C413 [*] Unnecessary `reversed` call around `sorted()` | @@ -197,15 +124,6 @@ C413.py:14:1: C413 [*] Unnecessary `reversed` call around `sorted()` | = help: Remove unnecessary `reversed` call -ℹ Unsafe fix -11 11 | reversed(sorted(x, reverse=not x)) -12 12 | -13 13 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289 -14 |-reversed(sorted(i for i in range(42))) - 14 |+sorted((i for i in range(42)), reverse=True) -15 15 | reversed(sorted((i for i in range(42)), reverse=True)) -16 16 | -17 17 | # Regression test for: https://github.com/astral-sh/ruff/issues/10335 C413.py:15:1: C413 [*] Unnecessary `reversed` call around `sorted()` | @@ -218,15 +136,6 @@ C413.py:15:1: C413 [*] Unnecessary `reversed` call around `sorted()` | = help: Remove unnecessary `reversed` call -ℹ Unsafe fix -12 12 | -13 13 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289 -14 14 | reversed(sorted(i for i in range(42))) -15 |-reversed(sorted((i for i in range(42)), reverse=True)) - 15 |+sorted((i for i in range(42)), reverse=False) -16 16 | -17 17 | # Regression test for: https://github.com/astral-sh/ruff/issues/10335 -18 18 | reversed(sorted([1, 2, 3], reverse=False or True)) C413.py:18:1: C413 [*] Unnecessary `reversed` call around `sorted()` | @@ -237,13 +146,6 @@ C413.py:18:1: C413 [*] Unnecessary `reversed` call around `sorted()` | = help: Remove unnecessary `reversed` call -ℹ Unsafe fix -15 15 | reversed(sorted((i for i in range(42)), reverse=True)) -16 16 | -17 17 | # Regression test for: https://github.com/astral-sh/ruff/issues/10335 -18 |-reversed(sorted([1, 2, 3], reverse=False or True)) - 18 |+sorted([1, 2, 3], reverse=not (False or True)) -19 19 | reversed(sorted([1, 2, 3], reverse=(False or True))) C413.py:19:1: C413 [*] Unnecessary `reversed` call around `sorted()` | @@ -253,10 +155,3 @@ C413.py:19:1: C413 [*] Unnecessary `reversed` call around `sorted()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 | = help: Remove unnecessary `reversed` call - -ℹ Unsafe fix -16 16 | -17 17 | # Regression test for: https://github.com/astral-sh/ruff/issues/10335 -18 18 | reversed(sorted([1, 2, 3], reverse=False or True)) -19 |-reversed(sorted([1, 2, 3], reverse=(False or True))) - 19 |+sorted([1, 2, 3], reverse=not (False or True)) diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C414_C414.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C414_C414.py.snap index 1551f9ccec221..d9dd304839e05 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C414_C414.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C414_C414.py.snap @@ -11,13 +11,6 @@ C414.py:2:1: C414 [*] Unnecessary `list` call within `list()` | = help: Remove the inner `list` call -ℹ Unsafe fix -1 1 | x = [1, 2, 3] -2 |-list(list(x)) - 2 |+list(x) -3 3 | list(tuple(x)) -4 4 | tuple(list(x)) -5 5 | tuple(tuple(x)) C414.py:3:1: C414 [*] Unnecessary `tuple` call within `list()` | @@ -30,14 +23,6 @@ C414.py:3:1: C414 [*] Unnecessary `tuple` call within `list()` | = help: Remove the inner `tuple` call -ℹ Unsafe fix -1 1 | x = [1, 2, 3] -2 2 | list(list(x)) -3 |-list(tuple(x)) - 3 |+list(x) -4 4 | tuple(list(x)) -5 5 | tuple(tuple(x)) -6 6 | set(set(x)) C414.py:4:1: C414 [*] Unnecessary `list` call within `tuple()` | @@ -50,15 +35,6 @@ C414.py:4:1: C414 [*] Unnecessary `list` call within `tuple()` | = help: Remove the inner `list` call -ℹ Unsafe fix -1 1 | x = [1, 2, 3] -2 2 | list(list(x)) -3 3 | list(tuple(x)) -4 |-tuple(list(x)) - 4 |+tuple(x) -5 5 | tuple(tuple(x)) -6 6 | set(set(x)) -7 7 | set(list(x)) C414.py:5:1: C414 [*] Unnecessary `tuple` call within `tuple()` | @@ -71,15 +47,6 @@ C414.py:5:1: C414 [*] Unnecessary `tuple` call within `tuple()` | = help: Remove the inner `tuple` call -ℹ Unsafe fix -2 2 | list(list(x)) -3 3 | list(tuple(x)) -4 4 | tuple(list(x)) -5 |-tuple(tuple(x)) - 5 |+tuple(x) -6 6 | set(set(x)) -7 7 | set(list(x)) -8 8 | set(tuple(x)) C414.py:6:1: C414 [*] Unnecessary `set` call within `set()` | @@ -92,15 +59,6 @@ C414.py:6:1: C414 [*] Unnecessary `set` call within `set()` | = help: Remove the inner `set` call -ℹ Unsafe fix -3 3 | list(tuple(x)) -4 4 | tuple(list(x)) -5 5 | tuple(tuple(x)) -6 |-set(set(x)) - 6 |+set(x) -7 7 | set(list(x)) -8 8 | set(tuple(x)) -9 9 | set(sorted(x)) C414.py:7:1: C414 [*] Unnecessary `list` call within `set()` | @@ -113,15 +71,6 @@ C414.py:7:1: C414 [*] Unnecessary `list` call within `set()` | = help: Remove the inner `list` call -ℹ Unsafe fix -4 4 | tuple(list(x)) -5 5 | tuple(tuple(x)) -6 6 | set(set(x)) -7 |-set(list(x)) - 7 |+set(x) -8 8 | set(tuple(x)) -9 9 | set(sorted(x)) -10 10 | set(sorted(x, key=lambda y: y)) C414.py:8:1: C414 [*] Unnecessary `tuple` call within `set()` | @@ -134,15 +83,6 @@ C414.py:8:1: C414 [*] Unnecessary `tuple` call within `set()` | = help: Remove the inner `tuple` call -ℹ Unsafe fix -5 5 | tuple(tuple(x)) -6 6 | set(set(x)) -7 7 | set(list(x)) -8 |-set(tuple(x)) - 8 |+set(x) -9 9 | set(sorted(x)) -10 10 | set(sorted(x, key=lambda y: y)) -11 11 | set(reversed(x)) C414.py:9:1: C414 [*] Unnecessary `sorted` call within `set()` | @@ -155,15 +95,6 @@ C414.py:9:1: C414 [*] Unnecessary `sorted` call within `set()` | = help: Remove the inner `sorted` call -ℹ Unsafe fix -6 6 | set(set(x)) -7 7 | set(list(x)) -8 8 | set(tuple(x)) -9 |-set(sorted(x)) - 9 |+set(x) -10 10 | set(sorted(x, key=lambda y: y)) -11 11 | set(reversed(x)) -12 12 | sorted(list(x)) C414.py:10:1: C414 [*] Unnecessary `sorted` call within `set()` | @@ -176,15 +107,6 @@ C414.py:10:1: C414 [*] Unnecessary `sorted` call within `set()` | = help: Remove the inner `sorted` call -ℹ Unsafe fix -7 7 | set(list(x)) -8 8 | set(tuple(x)) -9 9 | set(sorted(x)) -10 |-set(sorted(x, key=lambda y: y)) - 10 |+set(x) -11 11 | set(reversed(x)) -12 12 | sorted(list(x)) -13 13 | sorted(tuple(x)) C414.py:11:1: C414 [*] Unnecessary `reversed` call within `set()` | @@ -197,15 +119,6 @@ C414.py:11:1: C414 [*] Unnecessary `reversed` call within `set()` | = help: Remove the inner `reversed` call -ℹ Unsafe fix -8 8 | set(tuple(x)) -9 9 | set(sorted(x)) -10 10 | set(sorted(x, key=lambda y: y)) -11 |-set(reversed(x)) - 11 |+set(x) -12 12 | sorted(list(x)) -13 13 | sorted(tuple(x)) -14 14 | sorted(sorted(x)) C414.py:12:1: C414 [*] Unnecessary `list` call within `sorted()` | @@ -218,15 +131,6 @@ C414.py:12:1: C414 [*] Unnecessary `list` call within `sorted()` | = help: Remove the inner `list` call -ℹ Unsafe fix -9 9 | set(sorted(x)) -10 10 | set(sorted(x, key=lambda y: y)) -11 11 | set(reversed(x)) -12 |-sorted(list(x)) - 12 |+sorted(x) -13 13 | sorted(tuple(x)) -14 14 | sorted(sorted(x)) -15 15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) C414.py:13:1: C414 [*] Unnecessary `tuple` call within `sorted()` | @@ -239,15 +143,6 @@ C414.py:13:1: C414 [*] Unnecessary `tuple` call within `sorted()` | = help: Remove the inner `tuple` call -ℹ Unsafe fix -10 10 | set(sorted(x, key=lambda y: y)) -11 11 | set(reversed(x)) -12 12 | sorted(list(x)) -13 |-sorted(tuple(x)) - 13 |+sorted(x) -14 14 | sorted(sorted(x)) -15 15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) -16 16 | sorted(sorted(x, reverse=True), reverse=True) C414.py:14:1: C414 [*] Unnecessary `sorted` call within `sorted()` | @@ -260,15 +155,6 @@ C414.py:14:1: C414 [*] Unnecessary `sorted` call within `sorted()` | = help: Remove the inner `sorted` call -ℹ Unsafe fix -11 11 | set(reversed(x)) -12 12 | sorted(list(x)) -13 13 | sorted(tuple(x)) -14 |-sorted(sorted(x)) - 14 |+sorted(x) -15 15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) -16 16 | sorted(sorted(x, reverse=True), reverse=True) -17 17 | sorted(reversed(x)) C414.py:15:1: C414 [*] Unnecessary `sorted` call within `sorted()` | @@ -281,15 +167,6 @@ C414.py:15:1: C414 [*] Unnecessary `sorted` call within `sorted()` | = help: Remove the inner `sorted` call -ℹ Unsafe fix -12 12 | sorted(list(x)) -13 13 | sorted(tuple(x)) -14 14 | sorted(sorted(x)) -15 |-sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) - 15 |+sorted(x, reverse=False, key=foo) -16 16 | sorted(sorted(x, reverse=True), reverse=True) -17 17 | sorted(reversed(x)) -18 18 | sorted(list(x), key=lambda y: y) C414.py:16:1: C414 [*] Unnecessary `sorted` call within `sorted()` | @@ -302,15 +179,6 @@ C414.py:16:1: C414 [*] Unnecessary `sorted` call within `sorted()` | = help: Remove the inner `sorted` call -ℹ Unsafe fix -13 13 | sorted(tuple(x)) -14 14 | sorted(sorted(x)) -15 15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) -16 |-sorted(sorted(x, reverse=True), reverse=True) - 16 |+sorted(x, reverse=True) -17 17 | sorted(reversed(x)) -18 18 | sorted(list(x), key=lambda y: y) -19 19 | tuple( C414.py:17:1: C414 [*] Unnecessary `reversed` call within `sorted()` | @@ -323,15 +191,6 @@ C414.py:17:1: C414 [*] Unnecessary `reversed` call within `sorted()` | = help: Remove the inner `reversed` call -ℹ Unsafe fix -14 14 | sorted(sorted(x)) -15 15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) -16 16 | sorted(sorted(x, reverse=True), reverse=True) -17 |-sorted(reversed(x)) - 17 |+sorted(x) -18 18 | sorted(list(x), key=lambda y: y) -19 19 | tuple( -20 20 | list( C414.py:18:1: C414 [*] Unnecessary `list` call within `sorted()` | @@ -344,15 +203,6 @@ C414.py:18:1: C414 [*] Unnecessary `list` call within `sorted()` | = help: Remove the inner `list` call -ℹ Unsafe fix -15 15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) -16 16 | sorted(sorted(x, reverse=True), reverse=True) -17 17 | sorted(reversed(x)) -18 |-sorted(list(x), key=lambda y: y) - 18 |+sorted(x, key=lambda y: y) -19 19 | tuple( -20 20 | list( -21 21 | [x, 3, "hell"\ C414.py:19:1: C414 [*] Unnecessary `list` call within `tuple()` | @@ -370,18 +220,6 @@ C414.py:19:1: C414 [*] Unnecessary `list` call within `tuple()` | = help: Remove the inner `list` call -ℹ Unsafe fix -17 17 | sorted(reversed(x)) -18 18 | sorted(list(x), key=lambda y: y) -19 19 | tuple( -20 |- list( -21 |- [x, 3, "hell"\ - 20 |+ [x, 3, "hell"\ -22 21 | "o"] -23 |- ) -24 22 | ) -25 23 | set(set()) -26 24 | set(list()) C414.py:25:1: C414 [*] Unnecessary `set` call within `set()` | @@ -394,15 +232,6 @@ C414.py:25:1: C414 [*] Unnecessary `set` call within `set()` | = help: Remove the inner `set` call -ℹ Unsafe fix -22 22 | "o"] -23 23 | ) -24 24 | ) -25 |-set(set()) - 25 |+set() -26 26 | set(list()) -27 27 | set(tuple()) -28 28 | sorted(reversed()) C414.py:26:1: C414 [*] Unnecessary `list` call within `set()` | @@ -415,15 +244,6 @@ C414.py:26:1: C414 [*] Unnecessary `list` call within `set()` | = help: Remove the inner `list` call -ℹ Unsafe fix -23 23 | ) -24 24 | ) -25 25 | set(set()) -26 |-set(list()) - 26 |+set() -27 27 | set(tuple()) -28 28 | sorted(reversed()) -29 29 | C414.py:27:1: C414 [*] Unnecessary `tuple` call within `set()` | @@ -435,15 +255,6 @@ C414.py:27:1: C414 [*] Unnecessary `tuple` call within `set()` | = help: Remove the inner `tuple` call -ℹ Unsafe fix -24 24 | ) -25 25 | set(set()) -26 26 | set(list()) -27 |-set(tuple()) - 27 |+set() -28 28 | sorted(reversed()) -29 29 | -30 30 | # Nested sorts with differing keyword arguments. Not flagged. C414.py:28:1: C414 [*] Unnecessary `reversed` call within `sorted()` | @@ -456,15 +267,6 @@ C414.py:28:1: C414 [*] Unnecessary `reversed` call within `sorted()` | = help: Remove the inner `reversed` call -ℹ Unsafe fix -25 25 | set(set()) -26 26 | set(list()) -27 27 | set(tuple()) -28 |-sorted(reversed()) - 28 |+sorted() -29 29 | -30 30 | # Nested sorts with differing keyword arguments. Not flagged. -31 31 | sorted(sorted(x, key=lambda y: y)) C414.py:37:27: C414 [*] Unnecessary `list` call within `sorted()` | @@ -482,15 +284,6 @@ C414.py:37:27: C414 [*] Unnecessary `list` call within `sorted()` | = help: Remove the inner `list` call -ℹ Unsafe fix -35 35 | -36 36 | # Preserve trailing comments. -37 37 | xxxxxxxxxxx_xxxxx_xxxxx = sorted( -38 |- list(x_xxxx_xxxxxxxxxxx_xxxxx.xxxx()), - 38 |+ x_xxxx_xxxxxxxxxxx_xxxxx.xxxx(), -39 39 | # xxxxxxxxxxx xxxxx xxxx xxx xx Nxxx, xxx xxxxxx3 xxxxxxxxx xx -40 40 | # xx xxxx xxxxxxx xxxx xxx xxxxxxxx Nxxx -41 41 | key=lambda xxxxx: xxxxx or "", C414.py:44:27: C414 [*] Unnecessary `list` call within `sorted()` | @@ -504,14 +297,3 @@ C414.py:44:27: C414 [*] Unnecessary `list` call within `sorted()` | |_^ C414 | = help: Remove the inner `list` call - -ℹ Unsafe fix -42 42 | ) -43 43 | -44 44 | xxxxxxxxxxx_xxxxx_xxxxx = sorted( -45 |- list(x_xxxx_xxxxxxxxxxx_xxxxx.xxxx()), # xxxxxxxxxxx xxxxx xxxx xxx xx Nxxx - 45 |+ x_xxxx_xxxxxxxxxxx_xxxxx.xxxx(), # xxxxxxxxxxx xxxxx xxxx xxx xx Nxxx -46 46 | key=lambda xxxxx: xxxxx or "", -47 47 | ) - - diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C416_C416.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C416_C416.py.snap index 4ffbb2c029cde..0615a4e345b99 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C416_C416.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C416_C416.py.snap @@ -12,15 +12,6 @@ C416.py:6:1: C416 [*] Unnecessary `list` comprehension (rewrite using `list()`) | = help: Rewrite using `list()` -ℹ Unsafe fix -3 3 | z = [(1,), (2,), (3,)] -4 4 | d = {"a": 1, "b": 2, "c": 3} -5 5 | -6 |-[i for i in x] - 6 |+list(x) -7 7 | {i for i in x} -8 8 | {k: v for k, v in y} -9 9 | {k: v for k, v in d.items()} C416.py:7:1: C416 [*] Unnecessary `set` comprehension (rewrite using `set()`) | @@ -32,15 +23,6 @@ C416.py:7:1: C416 [*] Unnecessary `set` comprehension (rewrite using `set()`) | = help: Rewrite using `set()` -ℹ Unsafe fix -4 4 | d = {"a": 1, "b": 2, "c": 3} -5 5 | -6 6 | [i for i in x] -7 |-{i for i in x} - 7 |+set(x) -8 8 | {k: v for k, v in y} -9 9 | {k: v for k, v in d.items()} -10 10 | [(k, v) for k, v in d.items()] C416.py:8:1: C416 [*] Unnecessary `dict` comprehension (rewrite using `dict()`) | @@ -53,15 +35,6 @@ C416.py:8:1: C416 [*] Unnecessary `dict` comprehension (rewrite using `dict()`) | = help: Rewrite using `dict()` -ℹ Unsafe fix -5 5 | -6 6 | [i for i in x] -7 7 | {i for i in x} -8 |-{k: v for k, v in y} - 8 |+dict(y) -9 9 | {k: v for k, v in d.items()} -10 10 | [(k, v) for k, v in d.items()] -11 11 | {k: (a, b) for k, (a, b) in d.items()} C416.py:9:1: C416 [*] Unnecessary `dict` comprehension (rewrite using `dict()`) | @@ -74,15 +47,6 @@ C416.py:9:1: C416 [*] Unnecessary `dict` comprehension (rewrite using `dict()`) | = help: Rewrite using `dict()` -ℹ Unsafe fix -6 6 | [i for i in x] -7 7 | {i for i in x} -8 8 | {k: v for k, v in y} -9 |-{k: v for k, v in d.items()} - 9 |+dict(d.items()) -10 10 | [(k, v) for k, v in d.items()] -11 11 | {k: (a, b) for k, (a, b) in d.items()} -12 12 | C416.py:10:1: C416 [*] Unnecessary `list` comprehension (rewrite using `list()`) | @@ -94,15 +58,6 @@ C416.py:10:1: C416 [*] Unnecessary `list` comprehension (rewrite using `list()`) | = help: Rewrite using `list()` -ℹ Unsafe fix -7 7 | {i for i in x} -8 8 | {k: v for k, v in y} -9 9 | {k: v for k, v in d.items()} -10 |-[(k, v) for k, v in d.items()] - 10 |+list(d.items()) -11 11 | {k: (a, b) for k, (a, b) in d.items()} -12 12 | -13 13 | [i for i, in z] C416.py:11:1: C416 [*] Unnecessary `dict` comprehension (rewrite using `dict()`) | @@ -115,15 +70,6 @@ C416.py:11:1: C416 [*] Unnecessary `dict` comprehension (rewrite using `dict()`) | = help: Rewrite using `dict()` -ℹ Unsafe fix -8 8 | {k: v for k, v in y} -9 9 | {k: v for k, v in d.items()} -10 10 | [(k, v) for k, v in d.items()] -11 |-{k: (a, b) for k, (a, b) in d.items()} - 11 |+dict(d.items()) -12 12 | -13 13 | [i for i, in z] -14 14 | [i for i, j in y] C416.py:24:70: C416 [*] Unnecessary `list` comprehension (rewrite using `list()`) | @@ -132,12 +78,3 @@ C416.py:24:70: C416 [*] Unnecessary `list` comprehension (rewrite using `list()` | ^^^^^^^^^^^^^^^^^^^^^^^ C416 | = help: Rewrite using `list()` - -ℹ Unsafe fix -21 21 | {k: v if v else None for k, v in y} -22 22 | -23 23 | # Regression test for: https://github.com/astral-sh/ruff/issues/7196 -24 |-any(len(symbol_table.get_by_type(symbol_type)) > 0 for symbol_type in[t for t in SymbolType]) - 24 |+any(len(symbol_table.get_by_type(symbol_type)) > 0 for symbol_type in list(SymbolType)) - - diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C417_C417.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C417_C417.py.snap index fc37727a26d86..448d0771b6ad6 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C417_C417.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C417_C417.py.snap @@ -12,14 +12,6 @@ C417.py:3:1: C417 [*] Unnecessary `map` usage (rewrite using a generator express | = help: Replace `map` with a generator expression -ℹ Unsafe fix -1 1 | # Errors. -2 2 | nums = [1, 2, 3] -3 |-map(lambda x: x + 1, nums) - 3 |+(x + 1 for x in nums) -4 4 | map(lambda x: str(x), nums) -5 5 | list(map(lambda x: x * 2, nums)) -6 6 | set(map(lambda x: x % 2 == 0, nums)) C417.py:4:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) | @@ -32,15 +24,6 @@ C417.py:4:1: C417 [*] Unnecessary `map` usage (rewrite using a generator express | = help: Replace `map` with a generator expression -ℹ Unsafe fix -1 1 | # Errors. -2 2 | nums = [1, 2, 3] -3 3 | map(lambda x: x + 1, nums) -4 |-map(lambda x: str(x), nums) - 4 |+(str(x) for x in nums) -5 5 | list(map(lambda x: x * 2, nums)) -6 6 | set(map(lambda x: x % 2 == 0, nums)) -7 7 | dict(map(lambda v: (v, v**2), nums)) C417.py:5:1: C417 [*] Unnecessary `map` usage (rewrite using a `list` comprehension) | @@ -53,15 +36,6 @@ C417.py:5:1: C417 [*] Unnecessary `map` usage (rewrite using a `list` comprehens | = help: Replace `map` with a `list` comprehension -ℹ Unsafe fix -2 2 | nums = [1, 2, 3] -3 3 | map(lambda x: x + 1, nums) -4 4 | map(lambda x: str(x), nums) -5 |-list(map(lambda x: x * 2, nums)) - 5 |+[x * 2 for x in nums] -6 6 | set(map(lambda x: x % 2 == 0, nums)) -7 7 | dict(map(lambda v: (v, v**2), nums)) -8 8 | dict(map(lambda v: [v, v**2], nums)) C417.py:6:1: C417 [*] Unnecessary `map` usage (rewrite using a `set` comprehension) | @@ -74,15 +48,6 @@ C417.py:6:1: C417 [*] Unnecessary `map` usage (rewrite using a `set` comprehensi | = help: Replace `map` with a `set` comprehension -ℹ Unsafe fix -3 3 | map(lambda x: x + 1, nums) -4 4 | map(lambda x: str(x), nums) -5 5 | list(map(lambda x: x * 2, nums)) -6 |-set(map(lambda x: x % 2 == 0, nums)) - 6 |+{x % 2 == 0 for x in nums} -7 7 | dict(map(lambda v: (v, v**2), nums)) -8 8 | dict(map(lambda v: [v, v**2], nums)) -9 9 | map(lambda: "const", nums) C417.py:7:1: C417 [*] Unnecessary `map` usage (rewrite using a `dict` comprehension) | @@ -95,15 +60,6 @@ C417.py:7:1: C417 [*] Unnecessary `map` usage (rewrite using a `dict` comprehens | = help: Replace `map` with a `dict` comprehension -ℹ Unsafe fix -4 4 | map(lambda x: str(x), nums) -5 5 | list(map(lambda x: x * 2, nums)) -6 6 | set(map(lambda x: x % 2 == 0, nums)) -7 |-dict(map(lambda v: (v, v**2), nums)) - 7 |+{v: v**2 for v in nums} -8 8 | dict(map(lambda v: [v, v**2], nums)) -9 9 | map(lambda: "const", nums) -10 10 | map(lambda _: 3.0, nums) C417.py:8:1: C417 [*] Unnecessary `map` usage (rewrite using a `dict` comprehension) | @@ -116,15 +72,6 @@ C417.py:8:1: C417 [*] Unnecessary `map` usage (rewrite using a `dict` comprehens | = help: Replace `map` with a `dict` comprehension -ℹ Unsafe fix -5 5 | list(map(lambda x: x * 2, nums)) -6 6 | set(map(lambda x: x % 2 == 0, nums)) -7 7 | dict(map(lambda v: (v, v**2), nums)) -8 |-dict(map(lambda v: [v, v**2], nums)) - 8 |+{v: v**2 for v in nums} -9 9 | map(lambda: "const", nums) -10 10 | map(lambda _: 3.0, nums) -11 11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) C417.py:9:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) | @@ -137,15 +84,6 @@ C417.py:9:1: C417 [*] Unnecessary `map` usage (rewrite using a generator express | = help: Replace `map` with a generator expression -ℹ Unsafe fix -6 6 | set(map(lambda x: x % 2 == 0, nums)) -7 7 | dict(map(lambda v: (v, v**2), nums)) -8 8 | dict(map(lambda v: [v, v**2], nums)) -9 |-map(lambda: "const", nums) - 9 |+("const" for _ in nums) -10 10 | map(lambda _: 3.0, nums) -11 11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) -12 12 | all(map(lambda v: isinstance(v, dict), nums)) C417.py:10:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) | @@ -158,15 +96,6 @@ C417.py:10:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expres | = help: Replace `map` with a generator expression -ℹ Unsafe fix -7 7 | dict(map(lambda v: (v, v**2), nums)) -8 8 | dict(map(lambda v: [v, v**2], nums)) -9 9 | map(lambda: "const", nums) -10 |-map(lambda _: 3.0, nums) - 10 |+(3.0 for _ in nums) -11 11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) -12 12 | all(map(lambda v: isinstance(v, dict), nums)) -13 13 | filter(func, map(lambda v: v, nums)) C417.py:11:13: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) | @@ -179,15 +108,6 @@ C417.py:11:13: C417 [*] Unnecessary `map` usage (rewrite using a generator expre | = help: Replace `map` with a generator expression -ℹ Unsafe fix -8 8 | dict(map(lambda v: [v, v**2], nums)) -9 9 | map(lambda: "const", nums) -10 10 | map(lambda _: 3.0, nums) -11 |-_ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) - 11 |+_ = "".join((x in nums and "1" or "0" for x in range(123))) -12 12 | all(map(lambda v: isinstance(v, dict), nums)) -13 13 | filter(func, map(lambda v: v, nums)) -14 14 | list(map(lambda x, y: x * y, nums)) C417.py:12:5: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) | @@ -200,15 +120,6 @@ C417.py:12:5: C417 [*] Unnecessary `map` usage (rewrite using a generator expres | = help: Replace `map` with a generator expression -ℹ Unsafe fix -9 9 | map(lambda: "const", nums) -10 10 | map(lambda _: 3.0, nums) -11 11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) -12 |-all(map(lambda v: isinstance(v, dict), nums)) - 12 |+all((isinstance(v, dict) for v in nums)) -13 13 | filter(func, map(lambda v: v, nums)) -14 14 | list(map(lambda x, y: x * y, nums)) -15 15 | C417.py:13:14: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) | @@ -220,15 +131,6 @@ C417.py:13:14: C417 [*] Unnecessary `map` usage (rewrite using a generator expre | = help: Replace `map` with a generator expression -ℹ Unsafe fix -10 10 | map(lambda _: 3.0, nums) -11 11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) -12 12 | all(map(lambda v: isinstance(v, dict), nums)) -13 |-filter(func, map(lambda v: v, nums)) - 13 |+filter(func, (v for v in nums)) -14 14 | list(map(lambda x, y: x * y, nums)) -15 15 | -16 16 | # When inside f-string, then the fix should be surrounded by whitespace C417.py:14:1: C417 [*] Unnecessary `map` usage (rewrite using a `list` comprehension) | @@ -241,15 +143,6 @@ C417.py:14:1: C417 [*] Unnecessary `map` usage (rewrite using a `list` comprehen | = help: Replace `map` with a `list` comprehension -ℹ Unsafe fix -11 11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) -12 12 | all(map(lambda v: isinstance(v, dict), nums)) -13 13 | filter(func, map(lambda v: v, nums)) -14 |-list(map(lambda x, y: x * y, nums)) - 14 |+[x * y for x, y in nums] -15 15 | -16 16 | # When inside f-string, then the fix should be surrounded by whitespace -17 17 | _ = f"{set(map(lambda x: x % 2 == 0, nums))}" C417.py:17:8: C417 [*] Unnecessary `map` usage (rewrite using a `set` comprehension) | @@ -260,15 +153,6 @@ C417.py:17:8: C417 [*] Unnecessary `map` usage (rewrite using a `set` comprehens | = help: Replace `map` with a `set` comprehension -ℹ Unsafe fix -14 14 | list(map(lambda x, y: x * y, nums)) -15 15 | -16 16 | # When inside f-string, then the fix should be surrounded by whitespace -17 |-_ = f"{set(map(lambda x: x % 2 == 0, nums))}" - 17 |+_ = f"{ {x % 2 == 0 for x in nums} }" -18 18 | _ = f"{dict(map(lambda v: (v, v**2), nums))}" -19 19 | -20 20 | # False negatives. C417.py:18:8: C417 [*] Unnecessary `map` usage (rewrite using a `dict` comprehension) | @@ -281,15 +165,6 @@ C417.py:18:8: C417 [*] Unnecessary `map` usage (rewrite using a `dict` comprehen | = help: Replace `map` with a `dict` comprehension -ℹ Unsafe fix -15 15 | -16 16 | # When inside f-string, then the fix should be surrounded by whitespace -17 17 | _ = f"{set(map(lambda x: x % 2 == 0, nums))}" -18 |-_ = f"{dict(map(lambda v: (v, v**2), nums))}" - 18 |+_ = f"{ {v: v**2 for v in nums} }" -19 19 | -20 20 | # False negatives. -21 21 | map(lambda x=2, y=1: x + y, nums, nums) C417.py:36:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) | @@ -301,15 +176,6 @@ C417.py:36:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expres | = help: Replace `map` with a generator expression -ℹ Unsafe fix -33 33 | map(lambda x: lambda: x, range(4)) -34 34 | -35 35 | # Error: the `x` is overridden by the inner lambda. -36 |-map(lambda x: lambda x: x, range(4)) - 36 |+(lambda x: x for x in range(4)) -37 37 | -38 38 | # Ok because of the default parameters, and variadic arguments. -39 39 | map(lambda x=1: x, nums) C417.py:47:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) | @@ -321,14 +187,6 @@ C417.py:47:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expres | = help: Replace `map` with a generator expression -ℹ Unsafe fix -44 44 | dict(map(lambda k, v: (k, v), keys, values)) -45 45 | -46 46 | # Regression test for: https://github.com/astral-sh/ruff/issues/7121 -47 |-map(lambda x: x, y if y else z) - 47 |+(x for x in (y if y else z)) -48 48 | map(lambda x: x, (y if y else z)) -49 49 | map(lambda x: x, (x, y, z)) C417.py:48:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) | @@ -340,13 +198,6 @@ C417.py:48:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expres | = help: Replace `map` with a generator expression -ℹ Unsafe fix -45 45 | -46 46 | # Regression test for: https://github.com/astral-sh/ruff/issues/7121 -47 47 | map(lambda x: x, y if y else z) -48 |-map(lambda x: x, (y if y else z)) - 48 |+(x for x in (y if y else z)) -49 49 | map(lambda x: x, (x, y, z)) C417.py:49:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) | @@ -356,12 +207,3 @@ C417.py:49:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expres | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 | = help: Replace `map` with a generator expression - -ℹ Unsafe fix -46 46 | # Regression test for: https://github.com/astral-sh/ruff/issues/7121 -47 47 | map(lambda x: x, y if y else z) -48 48 | map(lambda x: x, (y if y else z)) -49 |-map(lambda x: x, (x, y, z)) - 49 |+(x for x in (x, y, z)) - - diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C418_C418.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C418_C418.py.snap index f350adcdcec62..4929f8962ffa7 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C418_C418.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C418_C418.py.snap @@ -10,12 +10,6 @@ C418.py:1:1: C418 [*] Unnecessary `dict` literal passed to `dict()` (remove the | = help: Remove outer `dict` call -ℹ Unsafe fix -1 |-dict({}) - 1 |+{} -2 2 | dict({'a': 1}) -3 3 | dict({'x': 1 for x in range(10)}) -4 4 | dict( C418.py:2:1: C418 [*] Unnecessary `dict` literal passed to `dict()` (remove the outer call to `dict()`) | @@ -27,13 +21,6 @@ C418.py:2:1: C418 [*] Unnecessary `dict` literal passed to `dict()` (remove the | = help: Remove outer `dict` call -ℹ Unsafe fix -1 1 | dict({}) -2 |-dict({'a': 1}) - 2 |+{'a': 1} -3 3 | dict({'x': 1 for x in range(10)}) -4 4 | dict( -5 5 | {'x': 1 for x in range(10)} C418.py:3:1: C418 [*] Unnecessary `dict` comprehension passed to `dict()` (remove the outer call to `dict()`) | @@ -46,14 +33,6 @@ C418.py:3:1: C418 [*] Unnecessary `dict` comprehension passed to `dict()` (remov | = help: Remove outer `dict` call -ℹ Unsafe fix -1 1 | dict({}) -2 2 | dict({'a': 1}) -3 |-dict({'x': 1 for x in range(10)}) - 3 |+{'x': 1 for x in range(10)} -4 4 | dict( -5 5 | {'x': 1 for x in range(10)} -6 6 | ) C418.py:4:1: C418 [*] Unnecessary `dict` comprehension passed to `dict()` (remove the outer call to `dict()`) | @@ -67,17 +46,3 @@ C418.py:4:1: C418 [*] Unnecessary `dict` comprehension passed to `dict()` (remov 8 | dict({}, a=1) | = help: Remove outer `dict` call - -ℹ Unsafe fix -1 1 | dict({}) -2 2 | dict({'a': 1}) -3 3 | dict({'x': 1 for x in range(10)}) -4 |-dict( -5 |- {'x': 1 for x in range(10)} -6 |-) - 4 |+{'x': 1 for x in range(10)} -7 5 | -8 6 | dict({}, a=1) -9 7 | dict({x: 1 for x in range(1)}, a=1) - - diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C419_C419.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C419_C419.py.snap index 4f47e3af10fe2..d04eb2647624e 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C419_C419.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C419_C419.py.snap @@ -10,12 +10,6 @@ C419.py:1:5: C419 [*] Unnecessary list comprehension | = help: Remove unnecessary list comprehension -ℹ Unsafe fix -1 |-any([x.id for x in bar]) - 1 |+any(x.id for x in bar) -2 2 | all([x.id for x in bar]) -3 3 | any( # first comment -4 4 | [x.id for x in bar], # second comment C419.py:2:5: C419 [*] Unnecessary list comprehension | @@ -27,13 +21,6 @@ C419.py:2:5: C419 [*] Unnecessary list comprehension | = help: Remove unnecessary list comprehension -ℹ Unsafe fix -1 1 | any([x.id for x in bar]) -2 |-all([x.id for x in bar]) - 2 |+all(x.id for x in bar) -3 3 | any( # first comment -4 4 | [x.id for x in bar], # second comment -5 5 | ) # third comment C419.py:4:5: C419 [*] Unnecessary list comprehension | @@ -46,15 +33,6 @@ C419.py:4:5: C419 [*] Unnecessary list comprehension | = help: Remove unnecessary list comprehension -ℹ Unsafe fix -1 1 | any([x.id for x in bar]) -2 2 | all([x.id for x in bar]) -3 3 | any( # first comment -4 |- [x.id for x in bar], # second comment - 4 |+ x.id for x in bar, # second comment -5 5 | ) # third comment -6 6 | all( # first comment -7 7 | [x.id for x in bar], # second comment C419.py:7:5: C419 [*] Unnecessary list comprehension | @@ -67,15 +45,6 @@ C419.py:7:5: C419 [*] Unnecessary list comprehension | = help: Remove unnecessary list comprehension -ℹ Unsafe fix -4 4 | [x.id for x in bar], # second comment -5 5 | ) # third comment -6 6 | all( # first comment -7 |- [x.id for x in bar], # second comment - 7 |+ x.id for x in bar, # second comment -8 8 | ) # third comment -9 9 | any({x.id for x in bar}) -10 10 | C419.py:9:5: C419 [*] Unnecessary list comprehension | @@ -88,15 +57,6 @@ C419.py:9:5: C419 [*] Unnecessary list comprehension | = help: Remove unnecessary list comprehension -ℹ Unsafe fix -6 6 | all( # first comment -7 7 | [x.id for x in bar], # second comment -8 8 | ) # third comment -9 |-any({x.id for x in bar}) - 9 |+any(x.id for x in bar) -10 10 | -11 11 | # OK -12 12 | all(x.id for x in bar) C419.py:28:5: C419 [*] Unnecessary list comprehension | @@ -115,23 +75,6 @@ C419.py:28:5: C419 [*] Unnecessary list comprehension | = help: Remove unnecessary list comprehension -ℹ Unsafe fix -25 25 | -26 26 | # Special comment handling -27 27 | any( -28 |- [ # lbracket comment -29 |- # second line comment -30 |- i.bit_count() - 28 |+ # lbracket comment - 29 |+ # second line comment - 30 |+ i.bit_count() -31 31 | # random middle comment -32 |- for i in range(5) # rbracket comment -33 |- ] # rpar comment - 32 |+ for i in range(5) # rbracket comment # rpar comment -34 33 | # trailing comment -35 34 | ) -36 35 | C419.py:39:5: C419 [*] Unnecessary list comprehension | @@ -146,17 +89,3 @@ C419.py:39:5: C419 [*] Unnecessary list comprehension 43 | ) | = help: Remove unnecessary list comprehension - -ℹ Unsafe fix -36 36 | -37 37 | # Weird case where the function call, opening bracket, and comment are all -38 38 | # on the same line. -39 |-any([ # lbracket comment -40 |- # second line comment -41 |- i.bit_count() for i in range(5) # rbracket comment -42 |- ] # rpar comment - 39 |+any( - 40 |+# lbracket comment - 41 |+# second line comment - 42 |+i.bit_count() for i in range(5) # rbracket comment # rpar comment -43 43 | ) diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__preview__C419_C419_1.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__preview__C419_C419_1.py.snap index 1c30178ac47d2..96f293084d558 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__preview__C419_C419_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__preview__C419_C419_1.py.snap @@ -10,12 +10,6 @@ C419_1.py:1:5: C419 [*] Unnecessary list comprehension | = help: Remove unnecessary list comprehension -ℹ Unsafe fix -1 |-sum([x.val for x in bar]) - 1 |+sum(x.val for x in bar) -2 2 | min([x.val for x in bar]) -3 3 | max([x.val for x in bar]) -4 4 | sum([x.val for x in bar], 0) C419_1.py:2:5: C419 [*] Unnecessary list comprehension | @@ -27,13 +21,6 @@ C419_1.py:2:5: C419 [*] Unnecessary list comprehension | = help: Remove unnecessary list comprehension -ℹ Unsafe fix -1 1 | sum([x.val for x in bar]) -2 |-min([x.val for x in bar]) - 2 |+min(x.val for x in bar) -3 3 | max([x.val for x in bar]) -4 4 | sum([x.val for x in bar], 0) -5 5 | C419_1.py:3:5: C419 [*] Unnecessary list comprehension | @@ -45,14 +32,6 @@ C419_1.py:3:5: C419 [*] Unnecessary list comprehension | = help: Remove unnecessary list comprehension -ℹ Unsafe fix -1 1 | sum([x.val for x in bar]) -2 2 | min([x.val for x in bar]) -3 |-max([x.val for x in bar]) - 3 |+max(x.val for x in bar) -4 4 | sum([x.val for x in bar], 0) -5 5 | -6 6 | # OK C419_1.py:4:5: C419 [*] Unnecessary list comprehension | @@ -65,15 +44,6 @@ C419_1.py:4:5: C419 [*] Unnecessary list comprehension | = help: Remove unnecessary list comprehension -ℹ Unsafe fix -1 1 | sum([x.val for x in bar]) -2 2 | min([x.val for x in bar]) -3 3 | max([x.val for x in bar]) -4 |-sum([x.val for x in bar], 0) - 4 |+sum((x.val for x in bar), 0) -5 5 | -6 6 | # OK -7 7 | sum(x.val for x in bar) C419_1.py:14:5: C419 [*] Unnecessary list comprehension | @@ -90,17 +60,3 @@ C419_1.py:14:5: C419 [*] Unnecessary list comprehension 20 | ) | = help: Remove unnecessary list comprehension - -ℹ Unsafe fix -11 11 | -12 12 | # Multi-line -13 13 | sum( -14 |- [ - 14 |+ ( -15 15 | delta -16 16 | for delta in timedelta_list -17 17 | if delta -18 |- ], - 18 |+ ), -19 19 | dt.timedelta(), -20 20 | ) diff --git a/crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__custom.snap b/crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__custom.snap index d29e987d4952a..8bc3ce01ad44d 100644 --- a/crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__custom.snap +++ b/crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__custom.snap @@ -9,16 +9,6 @@ EM.py:5:24: EM101 [*] Exception must not use a string literal, assign to variabl | = help: Assign to variable; remove string literal -ℹ Unsafe fix -2 2 | -3 3 | -4 4 | def f_a(): -5 |- raise RuntimeError("This is an example exception") - 5 |+ msg = "This is an example exception" - 6 |+ raise RuntimeError(msg) -6 7 | -7 8 | -8 9 | def f_a_short(): EM.py:18:24: EM102 [*] Exception must not use an f-string literal, assign to variable first | @@ -29,16 +19,6 @@ EM.py:18:24: EM102 [*] Exception must not use an f-string literal, assign to var | = help: Assign to variable; remove f-string literal -ℹ Unsafe fix -15 15 | -16 16 | def f_b(): -17 17 | example = "example" -18 |- raise RuntimeError(f"This is an {example} exception") - 18 |+ msg = f"This is an {example} exception" - 19 |+ raise RuntimeError(msg) -19 20 | -20 21 | -21 22 | def f_c(): EM.py:22:24: EM103 [*] Exception must not use a `.format()` string directly, assign to variable first | @@ -48,16 +28,6 @@ EM.py:22:24: EM103 [*] Exception must not use a `.format()` string directly, ass | = help: Assign to variable; remove `.format()` string -ℹ Unsafe fix -19 19 | -20 20 | -21 21 | def f_c(): -22 |- raise RuntimeError("This is an {example} exception".format(example="example")) - 22 |+ msg = "This is an {example} exception".format(example="example") - 23 |+ raise RuntimeError(msg) -23 24 | -24 25 | -25 26 | def f_ok(): EM.py:32:24: EM101 [*] Exception must not use a string literal, assign to variable first | @@ -68,16 +38,6 @@ EM.py:32:24: EM101 [*] Exception must not use a string literal, assign to variab | = help: Assign to variable; remove string literal -ℹ Unsafe fix -29 29 | -30 30 | def f_msg_defined(): -31 31 | msg = "hello" -32 |- raise RuntimeError("This is an example exception") - 32 |+ msg = "This is an example exception" - 33 |+ raise RuntimeError(msg) -33 34 | -34 35 | -35 36 | def f_msg_in_nested_scope(): EM.py:39:24: EM101 [*] Exception must not use a string literal, assign to variable first | @@ -88,16 +48,6 @@ EM.py:39:24: EM101 [*] Exception must not use a string literal, assign to variab | = help: Assign to variable; remove string literal -ℹ Unsafe fix -36 36 | def nested(): -37 37 | msg = "hello" -38 38 | -39 |- raise RuntimeError("This is an example exception") - 39 |+ msg = "This is an example exception" - 40 |+ raise RuntimeError(msg) -40 41 | -41 42 | -42 43 | def f_msg_in_parent_scope(): EM.py:46:28: EM101 [*] Exception must not use a string literal, assign to variable first | @@ -107,16 +57,6 @@ EM.py:46:28: EM101 [*] Exception must not use a string literal, assign to variab | = help: Assign to variable; remove string literal -ℹ Unsafe fix -43 43 | msg = "hello" -44 44 | -45 45 | def nested(): -46 |- raise RuntimeError("This is an example exception") - 46 |+ msg = "This is an example exception" - 47 |+ raise RuntimeError(msg) -47 48 | -48 49 | -49 50 | def f_fix_indentation_check(foo): EM.py:51:28: EM101 [*] Exception must not use a string literal, assign to variable first | @@ -129,16 +69,6 @@ EM.py:51:28: EM101 [*] Exception must not use a string literal, assign to variab | = help: Assign to variable; remove string literal -ℹ Unsafe fix -48 48 | -49 49 | def f_fix_indentation_check(foo): -50 50 | if foo: -51 |- raise RuntimeError("This is an example exception") - 51 |+ msg = "This is an example exception" - 52 |+ raise RuntimeError(msg) -52 53 | else: -53 54 | if foo == "foo": -54 55 | raise RuntimeError(f"This is an exception: {foo}") EM.py:54:32: EM102 [*] Exception must not use an f-string literal, assign to variable first | @@ -150,16 +80,6 @@ EM.py:54:32: EM102 [*] Exception must not use an f-string literal, assign to var | = help: Assign to variable; remove f-string literal -ℹ Unsafe fix -51 51 | raise RuntimeError("This is an example exception") -52 52 | else: -53 53 | if foo == "foo": -54 |- raise RuntimeError(f"This is an exception: {foo}") - 54 |+ msg = f"This is an exception: {foo}" - 55 |+ raise RuntimeError(msg) -55 56 | raise RuntimeError("This is an exception: {}".format(foo)) -56 57 | -57 58 | EM.py:55:24: EM103 [*] Exception must not use a `.format()` string directly, assign to variable first | @@ -170,16 +90,6 @@ EM.py:55:24: EM103 [*] Exception must not use a `.format()` string directly, ass | = help: Assign to variable; remove `.format()` string -ℹ Unsafe fix -52 52 | else: -53 53 | if foo == "foo": -54 54 | raise RuntimeError(f"This is an exception: {foo}") -55 |- raise RuntimeError("This is an exception: {}".format(foo)) - 55 |+ msg = "This is an exception: {}".format(foo) - 56 |+ raise RuntimeError(msg) -56 57 | -57 58 | -58 59 | # Report these, but don't fix them EM.py:59:28: EM101 Exception must not use a string literal, assign to variable first | @@ -207,16 +117,6 @@ EM.py:64:24: EM102 [*] Exception must not use an f-string literal, assign to var | = help: Assign to variable; remove f-string literal -ℹ Unsafe fix -61 61 | -62 62 | -63 63 | def f_triple_quoted_string(): -64 |- raise RuntimeError(f"""This is an {"example"} exception""") - 64 |+ msg = f"""This is an {"example"} exception""" - 65 |+ raise RuntimeError(msg) -65 66 | -66 67 | -67 68 | def f_multi_line_string(): EM.py:76:9: EM103 [*] Exception must not use a `.format()` string directly, assign to variable first | @@ -231,22 +131,6 @@ EM.py:76:9: EM103 [*] Exception must not use a `.format()` string directly, assi | = help: Assign to variable; remove `.format()` string -ℹ Unsafe fix -72 72 | -73 73 | -74 74 | def f_multi_line_string2(): -75 |- raise RuntimeError( - 75 |+ msg = ( -76 76 | "This is an {example} exception".format( -77 77 | example="example" -78 78 | ) -79 79 | ) - 80 |+ raise RuntimeError( - 81 |+ msg - 82 |+ ) -80 83 | -81 84 | -82 85 | def f_multi_line_string2(): EM.py:84:9: EM103 [*] Exception must not use a `.format()` string directly, assign to variable first | @@ -263,22 +147,3 @@ EM.py:84:9: EM103 [*] Exception must not use a `.format()` string directly, assi 90 | ) | = help: Assign to variable; remove `.format()` string - -ℹ Unsafe fix -80 80 | -81 81 | -82 82 | def f_multi_line_string2(): -83 |- raise RuntimeError( - 83 |+ msg = ( -84 84 | ( -85 85 | "This is an " -86 86 | "{example} exception" --------------------------------------------------------------------------------- -88 88 | example="example" -89 89 | ) -90 90 | ) - 91 |+ raise RuntimeError( - 92 |+ msg - 93 |+ ) - - diff --git a/crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__defaults.snap b/crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__defaults.snap index 593d6b30dcc0e..ca498b37b93c1 100644 --- a/crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__defaults.snap +++ b/crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__defaults.snap @@ -9,16 +9,6 @@ EM.py:5:24: EM101 [*] Exception must not use a string literal, assign to variabl | = help: Assign to variable; remove string literal -ℹ Unsafe fix -2 2 | -3 3 | -4 4 | def f_a(): -5 |- raise RuntimeError("This is an example exception") - 5 |+ msg = "This is an example exception" - 6 |+ raise RuntimeError(msg) -6 7 | -7 8 | -8 9 | def f_a_short(): EM.py:9:24: EM101 [*] Exception must not use a string literal, assign to variable first | @@ -28,16 +18,6 @@ EM.py:9:24: EM101 [*] Exception must not use a string literal, assign to variabl | = help: Assign to variable; remove string literal -ℹ Unsafe fix -6 6 | -7 7 | -8 8 | def f_a_short(): -9 |- raise RuntimeError("Error") - 9 |+ msg = "Error" - 10 |+ raise RuntimeError(msg) -10 11 | -11 12 | -12 13 | def f_a_empty(): EM.py:13:24: EM101 [*] Exception must not use a string literal, assign to variable first | @@ -47,16 +27,6 @@ EM.py:13:24: EM101 [*] Exception must not use a string literal, assign to variab | = help: Assign to variable; remove string literal -ℹ Unsafe fix -10 10 | -11 11 | -12 12 | def f_a_empty(): -13 |- raise RuntimeError("") - 13 |+ msg = "" - 14 |+ raise RuntimeError(msg) -14 15 | -15 16 | -16 17 | def f_b(): EM.py:18:24: EM102 [*] Exception must not use an f-string literal, assign to variable first | @@ -67,16 +37,6 @@ EM.py:18:24: EM102 [*] Exception must not use an f-string literal, assign to var | = help: Assign to variable; remove f-string literal -ℹ Unsafe fix -15 15 | -16 16 | def f_b(): -17 17 | example = "example" -18 |- raise RuntimeError(f"This is an {example} exception") - 18 |+ msg = f"This is an {example} exception" - 19 |+ raise RuntimeError(msg) -19 20 | -20 21 | -21 22 | def f_c(): EM.py:22:24: EM103 [*] Exception must not use a `.format()` string directly, assign to variable first | @@ -86,16 +46,6 @@ EM.py:22:24: EM103 [*] Exception must not use a `.format()` string directly, ass | = help: Assign to variable; remove `.format()` string -ℹ Unsafe fix -19 19 | -20 20 | -21 21 | def f_c(): -22 |- raise RuntimeError("This is an {example} exception".format(example="example")) - 22 |+ msg = "This is an {example} exception".format(example="example") - 23 |+ raise RuntimeError(msg) -23 24 | -24 25 | -25 26 | def f_ok(): EM.py:32:24: EM101 [*] Exception must not use a string literal, assign to variable first | @@ -106,16 +56,6 @@ EM.py:32:24: EM101 [*] Exception must not use a string literal, assign to variab | = help: Assign to variable; remove string literal -ℹ Unsafe fix -29 29 | -30 30 | def f_msg_defined(): -31 31 | msg = "hello" -32 |- raise RuntimeError("This is an example exception") - 32 |+ msg = "This is an example exception" - 33 |+ raise RuntimeError(msg) -33 34 | -34 35 | -35 36 | def f_msg_in_nested_scope(): EM.py:39:24: EM101 [*] Exception must not use a string literal, assign to variable first | @@ -126,16 +66,6 @@ EM.py:39:24: EM101 [*] Exception must not use a string literal, assign to variab | = help: Assign to variable; remove string literal -ℹ Unsafe fix -36 36 | def nested(): -37 37 | msg = "hello" -38 38 | -39 |- raise RuntimeError("This is an example exception") - 39 |+ msg = "This is an example exception" - 40 |+ raise RuntimeError(msg) -40 41 | -41 42 | -42 43 | def f_msg_in_parent_scope(): EM.py:46:28: EM101 [*] Exception must not use a string literal, assign to variable first | @@ -145,16 +75,6 @@ EM.py:46:28: EM101 [*] Exception must not use a string literal, assign to variab | = help: Assign to variable; remove string literal -ℹ Unsafe fix -43 43 | msg = "hello" -44 44 | -45 45 | def nested(): -46 |- raise RuntimeError("This is an example exception") - 46 |+ msg = "This is an example exception" - 47 |+ raise RuntimeError(msg) -47 48 | -48 49 | -49 50 | def f_fix_indentation_check(foo): EM.py:51:28: EM101 [*] Exception must not use a string literal, assign to variable first | @@ -167,16 +87,6 @@ EM.py:51:28: EM101 [*] Exception must not use a string literal, assign to variab | = help: Assign to variable; remove string literal -ℹ Unsafe fix -48 48 | -49 49 | def f_fix_indentation_check(foo): -50 50 | if foo: -51 |- raise RuntimeError("This is an example exception") - 51 |+ msg = "This is an example exception" - 52 |+ raise RuntimeError(msg) -52 53 | else: -53 54 | if foo == "foo": -54 55 | raise RuntimeError(f"This is an exception: {foo}") EM.py:54:32: EM102 [*] Exception must not use an f-string literal, assign to variable first | @@ -188,16 +98,6 @@ EM.py:54:32: EM102 [*] Exception must not use an f-string literal, assign to var | = help: Assign to variable; remove f-string literal -ℹ Unsafe fix -51 51 | raise RuntimeError("This is an example exception") -52 52 | else: -53 53 | if foo == "foo": -54 |- raise RuntimeError(f"This is an exception: {foo}") - 54 |+ msg = f"This is an exception: {foo}" - 55 |+ raise RuntimeError(msg) -55 56 | raise RuntimeError("This is an exception: {}".format(foo)) -56 57 | -57 58 | EM.py:55:24: EM103 [*] Exception must not use a `.format()` string directly, assign to variable first | @@ -208,16 +108,6 @@ EM.py:55:24: EM103 [*] Exception must not use a `.format()` string directly, ass | = help: Assign to variable; remove `.format()` string -ℹ Unsafe fix -52 52 | else: -53 53 | if foo == "foo": -54 54 | raise RuntimeError(f"This is an exception: {foo}") -55 |- raise RuntimeError("This is an exception: {}".format(foo)) - 55 |+ msg = "This is an exception: {}".format(foo) - 56 |+ raise RuntimeError(msg) -56 57 | -57 58 | -58 59 | # Report these, but don't fix them EM.py:59:28: EM101 Exception must not use a string literal, assign to variable first | @@ -245,16 +135,6 @@ EM.py:64:24: EM102 [*] Exception must not use an f-string literal, assign to var | = help: Assign to variable; remove f-string literal -ℹ Unsafe fix -61 61 | -62 62 | -63 63 | def f_triple_quoted_string(): -64 |- raise RuntimeError(f"""This is an {"example"} exception""") - 64 |+ msg = f"""This is an {"example"} exception""" - 65 |+ raise RuntimeError(msg) -65 66 | -66 67 | -67 68 | def f_multi_line_string(): EM.py:69:9: EM101 [*] Exception must not use a string literal, assign to variable first | @@ -268,21 +148,6 @@ EM.py:69:9: EM101 [*] Exception must not use a string literal, assign to variabl | = help: Assign to variable; remove string literal -ℹ Unsafe fix -65 65 | -66 66 | -67 67 | def f_multi_line_string(): -68 |- raise RuntimeError( - 68 |+ msg = ( -69 69 | "first" -70 70 | "second" -71 71 | ) - 72 |+ raise RuntimeError( - 73 |+ msg - 74 |+ ) -72 75 | -73 76 | -74 77 | def f_multi_line_string2(): EM.py:76:9: EM103 [*] Exception must not use a `.format()` string directly, assign to variable first | @@ -297,22 +162,6 @@ EM.py:76:9: EM103 [*] Exception must not use a `.format()` string directly, assi | = help: Assign to variable; remove `.format()` string -ℹ Unsafe fix -72 72 | -73 73 | -74 74 | def f_multi_line_string2(): -75 |- raise RuntimeError( - 75 |+ msg = ( -76 76 | "This is an {example} exception".format( -77 77 | example="example" -78 78 | ) -79 79 | ) - 80 |+ raise RuntimeError( - 81 |+ msg - 82 |+ ) -80 83 | -81 84 | -82 85 | def f_multi_line_string2(): EM.py:84:9: EM103 [*] Exception must not use a `.format()` string directly, assign to variable first | @@ -329,22 +178,3 @@ EM.py:84:9: EM103 [*] Exception must not use a `.format()` string directly, assi 90 | ) | = help: Assign to variable; remove `.format()` string - -ℹ Unsafe fix -80 80 | -81 81 | -82 82 | def f_multi_line_string2(): -83 |- raise RuntimeError( - 83 |+ msg = ( -84 84 | ( -85 85 | "This is an " -86 86 | "{example} exception" --------------------------------------------------------------------------------- -88 88 | example="example" -89 89 | ) -90 90 | ) - 91 |+ raise RuntimeError( - 92 |+ msg - 93 |+ ) - - diff --git a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_1.py.snap b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_1.py.snap index 1c613ab1b1398..742567ad3f743 100644 --- a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_1.py.snap @@ -8,8 +8,5 @@ EXE004_1.py:1:1: EXE004 [*] Avoid whitespace before shebang | = help: Remove whitespace before shebang -ℹ Safe fix 1 |- #!/usr/bin/python 1 |+#!/usr/bin/python - - diff --git a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_4.py.snap b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_4.py.snap index feff95aa86af5..a98b367a36adc 100644 --- a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_4.py.snap +++ b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_4.py.snap @@ -9,9 +9,6 @@ EXE004_4.py:1:1: EXE004 [*] Avoid whitespace before shebang | = help: Remove whitespace before shebang -ℹ Safe fix 1 |- 2 |- #!/usr/bin/env python 1 |+#!/usr/bin/env python - - diff --git a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_lowercase.py.snap b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_lowercase.py.snap index e9c8efa698a8f..4ddcfa6a4dd21 100644 --- a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_lowercase.py.snap +++ b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_lowercase.py.snap @@ -8,9 +8,3 @@ no_future_import_uses_lowercase.py:6:14: FA102 [*] Missing `from __future__ impo 7 | del y | = help: Add `from __future__ import annotations` - -ℹ Unsafe fix - 1 |+from __future__ import annotations -1 2 | def main() -> None: -2 3 | a_list: list[str] = [] -3 4 | a_list.append("hello") diff --git a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_union.py.snap b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_union.py.snap index 3631ff04335a3..6f7847f79f32c 100644 --- a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_union.py.snap +++ b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_union.py.snap @@ -9,11 +9,6 @@ no_future_import_uses_union.py:6:14: FA102 [*] Missing `from __future__ import a | = help: Add `from __future__ import annotations` -ℹ Unsafe fix - 1 |+from __future__ import annotations -1 2 | def main() -> None: -2 3 | a_list: list[str] | None = [] -3 4 | a_list.append("hello") no_future_import_uses_union.py:6:14: FA102 [*] Missing `from __future__ import annotations`, but uses PEP 604 union | @@ -22,9 +17,3 @@ no_future_import_uses_union.py:6:14: FA102 [*] Missing `from __future__ import a 7 | del y | = help: Add `from __future__ import annotations` - -ℹ Unsafe fix - 1 |+from __future__ import annotations -1 2 | def main() -> None: -2 3 | a_list: list[str] | None = [] -3 4 | a_list.append("hello") diff --git a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_union_inner.py.snap b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_union_inner.py.snap index 2f2e6dbb0375a..8a06aaa33492f 100644 --- a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_union_inner.py.snap +++ b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_union_inner.py.snap @@ -10,11 +10,6 @@ no_future_import_uses_union_inner.py:6:14: FA102 [*] Missing `from __future__ im | = help: Add `from __future__ import annotations` -ℹ Unsafe fix - 1 |+from __future__ import annotations -1 2 | def main() -> None: -2 3 | a_list: list[str | None] = [] -3 4 | a_list.append("hello") no_future_import_uses_union_inner.py:6:19: FA102 [*] Missing `from __future__ import annotations`, but uses PEP 604 union | @@ -24,9 +19,3 @@ no_future_import_uses_union_inner.py:6:19: FA102 [*] Missing `from __future__ im 8 | del z | = help: Add `from __future__ import annotations` - -ℹ Unsafe fix - 1 |+from __future__ import annotations -1 2 | def main() -> None: -2 3 | a_list: list[str | None] = [] -3 4 | a_list.append("hello") diff --git a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC001_ISC.py.snap b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC001_ISC.py.snap index c6a7536f7454c..ff39e00ef5b03 100644 --- a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC001_ISC.py.snap +++ b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC001_ISC.py.snap @@ -10,7 +10,6 @@ ISC.py:1:5: ISC001 [*] Implicitly concatenated string literals on one line | = help: Combine string literals -ℹ Safe fix 1 |-_ = "a" "b" "c" 1 |+_ = "ab" "c" 2 2 | @@ -26,7 +25,6 @@ ISC.py:1:9: ISC001 [*] Implicitly concatenated string literals on one line | = help: Combine string literals -ℹ Safe fix 1 |-_ = "a" "b" "c" 1 |+_ = "a" "bc" 2 2 | @@ -44,7 +42,6 @@ ISC.py:38:5: ISC001 [*] Implicitly concatenated string literals on one line | = help: Combine string literals -ℹ Safe fix 35 35 | b"def" 36 36 | ) 37 37 | @@ -68,7 +65,6 @@ ISC.py:40:5: ISC001 [*] Implicitly concatenated string literals on one line | = help: Combine string literals -ℹ Safe fix 38 38 | _ = """a""" """b""" 39 39 | 40 40 | _ = """a @@ -89,7 +85,6 @@ ISC.py:44:5: ISC001 [*] Implicitly concatenated string literals on one line | = help: Combine string literals -ℹ Safe fix 41 41 | b""" """c 42 42 | d""" 43 43 | @@ -143,7 +138,6 @@ ISC.py:52:5: ISC001 [*] Implicitly concatenated string literals on one line | = help: Combine string literals -ℹ Safe fix 49 49 | 50 50 | _ = 'a' "b" 51 51 | @@ -163,7 +157,6 @@ ISC.py:64:10: ISC001 [*] Implicitly concatenated string literals on one line | = help: Combine string literals -ℹ Safe fix 61 61 | _ = foo + "abc" + bar 62 62 | 63 63 | # Multiple strings nested inside a f-string @@ -183,7 +176,6 @@ ISC.py:64:14: ISC001 [*] Implicitly concatenated string literals on one line | = help: Combine string literals -ℹ Safe fix 61 61 | _ = foo + "abc" + bar 62 62 | 63 63 | # Multiple strings nested inside a f-string @@ -204,7 +196,6 @@ ISC.py:65:14: ISC001 [*] Implicitly concatenated string literals on one line | = help: Combine string literals -ℹ Safe fix 62 62 | 63 63 | # Multiple strings nested inside a f-string 64 64 | _ = f"a {'b' 'c' 'd'} e" @@ -244,7 +235,6 @@ ISC.py:72:14: ISC001 [*] Implicitly concatenated string literals on one line | = help: Combine string literals -ℹ Safe fix 69 69 | } jkl""" 70 70 | 71 71 | # Nested f-strings @@ -265,7 +255,6 @@ ISC.py:73:10: ISC001 [*] Implicitly concatenated string literals on one line | = help: Combine string literals -ℹ Safe fix 70 70 | 71 71 | # Nested f-strings 72 72 | _ = "a" f"b {f"c" f"d"} e" "f" @@ -286,7 +275,6 @@ ISC.py:73:20: ISC001 [*] Implicitly concatenated string literals on one line | = help: Combine string literals -ℹ Safe fix 70 70 | 71 71 | # Nested f-strings 72 72 | _ = "a" f"b {f"c" f"d"} e" "f" @@ -294,6 +282,4 @@ ISC.py:73:20: ISC001 [*] Implicitly concatenated string literals on one line 73 |+_ = f"b {f"c" f"d {f"ef"} g"} h" 74 74 | _ = f"b {f"abc" \ 75 75 | f"def"} g" -76 76 | - - +76 76 | diff --git a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__multiline_ISC001_ISC.py.snap b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__multiline_ISC001_ISC.py.snap index c6a7536f7454c..ff39e00ef5b03 100644 --- a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__multiline_ISC001_ISC.py.snap +++ b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__multiline_ISC001_ISC.py.snap @@ -10,7 +10,6 @@ ISC.py:1:5: ISC001 [*] Implicitly concatenated string literals on one line | = help: Combine string literals -ℹ Safe fix 1 |-_ = "a" "b" "c" 1 |+_ = "ab" "c" 2 2 | @@ -26,7 +25,6 @@ ISC.py:1:9: ISC001 [*] Implicitly concatenated string literals on one line | = help: Combine string literals -ℹ Safe fix 1 |-_ = "a" "b" "c" 1 |+_ = "a" "bc" 2 2 | @@ -44,7 +42,6 @@ ISC.py:38:5: ISC001 [*] Implicitly concatenated string literals on one line | = help: Combine string literals -ℹ Safe fix 35 35 | b"def" 36 36 | ) 37 37 | @@ -68,7 +65,6 @@ ISC.py:40:5: ISC001 [*] Implicitly concatenated string literals on one line | = help: Combine string literals -ℹ Safe fix 38 38 | _ = """a""" """b""" 39 39 | 40 40 | _ = """a @@ -89,7 +85,6 @@ ISC.py:44:5: ISC001 [*] Implicitly concatenated string literals on one line | = help: Combine string literals -ℹ Safe fix 41 41 | b""" """c 42 42 | d""" 43 43 | @@ -143,7 +138,6 @@ ISC.py:52:5: ISC001 [*] Implicitly concatenated string literals on one line | = help: Combine string literals -ℹ Safe fix 49 49 | 50 50 | _ = 'a' "b" 51 51 | @@ -163,7 +157,6 @@ ISC.py:64:10: ISC001 [*] Implicitly concatenated string literals on one line | = help: Combine string literals -ℹ Safe fix 61 61 | _ = foo + "abc" + bar 62 62 | 63 63 | # Multiple strings nested inside a f-string @@ -183,7 +176,6 @@ ISC.py:64:14: ISC001 [*] Implicitly concatenated string literals on one line | = help: Combine string literals -ℹ Safe fix 61 61 | _ = foo + "abc" + bar 62 62 | 63 63 | # Multiple strings nested inside a f-string @@ -204,7 +196,6 @@ ISC.py:65:14: ISC001 [*] Implicitly concatenated string literals on one line | = help: Combine string literals -ℹ Safe fix 62 62 | 63 63 | # Multiple strings nested inside a f-string 64 64 | _ = f"a {'b' 'c' 'd'} e" @@ -244,7 +235,6 @@ ISC.py:72:14: ISC001 [*] Implicitly concatenated string literals on one line | = help: Combine string literals -ℹ Safe fix 69 69 | } jkl""" 70 70 | 71 71 | # Nested f-strings @@ -265,7 +255,6 @@ ISC.py:73:10: ISC001 [*] Implicitly concatenated string literals on one line | = help: Combine string literals -ℹ Safe fix 70 70 | 71 71 | # Nested f-strings 72 72 | _ = "a" f"b {f"c" f"d"} e" "f" @@ -286,7 +275,6 @@ ISC.py:73:20: ISC001 [*] Implicitly concatenated string literals on one line | = help: Combine string literals -ℹ Safe fix 70 70 | 71 71 | # Nested f-strings 72 72 | _ = "a" f"b {f"c" f"d"} e" "f" @@ -294,6 +282,4 @@ ISC.py:73:20: ISC001 [*] Implicitly concatenated string literals on one line 73 |+_ = f"b {f"c" f"d {f"ef"} g"} h" 74 74 | _ = f"b {f"abc" \ 75 75 | f"def"} g" -76 76 | - - +76 76 | diff --git a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__defaults.snap b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__defaults.snap index d3f4b0a501404..d9dbdf1f00098 100644 --- a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__defaults.snap +++ b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__defaults.snap @@ -11,15 +11,6 @@ defaults.py:6:12: ICN001 [*] `altair` should be imported as `alt` | = help: Alias `altair` to `alt` -ℹ Unsafe fix -3 3 | -4 4 | -5 5 | def unconventional(): -6 |- import altair - 6 |+ import altair as alt -7 7 | import matplotlib.pyplot -8 8 | import numpy -9 9 | import pandas defaults.py:7:12: ICN001 `matplotlib.pyplot` should be imported as `plt` | @@ -43,15 +34,6 @@ defaults.py:8:12: ICN001 [*] `numpy` should be imported as `np` | = help: Alias `numpy` to `np` -ℹ Unsafe fix -5 5 | def unconventional(): -6 6 | import altair -7 7 | import matplotlib.pyplot -8 |- import numpy - 8 |+ import numpy as np -9 9 | import pandas -10 10 | import seaborn -11 11 | import tkinter defaults.py:9:12: ICN001 [*] `pandas` should be imported as `pd` | @@ -64,15 +46,6 @@ defaults.py:9:12: ICN001 [*] `pandas` should be imported as `pd` | = help: Alias `pandas` to `pd` -ℹ Unsafe fix -6 6 | import altair -7 7 | import matplotlib.pyplot -8 8 | import numpy -9 |- import pandas - 9 |+ import pandas as pd -10 10 | import seaborn -11 11 | import tkinter -12 12 | import networkx defaults.py:10:12: ICN001 [*] `seaborn` should be imported as `sns` | @@ -85,15 +58,6 @@ defaults.py:10:12: ICN001 [*] `seaborn` should be imported as `sns` | = help: Alias `seaborn` to `sns` -ℹ Unsafe fix -7 7 | import matplotlib.pyplot -8 8 | import numpy -9 9 | import pandas -10 |- import seaborn - 10 |+ import seaborn as sns -11 11 | import tkinter -12 12 | import networkx -13 13 | defaults.py:11:12: ICN001 [*] `tkinter` should be imported as `tk` | @@ -105,15 +69,6 @@ defaults.py:11:12: ICN001 [*] `tkinter` should be imported as `tk` | = help: Alias `tkinter` to `tk` -ℹ Unsafe fix -8 8 | import numpy -9 9 | import pandas -10 10 | import seaborn -11 |- import tkinter - 11 |+ import tkinter as tk -12 12 | import networkx -13 13 | -14 14 | defaults.py:12:12: ICN001 [*] `networkx` should be imported as `nx` | @@ -124,15 +79,6 @@ defaults.py:12:12: ICN001 [*] `networkx` should be imported as `nx` | = help: Alias `networkx` to `nx` -ℹ Unsafe fix -9 9 | import pandas -10 10 | import seaborn -11 11 | import tkinter -12 |- import networkx - 12 |+ import networkx as nx -13 13 | -14 14 | -15 15 | def unconventional_aliases(): defaults.py:16:22: ICN001 [*] `altair` should be imported as `alt` | @@ -144,15 +90,6 @@ defaults.py:16:22: ICN001 [*] `altair` should be imported as `alt` | = help: Alias `altair` to `alt` -ℹ Unsafe fix -13 13 | -14 14 | -15 15 | def unconventional_aliases(): -16 |- import altair as altr - 16 |+ import altair as alt -17 17 | import matplotlib.pyplot as plot -18 18 | import numpy as nmp -19 19 | import pandas as pdas defaults.py:17:33: ICN001 [*] `matplotlib.pyplot` should be imported as `plt` | @@ -165,15 +102,6 @@ defaults.py:17:33: ICN001 [*] `matplotlib.pyplot` should be imported as `plt` | = help: Alias `matplotlib.pyplot` to `plt` -ℹ Unsafe fix -14 14 | -15 15 | def unconventional_aliases(): -16 16 | import altair as altr -17 |- import matplotlib.pyplot as plot - 17 |+ import matplotlib.pyplot as plt -18 18 | import numpy as nmp -19 19 | import pandas as pdas -20 20 | import seaborn as sbrn defaults.py:18:21: ICN001 [*] `numpy` should be imported as `np` | @@ -186,15 +114,6 @@ defaults.py:18:21: ICN001 [*] `numpy` should be imported as `np` | = help: Alias `numpy` to `np` -ℹ Unsafe fix -15 15 | def unconventional_aliases(): -16 16 | import altair as altr -17 17 | import matplotlib.pyplot as plot -18 |- import numpy as nmp - 18 |+ import numpy as np -19 19 | import pandas as pdas -20 20 | import seaborn as sbrn -21 21 | import tkinter as tkr defaults.py:19:22: ICN001 [*] `pandas` should be imported as `pd` | @@ -207,15 +126,6 @@ defaults.py:19:22: ICN001 [*] `pandas` should be imported as `pd` | = help: Alias `pandas` to `pd` -ℹ Unsafe fix -16 16 | import altair as altr -17 17 | import matplotlib.pyplot as plot -18 18 | import numpy as nmp -19 |- import pandas as pdas - 19 |+ import pandas as pd -20 20 | import seaborn as sbrn -21 21 | import tkinter as tkr -22 22 | import networkx as nxy defaults.py:20:23: ICN001 [*] `seaborn` should be imported as `sns` | @@ -228,15 +138,6 @@ defaults.py:20:23: ICN001 [*] `seaborn` should be imported as `sns` | = help: Alias `seaborn` to `sns` -ℹ Unsafe fix -17 17 | import matplotlib.pyplot as plot -18 18 | import numpy as nmp -19 19 | import pandas as pdas -20 |- import seaborn as sbrn - 20 |+ import seaborn as sns -21 21 | import tkinter as tkr -22 22 | import networkx as nxy -23 23 | defaults.py:21:23: ICN001 [*] `tkinter` should be imported as `tk` | @@ -248,15 +149,6 @@ defaults.py:21:23: ICN001 [*] `tkinter` should be imported as `tk` | = help: Alias `tkinter` to `tk` -ℹ Unsafe fix -18 18 | import numpy as nmp -19 19 | import pandas as pdas -20 20 | import seaborn as sbrn -21 |- import tkinter as tkr - 21 |+ import tkinter as tk -22 22 | import networkx as nxy -23 23 | -24 24 | defaults.py:22:24: ICN001 [*] `networkx` should be imported as `nx` | @@ -266,13 +158,3 @@ defaults.py:22:24: ICN001 [*] `networkx` should be imported as `nx` | ^^^ ICN001 | = help: Alias `networkx` to `nx` - -ℹ Unsafe fix -19 19 | import pandas as pdas -20 20 | import seaborn as sbrn -21 21 | import tkinter as tkr -22 |- import networkx as nxy - 22 |+ import networkx as nx -23 23 | -24 24 | -25 25 | def conventional_aliases(): diff --git a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__same_name.snap b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__same_name.snap index c30be9f37554c..3e8042bfa409e 100644 --- a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__same_name.snap +++ b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__same_name.snap @@ -8,10 +8,3 @@ same_name.py:10:41: ICN001 [*] `django.conf.settings` should be imported as `set | ^ ICN001 | = help: Alias `django.conf.settings` to `settings` - -ℹ Unsafe fix -7 7 | -8 8 | -9 9 | def unconventional_alias(): -10 |- from django.conf import settings as s - 10 |+ from django.conf import settings as settings diff --git a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__tricky.snap b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__tricky.snap index b3c7cc2368a49..990c06525183d 100644 --- a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__tricky.snap +++ b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__tricky.snap @@ -11,16 +11,3 @@ tricky.py:7:16: ICN001 [*] `pandas` should be imported as `pd` 9 | return False | = help: Alias `pandas` to `pd` - -ℹ Unsafe fix -3 3 | -4 4 | def rename_global(): -5 5 | try: -6 |- global pandas -7 |- import pandas - 6 |+ global pd - 7 |+ import pandas as pd -8 8 | except ImportError: -9 9 | return False - - diff --git a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG001_LOG001.py.snap b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG001_LOG001.py.snap index c72edc6042394..3aa6319fe89bd 100644 --- a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG001_LOG001.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG001_LOG001.py.snap @@ -12,13 +12,6 @@ LOG001.py:3:1: LOG001 [*] Use `logging.getLogger()` to instantiate loggers | = help: Replace with `logging.getLogger()` -ℹ Unsafe fix -1 1 | import logging -2 2 | -3 |-logging.Logger(__name__) - 3 |+logging.getLogger(__name__) -4 4 | logging.Logger() -5 5 | logging.getLogger(__name__) LOG001.py:4:1: LOG001 [*] Use `logging.getLogger()` to instantiate loggers | @@ -28,13 +21,3 @@ LOG001.py:4:1: LOG001 [*] Use `logging.getLogger()` to instantiate loggers 5 | logging.getLogger(__name__) | = help: Replace with `logging.getLogger()` - -ℹ Unsafe fix -1 1 | import logging -2 2 | -3 3 | logging.Logger(__name__) -4 |-logging.Logger() - 4 |+logging.getLogger() -5 5 | logging.getLogger(__name__) - - diff --git a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG002_LOG002.py.snap b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG002_LOG002.py.snap index b73778126387b..ca25db02fa87b 100644 --- a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG002_LOG002.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG002_LOG002.py.snap @@ -10,15 +10,6 @@ LOG002.py:11:11: LOG002 [*] Use `__name__` with `logging.getLogger()` | = help: Replace with `__name__` -ℹ Unsafe fix -8 8 | logging.getLogger(name="custom") -9 9 | -10 10 | # LOG002 -11 |-getLogger(__file__) - 11 |+getLogger(__name__) -12 12 | logging.getLogger(name=__file__) -13 13 | -14 14 | logging.getLogger(__cached__) LOG002.py:12:24: LOG002 [*] Use `__name__` with `logging.getLogger()` | @@ -31,15 +22,6 @@ LOG002.py:12:24: LOG002 [*] Use `__name__` with `logging.getLogger()` | = help: Replace with `__name__` -ℹ Unsafe fix -9 9 | -10 10 | # LOG002 -11 11 | getLogger(__file__) -12 |-logging.getLogger(name=__file__) - 12 |+logging.getLogger(name=__name__) -13 13 | -14 14 | logging.getLogger(__cached__) -15 15 | getLogger(name=__cached__) LOG002.py:14:19: LOG002 [*] Use `__name__` with `logging.getLogger()` | @@ -51,15 +33,6 @@ LOG002.py:14:19: LOG002 [*] Use `__name__` with `logging.getLogger()` | = help: Replace with `__name__` -ℹ Unsafe fix -11 11 | getLogger(__file__) -12 12 | logging.getLogger(name=__file__) -13 13 | -14 |-logging.getLogger(__cached__) - 14 |+logging.getLogger(__name__) -15 15 | getLogger(name=__cached__) -16 16 | -17 17 | LOG002.py:15:16: LOG002 [*] Use `__name__` with `logging.getLogger()` | @@ -68,15 +41,3 @@ LOG002.py:15:16: LOG002 [*] Use `__name__` with `logging.getLogger()` | ^^^^^^^^^^ LOG002 | = help: Replace with `__name__` - -ℹ Unsafe fix -12 12 | logging.getLogger(name=__file__) -13 13 | -14 14 | logging.getLogger(__cached__) -15 |-getLogger(name=__cached__) - 15 |+getLogger(name=__name__) -16 16 | -17 17 | -18 18 | # Override `logging.getLogger` - - diff --git a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG009_LOG009.py.snap b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG009_LOG009.py.snap index b630875d83233..066b523830237 100644 --- a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG009_LOG009.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG009_LOG009.py.snap @@ -11,7 +11,6 @@ LOG009.py:4:5: LOG009 [*] Use of undocumented `logging.WARN` constant | = help: Replace `logging.WARN` with `logging.WARNING` -ℹ Safe fix 1 1 | def func(): 2 2 | import logging 3 3 | @@ -31,7 +30,6 @@ LOG009.py:11:5: LOG009 [*] Use of undocumented `logging.WARN` constant | = help: Replace `logging.WARN` with `logging.WARNING` -ℹ Safe fix 8 8 | def func(): 9 9 | from logging import WARN, WARNING 10 10 | diff --git a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G010.py.snap b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G010.py.snap index 8a9191704f79f..0aa7dc6864450 100644 --- a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G010.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G010.py.snap @@ -12,7 +12,6 @@ G010.py:6:9: G010 [*] Logging statement uses `warn` instead of `warning` | = help: Convert to `warning` -ℹ Safe fix 3 3 | 4 4 | from logging_setup import logger 5 5 | @@ -33,7 +32,6 @@ G010.py:8:8: G010 [*] Logging statement uses `warn` instead of `warning` | = help: Convert to `warning` -ℹ Safe fix 5 5 | 6 6 | logging.warn("Hello World!") 7 7 | log.warn("Hello world!") # This shouldn't be considered as a logger candidate @@ -54,7 +52,6 @@ G010.py:10:11: G010 [*] Logging statement uses `warn` instead of `warning` | = help: Convert to `warning` -ℹ Safe fix 7 7 | log.warn("Hello world!") # This shouldn't be considered as a logger candidate 8 8 | logger.warn("Hello world!") 9 9 | @@ -74,7 +71,6 @@ G010.py:13:1: G010 [*] Logging statement uses `warn` instead of `warning` | = help: Convert to `warning` -ℹ Safe fix 10 10 | logging . warn("Hello World!") 11 11 | 12 12 | from logging import warn, warning, exception @@ -82,5 +78,3 @@ G010.py:13:1: G010 [*] Logging statement uses `warn` instead of `warning` 14 13 | warning("foo") 14 |+warning("foo") 15 15 | exception("foo") - - diff --git a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE790_PIE790.py.snap b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE790_PIE790.py.snap index b2356b7f347a8..100572a94e4be 100644 --- a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE790_PIE790.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE790_PIE790.py.snap @@ -10,7 +10,6 @@ PIE790.py:4:5: PIE790 [*] Unnecessary `pass` statement | = help: Remove unnecessary `pass` -ℹ Safe fix 1 1 | class Foo: 2 2 | """buzz""" 3 3 | @@ -28,7 +27,6 @@ PIE790.py:9:5: PIE790 [*] Unnecessary `pass` statement | = help: Remove unnecessary `pass` -ℹ Safe fix 6 6 | 7 7 | if foo: 8 8 | """foo""" @@ -46,7 +44,6 @@ PIE790.py:14:5: PIE790 [*] Unnecessary `pass` statement | = help: Remove unnecessary `pass` -ℹ Safe fix 11 11 | 12 12 | def multi_statement() -> None: 13 13 | """This is a function.""" @@ -65,7 +62,6 @@ PIE790.py:21:5: PIE790 [*] Unnecessary `pass` statement | = help: Remove unnecessary `pass` -ℹ Safe fix 18 18 | pass 19 19 | else: 20 20 | """bar""" @@ -83,7 +79,6 @@ PIE790.py:28:5: PIE790 [*] Unnecessary `pass` statement | = help: Remove unnecessary `pass` -ℹ Safe fix 25 25 | pass 26 26 | else: 27 27 | """bar""" @@ -101,7 +96,6 @@ PIE790.py:35:5: PIE790 [*] Unnecessary `pass` statement | = help: Remove unnecessary `pass` -ℹ Safe fix 32 32 | pass 33 33 | else: 34 34 | """bar""" @@ -119,7 +113,6 @@ PIE790.py:42:5: PIE790 [*] Unnecessary `pass` statement | = help: Remove unnecessary `pass` -ℹ Safe fix 39 39 | pass 40 40 | else: 41 41 | """bar""" @@ -137,7 +130,6 @@ PIE790.py:50:5: PIE790 [*] Unnecessary `pass` statement | = help: Remove unnecessary `pass` -ℹ Safe fix 47 47 | buzz 48 48 | """ 49 49 | @@ -155,7 +147,6 @@ PIE790.py:58:5: PIE790 [*] Unnecessary `pass` statement | = help: Remove unnecessary `pass` -ℹ Safe fix 55 55 | buzz 56 56 | """ 57 57 | @@ -175,7 +166,6 @@ PIE790.py:65:5: PIE790 [*] Unnecessary `pass` statement | = help: Remove unnecessary `pass` -ℹ Safe fix 62 62 | """ 63 63 | buzz 64 64 | """ @@ -193,7 +183,6 @@ PIE790.py:74:5: PIE790 [*] Unnecessary `pass` statement | = help: Remove unnecessary `pass` -ℹ Safe fix 71 71 | bar() 72 72 | except ValueError: 73 73 | """bar""" @@ -213,7 +202,6 @@ PIE790.py:79:5: PIE790 [*] Unnecessary `pass` statement | = help: Remove unnecessary `pass` -ℹ Safe fix 76 76 | 77 77 | for _ in range(10): 78 78 | """buzz""" @@ -233,7 +221,6 @@ PIE790.py:83:5: PIE790 [*] Unnecessary `pass` statement | = help: Remove unnecessary `pass` -ℹ Safe fix 80 80 | 81 81 | async for _ in range(10): 82 82 | """buzz""" @@ -251,7 +238,6 @@ PIE790.py:87:5: PIE790 [*] Unnecessary `pass` statement | = help: Remove unnecessary `pass` -ℹ Safe fix 84 84 | 85 85 | while cond: 86 86 | """buzz""" @@ -271,7 +257,6 @@ PIE790.py:92:5: PIE790 [*] Unnecessary `pass` statement | = help: Remove unnecessary `pass` -ℹ Safe fix 89 89 | 90 90 | with bar: 91 91 | """buzz""" @@ -289,7 +274,6 @@ PIE790.py:96:5: PIE790 [*] Unnecessary `pass` statement | = help: Remove unnecessary `pass` -ℹ Safe fix 93 93 | 94 94 | async with bar: 95 95 | """buzz""" @@ -307,7 +291,6 @@ PIE790.py:101:5: PIE790 [*] Unnecessary `pass` statement | = help: Remove unnecessary `pass` -ℹ Safe fix 98 98 | 99 99 | def foo() -> None: 100 100 | """buzz""" @@ -326,7 +309,6 @@ PIE790.py:130:5: PIE790 [*] Unnecessary `pass` statement | = help: Remove unnecessary `pass` -ℹ Safe fix 127 127 | 128 128 | def foo(): 129 129 | print("foo") @@ -344,7 +326,6 @@ PIE790.py:136:5: PIE790 [*] Unnecessary `pass` statement | = help: Remove unnecessary `pass` -ℹ Safe fix 133 133 | def foo(): 134 134 | """A docstring.""" 135 135 | print("foo") @@ -362,7 +343,6 @@ PIE790.py:140:5: PIE790 [*] Unnecessary `pass` statement | = help: Remove unnecessary `pass` -ℹ Safe fix 138 138 | 139 139 | for i in range(10): 140 140 | pass @@ -382,7 +362,6 @@ PIE790.py:141:5: PIE790 [*] Unnecessary `pass` statement | = help: Remove unnecessary `pass` -ℹ Safe fix 138 138 | 139 139 | for i in range(10): 140 140 | pass @@ -401,7 +380,6 @@ PIE790.py:144:5: PIE790 [*] Unnecessary `pass` statement | = help: Remove unnecessary `pass` -ℹ Safe fix 141 141 | pass 142 142 | 143 143 | for i in range(10): @@ -421,7 +399,6 @@ PIE790.py:146:5: PIE790 [*] Unnecessary `pass` statement | = help: Remove unnecessary `pass` -ℹ Safe fix 143 143 | for i in range(10): 144 144 | pass 145 145 | @@ -439,7 +416,6 @@ PIE790.py:149:5: PIE790 [*] Unnecessary `pass` statement | = help: Remove unnecessary `pass` -ℹ Safe fix 146 146 | pass 147 147 | 148 148 | for i in range(10): @@ -458,7 +434,6 @@ PIE790.py:150:5: PIE790 [*] Unnecessary `pass` statement | = help: Remove unnecessary `pass` -ℹ Safe fix 147 147 | 148 148 | for i in range(10): 149 149 | pass # comment @@ -476,7 +451,6 @@ PIE790.py:155:5: PIE790 [*] Unnecessary `...` literal | = help: Remove unnecessary `...` -ℹ Safe fix 152 152 | 153 153 | def foo(): 154 154 | print("foo") @@ -494,7 +468,6 @@ PIE790.py:161:5: PIE790 [*] Unnecessary `...` literal | = help: Remove unnecessary `...` -ℹ Safe fix 158 158 | def foo(): 159 159 | """A docstring.""" 160 160 | print("foo") @@ -512,7 +485,6 @@ PIE790.py:165:5: PIE790 [*] Unnecessary `...` literal | = help: Remove unnecessary `...` -ℹ Safe fix 163 163 | 164 164 | for i in range(10): 165 165 | ... @@ -532,7 +504,6 @@ PIE790.py:166:5: PIE790 [*] Unnecessary `...` literal | = help: Remove unnecessary `...` -ℹ Safe fix 163 163 | 164 164 | for i in range(10): 165 165 | ... @@ -551,7 +522,6 @@ PIE790.py:169:5: PIE790 [*] Unnecessary `...` literal | = help: Remove unnecessary `...` -ℹ Safe fix 166 166 | ... 167 167 | 168 168 | for i in range(10): @@ -571,7 +541,6 @@ PIE790.py:171:5: PIE790 [*] Unnecessary `...` literal | = help: Remove unnecessary `...` -ℹ Safe fix 168 168 | for i in range(10): 169 169 | ... 170 170 | @@ -589,7 +558,6 @@ PIE790.py:174:5: PIE790 [*] Unnecessary `...` literal | = help: Remove unnecessary `...` -ℹ Safe fix 171 171 | ... 172 172 | 173 173 | for i in range(10): @@ -610,7 +578,6 @@ PIE790.py:175:5: PIE790 [*] Unnecessary `...` literal | = help: Remove unnecessary `...` -ℹ Safe fix 172 172 | 173 173 | for i in range(10): 174 174 | ... # comment @@ -628,7 +595,6 @@ PIE790.py:178:5: PIE790 [*] Unnecessary `...` literal | = help: Remove unnecessary `...` -ℹ Safe fix 175 175 | ... 176 176 | 177 177 | for i in range(10): @@ -648,7 +614,6 @@ PIE790.py:179:5: PIE790 [*] Unnecessary `pass` statement | = help: Remove unnecessary `pass` -ℹ Safe fix 176 176 | 177 177 | for i in range(10): 178 178 | ... @@ -666,7 +631,6 @@ PIE790.py:209:9: PIE790 [*] Unnecessary `...` literal | = help: Remove unnecessary `...` -ℹ Safe fix 206 206 | 207 207 | def stub(self) -> str: 208 208 | """Docstring""" @@ -674,5 +638,3 @@ PIE790.py:209:9: PIE790 [*] Unnecessary `...` literal 210 209 | 211 210 | 212 211 | class Repro(Protocol[int]): - - diff --git a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE794_PIE794.py.snap b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE794_PIE794.py.snap index f5945563ffb5f..12464bcf56e6f 100644 --- a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE794_PIE794.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE794_PIE794.py.snap @@ -12,14 +12,6 @@ PIE794.py:4:5: PIE794 [*] Class field `name` is defined multiple times | = help: Remove duplicate field definition for `name` -ℹ Unsafe fix -1 1 | class Foo(BaseModel): -2 2 | name = StringField() -3 3 | # .... -4 |- name = StringField() # PIE794 -5 4 | -6 5 | def remove(self) -> None: -7 6 | ... PIE794.py:13:5: PIE794 [*] Class field `name` is defined multiple times | @@ -32,14 +24,6 @@ PIE794.py:13:5: PIE794 [*] Class field `name` is defined multiple times | = help: Remove duplicate field definition for `name` -ℹ Unsafe fix -10 10 | class Foo(BaseModel): -11 11 | name: str = StringField() -12 12 | # .... -13 |- name = StringField() # PIE794 -14 13 | -15 14 | def foo(self) -> None: -16 15 | ... PIE794.py:23:5: PIE794 [*] Class field `bar` is defined multiple times | @@ -50,14 +34,6 @@ PIE794.py:23:5: PIE794 [*] Class field `bar` is defined multiple times | = help: Remove duplicate field definition for `bar` -ℹ Unsafe fix -20 20 | bar: str = StringField() -21 21 | foo: bool = BooleanField() -22 22 | # ... -23 |- bar = StringField() # PIE794 -24 23 | -25 24 | -26 25 | class User(BaseModel): PIE794.py:40:5: PIE794 [*] Class field `bar` is defined multiple times | @@ -68,14 +44,6 @@ PIE794.py:40:5: PIE794 [*] Class field `bar` is defined multiple times | = help: Remove duplicate field definition for `bar` -ℹ Unsafe fix -37 37 | bar: str = StringField() -38 38 | foo: bool = BooleanField() -39 39 | # ... -40 |- bar = StringField() # PIE794 -41 40 | -42 41 | -43 42 | class Person: PIE794.py:46:5: PIE794 [*] Class field `name` is defined multiple times | @@ -86,14 +54,6 @@ PIE794.py:46:5: PIE794 [*] Class field `name` is defined multiple times | = help: Remove duplicate field definition for `name` -ℹ Unsafe fix -43 43 | class Person: -44 44 | name = "Foo" -45 45 | name = name + " Bar" -46 |- name = "Bar" # PIE794 -47 46 | -48 47 | -49 48 | class Person: PIE794.py:52:5: PIE794 [*] Class field `name` is defined multiple times | @@ -103,11 +63,3 @@ PIE794.py:52:5: PIE794 [*] Class field `name` is defined multiple times | ^^^^^^^^^^^^^^^^^ PIE794 | = help: Remove duplicate field definition for `name` - -ℹ Unsafe fix -49 49 | class Person: -50 50 | name: str = "Foo" -51 51 | name: str = name + " Bar" -52 |- name: str = "Bar" # PIE794 - - diff --git a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE800_PIE800.py.snap b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE800_PIE800.py.snap index 217e4c71f3a21..1f0fac5892049 100644 --- a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE800_PIE800.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE800_PIE800.py.snap @@ -10,7 +10,6 @@ PIE800.py:1:14: PIE800 [*] Unnecessary spread `**` | = help: Remove unnecessary dict -ℹ Safe fix 1 |-{"foo": 1, **{"bar": 1}} # PIE800 1 |+{"foo": 1, "bar": 1} # PIE800 2 2 | @@ -28,7 +27,6 @@ PIE800.py:3:4: PIE800 [*] Unnecessary spread `**` | = help: Remove unnecessary dict -ℹ Safe fix 1 1 | {"foo": 1, **{"bar": 1}} # PIE800 2 2 | 3 |-{**{"bar": 10}, "a": "b"} # PIE800 @@ -48,7 +46,6 @@ PIE800.py:5:15: PIE800 [*] Unnecessary spread `**` | = help: Remove unnecessary dict -ℹ Safe fix 2 2 | 3 3 | {**{"bar": 10}, "a": "b"} # PIE800 4 4 | @@ -69,7 +66,6 @@ PIE800.py:7:11: PIE800 [*] Unnecessary spread `**` | = help: Remove unnecessary dict -ℹ Safe fix 4 4 | 5 5 | foo({**foo, **{"bar": True}}) # PIE800 6 6 | @@ -94,7 +90,6 @@ PIE800.py:12:7: PIE800 [*] Unnecessary spread `**` | = help: Remove unnecessary dict -ℹ Safe fix 9 9 | { # PIE800 10 10 | "a": "b", 11 11 | # Preserve @@ -121,7 +116,6 @@ PIE800.py:19:19: PIE800 [*] Unnecessary spread `**` | = help: Remove unnecessary dict -ℹ Safe fix 16 16 | }, 17 17 | } 18 18 | @@ -129,6 +123,4 @@ PIE800.py:19:19: PIE800 [*] Unnecessary spread `**` 19 |+{**foo, **buzz, bar: 10} # PIE800 20 20 | 21 21 | {**foo, "bar": True } # OK -22 22 | - - +22 22 | diff --git a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE804_PIE804.py.snap b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE804_PIE804.py.snap index b6a65ca50d257..d9313e0f9455d 100644 --- a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE804_PIE804.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE804_PIE804.py.snap @@ -10,7 +10,6 @@ PIE804.py:1:5: PIE804 [*] Unnecessary `dict` kwargs | = help: Remove unnecessary kwargs -ℹ Safe fix 1 |-foo(**{"bar": True}) # PIE804 1 |+foo(bar=True) # PIE804 2 2 | @@ -28,7 +27,6 @@ PIE804.py:3:5: PIE804 [*] Unnecessary `dict` kwargs | = help: Remove unnecessary kwargs -ℹ Safe fix 1 1 | foo(**{"bar": True}) # PIE804 2 2 | 3 |-foo(**{"r2d2": True}) # PIE804 @@ -48,7 +46,6 @@ PIE804.py:5:20: PIE804 [*] Unnecessary `dict` kwargs | = help: Remove unnecessary kwargs -ℹ Safe fix 2 2 | 3 3 | foo(**{"r2d2": True}) # PIE804 4 4 | @@ -69,7 +66,6 @@ PIE804.py:7:20: PIE804 [*] Unnecessary `dict` kwargs | = help: Remove unnecessary kwargs -ℹ Safe fix 4 4 | 5 5 | Foo.objects.create(**{"bar": True}) # PIE804 6 6 | @@ -90,7 +86,6 @@ PIE804.py:9:20: PIE804 [*] Unnecessary `dict` kwargs | = help: Remove unnecessary kwargs -ℹ Safe fix 6 6 | 7 7 | Foo.objects.create(**{"_id": some_id}) # PIE804 8 8 | @@ -111,7 +106,6 @@ PIE804.py:11:5: PIE804 [*] Unnecessary `dict` kwargs | = help: Remove unnecessary kwargs -ℹ Safe fix 8 8 | 9 9 | Foo.objects.create(**{**bar}) # PIE804 10 10 | @@ -132,7 +126,6 @@ PIE804.py:22:5: PIE804 [*] Unnecessary `dict` kwargs | = help: Remove unnecessary kwargs -ℹ Safe fix 19 19 | foo(**{"": True}) 20 20 | foo(**{f"buzz__{bar}": True}) 21 21 | abc(**{"for": 3}) @@ -182,7 +175,6 @@ PIE804.py:26:22: PIE804 [*] Unnecessary `dict` kwargs | = help: Remove unnecessary kwargs -ℹ Safe fix 23 23 | 24 24 | # Duplicated key names won't be fixed, to avoid syntax errors. 25 25 | abc(**{'a': b}, **{'a': c}) # PIE804 @@ -201,7 +193,6 @@ PIE804.py:29:12: PIE804 [*] Unnecessary `dict` kwargs | = help: Remove unnecessary kwargs -ℹ Safe fix 26 26 | abc(a=1, **{'a': c}, **{'b': c}) # PIE804 27 27 | 28 28 | # Some values need to be parenthesized. @@ -218,7 +209,6 @@ PIE804.py:30:12: PIE804 [*] Unnecessary `dict` kwargs | = help: Remove unnecessary kwargs -ℹ Safe fix 27 27 | 28 28 | # Some values need to be parenthesized. 29 29 | abc(foo=1, **{'bar': (bar := 1)}) # PIE804 diff --git a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE807_PIE807.py.snap b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE807_PIE807.py.snap index 474c3456d53f9..f56b215fbf3d6 100644 --- a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE807_PIE807.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE807_PIE807.py.snap @@ -11,7 +11,6 @@ PIE807.py:3:44: PIE807 [*] Prefer `list` over useless lambda | = help: Replace with `lambda` with `list` -ℹ Safe fix 1 1 | @dataclass 2 2 | class Foo: 3 |- foo: List[str] = field(default_factory=lambda: []) # PIE807 @@ -29,7 +28,6 @@ PIE807.py:4:49: PIE807 [*] Prefer `dict` over useless lambda | = help: Replace with `lambda` with `dict` -ℹ Safe fix 1 1 | @dataclass 2 2 | class Foo: 3 3 | foo: List[str] = field(default_factory=lambda: []) # PIE807 @@ -48,7 +46,6 @@ PIE807.py:8:36: PIE807 [*] Prefer `list` over useless lambda | = help: Replace with `lambda` with `list` -ℹ Safe fix 5 5 | 6 6 | 7 7 | class FooTable(BaseTable): @@ -67,7 +64,6 @@ PIE807.py:9:36: PIE807 [*] Prefer `dict` over useless lambda | = help: Replace with `lambda` with `dict` -ℹ Safe fix 6 6 | 7 7 | class FooTable(BaseTable): 8 8 | foo = fields.ListField(default=lambda: []) # PIE807 @@ -86,7 +82,6 @@ PIE807.py:13:28: PIE807 [*] Prefer `list` over useless lambda | = help: Replace with `lambda` with `list` -ℹ Safe fix 10 10 | 11 11 | 12 12 | class FooTable(BaseTable): @@ -105,7 +100,6 @@ PIE807.py:14:36: PIE807 [*] Prefer `dict` over useless lambda | = help: Replace with `lambda` with `dict` -ℹ Safe fix 11 11 | 12 12 | class FooTable(BaseTable): 13 13 | foo = fields.ListField(lambda: []) # PIE807 @@ -114,5 +108,3 @@ PIE807.py:14:36: PIE807 [*] Prefer `dict` over useless lambda 15 15 | 16 16 | 17 17 | @dataclass - - diff --git a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE808_PIE808.py.snap b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE808_PIE808.py.snap index 91c5932b028c7..df1d9306e6614 100644 --- a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE808_PIE808.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE808_PIE808.py.snap @@ -11,7 +11,6 @@ PIE808.py:2:7: PIE808 [*] Unnecessary `start` argument in `range` | = help: Remove `start` argument -ℹ Safe fix 1 1 | # PIE808 2 |-range(0, 10) 2 |+range(10) @@ -29,7 +28,6 @@ PIE808.py:5:16: PIE808 [*] Unnecessary `start` argument in `range` | = help: Remove `start` argument -ℹ Safe fix 2 2 | range(0, 10) 3 3 | 4 4 | import builtins diff --git a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE810_PIE810.py.snap b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE810_PIE810.py.snap index d2d29d693f350..525fc0af242a8 100644 --- a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE810_PIE810.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE810_PIE810.py.snap @@ -11,13 +11,6 @@ PIE810.py:2:1: PIE810 [*] Call `startswith` once with a `tuple` | = help: Merge into a single `startswith` call -ℹ Unsafe fix -1 1 | # error -2 |-obj.startswith("foo") or obj.startswith("bar") - 2 |+obj.startswith(("foo", "bar")) -3 3 | # error -4 4 | obj.endswith("foo") or obj.endswith("bar") -5 5 | # error PIE810.py:4:1: PIE810 [*] Call `endswith` once with a `tuple` | @@ -30,15 +23,6 @@ PIE810.py:4:1: PIE810 [*] Call `endswith` once with a `tuple` | = help: Merge into a single `endswith` call -ℹ Unsafe fix -1 1 | # error -2 2 | obj.startswith("foo") or obj.startswith("bar") -3 3 | # error -4 |-obj.endswith("foo") or obj.endswith("bar") - 4 |+obj.endswith(("foo", "bar")) -5 5 | # error -6 6 | obj.startswith(foo) or obj.startswith(bar) -7 7 | # error PIE810.py:6:1: PIE810 [*] Call `startswith` once with a `tuple` | @@ -51,15 +35,6 @@ PIE810.py:6:1: PIE810 [*] Call `startswith` once with a `tuple` | = help: Merge into a single `startswith` call -ℹ Unsafe fix -3 3 | # error -4 4 | obj.endswith("foo") or obj.endswith("bar") -5 5 | # error -6 |-obj.startswith(foo) or obj.startswith(bar) - 6 |+obj.startswith((foo, bar)) -7 7 | # error -8 8 | obj.startswith(foo) or obj.startswith("foo") -9 9 | # error PIE810.py:8:1: PIE810 [*] Call `startswith` once with a `tuple` | @@ -72,15 +47,6 @@ PIE810.py:8:1: PIE810 [*] Call `startswith` once with a `tuple` | = help: Merge into a single `startswith` call -ℹ Unsafe fix -5 5 | # error -6 6 | obj.startswith(foo) or obj.startswith(bar) -7 7 | # error -8 |-obj.startswith(foo) or obj.startswith("foo") - 8 |+obj.startswith((foo, "foo")) -9 9 | # error -10 10 | obj.endswith(foo) or obj.startswith(foo) or obj.startswith("foo") -11 11 | PIE810.py:10:1: PIE810 [*] Call `startswith` once with a `tuple` | @@ -93,15 +59,6 @@ PIE810.py:10:1: PIE810 [*] Call `startswith` once with a `tuple` | = help: Merge into a single `startswith` call -ℹ Unsafe fix -7 7 | # error -8 8 | obj.startswith(foo) or obj.startswith("foo") -9 9 | # error -10 |-obj.endswith(foo) or obj.startswith(foo) or obj.startswith("foo") - 10 |+obj.endswith(foo) or obj.startswith((foo, "foo")) -11 11 | -12 12 | def func(): -13 13 | msg = "hello world" PIE810.py:19:8: PIE810 [*] Call `startswith` once with a `tuple` | @@ -113,15 +70,6 @@ PIE810.py:19:8: PIE810 [*] Call `startswith` once with a `tuple` | = help: Merge into a single `startswith` call -ℹ Unsafe fix -16 16 | y = ("h", "e", "l", "l", "o") -17 17 | z = "w" -18 18 | -19 |- if msg.startswith(x) or msg.startswith(y) or msg.startswith(z): # Error - 19 |+ if msg.startswith((x, z)) or msg.startswith(y): # Error -20 20 | print("yes") -21 21 | -22 22 | def func(): PIE810.py:25:8: PIE810 [*] Call `startswith` once with a `tuple` | @@ -132,15 +80,3 @@ PIE810.py:25:8: PIE810 [*] Call `startswith` once with a `tuple` 26 | print("yes") | = help: Merge into a single `startswith` call - -ℹ Unsafe fix -22 22 | def func(): -23 23 | msg = "hello world" -24 24 | -25 |- if msg.startswith(("h", "e", "l", "l", "o")) or msg.startswith("h") or msg.startswith("w"): # Error - 25 |+ if msg.startswith(("h", "e", "l", "l", "o", "h", "w")): # Error -26 26 | print("yes") -27 27 | -28 28 | # ok - - diff --git a/crates/ruff_linter/src/rules/flake8_print/snapshots/ruff_linter__rules__flake8_print__tests__T201_T201.py.snap b/crates/ruff_linter/src/rules/flake8_print/snapshots/ruff_linter__rules__flake8_print__tests__T201_T201.py.snap index 2cbb5753612a3..4ca88a08185fd 100644 --- a/crates/ruff_linter/src/rules/flake8_print/snapshots/ruff_linter__rules__flake8_print__tests__T201_T201.py.snap +++ b/crates/ruff_linter/src/rules/flake8_print/snapshots/ruff_linter__rules__flake8_print__tests__T201_T201.py.snap @@ -12,14 +12,6 @@ T201.py:4:1: T201 [*] `print` found | = help: Remove `print` -ℹ Unsafe fix -1 1 | import sys -2 2 | import tempfile -3 3 | -4 |-print("Hello, world!") # T201 -5 4 | print("Hello, world!", file=None) # T201 -6 5 | print("Hello, world!", file=sys.stdout) # T201 -7 6 | print("Hello, world!", file=sys.stderr) # T201 T201.py:5:1: T201 [*] `print` found | @@ -31,14 +23,6 @@ T201.py:5:1: T201 [*] `print` found | = help: Remove `print` -ℹ Unsafe fix -2 2 | import tempfile -3 3 | -4 4 | print("Hello, world!") # T201 -5 |-print("Hello, world!", file=None) # T201 -6 5 | print("Hello, world!", file=sys.stdout) # T201 -7 6 | print("Hello, world!", file=sys.stderr) # T201 -8 7 | T201.py:6:1: T201 [*] `print` found | @@ -50,14 +34,6 @@ T201.py:6:1: T201 [*] `print` found | = help: Remove `print` -ℹ Unsafe fix -3 3 | -4 4 | print("Hello, world!") # T201 -5 5 | print("Hello, world!", file=None) # T201 -6 |-print("Hello, world!", file=sys.stdout) # T201 -7 6 | print("Hello, world!", file=sys.stderr) # T201 -8 7 | -9 8 | with tempfile.NamedTemporaryFile() as fp: T201.py:7:1: T201 [*] `print` found | @@ -69,14 +45,3 @@ T201.py:7:1: T201 [*] `print` found 9 | with tempfile.NamedTemporaryFile() as fp: | = help: Remove `print` - -ℹ Unsafe fix -4 4 | print("Hello, world!") # T201 -5 5 | print("Hello, world!", file=None) # T201 -6 6 | print("Hello, world!", file=sys.stdout) # T201 -7 |-print("Hello, world!", file=sys.stderr) # T201 -8 7 | -9 8 | with tempfile.NamedTemporaryFile() as fp: -10 9 | print("Hello, world!", file=fp) # OK - - diff --git a/crates/ruff_linter/src/rules/flake8_print/snapshots/ruff_linter__rules__flake8_print__tests__T203_T203.py.snap b/crates/ruff_linter/src/rules/flake8_print/snapshots/ruff_linter__rules__flake8_print__tests__T203_T203.py.snap index f63e108c8618c..019a1043075d0 100644 --- a/crates/ruff_linter/src/rules/flake8_print/snapshots/ruff_linter__rules__flake8_print__tests__T203_T203.py.snap +++ b/crates/ruff_linter/src/rules/flake8_print/snapshots/ruff_linter__rules__flake8_print__tests__T203_T203.py.snap @@ -12,13 +12,6 @@ T203.py:3:1: T203 [*] `pprint` found | = help: Remove `pprint` -ℹ Unsafe fix -1 1 | from pprint import pprint -2 2 | -3 |-pprint("Hello, world!") # T203 -4 3 | -5 4 | import pprint -6 5 | T203.py:7:1: T203 [*] `pprint` found | @@ -30,13 +23,3 @@ T203.py:7:1: T203 [*] `pprint` found 9 | pprint.pformat("Hello, world!") | = help: Remove `pprint` - -ℹ Unsafe fix -4 4 | -5 5 | import pprint -6 6 | -7 |-pprint.pprint("Hello, world!") # T203 -8 7 | -9 8 | pprint.pformat("Hello, world!") - - diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI009_PYI009.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI009_PYI009.pyi.snap index d4c1347bf3c7a..8a5513dfc82b5 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI009_PYI009.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI009_PYI009.pyi.snap @@ -12,7 +12,6 @@ PYI009.pyi:3:5: PYI009 [*] Empty body should contain `...`, not `pass` | = help: Replace `pass` with `...` -ℹ Safe fix 1 1 | def bar(): ... # OK 2 2 | def foo(): 3 |- pass # ERROR PYI009, since we're in a stub file @@ -29,11 +28,8 @@ PYI009.pyi:8:5: PYI009 [*] Empty body should contain `...`, not `pass` | = help: Replace `pass` with `...` -ℹ Safe fix 5 5 | class Bar: ... # OK 6 6 | 7 7 | class Foo: 8 |- pass # ERROR PYI009, since we're in a stub file 8 |+ ... # ERROR PYI009, since we're in a stub file - - diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI010_PYI010.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI010_PYI010.pyi.snap index 516ca749ad73b..bc77a0675ffe0 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI010_PYI010.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI010_PYI010.pyi.snap @@ -11,7 +11,6 @@ PYI010.pyi:6:5: PYI010 [*] Function body must contain only `...` | = help: Replace function body with `...` -ℹ Safe fix 3 3 | """foo""" # OK, docstrings are handled by another rule 4 4 | 5 5 | def buzz(): @@ -31,7 +30,6 @@ PYI010.pyi:9:5: PYI010 [*] Function body must contain only `...` | = help: Replace function body with `...` -ℹ Safe fix 6 6 | print("buzz") # ERROR PYI010 7 7 | 8 8 | def foo2(): @@ -51,7 +49,6 @@ PYI010.pyi:12:5: PYI010 [*] Function body must contain only `...` | = help: Replace function body with `...` -ℹ Safe fix 9 9 | 123 # ERROR PYI010 10 10 | 11 11 | def bizz(): @@ -60,5 +57,3 @@ PYI010.pyi:12:5: PYI010 [*] Function body must contain only `...` 13 13 | 14 14 | def foo3(): 15 15 | pass # OK, pass is handled by another rule - - diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI011_PYI011.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI011_PYI011.pyi.snap index 6a68fe21f28fb..9b8cc3a645886 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI011_PYI011.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI011_PYI011.pyi.snap @@ -12,7 +12,6 @@ PYI011.pyi:10:14: PYI011 [*] Only simple default values allowed for typed argume | = help: Replace default value with `...` -ℹ Safe fix 7 7 | 8 8 | def f12( 9 9 | x, @@ -37,7 +36,6 @@ PYI011.pyi:38:9: PYI011 [*] Only simple default values allowed for typed argumen | = help: Replace default value with `...` -ℹ Safe fix 35 35 | def f152( 36 36 | x: dict[ 37 37 | int, int @@ -74,7 +72,6 @@ PYI011.pyi:46:9: PYI011 [*] Only simple default values allowed for typed argumen | = help: Replace default value with `...` -ℹ Safe fix 43 43 | def f153( 44 44 | x: list[ 45 45 | int @@ -111,7 +108,6 @@ PYI011.pyi:63:9: PYI011 [*] Only simple default values allowed for typed argumen | = help: Replace default value with `...` -ℹ Safe fix 60 60 | def f154( 61 61 | x: tuple[ 62 62 | str, tuple[str, ...] @@ -138,7 +134,6 @@ PYI011.pyi:71:9: PYI011 [*] Only simple default values allowed for typed argumen | = help: Replace default value with `...` -ℹ Safe fix 68 68 | def f141( 69 69 | x: list[ 70 70 | int @@ -164,7 +159,6 @@ PYI011.pyi:78:9: PYI011 [*] Only simple default values allowed for typed argumen | = help: Replace default value with `...` -ℹ Safe fix 75 75 | def f142( 76 76 | x: list[ 77 77 | int @@ -190,7 +184,6 @@ PYI011.pyi:85:9: PYI011 [*] Only simple default values allowed for typed argumen | = help: Replace default value with `...` -ℹ Safe fix 82 82 | def f16( 83 83 | x: frozenset[ 84 84 | bytes @@ -215,7 +208,6 @@ PYI011.pyi:90:14: PYI011 [*] Only simple default values allowed for typed argume | = help: Replace default value with `...` -ℹ Safe fix 87 87 | ) 88 88 | ) -> None: ... 89 89 | def f17( @@ -239,7 +231,6 @@ PYI011.pyi:94:14: PYI011 [*] Only simple default values allowed for typed argume | = help: Replace default value with `...` -ℹ Safe fix 91 91 | + "bar", 92 92 | ) -> None: ... 93 93 | def f18( @@ -263,7 +254,6 @@ PYI011.pyi:98:17: PYI011 [*] Only simple default values allowed for typed argume | = help: Replace default value with `...` -ℹ Safe fix 95 95 | + b"bar", 96 96 | ) -> None: ... 97 97 | def f19( @@ -287,7 +277,6 @@ PYI011.pyi:102:14: PYI011 [*] Only simple default values allowed for typed argum | = help: Replace default value with `...` -ℹ Safe fix 99 99 | + 4, 100 100 | ) -> None: ... 101 101 | def f20( @@ -311,7 +300,6 @@ PYI011.pyi:106:18: PYI011 [*] Only simple default values allowed for typed argum | = help: Replace default value with `...` -ℹ Safe fix 103 103 | + 5, # Error PYI011 Only simple default values allowed for typed arguments 104 104 | ) -> None: ... 105 105 | def f21( @@ -335,7 +323,6 @@ PYI011.pyi:110:18: PYI011 [*] Only simple default values allowed for typed argum | = help: Replace default value with `...` -ℹ Safe fix 107 107 | - 3j, # Error PYI011 Only simple default values allowed for typed arguments 108 108 | ) -> None: ... 109 109 | def f22( @@ -357,7 +344,6 @@ PYI011.pyi:138:16: PYI011 [*] Only simple default values allowed for typed argum | = help: Replace default value with `...` -ℹ Safe fix 135 135 | x: float = -math.inf, # OK 136 136 | ) -> None: ... 137 137 | def f31( @@ -378,7 +364,6 @@ PYI011.pyi:141:16: PYI011 [*] Only simple default values allowed for typed argum | = help: Replace default value with `...` -ℹ Safe fix 138 138 | x: float = inf, # Error PYI011 Only simple default values allowed for typed arguments 139 139 | ) -> None: ... 140 140 | def f32( @@ -399,7 +384,6 @@ PYI011.pyi:147:16: PYI011 [*] Only simple default values allowed for typed argum | = help: Replace default value with `...` -ℹ Safe fix 144 144 | x: float = math.nan, # OK 145 145 | ) -> None: ... 146 146 | def f34( @@ -422,7 +406,6 @@ PYI011.pyi:150:18: PYI011 [*] Only simple default values allowed for typed argum | = help: Replace default value with `...` -ℹ Safe fix 147 147 | x: float = -math.nan, # Error PYI011 Only simple default values allowed for typed arguments 148 148 | ) -> None: ... 149 149 | def f35( @@ -445,7 +428,6 @@ PYI011.pyi:159:14: PYI011 [*] Only simple default values allowed for typed argum | = help: Replace default value with `...` -ℹ Safe fix 156 156 | ) -> None: ... 157 157 | def f37( 158 158 | *, @@ -453,5 +435,3 @@ PYI011.pyi:159:14: PYI011 [*] Only simple default values allowed for typed argum 160 |- + "", 159 |+ x: str = ..., 161 160 | ) -> None: ... - - diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI012_PYI012.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI012_PYI012.pyi.snap index 9b67fe2854108..1035e3f99f359 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI012_PYI012.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI012_PYI012.pyi.snap @@ -12,7 +12,6 @@ PYI012.pyi:5:5: PYI012 [*] Class body must not contain `pass` | = help: Remove unnecessary `pass` -ℹ Safe fix 2 2 | 3 3 | class OneAttributeClass: 4 4 | value: int @@ -30,7 +29,6 @@ PYI012.pyi:8:5: PYI012 [*] Class body must not contain `pass` | = help: Remove unnecessary `pass` -ℹ Safe fix 5 5 | pass # PYI012 Class body must not contain `pass` 6 6 | 7 7 | class OneAttributeClassRev: @@ -50,7 +48,6 @@ PYI012.pyi:16:5: PYI012 [*] Class body must not contain `pass` | = help: Remove unnecessary `pass` -ℹ Safe fix 13 13 | My body only contains pass. 14 14 | """ 15 15 | @@ -70,7 +67,6 @@ PYI012.pyi:20:5: PYI012 [*] Class body must not contain `pass` | = help: Remove unnecessary `pass` -ℹ Safe fix 17 17 | 18 18 | class NonEmptyChild(Exception): 19 19 | value: int @@ -88,7 +84,6 @@ PYI012.pyi:23:5: PYI012 [*] Class body must not contain `pass` | = help: Remove unnecessary `pass` -ℹ Safe fix 20 20 | pass # PYI012 Class body must not contain `pass` 21 21 | 22 22 | class NonEmptyChild2(Exception): @@ -108,7 +103,6 @@ PYI012.pyi:28:5: PYI012 [*] Class body must not contain `pass` | = help: Remove unnecessary `pass` -ℹ Safe fix 25 25 | 26 26 | class NonEmptyWithInit: 27 27 | value: int @@ -116,5 +110,3 @@ PYI012.pyi:28:5: PYI012 [*] Class body must not contain `pass` 29 28 | 30 29 | def __init__(): 31 30 | pass - - diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI013_PYI013.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI013_PYI013.py.snap index 5dfb8d8b4bdee..6dae79fc6e693 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI013_PYI013.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI013_PYI013.py.snap @@ -10,7 +10,6 @@ PYI013.py:3:5: PYI013 [*] Non-empty class body must not contain `...` | = help: Remove unnecessary `...` -ℹ Safe fix 1 1 | class OneAttributeClass: 2 2 | value: int 3 |- ... @@ -27,7 +26,6 @@ PYI013.py:7:5: PYI013 [*] Non-empty class body must not contain `...` | = help: Remove unnecessary `...` -ℹ Safe fix 4 4 | 5 5 | 6 6 | class OneAttributeClass2: @@ -45,7 +43,6 @@ PYI013.py:12:5: PYI013 [*] Non-empty class body must not contain `...` | = help: Remove unnecessary `...` -ℹ Safe fix 10 10 | 11 11 | class TwoEllipsesClass: 12 12 | ... @@ -63,7 +60,6 @@ PYI013.py:13:5: PYI013 [*] Non-empty class body must not contain `...` | = help: Remove unnecessary `...` -ℹ Safe fix 10 10 | 11 11 | class TwoEllipsesClass: 12 12 | ... @@ -81,7 +77,6 @@ PYI013.py:21:5: PYI013 [*] Non-empty class body must not contain `...` | = help: Remove unnecessary `...` -ℹ Safe fix 18 18 | My body only contains an ellipsis. 19 19 | """ 20 20 | @@ -99,7 +94,6 @@ PYI013.py:26:5: PYI013 [*] Non-empty class body must not contain `...` | = help: Remove unnecessary `...` -ℹ Safe fix 23 23 | 24 24 | class NonEmptyChild(Exception): 25 25 | value: int @@ -117,7 +111,6 @@ PYI013.py:30:5: PYI013 [*] Non-empty class body must not contain `...` | = help: Remove unnecessary `...` -ℹ Safe fix 27 27 | 28 28 | 29 29 | class NonEmptyChild2(Exception): @@ -137,7 +130,6 @@ PYI013.py:36:5: PYI013 [*] Non-empty class body must not contain `...` | = help: Remove unnecessary `...` -ℹ Safe fix 33 33 | 34 34 | class NonEmptyWithInit: 35 35 | value: int @@ -145,5 +137,3 @@ PYI013.py:36:5: PYI013 [*] Non-empty class body must not contain `...` 37 36 | 38 37 | def __init__(): 39 38 | pass - - diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI013_PYI013.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI013_PYI013.pyi.snap index 83ac30ca4e468..105863328e350 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI013_PYI013.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI013_PYI013.pyi.snap @@ -12,7 +12,6 @@ PYI013.pyi:5:5: PYI013 [*] Non-empty class body must not contain `...` | = help: Remove unnecessary `...` -ℹ Safe fix 2 2 | 3 3 | class OneAttributeClass: 4 4 | value: int @@ -30,7 +29,6 @@ PYI013.pyi:8:5: PYI013 [*] Non-empty class body must not contain `...` | = help: Remove unnecessary `...` -ℹ Safe fix 5 5 | ... # Error 6 6 | 7 7 | class OneAttributeClass2: @@ -48,7 +46,6 @@ PYI013.pyi:12:5: PYI013 [*] Non-empty class body must not contain `...` | = help: Remove unnecessary `...` -ℹ Safe fix 9 9 | value: int 10 10 | 11 11 | class MyClass: @@ -66,7 +63,6 @@ PYI013.pyi:16:5: PYI013 [*] Non-empty class body must not contain `...` | = help: Remove unnecessary `...` -ℹ Safe fix 13 13 | value: int 14 14 | 15 15 | class TwoEllipsesClass: @@ -86,7 +82,6 @@ PYI013.pyi:17:5: PYI013 [*] Non-empty class body must not contain `...` | = help: Remove unnecessary `...` -ℹ Safe fix 14 14 | 15 15 | class TwoEllipsesClass: 16 16 | ... @@ -106,7 +101,6 @@ PYI013.pyi:24:5: PYI013 [*] Non-empty class body must not contain `...` | = help: Remove unnecessary `...` -ℹ Safe fix 21 21 | My body only contains an ellipsis. 22 22 | """ 23 23 | @@ -126,7 +120,6 @@ PYI013.pyi:28:5: PYI013 [*] Non-empty class body must not contain `...` | = help: Remove unnecessary `...` -ℹ Safe fix 25 25 | 26 26 | class NonEmptyChild(Exception): 27 27 | value: int @@ -144,7 +137,6 @@ PYI013.pyi:31:5: PYI013 [*] Non-empty class body must not contain `...` | = help: Remove unnecessary `...` -ℹ Safe fix 28 28 | ... # Error 29 29 | 30 30 | class NonEmptyChild2(Exception): @@ -164,7 +156,6 @@ PYI013.pyi:36:5: PYI013 [*] Non-empty class body must not contain `...` | = help: Remove unnecessary `...` -ℹ Safe fix 33 33 | 34 34 | class NonEmptyWithInit: 35 35 | value: int @@ -172,5 +163,3 @@ PYI013.pyi:36:5: PYI013 [*] Non-empty class body must not contain `...` 37 36 | 38 37 | def __init__(): 39 38 | pass - - diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI014_PYI014.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI014_PYI014.pyi.snap index cdad97490f8b9..d73baed864528 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI014_PYI014.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI014_PYI014.pyi.snap @@ -12,7 +12,6 @@ PYI014.pyi:3:7: PYI014 [*] Only simple default values allowed for arguments | = help: Replace default value with `...` -ℹ Safe fix 1 1 | def f12( 2 2 | x, 3 |- y=os.pathsep, # Error PYI014 @@ -36,7 +35,6 @@ PYI014.pyi:29:7: PYI014 [*] Only simple default values allowed for arguments | = help: Replace default value with `...` -ℹ Safe fix 26 26 | ) -> None: ... 27 27 | def f151(x={1: 2}) -> None: ... 28 28 | def f152( @@ -73,7 +71,6 @@ PYI014.pyi:35:7: PYI014 [*] Only simple default values allowed for arguments | = help: Replace default value with `...` -ℹ Safe fix 32 32 | } 33 33 | ) -> None: ... 34 34 | def f153( @@ -110,7 +107,6 @@ PYI014.pyi:50:7: PYI014 [*] Only simple default values allowed for arguments | = help: Replace default value with `...` -ℹ Safe fix 47 47 | ] 48 48 | ) -> None: ... 49 49 | def f154( @@ -134,7 +130,6 @@ PYI014.pyi:56:7: PYI014 [*] Only simple default values allowed for arguments | = help: Replace default value with `...` -ℹ Safe fix 53 53 | ) 54 54 | ) -> None: ... 55 55 | def f141( @@ -155,7 +150,6 @@ PYI014.pyi:59:7: PYI014 [*] Only simple default values allowed for arguments | = help: Replace default value with `...` -ℹ Safe fix 56 56 | x=[*range(10)], # Error PYI014 57 57 | ) -> None: ... 58 58 | def f142( @@ -176,7 +170,6 @@ PYI014.pyi:61:11: PYI014 [*] Only simple default values allowed for arguments | = help: Replace default value with `...` -ℹ Safe fix 58 58 | def f142( 59 59 | x=list(range(10)), # Error PYI014 60 60 | ) -> None: ... @@ -197,7 +190,6 @@ PYI014.pyi:63:7: PYI014 [*] Only simple default values allowed for arguments | = help: Replace default value with `...` -ℹ Safe fix 60 60 | ) -> None: ... 61 61 | def f16(x=frozenset({b"foo", b"bar", b"baz"})) -> None: ... # Error PYI014 62 62 | def f17( @@ -218,7 +210,6 @@ PYI014.pyi:66:7: PYI014 [*] Only simple default values allowed for arguments | = help: Replace default value with `...` -ℹ Safe fix 63 63 | x="foo" + "bar", # Error PYI014 64 64 | ) -> None: ... 65 65 | def f18( @@ -239,7 +230,6 @@ PYI014.pyi:69:7: PYI014 [*] Only simple default values allowed for arguments | = help: Replace default value with `...` -ℹ Safe fix 66 66 | x=b"foo" + b"bar", # Error PYI014 67 67 | ) -> None: ... 68 68 | def f19( @@ -260,7 +250,6 @@ PYI014.pyi:72:7: PYI014 [*] Only simple default values allowed for arguments | = help: Replace default value with `...` -ℹ Safe fix 69 69 | x="foo" + 4, # Error PYI014 70 70 | ) -> None: ... 71 71 | def f20( @@ -281,7 +270,6 @@ PYI014.pyi:75:7: PYI014 [*] Only simple default values allowed for arguments | = help: Replace default value with `...` -ℹ Safe fix 72 72 | x=5 + 5, # Error PYI014 73 73 | ) -> None: ... 74 74 | def f21( @@ -302,7 +290,6 @@ PYI014.pyi:78:7: PYI014 [*] Only simple default values allowed for arguments | = help: Replace default value with `...` -ℹ Safe fix 75 75 | x=3j - 3j, # Error PYI014 76 76 | ) -> None: ... 77 77 | def f22( @@ -311,5 +298,3 @@ PYI014.pyi:78:7: PYI014 [*] Only simple default values allowed for arguments 79 79 | ) -> None: ... 80 80 | def f23( 81 81 | x=True, # OK - - diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI015_PYI015.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI015_PYI015.pyi.snap index 95ae4adb58ee0..103b66886c5d2 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI015_PYI015.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI015_PYI015.pyi.snap @@ -11,7 +11,6 @@ PYI015.pyi:44:23: PYI015 [*] Only simple default values allowed for assignments | = help: Replace default value with `...` -ℹ Safe fix 41 41 | field22: Final = {"foo": 5} 42 42 | 43 43 | # We *should* emit Y015 for more complex default values @@ -32,7 +31,6 @@ PYI015.pyi:45:23: PYI015 [*] Only simple default values allowed for assignments | = help: Replace default value with `...` -ℹ Safe fix 42 42 | 43 43 | # We *should* emit Y015 for more complex default values 44 44 | field221: list[int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] # Y015 Only simple default values are allowed for assignments @@ -53,7 +51,6 @@ PYI015.pyi:46:23: PYI015 [*] Only simple default values allowed for assignments | = help: Replace default value with `...` -ℹ Safe fix 43 43 | # We *should* emit Y015 for more complex default values 44 44 | field221: list[int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] # Y015 Only simple default values are allowed for assignments 45 45 | field223: list[int] = [*range(10)] # Y015 Only simple default values are allowed for assignments @@ -74,7 +71,6 @@ PYI015.pyi:47:26: PYI015 [*] Only simple default values allowed for assignments | = help: Replace default value with `...` -ℹ Safe fix 44 44 | field221: list[int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] # Y015 Only simple default values are allowed for assignments 45 45 | field223: list[int] = [*range(10)] # Y015 Only simple default values are allowed for assignments 46 46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments @@ -95,7 +91,6 @@ PYI015.pyi:48:47: PYI015 [*] Only simple default values allowed for assignments | = help: Replace default value with `...` -ℹ Safe fix 45 45 | field223: list[int] = [*range(10)] # Y015 Only simple default values are allowed for assignments 46 46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments 47 47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments @@ -116,7 +111,6 @@ PYI015.pyi:49:31: PYI015 [*] Only simple default values allowed for assignments | = help: Replace default value with `...` -ℹ Safe fix 46 46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments 47 47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments 48 48 | field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments @@ -137,7 +131,6 @@ PYI015.pyi:50:37: PYI015 [*] Only simple default values allowed for assignments | = help: Replace default value with `...` -ℹ Safe fix 47 47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments 48 48 | field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments 49 49 | field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments @@ -158,7 +151,6 @@ PYI015.pyi:52:28: PYI015 [*] Only simple default values allowed for assignments | = help: Replace default value with `...` -ℹ Safe fix 49 49 | field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments 50 50 | field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments 51 51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node @@ -179,7 +171,6 @@ PYI015.pyi:53:11: PYI015 [*] Only simple default values allowed for assignments | = help: Replace default value with `...` -ℹ Safe fix 50 50 | field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments 51 51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node 52 52 | field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments @@ -199,7 +190,6 @@ PYI015.pyi:54:11: PYI015 [*] Only simple default values allowed for assignments | = help: Replace default value with `...` -ℹ Safe fix 51 51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node 52 52 | field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments 53 53 | field23 = "foo" + "bar" # Y015 Only simple default values are allowed for assignments @@ -220,7 +210,6 @@ PYI015.pyi:55:11: PYI015 [*] Only simple default values allowed for assignments | = help: Replace default value with `...` -ℹ Safe fix 52 52 | field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments 53 53 | field23 = "foo" + "bar" # Y015 Only simple default values are allowed for assignments 54 54 | field24 = b"foo" + b"bar" # Y015 Only simple default values are allowed for assignments @@ -229,5 +218,3 @@ PYI015.pyi:55:11: PYI015 [*] Only simple default values allowed for assignments 56 56 | 57 57 | # We shouldn't emit Y015 within functions 58 58 | def f(): - - diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.py.snap index d3ba1b4f1334b..24ff2410e07a4 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.py.snap @@ -11,7 +11,6 @@ PYI016.py:7:15: PYI016 [*] Duplicate union member `str` | = help: Remove duplicate union member `str` -ℹ Safe fix 4 4 | field1: str 5 5 | 6 6 | # Should emit for duplicate field types. @@ -30,7 +29,6 @@ PYI016.py:10:23: PYI016 [*] Duplicate union member `int` | = help: Remove duplicate union member `int` -ℹ Safe fix 7 7 | field2: str | str # PYI016: Duplicate union member `str` 8 8 | 9 9 | # Should emit for union types in arguments. @@ -49,7 +47,6 @@ PYI016.py:14:22: PYI016 [*] Duplicate union member `str` | = help: Remove duplicate union member `str` -ℹ Safe fix 11 11 | print(arg1) 12 12 | 13 13 | # Should emit for unions in return types. @@ -69,7 +66,6 @@ PYI016.py:18:15: PYI016 [*] Duplicate union member `str` | = help: Remove duplicate union member `str` -ℹ Safe fix 15 15 | return "my string" 16 16 | 17 17 | # Should emit in longer unions, even if not directly adjacent. @@ -90,7 +86,6 @@ PYI016.py:19:15: PYI016 [*] Duplicate union member `int` | = help: Remove duplicate union member `int` -ℹ Safe fix 16 16 | 17 17 | # Should emit in longer unions, even if not directly adjacent. 18 18 | field3: str | str | int # PYI016: Duplicate union member `str` @@ -110,7 +105,6 @@ PYI016.py:20:21: PYI016 [*] Duplicate union member `str` | = help: Remove duplicate union member `str` -ℹ Safe fix 17 17 | # Should emit in longer unions, even if not directly adjacent. 18 18 | field3: str | str | int # PYI016: Duplicate union member `str` 19 19 | field4: int | int | str # PYI016: Duplicate union member `int` @@ -131,7 +125,6 @@ PYI016.py:21:28: PYI016 [*] Duplicate union member `int` | = help: Remove duplicate union member `int` -ℹ Safe fix 18 18 | field3: str | str | int # PYI016: Duplicate union member `str` 19 19 | field4: int | int | str # PYI016: Duplicate union member `int` 20 20 | field5: str | int | str # PYI016: Duplicate union member `str` @@ -151,7 +144,6 @@ PYI016.py:27:22: PYI016 [*] Duplicate union member `int` | = help: Remove duplicate union member `int` -ℹ Safe fix 24 24 | field7 = str | str 25 25 | 26 26 | # Should emit for strangely-bracketed unions. @@ -170,7 +162,6 @@ PYI016.py:30:16: PYI016 [*] Duplicate union member `int` | = help: Remove duplicate union member `int` -ℹ Safe fix 27 27 | field8: int | (str | int) # PYI016: Duplicate union member `int` 28 28 | 29 29 | # Should handle user brackets when fixing. @@ -191,7 +182,6 @@ PYI016.py:31:24: PYI016 [*] Duplicate union member `str` | = help: Remove duplicate union member `str` -ℹ Safe fix 28 28 | 29 29 | # Should handle user brackets when fixing. 30 30 | field9: int | (int | str) # PYI016: Duplicate union member `int` @@ -211,7 +201,6 @@ PYI016.py:34:21: PYI016 [*] Duplicate union member `int` | = help: Remove duplicate union member `int` -ℹ Safe fix 31 31 | field10: (str | int) | str # PYI016: Duplicate union member `str` 32 32 | 33 33 | # Should emit for nested unions. @@ -230,7 +219,6 @@ PYI016.py:37:16: PYI016 [*] Duplicate union member `int` | = help: Remove duplicate union member `int` -ℹ Safe fix 34 34 | field11: dict[int | int, str] 35 35 | 36 36 | # Should emit for unions with more than two cases @@ -249,7 +237,6 @@ PYI016.py:37:22: PYI016 [*] Duplicate union member `int` | = help: Remove duplicate union member `int` -ℹ Safe fix 34 34 | field11: dict[int | int, str] 35 35 | 36 36 | # Should emit for unions with more than two cases @@ -270,7 +257,6 @@ PYI016.py:38:16: PYI016 [*] Duplicate union member `int` | = help: Remove duplicate union member `int` -ℹ Safe fix 35 35 | 36 36 | # Should emit for unions with more than two cases 37 37 | field12: int | int | int # Error @@ -291,7 +277,6 @@ PYI016.py:38:22: PYI016 [*] Duplicate union member `int` | = help: Remove duplicate union member `int` -ℹ Safe fix 35 35 | 36 36 | # Should emit for unions with more than two cases 37 37 | field12: int | int | int # Error @@ -312,7 +297,6 @@ PYI016.py:38:28: PYI016 [*] Duplicate union member `int` | = help: Remove duplicate union member `int` -ℹ Safe fix 35 35 | 36 36 | # Should emit for unions with more than two cases 37 37 | field12: int | int | int # Error @@ -332,7 +316,6 @@ PYI016.py:41:16: PYI016 [*] Duplicate union member `int` | = help: Remove duplicate union member `int` -ℹ Safe fix 38 38 | field13: int | int | int | int # Error 39 39 | 40 40 | # Should emit for unions with more than two cases, even if not directly adjacent @@ -352,7 +335,6 @@ PYI016.py:41:28: PYI016 [*] Duplicate union member `int` | = help: Remove duplicate union member `int` -ℹ Safe fix 38 38 | field13: int | int | int | int # Error 39 39 | 40 40 | # Should emit for unions with more than two cases, even if not directly adjacent @@ -372,7 +354,6 @@ PYI016.py:44:30: PYI016 [*] Duplicate union member `typing.Literal[1]` | = help: Remove duplicate union member `typing.Literal[1]` -ℹ Safe fix 41 41 | field14: int | int | str | int # Error 42 42 | 43 43 | # Should emit for duplicate literal types; also covered by PYI030 @@ -425,7 +406,6 @@ PYI016.py:69:28: PYI016 [*] Duplicate union member `int` | = help: Remove duplicate union member `int` -ℹ Safe fix 66 66 | field20: typing.Union[int, typing.Union[int, str]] # Error 67 67 | 68 68 | # Should emit in cases with mixed `typing.Union` and `|` @@ -476,7 +456,6 @@ PYI016.py:76:12: PYI016 [*] Duplicate union member `set[int]` | = help: Remove duplicate union member `set[int]` -ℹ Safe fix 73 73 | 74 74 | # Should emit in cases with newlines 75 75 | field23: set[ # foo @@ -517,7 +496,6 @@ PYI016.py:86:28: PYI016 [*] Duplicate union member `int` | = help: Remove duplicate union member `int` -ℹ Safe fix 83 83 | # Should emit twice (once for each `int` in the nested union, both of which are 84 84 | # duplicates of the outer `int`), but not three times (which would indicate that 85 85 | # we incorrectly re-checked the nested union). @@ -533,11 +511,8 @@ PYI016.py:86:34: PYI016 [*] Duplicate union member `int` | = help: Remove duplicate union member `int` -ℹ Safe fix 83 83 | # Should emit twice (once for each `int` in the nested union, both of which are 84 84 | # duplicates of the outer `int`), but not three times (which would indicate that 85 85 | # we incorrectly re-checked the nested union). 86 |-field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` 86 |+field25: typing.Union[int, int] # PYI016: Duplicate union member `int` - - diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.pyi.snap index 647791e92b21e..ef4dd6f97491d 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.pyi.snap @@ -11,7 +11,6 @@ PYI016.pyi:7:15: PYI016 [*] Duplicate union member `str` | = help: Remove duplicate union member `str` -ℹ Safe fix 4 4 | field1: str 5 5 | 6 6 | # Should emit for duplicate field types. @@ -30,7 +29,6 @@ PYI016.pyi:10:23: PYI016 [*] Duplicate union member `int` | = help: Remove duplicate union member `int` -ℹ Safe fix 7 7 | field2: str | str # PYI016: Duplicate union member `str` 8 8 | 9 9 | # Should emit for union types in arguments. @@ -49,7 +47,6 @@ PYI016.pyi:14:22: PYI016 [*] Duplicate union member `str` | = help: Remove duplicate union member `str` -ℹ Safe fix 11 11 | print(arg1) 12 12 | 13 13 | # Should emit for unions in return types. @@ -69,7 +66,6 @@ PYI016.pyi:18:15: PYI016 [*] Duplicate union member `str` | = help: Remove duplicate union member `str` -ℹ Safe fix 15 15 | return "my string" 16 16 | 17 17 | # Should emit in longer unions, even if not directly adjacent. @@ -90,7 +86,6 @@ PYI016.pyi:19:15: PYI016 [*] Duplicate union member `int` | = help: Remove duplicate union member `int` -ℹ Safe fix 16 16 | 17 17 | # Should emit in longer unions, even if not directly adjacent. 18 18 | field3: str | str | int # PYI016: Duplicate union member `str` @@ -110,7 +105,6 @@ PYI016.pyi:20:21: PYI016 [*] Duplicate union member `str` | = help: Remove duplicate union member `str` -ℹ Safe fix 17 17 | # Should emit in longer unions, even if not directly adjacent. 18 18 | field3: str | str | int # PYI016: Duplicate union member `str` 19 19 | field4: int | int | str # PYI016: Duplicate union member `int` @@ -131,7 +125,6 @@ PYI016.pyi:21:28: PYI016 [*] Duplicate union member `int` | = help: Remove duplicate union member `int` -ℹ Safe fix 18 18 | field3: str | str | int # PYI016: Duplicate union member `str` 19 19 | field4: int | int | str # PYI016: Duplicate union member `int` 20 20 | field5: str | int | str # PYI016: Duplicate union member `str` @@ -151,7 +144,6 @@ PYI016.pyi:27:22: PYI016 [*] Duplicate union member `int` | = help: Remove duplicate union member `int` -ℹ Safe fix 24 24 | field7 = str | str 25 25 | 26 26 | # Should emit for strangely-bracketed unions. @@ -170,7 +162,6 @@ PYI016.pyi:30:16: PYI016 [*] Duplicate union member `int` | = help: Remove duplicate union member `int` -ℹ Safe fix 27 27 | field8: int | (str | int) # PYI016: Duplicate union member `int` 28 28 | 29 29 | # Should handle user brackets when fixing. @@ -191,7 +182,6 @@ PYI016.pyi:31:24: PYI016 [*] Duplicate union member `str` | = help: Remove duplicate union member `str` -ℹ Safe fix 28 28 | 29 29 | # Should handle user brackets when fixing. 30 30 | field9: int | (int | str) # PYI016: Duplicate union member `int` @@ -211,7 +201,6 @@ PYI016.pyi:34:21: PYI016 [*] Duplicate union member `int` | = help: Remove duplicate union member `int` -ℹ Safe fix 31 31 | field10: (str | int) | str # PYI016: Duplicate union member `str` 32 32 | 33 33 | # Should emit for nested unions. @@ -230,7 +219,6 @@ PYI016.pyi:37:16: PYI016 [*] Duplicate union member `int` | = help: Remove duplicate union member `int` -ℹ Safe fix 34 34 | field11: dict[int | int, str] 35 35 | 36 36 | # Should emit for unions with more than two cases @@ -249,7 +237,6 @@ PYI016.pyi:37:22: PYI016 [*] Duplicate union member `int` | = help: Remove duplicate union member `int` -ℹ Safe fix 34 34 | field11: dict[int | int, str] 35 35 | 36 36 | # Should emit for unions with more than two cases @@ -270,7 +257,6 @@ PYI016.pyi:38:16: PYI016 [*] Duplicate union member `int` | = help: Remove duplicate union member `int` -ℹ Safe fix 35 35 | 36 36 | # Should emit for unions with more than two cases 37 37 | field12: int | int | int # Error @@ -291,7 +277,6 @@ PYI016.pyi:38:22: PYI016 [*] Duplicate union member `int` | = help: Remove duplicate union member `int` -ℹ Safe fix 35 35 | 36 36 | # Should emit for unions with more than two cases 37 37 | field12: int | int | int # Error @@ -312,7 +297,6 @@ PYI016.pyi:38:28: PYI016 [*] Duplicate union member `int` | = help: Remove duplicate union member `int` -ℹ Safe fix 35 35 | 36 36 | # Should emit for unions with more than two cases 37 37 | field12: int | int | int # Error @@ -332,7 +316,6 @@ PYI016.pyi:41:16: PYI016 [*] Duplicate union member `int` | = help: Remove duplicate union member `int` -ℹ Safe fix 38 38 | field13: int | int | int | int # Error 39 39 | 40 40 | # Should emit for unions with more than two cases, even if not directly adjacent @@ -352,7 +335,6 @@ PYI016.pyi:41:28: PYI016 [*] Duplicate union member `int` | = help: Remove duplicate union member `int` -ℹ Safe fix 38 38 | field13: int | int | int | int # Error 39 39 | 40 40 | # Should emit for unions with more than two cases, even if not directly adjacent @@ -372,7 +354,6 @@ PYI016.pyi:44:30: PYI016 [*] Duplicate union member `typing.Literal[1]` | = help: Remove duplicate union member `typing.Literal[1]` -ℹ Safe fix 41 41 | field14: int | int | str | int # Error 42 42 | 43 43 | # Should emit for duplicate literal types; also covered by PYI030 @@ -425,7 +406,6 @@ PYI016.pyi:69:28: PYI016 [*] Duplicate union member `int` | = help: Remove duplicate union member `int` -ℹ Safe fix 66 66 | field20: typing.Union[int, typing.Union[int, str]] # Error 67 67 | 68 68 | # Should emit in cases with mixed `typing.Union` and `|` @@ -476,7 +456,6 @@ PYI016.pyi:76:12: PYI016 [*] Duplicate union member `set[int]` | = help: Remove duplicate union member `set[int]` -ℹ Safe fix 73 73 | 74 74 | # Should emit in cases with newlines 75 75 | field23: set[ # foo @@ -517,7 +496,6 @@ PYI016.pyi:86:28: PYI016 [*] Duplicate union member `int` | = help: Remove duplicate union member `int` -ℹ Safe fix 83 83 | # Should emit twice (once for each `int` in the nested union, both of which are 84 84 | # duplicates of the outer `int`), but not three times (which would indicate that 85 85 | # we incorrectly re-checked the nested union). @@ -533,11 +511,8 @@ PYI016.pyi:86:34: PYI016 [*] Duplicate union member `int` | = help: Remove duplicate union member `int` -ℹ Safe fix 83 83 | # Should emit twice (once for each `int` in the nested union, both of which are 84 84 | # duplicates of the outer `int`), but not three times (which would indicate that 85 85 | # we incorrectly re-checked the nested union). 86 |-field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` 86 |+field25: typing.Union[int, int] # PYI016: Duplicate union member `int` - - diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI020_PYI020.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI020_PYI020.pyi.snap index f10bbc7b832d8..064d706087aac 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI020_PYI020.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI020_PYI020.pyi.snap @@ -12,7 +12,6 @@ PYI020.pyi:7:10: PYI020 [*] Quoted annotations should not be included in stubs | = help: Remove quotes -ℹ Safe fix 4 4 | 5 5 | import typing_extensions 6 6 | @@ -31,7 +30,6 @@ PYI020.pyi:8:15: PYI020 [*] Quoted annotations should not be included in stubs | = help: Remove quotes -ℹ Safe fix 5 5 | import typing_extensions 6 6 | 7 7 | def f(x: "int"): ... # Y020 Quoted annotations should never be used in stubs @@ -52,7 +50,6 @@ PYI020.pyi:9:26: PYI020 [*] Quoted annotations should not be included in stubs | = help: Remove quotes -ℹ Safe fix 6 6 | 7 7 | def f(x: "int"): ... # Y020 Quoted annotations should never be used in stubs 8 8 | def g(x: list["int"]): ... # Y020 Quoted annotations should never be used in stubs @@ -72,7 +69,6 @@ PYI020.pyi:13:12: PYI020 [*] Quoted annotations should not be included in stubs | = help: Remove quotes -ℹ Safe fix 10 10 | 11 11 | def h(w: Literal["a", "b"], x: typing.Literal["c"], y: typing_extensions.Literal["d"], z: _T) -> _T: ... 12 12 | @@ -92,7 +88,6 @@ PYI020.pyi:14:25: PYI020 [*] Quoted annotations should not be included in stubs | = help: Remove quotes -ℹ Safe fix 11 11 | def h(w: Literal["a", "b"], x: typing.Literal["c"], y: typing_extensions.Literal["d"], z: _T) -> _T: ... 12 12 | 13 13 | def j() -> "int": ... # Y020 Quoted annotations should never be used in stubs @@ -112,7 +107,6 @@ PYI020.pyi:16:18: PYI020 [*] Quoted annotations should not be included in stubs | = help: Remove quotes -ℹ Safe fix 13 13 | def j() -> "int": ... # Y020 Quoted annotations should never be used in stubs 14 14 | Alias: TypeAlias = list["int"] # Y020 Quoted annotations should never be used in stubs 15 15 | @@ -132,7 +126,6 @@ PYI020.pyi:20:8: PYI020 [*] Quoted annotations should not be included in stubs | = help: Remove quotes -ℹ Safe fix 17 17 | """Documented and guaranteed useful.""" # Y021 Docstrings should not be included in stubs 18 18 | 19 19 | if sys.platform == "linux": @@ -153,7 +146,6 @@ PYI020.pyi:22:8: PYI020 [*] Quoted annotations should not be included in stubs | = help: Remove quotes -ℹ Safe fix 19 19 | if sys.platform == "linux": 20 20 | f: "int" # Y020 Quoted annotations should never be used in stubs 21 21 | elif sys.platform == "win32": @@ -174,7 +166,6 @@ PYI020.pyi:24:8: PYI020 [*] Quoted annotations should not be included in stubs | = help: Remove quotes -ℹ Safe fix 21 21 | elif sys.platform == "win32": 22 22 | f: "str" # Y020 Quoted annotations should never be used in stubs 23 23 | else: @@ -183,5 +174,3 @@ PYI020.pyi:24:8: PYI020 [*] Quoted annotations should not be included in stubs 25 25 | 26 26 | # These two shouldn't trigger Y020 -- empty strings can't be "quoted annotations" 27 27 | k = "" # Y052 Need type annotation for "k" - - diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_1.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_1.py.snap index 3fd40be9ec54c..c5dfde10cef2c 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_1.py.snap @@ -9,7 +9,6 @@ PYI025_1.py:10:33: PYI025 [*] Use `from collections.abc import Set as AbstractSe | = help: Alias `Set` to `AbstractSet` -ℹ Safe fix 7 7 | 8 8 | 9 9 | def f(): @@ -29,7 +28,6 @@ PYI025_1.py:14:51: PYI025 [*] Use `from collections.abc import Set as AbstractSe | = help: Alias `Set` to `AbstractSet` -ℹ Safe fix 11 11 | 12 12 | 13 13 | def f(): diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_1.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_1.pyi.snap index 208551931e8c2..400c231445cbd 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_1.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_1.pyi.snap @@ -11,7 +11,6 @@ PYI025_1.pyi:8:33: PYI025 [*] Use `from collections.abc import Set as AbstractSe | = help: Alias `Set` to `AbstractSet` -ℹ Safe fix 5 5 | from collections.abc import Container, Sized, Set as AbstractSet, ValuesView # Ok 6 6 | 7 7 | def f(): @@ -31,7 +30,6 @@ PYI025_1.pyi:11:51: PYI025 [*] Use `from collections.abc import Set as AbstractS | = help: Alias `Set` to `AbstractSet` -ℹ Safe fix 8 8 | from collections.abc import Set # PYI025 9 9 | 10 10 | def f(): @@ -52,7 +50,6 @@ PYI025_1.pyi:16:37: PYI025 [*] Use `from collections.abc import Set as AbstractS | = help: Alias `Set` to `AbstractSet` -ℹ Safe fix 13 13 | def f(): 14 14 | """Test: local symbol renaming.""" 15 15 | if True: @@ -87,7 +84,6 @@ PYI025_1.pyi:33:29: PYI025 [*] Use `from collections.abc import Set as AbstractS | = help: Alias `Set` to `AbstractSet` -ℹ Safe fix 17 17 | else: 18 18 | Set = 1 19 19 | @@ -130,7 +126,6 @@ PYI025_1.pyi:44:33: PYI025 [*] Use `from collections.abc import Set as AbstractS | = help: Alias `Set` to `AbstractSet` -ℹ Safe fix 41 41 | 42 42 | def f(): 43 43 | """Test: nonlocal symbol renaming.""" diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_2.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_2.py.snap index 1177dc90ecf8e..4c4fe8a98ac80 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_2.py.snap @@ -11,24 +11,3 @@ PYI025_2.py:3:29: PYI025 [*] Use `from collections.abc import Set as AbstractSet 5 | __all__ = ["Set"] | = help: Alias `Set` to `AbstractSet` - -ℹ Unsafe fix -1 1 | """Tests to ensure we correctly rename references inside `__all__`""" -2 2 | -3 |-from collections.abc import Set - 3 |+from collections.abc import Set as AbstractSet -4 4 | -5 |-__all__ = ["Set"] - 5 |+__all__ = ["AbstractSet"] -6 6 | -7 7 | if True: -8 |- __all__ += [r'''Set'''] - 8 |+ __all__ += ["AbstractSet"] -9 9 | -10 10 | if 1: -11 |- __all__ += ["S" "e" "t"] - 11 |+ __all__ += ["AbstractSet"] -12 12 | -13 13 | if not False: -14 |- __all__ += ["Se" 't'] - 14 |+ __all__ += ["AbstractSet"] diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_2.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_2.pyi.snap index 41feeabda6cf0..df115ef950559 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_2.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_2.pyi.snap @@ -11,24 +11,3 @@ PYI025_2.pyi:3:29: PYI025 [*] Use `from collections.abc import Set as AbstractSe 5 | __all__ = ["Set"] | = help: Alias `Set` to `AbstractSet` - -ℹ Unsafe fix -1 1 | """Tests to ensure we correctly rename references inside `__all__`""" -2 2 | -3 |-from collections.abc import Set - 3 |+from collections.abc import Set as AbstractSet -4 4 | -5 |-__all__ = ["Set"] - 5 |+__all__ = ["AbstractSet"] -6 6 | -7 7 | if True: -8 |- __all__ += [r'''Set'''] - 8 |+ __all__ += ["AbstractSet"] -9 9 | -10 10 | if 1: -11 |- __all__ += ["S" "e" "t"] - 11 |+ __all__ += ["AbstractSet"] -12 12 | -13 13 | if not False: -14 |- __all__ += ["Se" 't'] - 14 |+ __all__ += ["AbstractSet"] diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_3.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_3.py.snap index 008e68502946c..ac1f3499d93f9 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_3.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_3.py.snap @@ -9,10 +9,3 @@ PYI025_3.py:6:36: PYI025 [*] Use `from collections.abc import Set as AbstractSet | ^^^ PYI025 | = help: Alias `Set` to `AbstractSet` - -ℹ Unsafe fix -3 3 | through usage of a "redundant" `import Set as Set` alias -4 4 | """ -5 5 | -6 |-from collections.abc import Set as Set # PYI025 triggered but fix is not marked as safe - 6 |+from collections.abc import Set as AbstractSet # PYI025 triggered but fix is not marked as safe diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_3.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_3.pyi.snap index ae54570974134..02978bef495b9 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_3.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_3.pyi.snap @@ -9,10 +9,3 @@ PYI025_3.pyi:6:36: PYI025 [*] Use `from collections.abc import Set as AbstractSe | ^^^ PYI025 | = help: Alias `Set` to `AbstractSet` - -ℹ Unsafe fix -3 3 | through usage of a "redundant" `import Set as Set` alias -4 4 | """ -5 5 | -6 |-from collections.abc import Set as Set # PYI025 triggered but fix is not marked as safe - 6 |+from collections.abc import Set as AbstractSet # PYI025 triggered but fix is not marked as safe diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI026_PYI026.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI026_PYI026.pyi.snap index 91c4bbddd76ac..10e40436733b8 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI026_PYI026.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI026_PYI026.pyi.snap @@ -12,7 +12,6 @@ PYI026.pyi:3:1: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `NewAny: | = help: Add `TypeAlias` annotation -ℹ Safe fix 1 |-from typing import Literal, Any 1 |+from typing import Literal, Any, TypeAlias 2 2 | @@ -32,7 +31,6 @@ PYI026.pyi:4:1: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `Optiona | = help: Add `TypeAlias` annotation -ℹ Safe fix 1 |-from typing import Literal, Any 1 |+from typing import Literal, Any, TypeAlias 2 2 | @@ -54,7 +52,6 @@ PYI026.pyi:5:1: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `Foo: Ty | = help: Add `TypeAlias` annotation -ℹ Safe fix 1 |-from typing import Literal, Any 1 |+from typing import Literal, Any, TypeAlias 2 2 | @@ -76,7 +73,6 @@ PYI026.pyi:6:1: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `IntOrSt | = help: Add `TypeAlias` annotation -ℹ Safe fix 1 |-from typing import Literal, Any 1 |+from typing import Literal, Any, TypeAlias 2 2 | @@ -100,7 +96,6 @@ PYI026.pyi:7:1: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `AliasNo | = help: Add `TypeAlias` annotation -ℹ Safe fix 1 |-from typing import Literal, Any 1 |+from typing import Literal, Any, TypeAlias 2 2 | @@ -124,7 +119,6 @@ PYI026.pyi:17:5: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `FLAG_T | = help: Add `TypeAlias` annotation -ℹ Safe fix 1 |-from typing import Literal, Any 1 |+from typing import Literal, Any, TypeAlias 2 2 | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI029_PYI029.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI029_PYI029.pyi.snap index 40bdd22441e1c..538ffd82b5a13 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI029_PYI029.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI029_PYI029.pyi.snap @@ -11,7 +11,6 @@ PYI029.pyi:10:9: PYI029 [*] Defining `__str__` in a stub is almost always redund | = help: Remove definition of `__str__` -ℹ Safe fix 7 7 | def __repr__(self, *, foo) -> str: ... 8 8 | 9 9 | class ShouldRemoveSingle: @@ -30,7 +29,6 @@ PYI029.pyi:13:9: PYI029 [*] Defining `__repr__` in a stub is almost always redun | = help: Remove definition of `__repr__` -ℹ Safe fix 10 10 | def __str__(self) -> builtins.str: ... # Error: PYI029 11 11 | 12 12 | class ShouldRemove: @@ -50,7 +48,6 @@ PYI029.pyi:14:9: PYI029 [*] Defining `__str__` in a stub is almost always redund | = help: Remove definition of `__str__` -ℹ Safe fix 11 11 | 12 12 | class ShouldRemove: 13 13 | def __repr__(self) -> str: ... # Error: PYI029 @@ -58,5 +55,3 @@ PYI029.pyi:14:9: PYI029 [*] Defining `__str__` in a stub is almost always redund 15 14 | 16 15 | class NoReturnSpecified: 17 16 | def __str__(self): ... - - diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI030_PYI030.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI030_PYI030.py.snap index 47a803b8da44a..1de5c1dbeb6eb 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI030_PYI030.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI030_PYI030.py.snap @@ -11,7 +11,6 @@ PYI030.py:9:9: PYI030 [*] Multiple literal members in a union. Use a single lite | = help: Replace with a single `Literal` -ℹ Safe fix 6 6 | field1: Literal[1] # OK 7 7 | 8 8 | # Should emit for duplicate field types. @@ -30,7 +29,6 @@ PYI030.py:12:17: PYI030 [*] Multiple literal members in a union. Use a single li | = help: Replace with a single `Literal` -ℹ Safe fix 9 9 | field2: Literal[1] | Literal[2] # Error 10 10 | 11 11 | # Should emit for union types in arguments. @@ -49,7 +47,6 @@ PYI030.py:17:16: PYI030 [*] Multiple literal members in a union. Use a single li | = help: Replace with a single `Literal` -ℹ Safe fix 14 14 | 15 15 | 16 16 | # Should emit for unions in return types. @@ -69,7 +66,6 @@ PYI030.py:22:9: PYI030 [*] Multiple literal members in a union. Use a single lit | = help: Replace with a single `Literal` -ℹ Safe fix 19 19 | 20 20 | 21 21 | # Should emit in longer unions, even if not directly adjacent. @@ -90,7 +86,6 @@ PYI030.py:23:9: PYI030 [*] Multiple literal members in a union. Use a single lit | = help: Replace with a single `Literal` -ℹ Safe fix 20 20 | 21 21 | # Should emit in longer unions, even if not directly adjacent. 22 22 | field3: Literal[1] | Literal[2] | str # Error @@ -110,7 +105,6 @@ PYI030.py:24:9: PYI030 [*] Multiple literal members in a union. Use a single lit | = help: Replace with a single `Literal` -ℹ Safe fix 21 21 | # Should emit in longer unions, even if not directly adjacent. 22 22 | field3: Literal[1] | Literal[2] | str # Error 23 23 | field4: str | Literal[1] | Literal[2] # Error @@ -131,7 +125,6 @@ PYI030.py:25:9: PYI030 [*] Multiple literal members in a union. Use a single lit | = help: Replace with a single `Literal` -ℹ Safe fix 22 22 | field3: Literal[1] | Literal[2] | str # Error 23 23 | field4: str | Literal[1] | Literal[2] # Error 24 24 | field5: Literal[1] | str | Literal[2] # Error @@ -151,7 +144,6 @@ PYI030.py:28:10: PYI030 [*] Multiple literal members in a union. Use a single li | = help: Replace with a single `Literal` -ℹ Safe fix 25 25 | field6: Literal[1] | bool | Literal[2] | str # Error 26 26 | 27 27 | # Should emit for non-type unions. @@ -171,7 +163,6 @@ PYI030.py:31:9: PYI030 [*] Multiple literal members in a union. Use a single lit | = help: Replace with a single `Literal` -ℹ Safe fix 28 28 | field7 = Literal[1] | Literal[2] # Error 29 29 | 30 30 | # Should emit for parenthesized unions. @@ -190,7 +181,6 @@ PYI030.py:34:9: PYI030 [*] Multiple literal members in a union. Use a single lit | = help: Replace with a single `Literal` -ℹ Safe fix 31 31 | field8: Literal[1] | (Literal[2] | str) # Error 32 32 | 33 33 | # Should handle user parentheses when fixing. @@ -211,7 +201,6 @@ PYI030.py:35:10: PYI030 [*] Multiple literal members in a union. Use a single li | = help: Replace with a single `Literal` -ℹ Safe fix 32 32 | 33 33 | # Should handle user parentheses when fixing. 34 34 | field9: Literal[1] | (Literal[2] | str) # Error @@ -231,7 +220,6 @@ PYI030.py:38:15: PYI030 [*] Multiple literal members in a union. Use a single li | = help: Replace with a single `Literal` -ℹ Safe fix 35 35 | field10: (Literal[1] | str) | Literal[2] # Error 36 36 | 37 37 | # Should emit for union in generic parent type. @@ -250,7 +238,6 @@ PYI030.py:41:10: PYI030 [*] Multiple literal members in a union. Use a single li | = help: Replace with a single `Literal` -ℹ Safe fix 38 38 | field11: dict[Literal[1] | Literal[2], str] # Error 39 39 | 40 40 | # Should emit for unions with more than two cases @@ -271,7 +258,6 @@ PYI030.py:42:10: PYI030 [*] Multiple literal members in a union. Use a single li | = help: Replace with a single `Literal` -ℹ Safe fix 39 39 | 40 40 | # Should emit for unions with more than two cases 41 41 | field12: Literal[1] | Literal[2] | Literal[3] # Error @@ -291,7 +277,6 @@ PYI030.py:45:10: PYI030 [*] Multiple literal members in a union. Use a single li | = help: Replace with a single `Literal` -ℹ Safe fix 42 42 | field13: Literal[1] | Literal[2] | Literal[3] | Literal[4] # Error 43 43 | 44 44 | # Should emit for unions with more than two cases, even if not directly adjacent @@ -311,7 +296,6 @@ PYI030.py:48:10: PYI030 [*] Multiple literal members in a union. Use a single li | = help: Replace with a single `Literal` -ℹ Safe fix 45 45 | field14: Literal[1] | Literal[2] | str | Literal[3] # Error 46 46 | 47 47 | # Should emit for unions with mixed literal internal types @@ -331,7 +315,6 @@ PYI030.py:51:10: PYI030 [*] Multiple literal members in a union. Use a single li | = help: Replace with a single `Literal` -ℹ Safe fix 48 48 | field15: Literal[1] | Literal["foo"] | Literal[True] # Error 49 49 | 50 50 | # Shouldn't emit for duplicate field types with same value; covered by Y016 @@ -351,7 +334,6 @@ PYI030.py:60:10: PYI030 [*] Multiple literal members in a union. Use a single li | = help: Replace with a single `Literal` -ℹ Safe fix 57 57 | field18: dict[Literal[1], Literal[2]] # OK 58 58 | 59 59 | # Should respect name of literal type used @@ -377,7 +359,6 @@ PYI030.py:63:10: PYI030 [*] Multiple literal members in a union. Use a single li | = help: Replace with a single `Literal` -ℹ Safe fix 60 60 | field19: typing.Literal[1] | typing.Literal[2] # Error 61 61 | 62 62 | # Should emit in cases with newlines @@ -402,7 +383,6 @@ PYI030.py:71:10: PYI030 [*] Multiple literal members in a union. Use a single li | = help: Replace with a single `Literal` -ℹ Safe fix 68 68 | ] # Error, newline and comment will not be emitted in message 69 69 | 70 70 | # Should handle multiple unions with multiple members @@ -422,7 +402,6 @@ PYI030.py:74:10: PYI030 [*] Multiple literal members in a union. Use a single li | = help: Replace with a single `Literal` -ℹ Safe fix 71 71 | field21: Literal[1, 2] | Literal[3, 4] # Error 72 72 | 73 73 | # Should emit in cases with `typing.Union` instead of `|` @@ -442,7 +421,6 @@ PYI030.py:77:10: PYI030 [*] Multiple literal members in a union. Use a single li | = help: Replace with a single `Literal` -ℹ Safe fix 74 74 | field22: typing.Union[Literal[1], Literal[2]] # Error 75 75 | 76 76 | # Should emit in cases with `typing_extensions.Literal` @@ -462,7 +440,6 @@ PYI030.py:80:10: PYI030 [*] Multiple literal members in a union. Use a single li | = help: Replace with a single `Literal` -ℹ Safe fix 77 77 | field23: typing_extensions.Literal[1] | typing_extensions.Literal[2] # Error 78 78 | 79 79 | # Should emit in cases with nested `typing.Union` @@ -482,7 +459,6 @@ PYI030.py:83:10: PYI030 [*] Multiple literal members in a union. Use a single li | = help: Replace with a single `Literal` -ℹ Safe fix 80 80 | field24: typing.Union[Literal[1], typing.Union[Literal[2], str]] # Error 81 81 | 82 82 | # Should emit in cases with mixed `typing.Union` and `|` @@ -502,7 +478,6 @@ PYI030.py:86:10: PYI030 [*] Multiple literal members in a union. Use a single li | = help: Replace with a single `Literal` -ℹ Safe fix 83 83 | field25: typing.Union[Literal[1], Literal[2] | str] # Error 84 84 | 85 85 | # Should emit only once in cases with multiple nested `typing.Union` @@ -520,11 +495,8 @@ PYI030.py:89:10: PYI030 [*] Multiple literal members in a union. Use a single li | = help: Replace with a single `Literal` -ℹ Safe fix 86 86 | field24: typing.Union[Literal[1], typing.Union[Literal[2], typing.Union[Literal[3], Literal[4]]]] # Error 87 87 | 88 88 | # Should use the first literal subscript attribute when fixing 89 |-field25: typing.Union[typing_extensions.Literal[1], typing.Union[Literal[2], typing.Union[Literal[3], Literal[4]]], str] # Error 89 |+field25: typing.Union[typing_extensions.Literal[1, 2, 3, 4], str] # Error - - diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI030_PYI030.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI030_PYI030.pyi.snap index 7d49337d4cf41..bb3f935387432 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI030_PYI030.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI030_PYI030.pyi.snap @@ -11,7 +11,6 @@ PYI030.pyi:9:9: PYI030 [*] Multiple literal members in a union. Use a single lit | = help: Replace with a single `Literal` -ℹ Safe fix 6 6 | field1: Literal[1] # OK 7 7 | 8 8 | # Should emit for duplicate field types. @@ -30,7 +29,6 @@ PYI030.pyi:12:17: PYI030 [*] Multiple literal members in a union. Use a single l | = help: Replace with a single `Literal` -ℹ Safe fix 9 9 | field2: Literal[1] | Literal[2] # Error 10 10 | 11 11 | # Should emit for union types in arguments. @@ -49,7 +47,6 @@ PYI030.pyi:17:16: PYI030 [*] Multiple literal members in a union. Use a single l | = help: Replace with a single `Literal` -ℹ Safe fix 14 14 | 15 15 | 16 16 | # Should emit for unions in return types. @@ -69,7 +66,6 @@ PYI030.pyi:22:9: PYI030 [*] Multiple literal members in a union. Use a single li | = help: Replace with a single `Literal` -ℹ Safe fix 19 19 | 20 20 | 21 21 | # Should emit in longer unions, even if not directly adjacent. @@ -90,7 +86,6 @@ PYI030.pyi:23:9: PYI030 [*] Multiple literal members in a union. Use a single li | = help: Replace with a single `Literal` -ℹ Safe fix 20 20 | 21 21 | # Should emit in longer unions, even if not directly adjacent. 22 22 | field3: Literal[1] | Literal[2] | str # Error @@ -110,7 +105,6 @@ PYI030.pyi:24:9: PYI030 [*] Multiple literal members in a union. Use a single li | = help: Replace with a single `Literal` -ℹ Safe fix 21 21 | # Should emit in longer unions, even if not directly adjacent. 22 22 | field3: Literal[1] | Literal[2] | str # Error 23 23 | field4: str | Literal[1] | Literal[2] # Error @@ -131,7 +125,6 @@ PYI030.pyi:25:9: PYI030 [*] Multiple literal members in a union. Use a single li | = help: Replace with a single `Literal` -ℹ Safe fix 22 22 | field3: Literal[1] | Literal[2] | str # Error 23 23 | field4: str | Literal[1] | Literal[2] # Error 24 24 | field5: Literal[1] | str | Literal[2] # Error @@ -151,7 +144,6 @@ PYI030.pyi:28:10: PYI030 [*] Multiple literal members in a union. Use a single l | = help: Replace with a single `Literal` -ℹ Safe fix 25 25 | field6: Literal[1] | bool | Literal[2] | str # Error 26 26 | 27 27 | # Should emit for non-type unions. @@ -171,7 +163,6 @@ PYI030.pyi:31:9: PYI030 [*] Multiple literal members in a union. Use a single li | = help: Replace with a single `Literal` -ℹ Safe fix 28 28 | field7 = Literal[1] | Literal[2] # Error 29 29 | 30 30 | # Should emit for parenthesized unions. @@ -190,7 +181,6 @@ PYI030.pyi:34:9: PYI030 [*] Multiple literal members in a union. Use a single li | = help: Replace with a single `Literal` -ℹ Safe fix 31 31 | field8: Literal[1] | (Literal[2] | str) # Error 32 32 | 33 33 | # Should handle user parentheses when fixing. @@ -211,7 +201,6 @@ PYI030.pyi:35:10: PYI030 [*] Multiple literal members in a union. Use a single l | = help: Replace with a single `Literal` -ℹ Safe fix 32 32 | 33 33 | # Should handle user parentheses when fixing. 34 34 | field9: Literal[1] | (Literal[2] | str) # Error @@ -231,7 +220,6 @@ PYI030.pyi:38:15: PYI030 [*] Multiple literal members in a union. Use a single l | = help: Replace with a single `Literal` -ℹ Safe fix 35 35 | field10: (Literal[1] | str) | Literal[2] # Error 36 36 | 37 37 | # Should emit for union in generic parent type. @@ -250,7 +238,6 @@ PYI030.pyi:41:10: PYI030 [*] Multiple literal members in a union. Use a single l | = help: Replace with a single `Literal` -ℹ Safe fix 38 38 | field11: dict[Literal[1] | Literal[2], str] # Error 39 39 | 40 40 | # Should emit for unions with more than two cases @@ -271,7 +258,6 @@ PYI030.pyi:42:10: PYI030 [*] Multiple literal members in a union. Use a single l | = help: Replace with a single `Literal` -ℹ Safe fix 39 39 | 40 40 | # Should emit for unions with more than two cases 41 41 | field12: Literal[1] | Literal[2] | Literal[3] # Error @@ -291,7 +277,6 @@ PYI030.pyi:45:10: PYI030 [*] Multiple literal members in a union. Use a single l | = help: Replace with a single `Literal` -ℹ Safe fix 42 42 | field13: Literal[1] | Literal[2] | Literal[3] | Literal[4] # Error 43 43 | 44 44 | # Should emit for unions with more than two cases, even if not directly adjacent @@ -311,7 +296,6 @@ PYI030.pyi:48:10: PYI030 [*] Multiple literal members in a union. Use a single l | = help: Replace with a single `Literal` -ℹ Safe fix 45 45 | field14: Literal[1] | Literal[2] | str | Literal[3] # Error 46 46 | 47 47 | # Should emit for unions with mixed literal internal types @@ -331,7 +315,6 @@ PYI030.pyi:51:10: PYI030 [*] Multiple literal members in a union. Use a single l | = help: Replace with a single `Literal` -ℹ Safe fix 48 48 | field15: Literal[1] | Literal["foo"] | Literal[True] # Error 49 49 | 50 50 | # Shouldn't emit for duplicate field types with same value; covered by Y016 @@ -351,7 +334,6 @@ PYI030.pyi:60:10: PYI030 [*] Multiple literal members in a union. Use a single l | = help: Replace with a single `Literal` -ℹ Safe fix 57 57 | field18: dict[Literal[1], Literal[2]] # OK 58 58 | 59 59 | # Should respect name of literal type used @@ -377,7 +359,6 @@ PYI030.pyi:63:10: PYI030 [*] Multiple literal members in a union. Use a single l | = help: Replace with a single `Literal` -ℹ Safe fix 60 60 | field19: typing.Literal[1] | typing.Literal[2] # Error 61 61 | 62 62 | # Should emit in cases with newlines @@ -402,7 +383,6 @@ PYI030.pyi:71:10: PYI030 [*] Multiple literal members in a union. Use a single l | = help: Replace with a single `Literal` -ℹ Safe fix 68 68 | ] # Error, newline and comment will not be emitted in message 69 69 | 70 70 | # Should handle multiple unions with multiple members @@ -422,7 +402,6 @@ PYI030.pyi:74:10: PYI030 [*] Multiple literal members in a union. Use a single l | = help: Replace with a single `Literal` -ℹ Safe fix 71 71 | field21: Literal[1, 2] | Literal[3, 4] # Error 72 72 | 73 73 | # Should emit in cases with `typing.Union` instead of `|` @@ -442,7 +421,6 @@ PYI030.pyi:77:10: PYI030 [*] Multiple literal members in a union. Use a single l | = help: Replace with a single `Literal` -ℹ Safe fix 74 74 | field22: typing.Union[Literal[1], Literal[2]] # Error 75 75 | 76 76 | # Should emit in cases with `typing_extensions.Literal` @@ -462,7 +440,6 @@ PYI030.pyi:80:10: PYI030 [*] Multiple literal members in a union. Use a single l | = help: Replace with a single `Literal` -ℹ Safe fix 77 77 | field23: typing_extensions.Literal[1] | typing_extensions.Literal[2] # Error 78 78 | 79 79 | # Should emit in cases with nested `typing.Union` @@ -482,7 +459,6 @@ PYI030.pyi:83:10: PYI030 [*] Multiple literal members in a union. Use a single l | = help: Replace with a single `Literal` -ℹ Safe fix 80 80 | field24: typing.Union[Literal[1], typing.Union[Literal[2], str]] # Error 81 81 | 82 82 | # Should emit in cases with mixed `typing.Union` and `|` @@ -502,7 +478,6 @@ PYI030.pyi:86:10: PYI030 [*] Multiple literal members in a union. Use a single l | = help: Replace with a single `Literal` -ℹ Safe fix 83 83 | field25: typing.Union[Literal[1], Literal[2] | str] # Error 84 84 | 85 85 | # Should emit only once in cases with multiple nested `typing.Union` @@ -520,11 +495,8 @@ PYI030.pyi:89:10: PYI030 [*] Multiple literal members in a union. Use a single l | = help: Replace with a single `Literal` -ℹ Safe fix 86 86 | field24: typing.Union[Literal[1], typing.Union[Literal[2], typing.Union[Literal[3], Literal[4]]]] # Error 87 87 | 88 88 | # Should use the first literal subscript attribute when fixing 89 |-field25: typing.Union[typing_extensions.Literal[1], typing.Union[Literal[2], typing.Union[Literal[3], Literal[4]]], str] # Error 89 |+field25: typing.Union[typing_extensions.Literal[1, 2, 3, 4], str] # Error - - diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI032_PYI032.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI032_PYI032.py.snap index 7415a2ab741be..c521f243f92b5 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI032_PYI032.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI032_PYI032.py.snap @@ -10,7 +10,6 @@ PYI032.py:6:29: PYI032 [*] Prefer `object` to `Any` for the second parameter to | = help: Replace with `object` -ℹ Safe fix 3 3 | 4 4 | 5 5 | class Bad: @@ -29,7 +28,6 @@ PYI032.py:7:29: PYI032 [*] Prefer `object` to `Any` for the second parameter to | = help: Replace with `object` -ℹ Safe fix 4 4 | 5 5 | class Bad: 6 6 | def __eq__(self, other: Any) -> bool: ... # Y032 @@ -38,5 +36,3 @@ PYI032.py:7:29: PYI032 [*] Prefer `object` to `Any` for the second parameter to 8 8 | 9 9 | 10 10 | class Good: - - diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI032_PYI032.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI032_PYI032.pyi.snap index 0017fe8889720..0a1b512351a0f 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI032_PYI032.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI032_PYI032.pyi.snap @@ -10,7 +10,6 @@ PYI032.pyi:6:29: PYI032 [*] Prefer `object` to `Any` for the second parameter to | = help: Replace with `object` -ℹ Safe fix 3 3 | 4 4 | 5 5 | class Bad: @@ -29,7 +28,6 @@ PYI032.pyi:7:29: PYI032 [*] Prefer `object` to `Any` for the second parameter to | = help: Replace with `object` -ℹ Safe fix 4 4 | 5 5 | class Bad: 6 6 | def __eq__(self, other: Any) -> bool: ... # Y032 @@ -38,5 +36,3 @@ PYI032.pyi:7:29: PYI032 [*] Prefer `object` to `Any` for the second parameter to 8 8 | 9 9 | 10 10 | class Good: - - diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI036_PYI036.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI036_PYI036.py.snap index 2f3dc38a504bd..064410ed79023 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI036_PYI036.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI036_PYI036.py.snap @@ -10,7 +10,6 @@ PYI036.py:54:31: PYI036 [*] Star-args in `__exit__` should be annotated with `ob | = help: Annotate star-args with `object` -ℹ Safe fix 51 51 | 52 52 | 53 53 | class BadOne: @@ -111,7 +110,6 @@ PYI036.py:70:58: PYI036 [*] Star-args in `__exit__` should be annotated with `ob | = help: Annotate star-args with `object` -ℹ Safe fix 67 67 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException | None, __tb: typing.Union[TracebackType, None, int]) -> bool | None: ... # PYI036: Third arg has bad annotation 68 68 | 69 69 | class BadFive: @@ -132,7 +130,6 @@ PYI036.py:71:74: PYI036 [*] Star-args in `__aexit__` should be annotated with `o | = help: Annotate star-args with `object` -ℹ Safe fix 68 68 | 69 69 | class BadFive: 70 70 | def __exit__(self, typ: BaseException | None, *args: list[str]) -> bool: ... # PYI036: Bad star-args annotation diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI036_PYI036.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI036_PYI036.pyi.snap index 7f31ca0ccdf0b..0bb6b20b198ec 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI036_PYI036.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI036_PYI036.pyi.snap @@ -10,7 +10,6 @@ PYI036.pyi:54:31: PYI036 [*] Star-args in `__exit__` should be annotated with `o | = help: Annotate star-args with `object` -ℹ Safe fix 51 51 | 52 52 | 53 53 | class BadOne: @@ -121,7 +120,6 @@ PYI036.pyi:70:58: PYI036 [*] Star-args in `__exit__` should be annotated with `o | = help: Annotate star-args with `object` -ℹ Safe fix 67 67 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException | None, __tb: typing.Union[TracebackType, None, int]) -> bool | None: ... # PYI036: Third arg has bad annotation 68 68 | 69 69 | class BadFive: @@ -142,7 +140,6 @@ PYI036.pyi:71:74: PYI036 [*] Star-args in `__aexit__` should be annotated with ` | = help: Annotate star-args with `object` -ℹ Safe fix 68 68 | 69 69 | class BadFive: 70 70 | def __exit__(self, typ: BaseException | None, *args: list[str]) -> bool: ... # PYI036: Bad star-args annotation diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI053_PYI053.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI053_PYI053.pyi.snap index 19ca04f611b51..8c2a95255da96 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI053_PYI053.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI053_PYI053.pyi.snap @@ -12,7 +12,6 @@ PYI053.pyi:7:14: PYI053 [*] String and bytes literals longer than 50 characters | = help: Replace with `...` -ℹ Safe fix 4 4 | 5 5 | def f1(x: str = "50 character stringggggggggggggggggggggggggggggggg") -> None: ... # OK 6 6 | def f2( @@ -33,7 +32,6 @@ PYI053.pyi:13:14: PYI053 [*] String and bytes literals longer than 50 characters | = help: Replace with `...` -ℹ Safe fix 10 10 | x: str = "50 character stringgggggggggggggggggggggggggggggg\U0001f600", # OK 11 11 | ) -> None: ... 12 12 | def f4( @@ -53,7 +51,6 @@ PYI053.pyi:25:16: PYI053 [*] String and bytes literals longer than 50 characters | = help: Replace with `...` -ℹ Safe fix 22 22 | x: bytes = b"50 character byte stringggggggggggggggggggggggggg\xff", # OK 23 23 | ) -> None: ... 24 24 | def f8( @@ -74,7 +71,6 @@ PYI053.pyi:30:12: PYI053 [*] String and bytes literals longer than 50 characters | = help: Replace with `...` -ℹ Safe fix 27 27 | 28 28 | foo: str = "50 character stringggggggggggggggggggggggggggggggg" # OK 29 29 | @@ -95,7 +91,6 @@ PYI053.pyi:34:14: PYI053 [*] String and bytes literals longer than 50 characters | = help: Replace with `...` -ℹ Safe fix 31 31 | 32 32 | baz: bytes = b"50 character byte stringgggggggggggggggggggggggggg" # OK 33 33 | @@ -116,7 +111,6 @@ PYI053.pyi:38:13: PYI053 [*] String and bytes literals longer than 50 characters | = help: Replace with `...` -ℹ Safe fix 35 35 | 36 36 | ffoo: str = f"50 character stringggggggggggggggggggggggggggggggg" # OK 37 37 | @@ -136,7 +130,6 @@ PYI053.pyi:64:5: PYI053 [*] String and bytes literals longer than 50 characters | = help: Replace with `...` -ℹ Safe fix 61 61 | ) -> Callable[[Callable[[], None]], Callable[[], None]]: ... 62 62 | 63 63 | @not_warnings_dot_deprecated( @@ -155,7 +148,6 @@ PYI053.pyi:68:13: PYI053 [*] String and bytes literals longer than 50 characters | = help: Replace with `...` -ℹ Safe fix 65 65 | ) 66 66 | def not_a_deprecated_function() -> None: ... 67 67 | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI054_PYI054.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI054_PYI054.pyi.snap index 24457599a3ba0..891fa4d843cb3 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI054_PYI054.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI054_PYI054.pyi.snap @@ -11,7 +11,6 @@ PYI054.pyi:2:16: PYI054 [*] Numeric literals with a string representation longer | = help: Replace with `...` -ℹ Safe fix 1 1 | field01: int = 0xFFFFFFFF 2 |-field02: int = 0xFFFFFFFFF # Error: PYI054 2 |+field02: int = ... # Error: PYI054 @@ -30,7 +29,6 @@ PYI054.pyi:4:17: PYI054 [*] Numeric literals with a string representation longer | = help: Replace with `...` -ℹ Safe fix 1 1 | field01: int = 0xFFFFFFFF 2 2 | field02: int = 0xFFFFFFFFF # Error: PYI054 3 3 | field03: int = -0xFFFFFFFF @@ -51,7 +49,6 @@ PYI054.pyi:8:16: PYI054 [*] Numeric literals with a string representation longer | = help: Replace with `...` -ℹ Safe fix 5 5 | 6 6 | field05: int = 1234567890 7 7 | field06: int = 12_456_890 @@ -72,7 +69,6 @@ PYI054.pyi:10:17: PYI054 [*] Numeric literals with a string representation longe | = help: Replace with `...` -ℹ Safe fix 7 7 | field06: int = 12_456_890 8 8 | field07: int = 12345678901 # Error: PYI054 9 9 | field08: int = -1234567801 @@ -92,7 +88,6 @@ PYI054.pyi:13:18: PYI054 [*] Numeric literals with a string representation longe | = help: Replace with `...` -ℹ Safe fix 10 10 | field09: int = -234_567_890 # Error: PYI054 11 11 | 12 12 | field10: float = 123.456789 @@ -113,7 +108,6 @@ PYI054.pyi:15:19: PYI054 [*] Numeric literals with a string representation longe | = help: Replace with `...` -ℹ Safe fix 12 12 | field10: float = 123.456789 13 13 | field11: float = 123.4567890 # Error: PYI054 14 14 | field12: float = -123.456789 @@ -133,7 +127,6 @@ PYI054.pyi:18:20: PYI054 [*] Numeric literals with a string representation longe | = help: Replace with `...` -ℹ Safe fix 15 15 | field13: float = -123.567_890 # Error: PYI054 16 16 | 17 17 | field14: complex = 1e1234567j @@ -151,11 +144,8 @@ PYI054.pyi:20:20: PYI054 [*] Numeric literals with a string representation longe | = help: Replace with `...` -ℹ Safe fix 17 17 | field14: complex = 1e1234567j 18 18 | field15: complex = 1e12345678j # Error: PYI054 19 19 | field16: complex = -1e1234567j 20 |-field17: complex = 1e123456789j # Error: PYI054 20 |+field17: complex = ... # Error: PYI054 - - diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI055_PYI055.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI055_PYI055.py.snap index e93e79a12d48a..6a59f43557454 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI055_PYI055.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI055_PYI055.py.snap @@ -11,7 +11,6 @@ PYI055.py:31:8: PYI055 [*] Multiple `type` members in a union. Combine them into | = help: Combine multiple `type` members -ℹ Safe fix 28 28 | 29 29 | def func(): 30 30 | # PYI055 @@ -30,7 +29,6 @@ PYI055.py:32:8: PYI055 [*] Multiple `type` members in a union. Combine them into | = help: Combine multiple `type` members -ℹ Safe fix 29 29 | def func(): 30 30 | # PYI055 31 31 | x: type[requests_mock.Mocker] | type[httpretty] | type[str] = requests_mock.Mocker @@ -48,7 +46,6 @@ PYI055.py:39:8: PYI055 [*] Multiple `type` members in a union. Combine them into | = help: Combine multiple `type` members -ℹ Safe fix 36 36 | from typing import Union as U 37 37 | 38 38 | # PYI055 @@ -69,7 +66,6 @@ PYI055.py:44:9: PYI055 [*] Multiple `type` members in a union. Combine them into | = help: Combine multiple `type` members -ℹ Safe fix 41 41 | 42 42 | def convert_union(union: UnionType) -> _T | None: 43 43 | converters: tuple[ @@ -90,7 +86,6 @@ PYI055.py:50:15: PYI055 [*] Multiple `type` members in a union. Combine them int | = help: Combine multiple `type` members -ℹ Safe fix 47 47 | 48 48 | def convert_union(union: UnionType) -> _T | None: 49 49 | converters: tuple[ @@ -111,7 +106,6 @@ PYI055.py:56:15: PYI055 [*] Multiple `type` members in a union. Combine them int | = help: Combine multiple `type` members -ℹ Safe fix 53 53 | 54 54 | def convert_union(union: UnionType) -> _T | None: 55 55 | converters: tuple[ @@ -132,7 +126,6 @@ PYI055.py:62:15: PYI055 [*] Multiple `type` members in a union. Combine them int | = help: Combine multiple `type` members -ℹ Safe fix 59 59 | 60 60 | def convert_union(union: UnionType) -> _T | None: 61 61 | converters: tuple[ @@ -140,5 +133,3 @@ PYI055.py:62:15: PYI055 [*] Multiple `type` members in a union. Combine them int 62 |+ Union[type[_T | Converter[_T]] | str] | Converter[_T] | Callable[[str], _T], ... # PYI055 63 63 | ] = union.__args__ 64 64 | ... - - diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI055_PYI055.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI055_PYI055.pyi.snap index 0e41288be5073..763a01229df28 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI055_PYI055.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI055_PYI055.pyi.snap @@ -12,7 +12,6 @@ PYI055.pyi:4:4: PYI055 [*] Multiple `type` members in a union. Combine them into | = help: Combine multiple `type` members -ℹ Safe fix 1 1 | import builtins 2 2 | from typing import Union 3 3 | @@ -32,7 +31,6 @@ PYI055.pyi:5:4: PYI055 [*] Multiple `type` members in a union. Combine them into | = help: Combine multiple `type` members -ℹ Safe fix 2 2 | from typing import Union 3 3 | 4 4 | w: builtins.type[int] | builtins.type[str] | builtins.type[complex] @@ -53,7 +51,6 @@ PYI055.pyi:6:4: PYI055 [*] Multiple `type` members in a union. Combine them into | = help: Combine multiple `type` members -ℹ Safe fix 3 3 | 4 4 | w: builtins.type[int] | builtins.type[str] | builtins.type[complex] 5 5 | x: type[int] | type[str] | type[float] @@ -73,7 +70,6 @@ PYI055.pyi:7:4: PYI055 [*] Multiple `type` members in a union. Combine them into | = help: Combine multiple `type` members -ℹ Safe fix 4 4 | w: builtins.type[int] | builtins.type[str] | builtins.type[complex] 5 5 | x: type[int] | type[str] | type[float] 6 6 | y: builtins.type[int] | type[str] | builtins.type[complex] @@ -94,7 +90,6 @@ PYI055.pyi:8:4: PYI055 [*] Multiple `type` members in a union. Combine them into | = help: Combine multiple `type` members -ℹ Safe fix 5 5 | x: type[int] | type[str] | type[float] 6 6 | y: builtins.type[int] | type[str] | builtins.type[complex] 7 7 | z: Union[type[float], type[complex]] @@ -115,7 +110,6 @@ PYI055.pyi:10:15: PYI055 [*] Multiple `type` members in a union. Combine them in | = help: Combine multiple `type` members -ℹ Safe fix 7 7 | z: Union[type[float], type[complex]] 8 8 | z: Union[type[float, int], type[complex]] 9 9 | @@ -135,7 +129,6 @@ PYI055.pyi:20:7: PYI055 [*] Multiple `type` members in a union. Combine them int | = help: Combine multiple `type` members -ℹ Safe fix 17 17 | def func(arg: type[int, float] | str) -> None: ... 18 18 | 19 19 | # OK @@ -155,7 +148,6 @@ PYI055.pyi:24:11: PYI055 [*] Multiple `type` members in a union. Combine them in | = help: Combine multiple `type` members -ℹ Safe fix 21 21 | 22 22 | def func(): 23 23 | # PYI055 @@ -172,11 +164,8 @@ PYI055.pyi:25:12: PYI055 [*] Multiple `type` members in a union. Combine them in | = help: Combine multiple `type` members -ℹ Safe fix 22 22 | def func(): 23 23 | # PYI055 24 24 | item: type[requests_mock.Mocker] | type[httpretty] | type[str] = requests_mock.Mocker 25 |- item2: Union[type[requests_mock.Mocker], type[httpretty], type[str]] = requests_mock.Mocker 25 |+ item2: type[Union[requests_mock.Mocker, httpretty, str]] = requests_mock.Mocker - - diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI058_PYI058.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI058_PYI058.py.snap index 67a1ecba57303..49001f96d1ade 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI058_PYI058.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI058_PYI058.py.snap @@ -10,7 +10,6 @@ PYI058.py:5:13: PYI058 [*] Use `Iterator` as the return value for simple `__iter | = help: Convert the return annotation of your `__iter__` method to `Iterator` -ℹ Safe fix 1 |+from collections.abc import Iterator 1 2 | def scope(): 2 3 | from collections.abc import Generator @@ -31,7 +30,6 @@ PYI058.py:13:13: PYI058 [*] Use `Iterator` as the return value for simple `__ite | = help: Convert the return annotation of your `__iter__` method to `Iterator` -ℹ Safe fix 10 10 | import typing 11 11 | 12 12 | class IteratorReturningSimpleGenerator2: @@ -50,7 +48,6 @@ PYI058.py:21:13: PYI058 [*] Use `Iterator` as the return value for simple `__ite | = help: Convert the return annotation of your `__iter__` method to `Iterator` -ℹ Safe fix 18 18 | import collections.abc 19 19 | 20 20 | class IteratorReturningSimpleGenerator3: @@ -69,7 +66,6 @@ PYI058.py:30:13: PYI058 [*] Use `Iterator` as the return value for simple `__ite | = help: Convert the return annotation of your `__iter__` method to `Iterator` -ℹ Safe fix 27 27 | from typing import Any 28 28 | 29 29 | class IteratorReturningSimpleGenerator4: @@ -88,7 +84,6 @@ PYI058.py:39:13: PYI058 [*] Use `Iterator` as the return value for simple `__ite | = help: Convert the return annotation of your `__iter__` method to `Iterator` -ℹ Safe fix 36 36 | import typing 37 37 | 38 38 | class IteratorReturningSimpleGenerator5: @@ -107,7 +102,6 @@ PYI058.py:47:13: PYI058 [*] Use `Iterator` as the return value for simple `__ite | = help: Convert the return annotation of your `__iter__` method to `Iterator` -ℹ Safe fix 1 |+from collections.abc import Iterator 1 2 | def scope(): 2 3 | from collections.abc import Generator @@ -132,7 +126,6 @@ PYI058.py:55:13: PYI058 [*] Use `AsyncIterator` as the return value for simple ` | = help: Convert the return annotation of your `__aiter__` method to `AsyncIterator` -ℹ Safe fix 54 54 | class AsyncIteratorReturningSimpleAsyncGenerator1: 55 55 | def __aiter__( 56 56 | self, @@ -151,7 +144,6 @@ PYI058.py:73:13: PYI058 [*] Use `AsyncIterator` as the return value for simple ` | = help: Convert the return annotation of your `__aiter__` method to `AsyncIterator` -ℹ Safe fix 70 70 | import collections.abc 71 71 | 72 72 | class AsyncIteratorReturningSimpleAsyncGenerator3: @@ -159,6 +151,4 @@ PYI058.py:73:13: PYI058 [*] Use `AsyncIterator` as the return value for simple ` 73 |+ def __aiter__(self, /) -> collections.abc.AsyncIterator[str]: 74 74 | ... # PYI058 (Use `AsyncIterator`) 75 75 | -76 76 | - - +76 76 | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI058_PYI058.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI058_PYI058.pyi.snap index 9da7931b514db..90b47bbbc4b11 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI058_PYI058.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI058_PYI058.pyi.snap @@ -11,7 +11,6 @@ PYI058.pyi:5:13: PYI058 [*] Use `Iterator` as the return value for simple `__ite | = help: Convert the return annotation of your `__iter__` method to `Iterator` -ℹ Safe fix 1 |+from collections.abc import Iterator 1 2 | def scope(): 2 3 | from collections.abc import Generator @@ -33,7 +32,6 @@ PYI058.pyi:11:13: PYI058 [*] Use `Iterator` as the return value for simple `__it | = help: Convert the return annotation of your `__iter__` method to `Iterator` -ℹ Safe fix 8 8 | import typing 9 9 | 10 10 | class IteratorReturningSimpleGenerator2: @@ -53,7 +51,6 @@ PYI058.pyi:17:13: PYI058 [*] Use `Iterator` as the return value for simple `__it | = help: Convert the return annotation of your `__iter__` method to `Iterator` -ℹ Safe fix 14 14 | import collections.abc 15 15 | 16 16 | class IteratorReturningSimpleGenerator3: @@ -73,7 +70,6 @@ PYI058.pyi:24:13: PYI058 [*] Use `Iterator` as the return value for simple `__it | = help: Convert the return annotation of your `__iter__` method to `Iterator` -ℹ Safe fix 21 21 | from typing import Any 22 22 | 23 23 | class IteratorReturningSimpleGenerator4: @@ -93,7 +89,6 @@ PYI058.pyi:31:13: PYI058 [*] Use `Iterator` as the return value for simple `__it | = help: Convert the return annotation of your `__iter__` method to `Iterator` -ℹ Safe fix 28 28 | import typing 29 29 | 30 30 | class IteratorReturningSimpleGenerator5: @@ -113,7 +108,6 @@ PYI058.pyi:37:13: PYI058 [*] Use `Iterator` as the return value for simple `__it | = help: Convert the return annotation of your `__iter__` method to `Iterator` -ℹ Safe fix 1 |+from collections.abc import Iterator 1 2 | def scope(): 2 3 | from collections.abc import Generator @@ -138,7 +132,6 @@ PYI058.pyi:43:13: PYI058 [*] Use `AsyncIterator` as the return value for simple | = help: Convert the return annotation of your `__aiter__` method to `AsyncIterator` -ℹ Safe fix 40 40 | import typing_extensions 41 41 | 42 42 | class AsyncIteratorReturningSimpleAsyncGenerator1: @@ -157,7 +150,6 @@ PYI058.pyi:49:13: PYI058 [*] Use `AsyncIterator` as the return value for simple | = help: Convert the return annotation of your `__aiter__` method to `AsyncIterator` -ℹ Safe fix 46 46 | import collections.abc 47 47 | 48 48 | class AsyncIteratorReturningSimpleAsyncGenerator3: @@ -177,7 +169,6 @@ PYI058.pyi:56:13: PYI058 [*] Use `AsyncIterator` as the return value for simple | = help: Convert the return annotation of your `__aiter__` method to `AsyncIterator` -ℹ Safe fix 53 53 | import collections.abc 54 54 | 55 55 | class AsyncIteratorReturningSimpleAsyncGenerator3: @@ -186,5 +177,3 @@ PYI058.pyi:56:13: PYI058 [*] Use `AsyncIterator` as the return value for simple 57 57 | 58 58 | def scope(): 59 59 | from typing import Iterator - - diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI059_PYI059.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI059_PYI059.py.snap index bcb28618ff3c8..0ad6bec302a0f 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI059_PYI059.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI059_PYI059.py.snap @@ -12,7 +12,6 @@ PYI059.py:8:17: PYI059 [*] `Generic[]` should always be the last base class | = help: Move `Generic[]` to the end -ℹ Safe fix 5 5 | K = TypeVar('K') 6 6 | V = TypeVar('V') 7 7 | @@ -37,7 +36,6 @@ PYI059.py:15:16: PYI059 [*] `Generic[]` should always be the last base class | = help: Move `Generic[]` to the end -ℹ Safe fix 13 13 | self._items.append(item) 14 14 | 15 15 | class MyMapping( # PYI059 @@ -59,7 +57,6 @@ PYI059.py:26:10: PYI059 [*] `Generic[]` should always be the last base class | = help: Move `Generic[]` to the end -ℹ Safe fix 23 23 | # Inheriting from just `Generic` is a TypeError, but it's probably fine 24 24 | # to flag this issue in this case as well, since after fixing the error 25 25 | # the Generic's position issue persists. @@ -88,7 +85,6 @@ PYI059.py:30:10: PYI059 [*] `Generic[]` should always be the last base class | = help: Move `Generic[]` to the end -ℹ Safe fix 30 30 | class Foo( # comment about the bracket 31 31 | # Part 1 of multiline comment 1 32 32 | # Part 2 of multiline comment 1 diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI059_PYI059.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI059_PYI059.pyi.snap index eec9fa9f22c4c..b8472c9377092 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI059_PYI059.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI059_PYI059.pyi.snap @@ -12,7 +12,6 @@ PYI059.pyi:8:17: PYI059 [*] `Generic[]` should always be the last base class | = help: Move `Generic[]` to the end -ℹ Safe fix 5 5 | K = TypeVar('K') 6 6 | V = TypeVar('V') 7 7 | @@ -37,7 +36,6 @@ PYI059.pyi:12:16: PYI059 [*] `Generic[]` should always be the last base class | = help: Move `Generic[]` to the end -ℹ Safe fix 10 10 | def push(self, item: T) -> None: ... 11 11 | 12 12 | class MyMapping( # PYI059 @@ -58,7 +56,6 @@ PYI059.pyi:22:10: PYI059 [*] `Generic[]` should always be the last base class | = help: Move `Generic[]` to the end -ℹ Safe fix 19 19 | # Inheriting from just `Generic` is a TypeError, but it's probably fine 20 20 | # to flag this issue in this case as well, since after fixing the error 21 21 | # the Generic's position issue persists. @@ -87,7 +84,6 @@ PYI059.pyi:25:10: PYI059 [*] `Generic[]` should always be the last base class | = help: Move `Generic[]` to the end -ℹ Safe fix 25 25 | class Foo( # comment about the bracket 26 26 | # Part 1 of multiline comment 1 27 27 | # Part 2 of multiline comment 1 diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI064_PYI064.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI064_PYI064.py.snap index 4e441d5012a1f..61c46fd30fe69 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI064_PYI064.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI064_PYI064.py.snap @@ -12,7 +12,6 @@ PYI064.py:3:1: PYI064 [*] `Final[Literal[True]]` can be replaced with a bare `Fi | = help: Replace with `Final` -ℹ Safe fix 1 1 | from typing import Final, Literal 2 2 | 3 |-x: Final[Literal[True]] = True # PYI064 @@ -31,7 +30,6 @@ PYI064.py:4:1: PYI064 [*] `Final[Literal[None]]` can be replaced with a bare `Fi | = help: Replace with `Final` -ℹ Safe fix 1 1 | from typing import Final, Literal 2 2 | 3 3 | x: Final[Literal[True]] = True # PYI064 @@ -54,7 +52,6 @@ PYI064.py:5:1: PYI064 [*] `Final[Literal[...]]` can be replaced with a bare `Fin | = help: Replace with `Final` -ℹ Safe fix 2 2 | 3 3 | x: Final[Literal[True]] = True # PYI064 4 4 | y: Final[Literal[None]] = None # PYI064 @@ -76,7 +73,6 @@ PYI064.py:10:1: PYI064 [*] `Final[Literal[123]]` can be replaced with a bare `Fi | = help: Replace with `Final` -ℹ Safe fix 7 7 | ]] = "this is a really long literal, that won't be rendered in the issue text" 8 8 | 9 9 | # This should be fixable, and marked as safe diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI064_PYI064.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI064_PYI064.pyi.snap index 2c25d8adc5f36..7a8cfbd5221c8 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI064_PYI064.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI064_PYI064.pyi.snap @@ -12,7 +12,6 @@ PYI064.pyi:3:1: PYI064 [*] `Final[Literal[True]]` can be replaced with a bare `F | = help: Replace with `Final` -ℹ Safe fix 1 1 | from typing import Final, Literal 2 2 | 3 |-x: Final[Literal[True]] # PYI064 @@ -30,7 +29,6 @@ PYI064.pyi:4:1: PYI064 [*] `Final[Literal[None]]` can be replaced with a bare `F | = help: Replace with `Final` -ℹ Safe fix 1 1 | from typing import Final, Literal 2 2 | 3 3 | x: Final[Literal[True]] # PYI064 @@ -51,7 +49,6 @@ PYI064.pyi:5:1: PYI064 [*] `Final[Literal[...]]` can be replaced with a bare `Fi | = help: Replace with `Final` -ℹ Safe fix 2 2 | 3 3 | x: Final[Literal[True]] # PYI064 4 4 | y: Final[Literal[None]] = None # PYI064 @@ -71,7 +68,6 @@ PYI064.pyi:8:1: PYI064 [*] `Final[Literal[123]]` can be replaced with a bare `Fi | = help: Replace with `Final` -ℹ Safe fix 5 5 | z: Final[Literal["this is a really long literal, that won't be rendered in the issue text"]] # PYI064 6 6 | 7 7 | # This should be fixable, and marked as safe diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__py38_PYI026_PYI026.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__py38_PYI026_PYI026.pyi.snap index 7c5cd3152327a..a48673aef5903 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__py38_PYI026_PYI026.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__py38_PYI026_PYI026.pyi.snap @@ -12,7 +12,6 @@ PYI026.pyi:3:1: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g | = help: Add `TypeAlias` annotation -ℹ Safe fix 1 1 | from typing import Literal, Any 2 |+import typing_extensions 2 3 | @@ -32,7 +31,6 @@ PYI026.pyi:4:1: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g | = help: Add `TypeAlias` annotation -ℹ Safe fix 1 1 | from typing import Literal, Any 2 |+import typing_extensions 2 3 | @@ -54,7 +52,6 @@ PYI026.pyi:5:1: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g | = help: Add `TypeAlias` annotation -ℹ Safe fix 1 1 | from typing import Literal, Any 2 |+import typing_extensions 2 3 | @@ -76,7 +73,6 @@ PYI026.pyi:6:1: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g | = help: Add `TypeAlias` annotation -ℹ Safe fix 1 1 | from typing import Literal, Any 2 |+import typing_extensions 2 3 | @@ -100,7 +96,6 @@ PYI026.pyi:7:1: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g | = help: Add `TypeAlias` annotation -ℹ Safe fix 1 1 | from typing import Literal, Any 2 |+import typing_extensions 2 3 | @@ -124,7 +119,6 @@ PYI026.pyi:17:5: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e. | = help: Add `TypeAlias` annotation -ℹ Safe fix 1 1 | from typing import Literal, Any 2 |+import typing_extensions 2 3 | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT001_default.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT001_default.snap index ebb023025c2cd..b9cd89379ec75 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT001_default.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT001_default.snap @@ -10,7 +10,6 @@ PT001.py:9:1: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture` | = help: Add parentheses -ℹ Safe fix 6 6 | # `import pytest` 7 7 | 8 8 | @@ -29,7 +28,6 @@ PT001.py:34:1: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture` | = help: Add parentheses -ℹ Safe fix 31 31 | # `from pytest import fixture` 32 32 | 33 33 | @@ -48,7 +46,6 @@ PT001.py:59:1: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture` | = help: Add parentheses -ℹ Safe fix 56 56 | # `from pytest import fixture as aliased` 57 57 | 58 58 | @@ -56,6 +53,4 @@ PT001.py:59:1: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture` 59 |+@aliased() 60 60 | def aliased_no_parentheses(): 61 61 | return 42 -62 62 | - - +62 62 | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT001_no_parentheses.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT001_no_parentheses.snap index e508652be8397..dafbb57a29e70 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT001_no_parentheses.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT001_no_parentheses.snap @@ -10,7 +10,6 @@ PT001.py:14:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` | = help: Remove parentheses -ℹ Safe fix 11 11 | return 42 12 12 | 13 13 | @@ -31,7 +30,6 @@ PT001.py:24:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` | = help: Remove parentheses -ℹ Safe fix 21 21 | return 42 22 22 | 23 23 | @@ -52,7 +50,6 @@ PT001.py:39:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` | = help: Remove parentheses -ℹ Safe fix 36 36 | return 42 37 37 | 38 38 | @@ -73,7 +70,6 @@ PT001.py:49:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` | = help: Remove parentheses -ℹ Safe fix 46 46 | return 42 47 47 | 48 48 | @@ -94,7 +90,6 @@ PT001.py:64:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` | = help: Remove parentheses -ℹ Safe fix 61 61 | return 42 62 62 | 63 63 | @@ -115,7 +110,6 @@ PT001.py:74:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` | = help: Remove parentheses -ℹ Safe fix 71 71 | return 42 72 72 | 73 73 | @@ -125,5 +119,3 @@ PT001.py:74:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` 74 |+@aliased 77 75 | def aliased_parentheses_no_params_multiline(): 78 76 | return 42 - - diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT003.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT003.snap index 1e7536acab7f0..8f26915479d2f 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT003.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT003.snap @@ -10,15 +10,6 @@ PT003.py:14:17: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` | = help: Remove implied `scope` argument -ℹ Unsafe fix -11 11 | ... -12 12 | -13 13 | -14 |-@pytest.fixture(scope="function") - 14 |+@pytest.fixture() -15 15 | def error(): -16 16 | ... -17 17 | PT003.py:19:17: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` | @@ -29,15 +20,6 @@ PT003.py:19:17: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` | = help: Remove implied `scope` argument -ℹ Unsafe fix -16 16 | ... -17 17 | -18 18 | -19 |-@pytest.fixture(scope="function", name="my_fixture") - 19 |+@pytest.fixture(name="my_fixture") -20 20 | def error_multiple_args(): -21 21 | ... -22 22 | PT003.py:24:36: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` | @@ -48,15 +30,6 @@ PT003.py:24:36: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` | = help: Remove implied `scope` argument -ℹ Unsafe fix -21 21 | ... -22 22 | -23 23 | -24 |-@pytest.fixture(name="my_fixture", scope="function") - 24 |+@pytest.fixture(name="my_fixture") -25 25 | def error_multiple_args(): -26 26 | ... -27 27 | PT003.py:29:36: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` | @@ -67,15 +40,6 @@ PT003.py:29:36: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` | = help: Remove implied `scope` argument -ℹ Unsafe fix -26 26 | ... -27 27 | -28 28 | -29 |-@pytest.fixture(name="my_fixture", scope="function", **kwargs) - 29 |+@pytest.fixture(name="my_fixture", **kwargs) -30 30 | def error_second_arg(): -31 31 | ... -32 32 | PT003.py:37:31: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` | @@ -88,15 +52,6 @@ PT003.py:37:31: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` | = help: Remove implied `scope` argument -ℹ Unsafe fix -34 34 | # pytest.fixture does not take positional arguments, however this -35 35 | # tests the general case as we use a helper function that should -36 36 | # work for all cases. -37 |-@pytest.fixture("my_fixture", scope="function") - 37 |+@pytest.fixture("my_fixture") -38 38 | def error_arg(): -39 39 | ... -40 40 | PT003.py:43:5: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` | @@ -108,14 +63,6 @@ PT003.py:43:5: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` | = help: Remove implied `scope` argument -ℹ Unsafe fix -40 40 | -41 41 | -42 42 | @pytest.fixture( -43 |- scope="function", -44 43 | name="my_fixture", -45 44 | ) -46 45 | def error_multiple_args(): PT003.py:52:5: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` | @@ -128,14 +75,6 @@ PT003.py:52:5: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` | = help: Remove implied `scope` argument -ℹ Unsafe fix -49 49 | -50 50 | @pytest.fixture( -51 51 | name="my_fixture", -52 |- scope="function", -53 52 | ) -54 53 | def error_multiple_args(): -55 54 | ... PT003.py:66:5: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` | @@ -148,17 +87,3 @@ PT003.py:66:5: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` 68 | , | = help: Remove implied `scope` argument - -ℹ Unsafe fix -63 63 | -64 64 | # another comment ,) -65 65 | -66 |- scope=\ -67 |- "function" # some comment ), -68 |- , -69 |- -70 66 | name2=name, name3="my_fixture", **kwargs -71 67 | ) -72 68 | def error_multiple_args(): - - diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_csv.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_csv.snap index 2f17c775677ee..81e6dd9364649 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_csv.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_csv.snap @@ -10,15 +10,6 @@ PT006.py:24:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.p | = help: Use a string of comma-separated values for the first argument -ℹ Unsafe fix -21 21 | ... -22 22 | -23 23 | -24 |-@pytest.mark.parametrize(("param1", "param2"), [(1, 2), (3, 4)]) - 24 |+@pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)]) -25 25 | def test_tuple(param1, param2): -26 26 | ... -27 27 | PT006.py:29:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `str` | @@ -29,7 +20,6 @@ PT006.py:29:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.p | = help: Use a string for the first argument -ℹ Safe fix 26 26 | ... 27 27 | 28 28 | @@ -48,15 +38,6 @@ PT006.py:34:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.p | = help: Use a string of comma-separated values for the first argument -ℹ Unsafe fix -31 31 | ... -32 32 | -33 33 | -34 |-@pytest.mark.parametrize(["param1", "param2"], [(1, 2), (3, 4)]) - 34 |+@pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)]) -35 35 | def test_list(param1, param2): -36 36 | ... -37 37 | PT006.py:39:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `str` | @@ -67,7 +48,6 @@ PT006.py:39:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.p | = help: Use a string for the first argument -ℹ Safe fix 36 36 | ... 37 37 | 38 38 | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_default.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_default.snap index 2942fa06d4dc9..6ee6f03da5ebb 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_default.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_default.snap @@ -10,15 +10,6 @@ PT006.py:9:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.pa | = help: Use a `tuple` for the first argument -ℹ Unsafe fix -6 6 | ... -7 7 | -8 8 | -9 |-@pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)]) - 9 |+@pytest.mark.parametrize(("param1", "param2"), [(1, 2), (3, 4)]) -10 10 | def test_csv(param1, param2): -11 11 | ... -12 12 | PT006.py:14:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `tuple` | @@ -29,15 +20,6 @@ PT006.py:14:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.p | = help: Use a `tuple` for the first argument -ℹ Unsafe fix -11 11 | ... -12 12 | -13 13 | -14 |-@pytest.mark.parametrize(" param1, , param2 , ", [(1, 2), (3, 4)]) - 14 |+@pytest.mark.parametrize(("param1", "param2"), [(1, 2), (3, 4)]) -15 15 | def test_csv_with_whitespace(param1, param2): -16 16 | ... -17 17 | PT006.py:19:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `tuple` | @@ -48,15 +30,6 @@ PT006.py:19:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.p | = help: Use a `tuple` for the first argument -ℹ Unsafe fix -16 16 | ... -17 17 | -18 18 | -19 |-@pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)]) - 19 |+@pytest.mark.parametrize(("param1", "param2"), [(1, 2), (3, 4)]) -20 20 | def test_csv_bad_quotes(param1, param2): -21 21 | ... -22 22 | PT006.py:29:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `str` | @@ -67,7 +40,6 @@ PT006.py:29:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.p | = help: Use a string for the first argument -ℹ Safe fix 26 26 | ... 27 27 | 28 28 | @@ -86,15 +58,6 @@ PT006.py:34:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.p | = help: Use a `tuple` for the first argument -ℹ Unsafe fix -31 31 | ... -32 32 | -33 33 | -34 |-@pytest.mark.parametrize(["param1", "param2"], [(1, 2), (3, 4)]) - 34 |+@pytest.mark.parametrize(("param1", "param2"), [(1, 2), (3, 4)]) -35 35 | def test_list(param1, param2): -36 36 | ... -37 37 | PT006.py:39:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `str` | @@ -105,7 +68,6 @@ PT006.py:39:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.p | = help: Use a string for the first argument -ℹ Safe fix 36 36 | ... 37 37 | 38 38 | @@ -124,15 +86,6 @@ PT006.py:44:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.p | = help: Use a `tuple` for the first argument -ℹ Unsafe fix -41 41 | ... -42 42 | -43 43 | -44 |-@pytest.mark.parametrize([some_expr, another_expr], [1, 2, 3]) - 44 |+@pytest.mark.parametrize((some_expr, another_expr), [1, 2, 3]) -45 45 | def test_list_expressions(param1, param2): -46 46 | ... -47 47 | PT006.py:49:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `tuple` | @@ -143,15 +96,6 @@ PT006.py:49:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.p | = help: Use a `tuple` for the first argument -ℹ Unsafe fix -46 46 | ... -47 47 | -48 48 | -49 |-@pytest.mark.parametrize([some_expr, "param2"], [1, 2, 3]) - 49 |+@pytest.mark.parametrize((some_expr, "param2"), [1, 2, 3]) -50 50 | def test_list_mixed_expr_literal(param1, param2): -51 51 | ... -52 52 | PT006.py:54:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `tuple` | @@ -162,15 +106,6 @@ PT006.py:54:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.p | = help: Use a `tuple` for the first argument -ℹ Unsafe fix -51 51 | ... -52 52 | -53 53 | -54 |-@pytest.mark.parametrize(("param1, " "param2, " "param3"), [(1, 2, 3), (4, 5, 6)]) - 54 |+@pytest.mark.parametrize(("param1", "param2", "param3"), [(1, 2, 3), (4, 5, 6)]) -55 55 | def test_implicit_str_concat_with_parens(param1, param2, param3): -56 56 | ... -57 57 | PT006.py:59:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `tuple` | @@ -181,15 +116,6 @@ PT006.py:59:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.p | = help: Use a `tuple` for the first argument -ℹ Unsafe fix -56 56 | ... -57 57 | -58 58 | -59 |-@pytest.mark.parametrize("param1, " "param2, " "param3", [(1, 2, 3), (4, 5, 6)]) - 59 |+@pytest.mark.parametrize(("param1", "param2", "param3"), [(1, 2, 3), (4, 5, 6)]) -60 60 | def test_implicit_str_concat_no_parens(param1, param2, param3): -61 61 | ... -62 62 | PT006.py:64:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `tuple` | @@ -200,15 +126,6 @@ PT006.py:64:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.p | = help: Use a `tuple` for the first argument -ℹ Unsafe fix -61 61 | ... -62 62 | -63 63 | -64 |-@pytest.mark.parametrize((("param1, " "param2, " "param3")), [(1, 2, 3), (4, 5, 6)]) - 64 |+@pytest.mark.parametrize(("param1", "param2", "param3"), [(1, 2, 3), (4, 5, 6)]) -65 65 | def test_implicit_str_concat_with_multi_parens(param1, param2, param3): -66 66 | ... -67 67 | PT006.py:69:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `tuple` | @@ -218,12 +135,3 @@ PT006.py:69:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.p 71 | ... | = help: Use a `tuple` for the first argument - -ℹ Unsafe fix -66 66 | ... -67 67 | -68 68 | -69 |-@pytest.mark.parametrize(("param1,param2"), [(1, 2), (3, 4)]) - 69 |+@pytest.mark.parametrize(("param1", "param2"), [(1, 2), (3, 4)]) -70 70 | def test_csv_with_parens(param1, param2): -71 71 | ... diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_list.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_list.snap index b5c44886ca862..c8d3b5f202cb7 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_list.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_list.snap @@ -10,15 +10,6 @@ PT006.py:9:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.pa | = help: Use a `list` for the first argument -ℹ Unsafe fix -6 6 | ... -7 7 | -8 8 | -9 |-@pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)]) - 9 |+@pytest.mark.parametrize(["param1", "param2"], [(1, 2), (3, 4)]) -10 10 | def test_csv(param1, param2): -11 11 | ... -12 12 | PT006.py:14:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `list` | @@ -29,15 +20,6 @@ PT006.py:14:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.p | = help: Use a `list` for the first argument -ℹ Unsafe fix -11 11 | ... -12 12 | -13 13 | -14 |-@pytest.mark.parametrize(" param1, , param2 , ", [(1, 2), (3, 4)]) - 14 |+@pytest.mark.parametrize(["param1", "param2"], [(1, 2), (3, 4)]) -15 15 | def test_csv_with_whitespace(param1, param2): -16 16 | ... -17 17 | PT006.py:19:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `list` | @@ -48,15 +30,6 @@ PT006.py:19:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.p | = help: Use a `list` for the first argument -ℹ Unsafe fix -16 16 | ... -17 17 | -18 18 | -19 |-@pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)]) - 19 |+@pytest.mark.parametrize(["param1", "param2"], [(1, 2), (3, 4)]) -20 20 | def test_csv_bad_quotes(param1, param2): -21 21 | ... -22 22 | PT006.py:24:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `list` | @@ -67,15 +40,6 @@ PT006.py:24:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.p | = help: Use a `list` for the first argument -ℹ Unsafe fix -21 21 | ... -22 22 | -23 23 | -24 |-@pytest.mark.parametrize(("param1", "param2"), [(1, 2), (3, 4)]) - 24 |+@pytest.mark.parametrize(["param1", "param2"], [(1, 2), (3, 4)]) -25 25 | def test_tuple(param1, param2): -26 26 | ... -27 27 | PT006.py:29:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `str` | @@ -86,7 +50,6 @@ PT006.py:29:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.p | = help: Use a string for the first argument -ℹ Safe fix 26 26 | ... 27 27 | 28 28 | @@ -105,7 +68,6 @@ PT006.py:39:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.p | = help: Use a string for the first argument -ℹ Safe fix 36 36 | ... 37 37 | 38 38 | @@ -124,15 +86,6 @@ PT006.py:54:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.p | = help: Use a `list` for the first argument -ℹ Unsafe fix -51 51 | ... -52 52 | -53 53 | -54 |-@pytest.mark.parametrize(("param1, " "param2, " "param3"), [(1, 2, 3), (4, 5, 6)]) - 54 |+@pytest.mark.parametrize(["param1", "param2", "param3"], [(1, 2, 3), (4, 5, 6)]) -55 55 | def test_implicit_str_concat_with_parens(param1, param2, param3): -56 56 | ... -57 57 | PT006.py:59:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `list` | @@ -143,15 +96,6 @@ PT006.py:59:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.p | = help: Use a `list` for the first argument -ℹ Unsafe fix -56 56 | ... -57 57 | -58 58 | -59 |-@pytest.mark.parametrize("param1, " "param2, " "param3", [(1, 2, 3), (4, 5, 6)]) - 59 |+@pytest.mark.parametrize(["param1", "param2", "param3"], [(1, 2, 3), (4, 5, 6)]) -60 60 | def test_implicit_str_concat_no_parens(param1, param2, param3): -61 61 | ... -62 62 | PT006.py:64:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `list` | @@ -162,15 +106,6 @@ PT006.py:64:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.p | = help: Use a `list` for the first argument -ℹ Unsafe fix -61 61 | ... -62 62 | -63 63 | -64 |-@pytest.mark.parametrize((("param1, " "param2, " "param3")), [(1, 2, 3), (4, 5, 6)]) - 64 |+@pytest.mark.parametrize(["param1", "param2", "param3"], [(1, 2, 3), (4, 5, 6)]) -65 65 | def test_implicit_str_concat_with_multi_parens(param1, param2, param3): -66 66 | ... -67 67 | PT006.py:69:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `list` | @@ -180,12 +115,3 @@ PT006.py:69:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.p 71 | ... | = help: Use a `list` for the first argument - -ℹ Unsafe fix -66 66 | ... -67 67 | -68 68 | -69 |-@pytest.mark.parametrize(("param1,param2"), [(1, 2), (3, 4)]) - 69 |+@pytest.mark.parametrize(["param1", "param2"], [(1, 2), (3, 4)]) -70 70 | def test_csv_with_parens(param1, param2): -71 71 | ... diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_list_of_lists.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_list_of_lists.snap index 1feb8b1d245d0..09ddb219d9ec3 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_list_of_lists.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_list_of_lists.snap @@ -10,15 +10,6 @@ PT007.py:4:35: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `list` of `list` for parameter values -ℹ Unsafe fix -1 1 | import pytest -2 2 | -3 3 | -4 |-@pytest.mark.parametrize("param", (1, 2)) - 4 |+@pytest.mark.parametrize("param", [1, 2]) -5 5 | def test_tuple(param): -6 6 | ... -7 7 | PT007.py:11:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `list` of `list` | @@ -35,19 +26,6 @@ PT007.py:11:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `list` of `list` for parameter values -ℹ Unsafe fix -8 8 | -9 9 | @pytest.mark.parametrize( -10 10 | ("param1", "param2"), -11 |- ( - 11 |+ [ -12 12 | (1, 2), -13 13 | (3, 4), -14 |- ), - 14 |+ ], -15 15 | ) -16 16 | def test_tuple_of_tuples(param1, param2): -17 17 | ... PT007.py:12:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `list` of `list` | @@ -60,15 +38,6 @@ PT007.py:12:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `list` of `list` for parameter values -ℹ Unsafe fix -9 9 | @pytest.mark.parametrize( -10 10 | ("param1", "param2"), -11 11 | ( -12 |- (1, 2), - 12 |+ [1, 2], -13 13 | (3, 4), -14 14 | ), -15 15 | ) PT007.py:13:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `list` of `list` | @@ -81,15 +50,6 @@ PT007.py:13:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `list` of `list` for parameter values -ℹ Unsafe fix -10 10 | ("param1", "param2"), -11 11 | ( -12 12 | (1, 2), -13 |- (3, 4), - 13 |+ [3, 4], -14 14 | ), -15 15 | ) -16 16 | def test_tuple_of_tuples(param1, param2): PT007.py:22:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `list` of `list` | @@ -106,19 +66,6 @@ PT007.py:22:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `list` of `list` for parameter values -ℹ Unsafe fix -19 19 | -20 20 | @pytest.mark.parametrize( -21 21 | ("param1", "param2"), -22 |- ( - 22 |+ [ -23 23 | [1, 2], -24 24 | [3, 4], -25 |- ), - 25 |+ ], -26 26 | ) -27 27 | def test_tuple_of_lists(param1, param2): -28 28 | ... PT007.py:39:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `list` of `list` | @@ -131,15 +78,6 @@ PT007.py:39:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `list` of `list` for parameter values -ℹ Unsafe fix -36 36 | @pytest.mark.parametrize( -37 37 | ("param1", "param2"), -38 38 | [ -39 |- (1, 2), - 39 |+ [1, 2], -40 40 | (3, 4), -41 41 | ], -42 42 | ) PT007.py:40:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `list` of `list` | @@ -152,15 +90,6 @@ PT007.py:40:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `list` of `list` for parameter values -ℹ Unsafe fix -37 37 | ("param1", "param2"), -38 38 | [ -39 39 | (1, 2), -40 |- (3, 4), - 40 |+ [3, 4], -41 41 | ], -42 42 | ) -43 43 | def test_list_of_tuples(param1, param2): PT007.py:81:38: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `list` of `list` | @@ -172,15 +101,6 @@ PT007.py:81:38: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expect | = help: Use `list` of `list` for parameter values -ℹ Unsafe fix -78 78 | -79 79 | -80 80 | @pytest.mark.parametrize("a", [1, 2]) -81 |-@pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) - 81 |+@pytest.mark.parametrize(("b", "c"), [(3, 4), (5, 6)]) -82 82 | @pytest.mark.parametrize("d", [3,]) -83 83 | @pytest.mark.parametrize( -84 84 | "d", PT007.py:81:39: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `list` of `list` | @@ -192,15 +112,6 @@ PT007.py:81:39: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expect | = help: Use `list` of `list` for parameter values -ℹ Unsafe fix -78 78 | -79 79 | -80 80 | @pytest.mark.parametrize("a", [1, 2]) -81 |-@pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) - 81 |+@pytest.mark.parametrize(("b", "c"), ([3, 4], (5, 6))) -82 82 | @pytest.mark.parametrize("d", [3,]) -83 83 | @pytest.mark.parametrize( -84 84 | "d", PT007.py:81:47: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `list` of `list` | @@ -211,13 +122,3 @@ PT007.py:81:47: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expect 83 | @pytest.mark.parametrize( | = help: Use `list` of `list` for parameter values - -ℹ Unsafe fix -78 78 | -79 79 | -80 80 | @pytest.mark.parametrize("a", [1, 2]) -81 |-@pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) - 81 |+@pytest.mark.parametrize(("b", "c"), ((3, 4), [5, 6])) -82 82 | @pytest.mark.parametrize("d", [3,]) -83 83 | @pytest.mark.parametrize( -84 84 | "d", diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_list_of_tuples.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_list_of_tuples.snap index 2ee341b846203..8ad1982c5e787 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_list_of_tuples.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_list_of_tuples.snap @@ -10,15 +10,6 @@ PT007.py:4:35: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `list` of `tuple` for parameter values -ℹ Unsafe fix -1 1 | import pytest -2 2 | -3 3 | -4 |-@pytest.mark.parametrize("param", (1, 2)) - 4 |+@pytest.mark.parametrize("param", [1, 2]) -5 5 | def test_tuple(param): -6 6 | ... -7 7 | PT007.py:11:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple` | @@ -35,19 +26,6 @@ PT007.py:11:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `list` of `tuple` for parameter values -ℹ Unsafe fix -8 8 | -9 9 | @pytest.mark.parametrize( -10 10 | ("param1", "param2"), -11 |- ( - 11 |+ [ -12 12 | (1, 2), -13 13 | (3, 4), -14 |- ), - 14 |+ ], -15 15 | ) -16 16 | def test_tuple_of_tuples(param1, param2): -17 17 | ... PT007.py:22:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple` | @@ -64,19 +42,6 @@ PT007.py:22:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `list` of `tuple` for parameter values -ℹ Unsafe fix -19 19 | -20 20 | @pytest.mark.parametrize( -21 21 | ("param1", "param2"), -22 |- ( - 22 |+ [ -23 23 | [1, 2], -24 24 | [3, 4], -25 |- ), - 25 |+ ], -26 26 | ) -27 27 | def test_tuple_of_lists(param1, param2): -28 28 | ... PT007.py:23:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple` | @@ -89,15 +54,6 @@ PT007.py:23:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `list` of `tuple` for parameter values -ℹ Unsafe fix -20 20 | @pytest.mark.parametrize( -21 21 | ("param1", "param2"), -22 22 | ( -23 |- [1, 2], - 23 |+ (1, 2), -24 24 | [3, 4], -25 25 | ), -26 26 | ) PT007.py:24:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple` | @@ -110,15 +66,6 @@ PT007.py:24:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `list` of `tuple` for parameter values -ℹ Unsafe fix -21 21 | ("param1", "param2"), -22 22 | ( -23 23 | [1, 2], -24 |- [3, 4], - 24 |+ (3, 4), -25 25 | ), -26 26 | ) -27 27 | def test_tuple_of_lists(param1, param2): PT007.py:50:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple` | @@ -131,15 +78,6 @@ PT007.py:50:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `list` of `tuple` for parameter values -ℹ Unsafe fix -47 47 | @pytest.mark.parametrize( -48 48 | ("param1", "param2"), -49 49 | [ -50 |- [1, 2], - 50 |+ (1, 2), -51 51 | [3, 4], -52 52 | ], -53 53 | ) PT007.py:51:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple` | @@ -152,15 +90,6 @@ PT007.py:51:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `list` of `tuple` for parameter values -ℹ Unsafe fix -48 48 | ("param1", "param2"), -49 49 | [ -50 50 | [1, 2], -51 |- [3, 4], - 51 |+ (3, 4), -52 52 | ], -53 53 | ) -54 54 | def test_list_of_lists(param1, param2): PT007.py:61:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple` | @@ -173,15 +102,6 @@ PT007.py:61:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `list` of `tuple` for parameter values -ℹ Unsafe fix -58 58 | @pytest.mark.parametrize( -59 59 | "param1,param2", -60 60 | [ -61 |- [1, 2], - 61 |+ (1, 2), -62 62 | [3, 4], -63 63 | ], -64 64 | ) PT007.py:62:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple` | @@ -194,15 +114,6 @@ PT007.py:62:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `list` of `tuple` for parameter values -ℹ Unsafe fix -59 59 | "param1,param2", -60 60 | [ -61 61 | [1, 2], -62 |- [3, 4], - 62 |+ (3, 4), -63 63 | ], -64 64 | ) -65 65 | def test_csv_name_list_of_lists(param1, param2): PT007.py:81:38: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple` | @@ -213,13 +124,3 @@ PT007.py:81:38: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expect 83 | @pytest.mark.parametrize( | = help: Use `list` of `tuple` for parameter values - -ℹ Unsafe fix -78 78 | -79 79 | -80 80 | @pytest.mark.parametrize("a", [1, 2]) -81 |-@pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) - 81 |+@pytest.mark.parametrize(("b", "c"), [(3, 4), (5, 6)]) -82 82 | @pytest.mark.parametrize("d", [3,]) -83 83 | @pytest.mark.parametrize( -84 84 | "d", diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_tuple_of_lists.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_tuple_of_lists.snap index 93a0b2954c463..310110ac84562 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_tuple_of_lists.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_tuple_of_lists.snap @@ -12,15 +12,6 @@ PT007.py:12:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `tuple` of `list` for parameter values -ℹ Unsafe fix -9 9 | @pytest.mark.parametrize( -10 10 | ("param1", "param2"), -11 11 | ( -12 |- (1, 2), - 12 |+ [1, 2], -13 13 | (3, 4), -14 14 | ), -15 15 | ) PT007.py:13:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` | @@ -33,15 +24,6 @@ PT007.py:13:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `tuple` of `list` for parameter values -ℹ Unsafe fix -10 10 | ("param1", "param2"), -11 11 | ( -12 12 | (1, 2), -13 |- (3, 4), - 13 |+ [3, 4], -14 14 | ), -15 15 | ) -16 16 | def test_tuple_of_tuples(param1, param2): PT007.py:31:35: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` | @@ -52,15 +34,6 @@ PT007.py:31:35: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expect | = help: Use `tuple` of `list` for parameter values -ℹ Unsafe fix -28 28 | ... -29 29 | -30 30 | -31 |-@pytest.mark.parametrize("param", [1, 2]) - 31 |+@pytest.mark.parametrize("param", (1, 2)) -32 32 | def test_list(param): -33 33 | ... -34 34 | PT007.py:38:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` | @@ -77,19 +50,6 @@ PT007.py:38:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `tuple` of `list` for parameter values -ℹ Unsafe fix -35 35 | -36 36 | @pytest.mark.parametrize( -37 37 | ("param1", "param2"), -38 |- [ - 38 |+ ( -39 39 | (1, 2), -40 40 | (3, 4), -41 |- ], - 41 |+ ), -42 42 | ) -43 43 | def test_list_of_tuples(param1, param2): -44 44 | ... PT007.py:39:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` | @@ -102,15 +62,6 @@ PT007.py:39:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `tuple` of `list` for parameter values -ℹ Unsafe fix -36 36 | @pytest.mark.parametrize( -37 37 | ("param1", "param2"), -38 38 | [ -39 |- (1, 2), - 39 |+ [1, 2], -40 40 | (3, 4), -41 41 | ], -42 42 | ) PT007.py:40:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` | @@ -123,15 +74,6 @@ PT007.py:40:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `tuple` of `list` for parameter values -ℹ Unsafe fix -37 37 | ("param1", "param2"), -38 38 | [ -39 39 | (1, 2), -40 |- (3, 4), - 40 |+ [3, 4], -41 41 | ], -42 42 | ) -43 43 | def test_list_of_tuples(param1, param2): PT007.py:49:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` | @@ -148,19 +90,6 @@ PT007.py:49:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `tuple` of `list` for parameter values -ℹ Unsafe fix -46 46 | -47 47 | @pytest.mark.parametrize( -48 48 | ("param1", "param2"), -49 |- [ - 49 |+ ( -50 50 | [1, 2], -51 51 | [3, 4], -52 |- ], - 52 |+ ), -53 53 | ) -54 54 | def test_list_of_lists(param1, param2): -55 55 | ... PT007.py:60:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` | @@ -177,19 +106,6 @@ PT007.py:60:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `tuple` of `list` for parameter values -ℹ Unsafe fix -57 57 | -58 58 | @pytest.mark.parametrize( -59 59 | "param1,param2", -60 |- [ - 60 |+ ( -61 61 | [1, 2], -62 62 | [3, 4], -63 |- ], - 63 |+ ), -64 64 | ) -65 65 | def test_csv_name_list_of_lists(param1, param2): -66 66 | ... PT007.py:71:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` | @@ -206,19 +122,6 @@ PT007.py:71:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `tuple` of `list` for parameter values -ℹ Unsafe fix -68 68 | -69 69 | @pytest.mark.parametrize( -70 70 | "param", -71 |- [ - 71 |+ ( -72 72 | [1, 2], -73 73 | [3, 4], -74 |- ], - 74 |+ ), -75 75 | ) -76 76 | def test_single_list_of_lists(param): -77 77 | ... PT007.py:80:31: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` | @@ -229,15 +132,6 @@ PT007.py:80:31: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expect | = help: Use `tuple` of `list` for parameter values -ℹ Unsafe fix -77 77 | ... -78 78 | -79 79 | -80 |-@pytest.mark.parametrize("a", [1, 2]) - 80 |+@pytest.mark.parametrize("a", (1, 2)) -81 81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) -82 82 | @pytest.mark.parametrize("d", [3,]) -83 83 | @pytest.mark.parametrize( PT007.py:81:39: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` | @@ -249,15 +143,6 @@ PT007.py:81:39: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expect | = help: Use `tuple` of `list` for parameter values -ℹ Unsafe fix -78 78 | -79 79 | -80 80 | @pytest.mark.parametrize("a", [1, 2]) -81 |-@pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) - 81 |+@pytest.mark.parametrize(("b", "c"), ([3, 4], (5, 6))) -82 82 | @pytest.mark.parametrize("d", [3,]) -83 83 | @pytest.mark.parametrize( -84 84 | "d", PT007.py:81:47: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` | @@ -269,15 +154,6 @@ PT007.py:81:47: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expect | = help: Use `tuple` of `list` for parameter values -ℹ Unsafe fix -78 78 | -79 79 | -80 80 | @pytest.mark.parametrize("a", [1, 2]) -81 |-@pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) - 81 |+@pytest.mark.parametrize(("b", "c"), ((3, 4), [5, 6])) -82 82 | @pytest.mark.parametrize("d", [3,]) -83 83 | @pytest.mark.parametrize( -84 84 | "d", PT007.py:82:31: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` | @@ -290,15 +166,6 @@ PT007.py:82:31: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expect | = help: Use `tuple` of `list` for parameter values -ℹ Unsafe fix -79 79 | -80 80 | @pytest.mark.parametrize("a", [1, 2]) -81 81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) -82 |-@pytest.mark.parametrize("d", [3,]) - 82 |+@pytest.mark.parametrize("d", (3,)) -83 83 | @pytest.mark.parametrize( -84 84 | "d", -85 85 | [("3", "4")], PT007.py:85:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` | @@ -311,15 +178,6 @@ PT007.py:85:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `tuple` of `list` for parameter values -ℹ Unsafe fix -82 82 | @pytest.mark.parametrize("d", [3,]) -83 83 | @pytest.mark.parametrize( -84 84 | "d", -85 |- [("3", "4")], - 85 |+ (("3", "4"),), -86 86 | ) -87 87 | @pytest.mark.parametrize( -88 88 | "e", PT007.py:89:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` | @@ -331,13 +189,3 @@ PT007.py:89:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte 91 | def test_multiple_decorators(a, b, c, d, e): | = help: Use `tuple` of `list` for parameter values - -ℹ Unsafe fix -86 86 | ) -87 87 | @pytest.mark.parametrize( -88 88 | "e", -89 |- [("3", "4"),], - 89 |+ (("3", "4"),), -90 90 | ) -91 91 | def test_multiple_decorators(a, b, c, d, e): -92 92 | pass diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_tuple_of_tuples.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_tuple_of_tuples.snap index 3d90a13b2eb9c..c3d573f0db376 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_tuple_of_tuples.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_tuple_of_tuples.snap @@ -12,15 +12,6 @@ PT007.py:23:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `tuple` of `tuple` for parameter values -ℹ Unsafe fix -20 20 | @pytest.mark.parametrize( -21 21 | ("param1", "param2"), -22 22 | ( -23 |- [1, 2], - 23 |+ (1, 2), -24 24 | [3, 4], -25 25 | ), -26 26 | ) PT007.py:24:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` | @@ -33,15 +24,6 @@ PT007.py:24:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `tuple` of `tuple` for parameter values -ℹ Unsafe fix -21 21 | ("param1", "param2"), -22 22 | ( -23 23 | [1, 2], -24 |- [3, 4], - 24 |+ (3, 4), -25 25 | ), -26 26 | ) -27 27 | def test_tuple_of_lists(param1, param2): PT007.py:31:35: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` | @@ -52,15 +34,6 @@ PT007.py:31:35: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expect | = help: Use `tuple` of `tuple` for parameter values -ℹ Unsafe fix -28 28 | ... -29 29 | -30 30 | -31 |-@pytest.mark.parametrize("param", [1, 2]) - 31 |+@pytest.mark.parametrize("param", (1, 2)) -32 32 | def test_list(param): -33 33 | ... -34 34 | PT007.py:38:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` | @@ -77,19 +50,6 @@ PT007.py:38:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `tuple` of `tuple` for parameter values -ℹ Unsafe fix -35 35 | -36 36 | @pytest.mark.parametrize( -37 37 | ("param1", "param2"), -38 |- [ - 38 |+ ( -39 39 | (1, 2), -40 40 | (3, 4), -41 |- ], - 41 |+ ), -42 42 | ) -43 43 | def test_list_of_tuples(param1, param2): -44 44 | ... PT007.py:49:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` | @@ -106,19 +66,6 @@ PT007.py:49:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `tuple` of `tuple` for parameter values -ℹ Unsafe fix -46 46 | -47 47 | @pytest.mark.parametrize( -48 48 | ("param1", "param2"), -49 |- [ - 49 |+ ( -50 50 | [1, 2], -51 51 | [3, 4], -52 |- ], - 52 |+ ), -53 53 | ) -54 54 | def test_list_of_lists(param1, param2): -55 55 | ... PT007.py:50:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` | @@ -131,15 +78,6 @@ PT007.py:50:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `tuple` of `tuple` for parameter values -ℹ Unsafe fix -47 47 | @pytest.mark.parametrize( -48 48 | ("param1", "param2"), -49 49 | [ -50 |- [1, 2], - 50 |+ (1, 2), -51 51 | [3, 4], -52 52 | ], -53 53 | ) PT007.py:51:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` | @@ -152,15 +90,6 @@ PT007.py:51:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `tuple` of `tuple` for parameter values -ℹ Unsafe fix -48 48 | ("param1", "param2"), -49 49 | [ -50 50 | [1, 2], -51 |- [3, 4], - 51 |+ (3, 4), -52 52 | ], -53 53 | ) -54 54 | def test_list_of_lists(param1, param2): PT007.py:60:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` | @@ -177,19 +106,6 @@ PT007.py:60:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `tuple` of `tuple` for parameter values -ℹ Unsafe fix -57 57 | -58 58 | @pytest.mark.parametrize( -59 59 | "param1,param2", -60 |- [ - 60 |+ ( -61 61 | [1, 2], -62 62 | [3, 4], -63 |- ], - 63 |+ ), -64 64 | ) -65 65 | def test_csv_name_list_of_lists(param1, param2): -66 66 | ... PT007.py:61:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` | @@ -202,15 +118,6 @@ PT007.py:61:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `tuple` of `tuple` for parameter values -ℹ Unsafe fix -58 58 | @pytest.mark.parametrize( -59 59 | "param1,param2", -60 60 | [ -61 |- [1, 2], - 61 |+ (1, 2), -62 62 | [3, 4], -63 63 | ], -64 64 | ) PT007.py:62:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` | @@ -223,15 +130,6 @@ PT007.py:62:9: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `tuple` of `tuple` for parameter values -ℹ Unsafe fix -59 59 | "param1,param2", -60 60 | [ -61 61 | [1, 2], -62 |- [3, 4], - 62 |+ (3, 4), -63 63 | ], -64 64 | ) -65 65 | def test_csv_name_list_of_lists(param1, param2): PT007.py:71:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` | @@ -248,19 +146,6 @@ PT007.py:71:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `tuple` of `tuple` for parameter values -ℹ Unsafe fix -68 68 | -69 69 | @pytest.mark.parametrize( -70 70 | "param", -71 |- [ - 71 |+ ( -72 72 | [1, 2], -73 73 | [3, 4], -74 |- ], - 74 |+ ), -75 75 | ) -76 76 | def test_single_list_of_lists(param): -77 77 | ... PT007.py:80:31: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` | @@ -271,15 +156,6 @@ PT007.py:80:31: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expect | = help: Use `tuple` of `tuple` for parameter values -ℹ Unsafe fix -77 77 | ... -78 78 | -79 79 | -80 |-@pytest.mark.parametrize("a", [1, 2]) - 80 |+@pytest.mark.parametrize("a", (1, 2)) -81 81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) -82 82 | @pytest.mark.parametrize("d", [3,]) -83 83 | @pytest.mark.parametrize( PT007.py:82:31: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` | @@ -292,15 +168,6 @@ PT007.py:82:31: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expect | = help: Use `tuple` of `tuple` for parameter values -ℹ Unsafe fix -79 79 | -80 80 | @pytest.mark.parametrize("a", [1, 2]) -81 81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) -82 |-@pytest.mark.parametrize("d", [3,]) - 82 |+@pytest.mark.parametrize("d", (3,)) -83 83 | @pytest.mark.parametrize( -84 84 | "d", -85 85 | [("3", "4")], PT007.py:85:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` | @@ -313,15 +180,6 @@ PT007.py:85:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte | = help: Use `tuple` of `tuple` for parameter values -ℹ Unsafe fix -82 82 | @pytest.mark.parametrize("d", [3,]) -83 83 | @pytest.mark.parametrize( -84 84 | "d", -85 |- [("3", "4")], - 85 |+ (("3", "4"),), -86 86 | ) -87 87 | @pytest.mark.parametrize( -88 88 | "e", PT007.py:89:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` | @@ -333,13 +191,3 @@ PT007.py:89:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expecte 91 | def test_multiple_decorators(a, b, c, d, e): | = help: Use `tuple` of `tuple` for parameter values - -ℹ Unsafe fix -86 86 | ) -87 87 | @pytest.mark.parametrize( -88 88 | "e", -89 |- [("3", "4"),], - 89 |+ (("3", "4"),), -90 90 | ) -91 91 | def test_multiple_decorators(a, b, c, d, e): -92 92 | pass diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT009.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT009.snap index 572c08916f966..b231775a53b6e 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT009.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT009.snap @@ -12,15 +12,6 @@ PT009.py:11:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser | = help: Replace `assertTrue(...)` with `assert ...` -ℹ Unsafe fix -8 8 | def test_assert_true(self): -9 9 | expr = 1 -10 10 | msg = "Must be True" -11 |- self.assertTrue(expr) # Error - 11 |+ assert expr # Error -12 12 | self.assertTrue(expr=expr) # Error -13 13 | self.assertTrue(expr, msg) # Error -14 14 | self.assertTrue(expr=expr, msg=msg) # Error PT009.py:12:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertTrue` | @@ -33,15 +24,6 @@ PT009.py:12:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser | = help: Replace `assertTrue(...)` with `assert ...` -ℹ Unsafe fix -9 9 | expr = 1 -10 10 | msg = "Must be True" -11 11 | self.assertTrue(expr) # Error -12 |- self.assertTrue(expr=expr) # Error - 12 |+ assert expr # Error -13 13 | self.assertTrue(expr, msg) # Error -14 14 | self.assertTrue(expr=expr, msg=msg) # Error -15 15 | self.assertTrue(msg=msg, expr=expr) # Error PT009.py:13:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertTrue` | @@ -54,15 +36,6 @@ PT009.py:13:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser | = help: Replace `assertTrue(...)` with `assert ...` -ℹ Unsafe fix -10 10 | msg = "Must be True" -11 11 | self.assertTrue(expr) # Error -12 12 | self.assertTrue(expr=expr) # Error -13 |- self.assertTrue(expr, msg) # Error - 13 |+ assert expr, msg # Error -14 14 | self.assertTrue(expr=expr, msg=msg) # Error -15 15 | self.assertTrue(msg=msg, expr=expr) # Error -16 16 | self.assertTrue(*(expr, msg)) # Error, unfixable PT009.py:14:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertTrue` | @@ -75,15 +48,6 @@ PT009.py:14:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser | = help: Replace `assertTrue(...)` with `assert ...` -ℹ Unsafe fix -11 11 | self.assertTrue(expr) # Error -12 12 | self.assertTrue(expr=expr) # Error -13 13 | self.assertTrue(expr, msg) # Error -14 |- self.assertTrue(expr=expr, msg=msg) # Error - 14 |+ assert expr, msg # Error -15 15 | self.assertTrue(msg=msg, expr=expr) # Error -16 16 | self.assertTrue(*(expr, msg)) # Error, unfixable -17 17 | self.assertTrue(**{"expr": expr, "msg": msg}) # Error, unfixable PT009.py:15:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertTrue` | @@ -96,15 +60,6 @@ PT009.py:15:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser | = help: Replace `assertTrue(...)` with `assert ...` -ℹ Unsafe fix -12 12 | self.assertTrue(expr=expr) # Error -13 13 | self.assertTrue(expr, msg) # Error -14 14 | self.assertTrue(expr=expr, msg=msg) # Error -15 |- self.assertTrue(msg=msg, expr=expr) # Error - 15 |+ assert expr, msg # Error -16 16 | self.assertTrue(*(expr, msg)) # Error, unfixable -17 17 | self.assertTrue(**{"expr": expr, "msg": msg}) # Error, unfixable -18 18 | self.assertTrue(msg=msg, expr=expr, unexpected_arg=False) # Error, unfixable PT009.py:16:9: PT009 Use a regular `assert` instead of unittest-style `assertTrue` | @@ -193,15 +148,6 @@ PT009.py:28:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser | = help: Replace `assertFalse(...)` with `assert ...` -ℹ Unsafe fix -25 25 | return self.assertEqual(True, False) # Error, unfixable -26 26 | -27 27 | def test_assert_false(self): -28 |- self.assertFalse(True) # Error - 28 |+ assert not True # Error -29 29 | -30 30 | def test_assert_equal(self): -31 31 | self.assertEqual(1, 2) # Error PT009.py:31:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertEqual` | @@ -213,15 +159,6 @@ PT009.py:31:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser | = help: Replace `assertEqual(...)` with `assert ...` -ℹ Unsafe fix -28 28 | self.assertFalse(True) # Error -29 29 | -30 30 | def test_assert_equal(self): -31 |- self.assertEqual(1, 2) # Error - 31 |+ assert 1 == 2 # Error -32 32 | -33 33 | def test_assert_not_equal(self): -34 34 | self.assertNotEqual(1, 1) # Error PT009.py:34:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertNotEqual` | @@ -233,15 +170,6 @@ PT009.py:34:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser | = help: Replace `assertNotEqual(...)` with `assert ...` -ℹ Unsafe fix -31 31 | self.assertEqual(1, 2) # Error -32 32 | -33 33 | def test_assert_not_equal(self): -34 |- self.assertNotEqual(1, 1) # Error - 34 |+ assert 1 != 1 # Error -35 35 | -36 36 | def test_assert_greater(self): -37 37 | self.assertGreater(1, 2) # Error PT009.py:37:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertGreater` | @@ -253,15 +181,6 @@ PT009.py:37:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser | = help: Replace `assertGreater(...)` with `assert ...` -ℹ Unsafe fix -34 34 | self.assertNotEqual(1, 1) # Error -35 35 | -36 36 | def test_assert_greater(self): -37 |- self.assertGreater(1, 2) # Error - 37 |+ assert 1 > 2 # Error -38 38 | -39 39 | def test_assert_greater_equal(self): -40 40 | self.assertGreaterEqual(1, 2) # Error PT009.py:40:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertGreaterEqual` | @@ -273,15 +192,6 @@ PT009.py:40:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser | = help: Replace `assertGreaterEqual(...)` with `assert ...` -ℹ Unsafe fix -37 37 | self.assertGreater(1, 2) # Error -38 38 | -39 39 | def test_assert_greater_equal(self): -40 |- self.assertGreaterEqual(1, 2) # Error - 40 |+ assert 1 >= 2 # Error -41 41 | -42 42 | def test_assert_less(self): -43 43 | self.assertLess(2, 1) # Error PT009.py:43:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertLess` | @@ -293,15 +203,6 @@ PT009.py:43:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser | = help: Replace `assertLess(...)` with `assert ...` -ℹ Unsafe fix -40 40 | self.assertGreaterEqual(1, 2) # Error -41 41 | -42 42 | def test_assert_less(self): -43 |- self.assertLess(2, 1) # Error - 43 |+ assert 2 < 1 # Error -44 44 | -45 45 | def test_assert_less_equal(self): -46 46 | self.assertLessEqual(1, 2) # Error PT009.py:46:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertLessEqual` | @@ -313,15 +214,6 @@ PT009.py:46:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser | = help: Replace `assertLessEqual(...)` with `assert ...` -ℹ Unsafe fix -43 43 | self.assertLess(2, 1) # Error -44 44 | -45 45 | def test_assert_less_equal(self): -46 |- self.assertLessEqual(1, 2) # Error - 46 |+ assert 1 <= 2 # Error -47 47 | -48 48 | def test_assert_in(self): -49 49 | self.assertIn(1, [2, 3]) # Error PT009.py:49:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertIn` | @@ -333,15 +225,6 @@ PT009.py:49:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser | = help: Replace `assertIn(...)` with `assert ...` -ℹ Unsafe fix -46 46 | self.assertLessEqual(1, 2) # Error -47 47 | -48 48 | def test_assert_in(self): -49 |- self.assertIn(1, [2, 3]) # Error - 49 |+ assert 1 in [2, 3] # Error -50 50 | -51 51 | def test_assert_not_in(self): -52 52 | self.assertNotIn(2, [2, 3]) # Error PT009.py:52:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertNotIn` | @@ -353,15 +236,6 @@ PT009.py:52:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser | = help: Replace `assertNotIn(...)` with `assert ...` -ℹ Unsafe fix -49 49 | self.assertIn(1, [2, 3]) # Error -50 50 | -51 51 | def test_assert_not_in(self): -52 |- self.assertNotIn(2, [2, 3]) # Error - 52 |+ assert 2 not in [2, 3] # Error -53 53 | -54 54 | def test_assert_is_none(self): -55 55 | self.assertIsNone(0) # Error PT009.py:55:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertIsNone` | @@ -373,15 +247,6 @@ PT009.py:55:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser | = help: Replace `assertIsNone(...)` with `assert ...` -ℹ Unsafe fix -52 52 | self.assertNotIn(2, [2, 3]) # Error -53 53 | -54 54 | def test_assert_is_none(self): -55 |- self.assertIsNone(0) # Error - 55 |+ assert 0 is None # Error -56 56 | -57 57 | def test_assert_is_not_none(self): -58 58 | self.assertIsNotNone(0) # Error PT009.py:58:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertIsNotNone` | @@ -393,15 +258,6 @@ PT009.py:58:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser | = help: Replace `assertIsNotNone(...)` with `assert ...` -ℹ Unsafe fix -55 55 | self.assertIsNone(0) # Error -56 56 | -57 57 | def test_assert_is_not_none(self): -58 |- self.assertIsNotNone(0) # Error - 58 |+ assert 0 is not None # Error -59 59 | -60 60 | def test_assert_is(self): -61 61 | self.assertIs([], []) # Error PT009.py:61:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertIs` | @@ -413,15 +269,6 @@ PT009.py:61:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser | = help: Replace `assertIs(...)` with `assert ...` -ℹ Unsafe fix -58 58 | self.assertIsNotNone(0) # Error -59 59 | -60 60 | def test_assert_is(self): -61 |- self.assertIs([], []) # Error - 61 |+ assert [] is [] # Error -62 62 | -63 63 | def test_assert_is_not(self): -64 64 | self.assertIsNot(1, 1) # Error PT009.py:64:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertIsNot` | @@ -433,15 +280,6 @@ PT009.py:64:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser | = help: Replace `assertIsNot(...)` with `assert ...` -ℹ Unsafe fix -61 61 | self.assertIs([], []) # Error -62 62 | -63 63 | def test_assert_is_not(self): -64 |- self.assertIsNot(1, 1) # Error - 64 |+ assert 1 is not 1 # Error -65 65 | -66 66 | def test_assert_is_instance(self): -67 67 | self.assertIsInstance(1, str) # Error PT009.py:67:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertIsInstance` | @@ -453,15 +291,6 @@ PT009.py:67:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser | = help: Replace `assertIsInstance(...)` with `assert ...` -ℹ Unsafe fix -64 64 | self.assertIsNot(1, 1) # Error -65 65 | -66 66 | def test_assert_is_instance(self): -67 |- self.assertIsInstance(1, str) # Error - 67 |+ assert isinstance(1, str) # Error -68 68 | -69 69 | def test_assert_is_not_instance(self): -70 70 | self.assertNotIsInstance(1, int) # Error PT009.py:70:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertNotIsInstance` | @@ -473,15 +302,6 @@ PT009.py:70:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser | = help: Replace `assertNotIsInstance(...)` with `assert ...` -ℹ Unsafe fix -67 67 | self.assertIsInstance(1, str) # Error -68 68 | -69 69 | def test_assert_is_not_instance(self): -70 |- self.assertNotIsInstance(1, int) # Error - 70 |+ assert not isinstance(1, int) # Error -71 71 | -72 72 | def test_assert_regex(self): -73 73 | self.assertRegex("abc", r"def") # Error PT009.py:73:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertRegex` | @@ -493,15 +313,6 @@ PT009.py:73:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser | = help: Replace `assertRegex(...)` with `assert ...` -ℹ Unsafe fix -70 70 | self.assertNotIsInstance(1, int) # Error -71 71 | -72 72 | def test_assert_regex(self): -73 |- self.assertRegex("abc", r"def") # Error - 73 |+ assert re.search("def", "abc") # Error -74 74 | -75 75 | def test_assert_not_regex(self): -76 76 | self.assertNotRegex("abc", r"abc") # Error PT009.py:76:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertNotRegex` | @@ -513,15 +324,6 @@ PT009.py:76:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser | = help: Replace `assertNotRegex(...)` with `assert ...` -ℹ Unsafe fix -73 73 | self.assertRegex("abc", r"def") # Error -74 74 | -75 75 | def test_assert_not_regex(self): -76 |- self.assertNotRegex("abc", r"abc") # Error - 76 |+ assert not re.search("abc", "abc") # Error -77 77 | -78 78 | def test_assert_regexp_matches(self): -79 79 | self.assertRegexpMatches("abc", r"def") # Error PT009.py:79:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertRegexpMatches` | @@ -533,15 +335,6 @@ PT009.py:79:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser | = help: Replace `assertRegexpMatches(...)` with `assert ...` -ℹ Unsafe fix -76 76 | self.assertNotRegex("abc", r"abc") # Error -77 77 | -78 78 | def test_assert_regexp_matches(self): -79 |- self.assertRegexpMatches("abc", r"def") # Error - 79 |+ assert re.search("def", "abc") # Error -80 80 | -81 81 | def test_assert_not_regexp_matches(self): -82 82 | self.assertNotRegex("abc", r"abc") # Error PT009.py:82:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertNotRegex` | @@ -553,15 +346,6 @@ PT009.py:82:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser | = help: Replace `assertNotRegex(...)` with `assert ...` -ℹ Unsafe fix -79 79 | self.assertRegexpMatches("abc", r"def") # Error -80 80 | -81 81 | def test_assert_not_regexp_matches(self): -82 |- self.assertNotRegex("abc", r"abc") # Error - 82 |+ assert not re.search("abc", "abc") # Error -83 83 | -84 84 | def test_fail_if(self): -85 85 | self.failIf("abc") # Error PT009.py:85:9: PT009 [*] Use a regular `assert` instead of unittest-style `failIf` | @@ -573,15 +357,6 @@ PT009.py:85:9: PT009 [*] Use a regular `assert` instead of unittest-style `failI | = help: Replace `failIf(...)` with `assert ...` -ℹ Unsafe fix -82 82 | self.assertNotRegex("abc", r"abc") # Error -83 83 | -84 84 | def test_fail_if(self): -85 |- self.failIf("abc") # Error - 85 |+ assert not "abc" # Error -86 86 | -87 87 | def test_fail_unless(self): -88 88 | self.failUnless("abc") # Error PT009.py:88:9: PT009 [*] Use a regular `assert` instead of unittest-style `failUnless` | @@ -593,15 +368,6 @@ PT009.py:88:9: PT009 [*] Use a regular `assert` instead of unittest-style `failU | = help: Replace `failUnless(...)` with `assert ...` -ℹ Unsafe fix -85 85 | self.failIf("abc") # Error -86 86 | -87 87 | def test_fail_unless(self): -88 |- self.failUnless("abc") # Error - 88 |+ assert "abc" # Error -89 89 | -90 90 | def test_fail_unless_equal(self): -91 91 | self.failUnlessEqual(1, 2) # Error PT009.py:91:9: PT009 [*] Use a regular `assert` instead of unittest-style `failUnlessEqual` | @@ -613,15 +379,6 @@ PT009.py:91:9: PT009 [*] Use a regular `assert` instead of unittest-style `failU | = help: Replace `failUnlessEqual(...)` with `assert ...` -ℹ Unsafe fix -88 88 | self.failUnless("abc") # Error -89 89 | -90 90 | def test_fail_unless_equal(self): -91 |- self.failUnlessEqual(1, 2) # Error - 91 |+ assert 1 == 2 # Error -92 92 | -93 93 | def test_fail_if_equal(self): -94 94 | self.failIfEqual(1, 2) # Error PT009.py:94:9: PT009 [*] Use a regular `assert` instead of unittest-style `failIfEqual` | @@ -631,15 +388,6 @@ PT009.py:94:9: PT009 [*] Use a regular `assert` instead of unittest-style `failI | = help: Replace `failIfEqual(...)` with `assert ...` -ℹ Unsafe fix -91 91 | self.failUnlessEqual(1, 2) # Error -92 92 | -93 93 | def test_fail_if_equal(self): -94 |- self.failIfEqual(1, 2) # Error - 94 |+ assert 1 != 2 # Error -95 95 | -96 96 | -97 97 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722459517 PT009.py:98:2: PT009 [*] Use a regular `assert` instead of unittest-style `assertTrue` | @@ -650,14 +398,3 @@ PT009.py:98:2: PT009 [*] Use a regular `assert` instead of unittest-style `asser 100 | self.model.piAx_piAy_beta[r][x][y]))) | = help: Replace `assertTrue(...)` with `assert ...` - -ℹ Unsafe fix -95 95 | -96 96 | -97 97 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722459517 -98 |-(self.assertTrue( -99 |- "piAx_piAy_beta[r][x][y] = {17}".format( -100 |- self.model.piAx_piAy_beta[r][x][y]))) - 98 |+assert "piAx_piAy_beta[r][x][y] = {17}".format(self.model.piAx_piAy_beta[r][x][y]) - - diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT014.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT014.snap index 92240183c3672..842031377f56c 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT014.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT014.snap @@ -10,15 +10,6 @@ PT014.py:4:35: PT014 [*] Duplicate of test case at index 0 in `@pytest_mark.para | = help: Remove duplicate test case -ℹ Unsafe fix -1 1 | import pytest -2 2 | -3 3 | -4 |-@pytest.mark.parametrize("x", [1, 1, 2]) - 4 |+@pytest.mark.parametrize("x", [1, 2]) -5 5 | def test_error_literal(x): -6 6 | ... -7 7 | PT014.py:14:35: PT014 [*] Duplicate of test case at index 0 in `@pytest_mark.parametrize` | @@ -29,15 +20,6 @@ PT014.py:14:35: PT014 [*] Duplicate of test case at index 0 in `@pytest_mark.par | = help: Remove duplicate test case -ℹ Unsafe fix -11 11 | c = 3 -12 12 | -13 13 | -14 |-@pytest.mark.parametrize("x", [a, a, b, b, b, c]) - 14 |+@pytest.mark.parametrize("x", [a, b, b, b, c]) -15 15 | def test_error_expr_simple(x): -16 16 | ... -17 17 | PT014.py:14:41: PT014 [*] Duplicate of test case at index 2 in `@pytest_mark.parametrize` | @@ -48,15 +30,6 @@ PT014.py:14:41: PT014 [*] Duplicate of test case at index 2 in `@pytest_mark.par | = help: Remove duplicate test case -ℹ Unsafe fix -11 11 | c = 3 -12 12 | -13 13 | -14 |-@pytest.mark.parametrize("x", [a, a, b, b, b, c]) - 14 |+@pytest.mark.parametrize("x", [a, a, b, b, c]) -15 15 | def test_error_expr_simple(x): -16 16 | ... -17 17 | PT014.py:14:44: PT014 [*] Duplicate of test case at index 2 in `@pytest_mark.parametrize` | @@ -67,15 +40,6 @@ PT014.py:14:44: PT014 [*] Duplicate of test case at index 2 in `@pytest_mark.par | = help: Remove duplicate test case -ℹ Unsafe fix -11 11 | c = 3 -12 12 | -13 13 | -14 |-@pytest.mark.parametrize("x", [a, a, b, b, b, c]) - 14 |+@pytest.mark.parametrize("x", [a, a, b, b, c]) -15 15 | def test_error_expr_simple(x): -16 16 | ... -17 17 | PT014.py:24:9: PT014 Duplicate of test case at index 0 in `@pytest_mark.parametrize` | @@ -97,15 +61,6 @@ PT014.py:32:39: PT014 [*] Duplicate of test case at index 0 in `@pytest_mark.par | = help: Remove duplicate test case -ℹ Unsafe fix -29 29 | ... -30 30 | -31 31 | -32 |-@pytest.mark.parametrize("x", [a, b, (a), c, ((a))]) - 32 |+@pytest.mark.parametrize("x", [a, b, c, ((a))]) -33 33 | def test_error_parentheses(x): -34 34 | ... -35 35 | PT014.py:32:48: PT014 [*] Duplicate of test case at index 0 in `@pytest_mark.parametrize` | @@ -116,15 +71,6 @@ PT014.py:32:48: PT014 [*] Duplicate of test case at index 0 in `@pytest_mark.par | = help: Remove duplicate test case -ℹ Unsafe fix -29 29 | ... -30 30 | -31 31 | -32 |-@pytest.mark.parametrize("x", [a, b, (a), c, ((a))]) - 32 |+@pytest.mark.parametrize("x", [a, b, (a), c]) -33 33 | def test_error_parentheses(x): -34 34 | ... -35 35 | PT014.py:42:10: PT014 [*] Duplicate of test case at index 0 in `@pytest_mark.parametrize` | @@ -137,14 +83,6 @@ PT014.py:42:10: PT014 [*] Duplicate of test case at index 0 in `@pytest_mark.par | = help: Remove duplicate test case -ℹ Unsafe fix -39 39 | [ -40 40 | a, -41 41 | b, -42 |- (a), -43 42 | c, -44 43 | ((a)), -45 44 | ], PT014.py:44:11: PT014 [*] Duplicate of test case at index 0 in `@pytest_mark.parametrize` | @@ -157,14 +95,6 @@ PT014.py:44:11: PT014 [*] Duplicate of test case at index 0 in `@pytest_mark.par | = help: Remove duplicate test case -ℹ Unsafe fix -41 41 | b, -42 42 | (a), -43 43 | c, -44 |- ((a)), -45 44 | ], -46 45 | ) -47 46 | def test_error_parentheses_trailing_comma(x): PT014.py:56:53: PT014 [*] Duplicate of test case at index 0 in `@pytest_mark.parametrize` | @@ -174,12 +104,3 @@ PT014.py:56:53: PT014 [*] Duplicate of test case at index 0 in `@pytest_mark.par 58 | ... | = help: Remove duplicate test case - -ℹ Unsafe fix -53 53 | ... -54 54 | -55 55 | -56 |-@pytest.mark.parametrize('data, spec', [(1.0, 1.0), (1.0, 1.0)]) - 56 |+@pytest.mark.parametrize('data, spec', [(1.0, 1.0)]) -57 57 | def test_numbers(data, spec): -58 58 | ... diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT018.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT018.snap index cf96ebfbb180e..287d3825b51a2 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT018.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT018.snap @@ -11,16 +11,6 @@ PT018.py:14:5: PT018 [*] Assertion should be broken down into multiple parts | = help: Break down assertion into multiple parts -ℹ Unsafe fix -11 11 | -12 12 | -13 13 | def test_error(): -14 |- assert something and something_else - 14 |+ assert something - 15 |+ assert something_else -15 16 | assert something and something_else and something_third -16 17 | assert something and not something_else -17 18 | assert something and (something_else or something_third) PT018.py:15:5: PT018 [*] Assertion should be broken down into multiple parts | @@ -33,16 +23,6 @@ PT018.py:15:5: PT018 [*] Assertion should be broken down into multiple parts | = help: Break down assertion into multiple parts -ℹ Unsafe fix -12 12 | -13 13 | def test_error(): -14 14 | assert something and something_else -15 |- assert something and something_else and something_third - 15 |+ assert something and something_else - 16 |+ assert something_third -16 17 | assert something and not something_else -17 18 | assert something and (something_else or something_third) -18 19 | assert not something and something_else PT018.py:16:5: PT018 [*] Assertion should be broken down into multiple parts | @@ -55,16 +35,6 @@ PT018.py:16:5: PT018 [*] Assertion should be broken down into multiple parts | = help: Break down assertion into multiple parts -ℹ Unsafe fix -13 13 | def test_error(): -14 14 | assert something and something_else -15 15 | assert something and something_else and something_third -16 |- assert something and not something_else - 16 |+ assert something - 17 |+ assert not something_else -17 18 | assert something and (something_else or something_third) -18 19 | assert not something and something_else -19 20 | assert not (something or something_else) PT018.py:17:5: PT018 [*] Assertion should be broken down into multiple parts | @@ -77,16 +47,6 @@ PT018.py:17:5: PT018 [*] Assertion should be broken down into multiple parts | = help: Break down assertion into multiple parts -ℹ Unsafe fix -14 14 | assert something and something_else -15 15 | assert something and something_else and something_third -16 16 | assert something and not something_else -17 |- assert something and (something_else or something_third) - 17 |+ assert something - 18 |+ assert (something_else or something_third) -18 19 | assert not something and something_else -19 20 | assert not (something or something_else) -20 21 | assert not (something or something_else or something_third) PT018.py:18:5: PT018 [*] Assertion should be broken down into multiple parts | @@ -99,16 +59,6 @@ PT018.py:18:5: PT018 [*] Assertion should be broken down into multiple parts | = help: Break down assertion into multiple parts -ℹ Unsafe fix -15 15 | assert something and something_else and something_third -16 16 | assert something and not something_else -17 17 | assert something and (something_else or something_third) -18 |- assert not something and something_else - 18 |+ assert not something - 19 |+ assert something_else -19 20 | assert not (something or something_else) -20 21 | assert not (something or something_else or something_third) -21 22 | assert something and something_else == """error PT018.py:19:5: PT018 [*] Assertion should be broken down into multiple parts | @@ -121,16 +71,6 @@ PT018.py:19:5: PT018 [*] Assertion should be broken down into multiple parts | = help: Break down assertion into multiple parts -ℹ Unsafe fix -16 16 | assert something and not something_else -17 17 | assert something and (something_else or something_third) -18 18 | assert not something and something_else -19 |- assert not (something or something_else) - 19 |+ assert not something - 20 |+ assert not something_else -20 21 | assert not (something or something_else or something_third) -21 22 | assert something and something_else == """error -22 23 | message PT018.py:20:5: PT018 [*] Assertion should be broken down into multiple parts | @@ -143,16 +83,6 @@ PT018.py:20:5: PT018 [*] Assertion should be broken down into multiple parts | = help: Break down assertion into multiple parts -ℹ Unsafe fix -17 17 | assert something and (something_else or something_third) -18 18 | assert not something and something_else -19 19 | assert not (something or something_else) -20 |- assert not (something or something_else or something_third) - 20 |+ assert not (something or something_else) - 21 |+ assert not something_third -21 22 | assert something and something_else == """error -22 23 | message -23 24 | """ PT018.py:21:5: PT018 [*] Assertion should be broken down into multiple parts | @@ -168,16 +98,6 @@ PT018.py:21:5: PT018 [*] Assertion should be broken down into multiple parts | = help: Break down assertion into multiple parts -ℹ Unsafe fix -18 18 | assert not something and something_else -19 19 | assert not (something or something_else) -20 20 | assert not (something or something_else or something_third) -21 |- assert something and something_else == """error - 21 |+ assert something - 22 |+ assert something_else == """error -22 23 | message -23 24 | """ -24 25 | assert ( PT018.py:24:5: PT018 [*] Assertion should be broken down into multiple parts | @@ -197,18 +117,6 @@ PT018.py:24:5: PT018 [*] Assertion should be broken down into multiple parts | = help: Break down assertion into multiple parts -ℹ Unsafe fix -21 21 | assert something and something_else == """error -22 22 | message -23 23 | """ - 24 |+ assert something -24 25 | assert ( -25 |- something -26 |- and something_else - 26 |+ something_else -27 27 | == """error -28 28 | message -29 29 | """ PT018.py:33:5: PT018 [*] Assertion should be broken down into multiple parts | @@ -219,16 +127,6 @@ PT018.py:33:5: PT018 [*] Assertion should be broken down into multiple parts | = help: Break down assertion into multiple parts -ℹ Unsafe fix -30 30 | ) -31 31 | -32 32 | # recursive case -33 |- assert not (a or not (b or c)) - 33 |+ assert not a - 34 |+ assert (b or c) -34 35 | assert not (a or not (b and c)) -35 36 | -36 37 | # detected, but no fix for messages PT018.py:34:5: PT018 [*] Assertion should be broken down into multiple parts | @@ -241,16 +139,6 @@ PT018.py:34:5: PT018 [*] Assertion should be broken down into multiple parts | = help: Break down assertion into multiple parts -ℹ Unsafe fix -31 31 | -32 32 | # recursive case -33 33 | assert not (a or not (b or c)) -34 |- assert not (a or not (b and c)) - 34 |+ assert not a - 35 |+ assert (b and c) -35 36 | -36 37 | # detected, but no fix for messages -37 38 | assert something and something_else, "error message" PT018.py:37:5: PT018 Assertion should be broken down into multiple parts | @@ -291,16 +179,6 @@ PT018.py:44:1: PT018 [*] Assertion should be broken down into multiple parts | = help: Break down assertion into multiple parts -ℹ Unsafe fix -41 41 | -42 42 | -43 43 | assert something # OK -44 |-assert something and something_else # Error - 44 |+assert something - 45 |+assert something_else -45 46 | assert something and something_else and something_third # Error -46 47 | -47 48 | PT018.py:45:1: PT018 [*] Assertion should be broken down into multiple parts | @@ -311,16 +189,6 @@ PT018.py:45:1: PT018 [*] Assertion should be broken down into multiple parts | = help: Break down assertion into multiple parts -ℹ Unsafe fix -42 42 | -43 43 | assert something # OK -44 44 | assert something and something_else # Error -45 |-assert something and something_else and something_third # Error - 45 |+assert something and something_else - 46 |+assert something_third -46 47 | -47 48 | -48 49 | def test_multiline(): PT018.py:49:5: PT018 Assertion should be broken down into multiple parts | @@ -367,18 +235,6 @@ PT018.py:59:5: PT018 [*] Assertion should be broken down into multiple parts | = help: Break down assertion into multiple parts -ℹ Unsafe fix -59 59 | assert not ( -60 60 | self.find_graph_output(node.output[0]) -61 61 | or self.find_graph_input(node.input[0]) -62 |- or self.find_graph_output(node.input[0]) -63 62 | ) - 63 |+ assert not ( - 64 |+ self.find_graph_output(node.input[0]) - 65 |+ ) -64 66 | -65 67 | assert (not ( -66 68 | self.find_graph_output(node.output[0]) PT018.py:65:5: PT018 [*] Assertion should be broken down into multiple parts | @@ -395,21 +251,3 @@ PT018.py:65:5: PT018 [*] Assertion should be broken down into multiple parts 71 | assert (not self.find_graph_output(node.output[0]) or | = help: Break down assertion into multiple parts - -ℹ Unsafe fix -62 62 | or self.find_graph_output(node.input[0]) -63 63 | ) -64 64 | -65 |- assert (not ( - 65 |+ assert not ( -66 66 | self.find_graph_output(node.output[0]) -67 67 | or self.find_graph_input(node.input[0]) -68 |- or self.find_graph_output(node.input[0]) -69 |- )) - 68 |+ ) - 69 |+ assert not ( - 70 |+ self.find_graph_output(node.input[0]) - 71 |+ ) -70 72 | -71 73 | assert (not self.find_graph_output(node.output[0]) or -72 74 | self.find_graph_input(node.input[0])) diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT022.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT022.snap index 33378e77f0007..55b49f6b74548 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT022.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT022.snap @@ -10,7 +10,6 @@ PT022.py:17:5: PT022 [*] No teardown in fixture `error`, use `return` instead of | = help: Replace `yield` with `return` -ℹ Safe fix 14 14 | @pytest.fixture() 15 15 | def error(): 16 16 | resource = acquire_resource() @@ -29,7 +28,6 @@ PT022.py:37:5: PT022 [*] No teardown in fixture `error`, use `return` instead of | = help: Replace `yield` with `return` -ℹ Safe fix 32 32 | 33 33 | 34 34 | @pytest.fixture() @@ -51,7 +49,6 @@ PT022.py:43:5: PT022 [*] No teardown in fixture `error`, use `return` instead of | = help: Replace `yield` with `return` -ℹ Safe fix 38 38 | 39 39 | 40 40 | @pytest.fixture() @@ -60,5 +57,3 @@ PT022.py:43:5: PT022 [*] No teardown in fixture `error`, use `return` instead of 42 42 | resource = acquire_resource() 43 |- yield resource 43 |+ return resource - - diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT023_default.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT023_default.snap index 419dbb107af8b..489d0ac51a6ff 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT023_default.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT023_default.snap @@ -10,7 +10,6 @@ PT023.py:12:1: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo` | = help: Add/remove parentheses -ℹ Safe fix 9 9 | # Without parentheses 10 10 | 11 11 | @@ -29,7 +28,6 @@ PT023.py:17:1: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo` | = help: Add/remove parentheses -ℹ Safe fix 14 14 | pass 15 15 | 16 16 | @@ -49,7 +47,6 @@ PT023.py:24:5: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo` | = help: Add/remove parentheses -ℹ Safe fix 21 21 | 22 22 | 23 23 | class TestClass: @@ -69,7 +66,6 @@ PT023.py:30:5: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo` | = help: Add/remove parentheses -ℹ Safe fix 27 27 | 28 28 | 29 29 | class TestClass: @@ -90,7 +86,6 @@ PT023.py:38:9: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo` | = help: Add/remove parentheses -ℹ Safe fix 35 35 | 36 36 | class TestClass: 37 37 | class TestNestedClass: @@ -98,6 +93,4 @@ PT023.py:38:9: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo` 38 |+ @pytest.mark.foo() 39 39 | def test_something(): 40 40 | pass -41 41 | - - +41 41 | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT023_no_parentheses.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT023_no_parentheses.snap index da77a9ecac2f8..b12d5ffb37364 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT023_no_parentheses.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT023_no_parentheses.snap @@ -10,7 +10,6 @@ PT023.py:46:1: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` | = help: Add/remove parentheses -ℹ Safe fix 43 43 | # With parentheses 44 44 | 45 45 | @@ -29,7 +28,6 @@ PT023.py:51:1: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` | = help: Add/remove parentheses -ℹ Safe fix 48 48 | pass 49 49 | 50 50 | @@ -49,7 +47,6 @@ PT023.py:58:5: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` | = help: Add/remove parentheses -ℹ Safe fix 55 55 | 56 56 | 57 57 | class TestClass: @@ -69,7 +66,6 @@ PT023.py:64:5: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` | = help: Add/remove parentheses -ℹ Safe fix 61 61 | 62 62 | 63 63 | class TestClass: @@ -90,7 +86,6 @@ PT023.py:72:9: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` | = help: Add/remove parentheses -ℹ Safe fix 69 69 | 70 70 | class TestClass: 71 71 | class TestNestedClass: @@ -98,5 +93,3 @@ PT023.py:72:9: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` 72 |+ @pytest.mark.foo 73 73 | def test_something(): 74 74 | pass - - diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT024.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT024.snap index 29707b0e7335a..a05303088e19d 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT024.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT024.snap @@ -10,7 +10,6 @@ PT024.py:14:1: PT024 [*] `pytest.mark.asyncio` is unnecessary for fixtures | = help: Remove `pytest.mark.asyncio` -ℹ Safe fix 11 11 | pass 12 12 | 13 13 | @@ -28,7 +27,6 @@ PT024.py:20:1: PT024 [*] `pytest.mark.asyncio` is unnecessary for fixtures | = help: Remove `pytest.mark.asyncio` -ℹ Safe fix 17 17 | return 0 18 18 | 19 19 | @@ -47,7 +45,6 @@ PT024.py:27:1: PT024 [*] `pytest.mark.asyncio` is unnecessary for fixtures | = help: Remove `pytest.mark.asyncio` -ℹ Safe fix 24 24 | 25 25 | 26 26 | @pytest.fixture() @@ -66,12 +63,9 @@ PT024.py:33:1: PT024 [*] `pytest.mark.asyncio` is unnecessary for fixtures | = help: Remove `pytest.mark.asyncio` -ℹ Safe fix 30 30 | 31 31 | 32 32 | @pytest.fixture() 33 |-@pytest.mark.asyncio 34 33 | async def my_fixture(): # Error after no parens 35 34 | return 0 - - diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT025.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT025.snap index ba4457e915e08..ac3738a2b2158 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT025.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT025.snap @@ -10,7 +10,6 @@ PT025.py:9:1: PT025 [*] `pytest.mark.usefixtures` has no effect on fixtures | = help: Remove `pytest.mark.usefixtures` -ℹ Safe fix 6 6 | pass 7 7 | 8 8 | @@ -29,12 +28,9 @@ PT025.py:16:1: PT025 [*] `pytest.mark.usefixtures` has no effect on fixtures | = help: Remove `pytest.mark.usefixtures` -ℹ Safe fix 13 13 | 14 14 | 15 15 | @pytest.fixture() 16 |-@pytest.mark.usefixtures("a") 17 16 | def my_fixture(): # Error after 18 17 | return 0 - - diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT026.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT026.snap index 8fb8c8d7fe6c1..f53eb9a98210e 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT026.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT026.snap @@ -10,15 +10,6 @@ PT026.py:19:1: PT026 [*] Useless `pytest.mark.usefixtures` without parameters | = help: Remove `usefixtures` decorator or pass parameters -ℹ Unsafe fix -16 16 | pass -17 17 | -18 18 | -19 |-@pytest.mark.usefixtures() - 19 |+ -20 20 | def test_error_with_parens(): -21 21 | pass -22 22 | PT026.py:24:1: PT026 [*] Useless `pytest.mark.usefixtures` without parameters | @@ -28,14 +19,3 @@ PT026.py:24:1: PT026 [*] Useless `pytest.mark.usefixtures` without parameters 26 | pass | = help: Remove `usefixtures` decorator or pass parameters - -ℹ Unsafe fix -21 21 | pass -22 22 | -23 23 | -24 |-@pytest.mark.usefixtures - 24 |+ -25 25 | def test_error_no_parens(): -26 26 | pass - - diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT027_0.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT027_0.snap index 555cfdd5c772b..0923669e2ea7b 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT027_0.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT027_0.snap @@ -12,18 +12,6 @@ PT027_0.py:6:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assert | = help: Replace `assertRaises` with `pytest.raises` -ℹ Unsafe fix -1 1 | import unittest - 2 |+import pytest -2 3 | -3 4 | -4 5 | class Test(unittest.TestCase): -5 6 | def test_errors(self): -6 |- with self.assertRaises(ValueError): - 7 |+ with pytest.raises(ValueError): -7 8 | raise ValueError -8 9 | with self.assertRaises(expected_exception=ValueError): -9 10 | raise ValueError PT027_0.py:8:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaises` | @@ -35,20 +23,6 @@ PT027_0.py:8:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assert | = help: Replace `assertRaises` with `pytest.raises` -ℹ Unsafe fix -1 1 | import unittest - 2 |+import pytest -2 3 | -3 4 | -4 5 | class Test(unittest.TestCase): -5 6 | def test_errors(self): -6 7 | with self.assertRaises(ValueError): -7 8 | raise ValueError -8 |- with self.assertRaises(expected_exception=ValueError): - 9 |+ with pytest.raises(ValueError): -9 10 | raise ValueError -10 11 | -11 12 | with self.failUnlessRaises(ValueError): PT027_0.py:11:14: PT027 [*] Use `pytest.raises` instead of unittest-style `failUnlessRaises` | @@ -60,21 +34,6 @@ PT027_0.py:11:14: PT027 [*] Use `pytest.raises` instead of unittest-style `failU | = help: Replace `failUnlessRaises` with `pytest.raises` -ℹ Unsafe fix -1 1 | import unittest - 2 |+import pytest -2 3 | -3 4 | -4 5 | class Test(unittest.TestCase): --------------------------------------------------------------------------------- -8 9 | with self.assertRaises(expected_exception=ValueError): -9 10 | raise ValueError -10 11 | -11 |- with self.failUnlessRaises(ValueError): - 12 |+ with pytest.raises(ValueError): -12 13 | raise ValueError -13 14 | -14 15 | with self.assertRaisesRegex(ValueError, "test"): PT027_0.py:14:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaisesRegex` | @@ -86,21 +45,6 @@ PT027_0.py:14:14: PT027 [*] Use `pytest.raises` instead of unittest-style `asser | = help: Replace `assertRaisesRegex` with `pytest.raises` -ℹ Unsafe fix -1 1 | import unittest - 2 |+import pytest -2 3 | -3 4 | -4 5 | class Test(unittest.TestCase): --------------------------------------------------------------------------------- -11 12 | with self.failUnlessRaises(ValueError): -12 13 | raise ValueError -13 14 | -14 |- with self.assertRaisesRegex(ValueError, "test"): - 15 |+ with pytest.raises(ValueError, match="test"): -15 16 | raise ValueError("test") -16 17 | -17 18 | with self.assertRaisesRegex(ValueError, expected_regex="test"): PT027_0.py:17:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaisesRegex` | @@ -112,21 +56,6 @@ PT027_0.py:17:14: PT027 [*] Use `pytest.raises` instead of unittest-style `asser | = help: Replace `assertRaisesRegex` with `pytest.raises` -ℹ Unsafe fix -1 1 | import unittest - 2 |+import pytest -2 3 | -3 4 | -4 5 | class Test(unittest.TestCase): --------------------------------------------------------------------------------- -14 15 | with self.assertRaisesRegex(ValueError, "test"): -15 16 | raise ValueError("test") -16 17 | -17 |- with self.assertRaisesRegex(ValueError, expected_regex="test"): - 18 |+ with pytest.raises(ValueError, match="test"): -18 19 | raise ValueError("test") -19 20 | -20 21 | with self.assertRaisesRegex( PT027_0.py:20:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaisesRegex` | @@ -139,23 +68,6 @@ PT027_0.py:20:14: PT027 [*] Use `pytest.raises` instead of unittest-style `asser | = help: Replace `assertRaisesRegex` with `pytest.raises` -ℹ Unsafe fix -1 1 | import unittest - 2 |+import pytest -2 3 | -3 4 | -4 5 | class Test(unittest.TestCase): --------------------------------------------------------------------------------- -17 18 | with self.assertRaisesRegex(ValueError, expected_regex="test"): -18 19 | raise ValueError("test") -19 20 | -20 |- with self.assertRaisesRegex( -21 |- expected_exception=ValueError, expected_regex="test" -22 |- ): - 21 |+ with pytest.raises(ValueError, match="test"): -23 22 | raise ValueError("test") -24 23 | -25 24 | with self.assertRaisesRegex( PT027_0.py:25:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaisesRegex` | @@ -168,23 +80,6 @@ PT027_0.py:25:14: PT027 [*] Use `pytest.raises` instead of unittest-style `asser | = help: Replace `assertRaisesRegex` with `pytest.raises` -ℹ Unsafe fix -1 1 | import unittest - 2 |+import pytest -2 3 | -3 4 | -4 5 | class Test(unittest.TestCase): --------------------------------------------------------------------------------- -22 23 | ): -23 24 | raise ValueError("test") -24 25 | -25 |- with self.assertRaisesRegex( -26 |- expected_regex="test", expected_exception=ValueError -27 |- ): - 26 |+ with pytest.raises(ValueError, match="test"): -28 27 | raise ValueError("test") -29 28 | -30 29 | with self.assertRaisesRegexp(ValueError, "test"): PT027_0.py:30:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaisesRegexp` | @@ -196,21 +91,6 @@ PT027_0.py:30:14: PT027 [*] Use `pytest.raises` instead of unittest-style `asser | = help: Replace `assertRaisesRegexp` with `pytest.raises` -ℹ Unsafe fix -1 1 | import unittest - 2 |+import pytest -2 3 | -3 4 | -4 5 | class Test(unittest.TestCase): --------------------------------------------------------------------------------- -27 28 | ): -28 29 | raise ValueError("test") -29 30 | -30 |- with self.assertRaisesRegexp(ValueError, "test"): - 31 |+ with pytest.raises(ValueError, match="test"): -31 32 | raise ValueError("test") -32 33 | -33 34 | def test_unfixable_errors(self): PT027_0.py:34:14: PT027 Use `pytest.raises` instead of unittest-style `assertRaises` | @@ -244,5 +124,3 @@ PT027_0.py:44:13: PT027 Use `pytest.raises` instead of unittest-style `assertRai 48 | raise ValueError | = help: Replace `assertRaises` with `pytest.raises` - - diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT027_1.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT027_1.snap index cc642fb5d8aa7..8387a9d122f3f 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT027_1.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT027_1.snap @@ -9,13 +9,3 @@ PT027_1.py:11:14: PT027 [*] Use `pytest.raises` instead of unittest-style `asser 12 | raise ValueError | = help: Replace `assertRaises` with `pytest.raises` - -ℹ Unsafe fix -8 8 | raise ValueError -9 9 | -10 10 | def test_errors(self): -11 |- with self.assertRaises(ValueError): - 11 |+ with pytest.raises(ValueError): -12 12 | raise ValueError - - diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_docstring_doubles_all.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_docstring_doubles_all.py.snap index 6a87062097567..0c2bb3a868463 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_docstring_doubles_all.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_docstring_doubles_all.py.snap @@ -10,7 +10,6 @@ doubles_all.py:1:1: Q002 [*] Double quote docstring found but single quotes pref | = help: Replace double quotes docstring with single quotes -ℹ Safe fix 1 |-"""This is a docstring.""" 1 |+'''This is a docstring.''' 2 2 | diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_inline_doubles_all.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_inline_doubles_all.py.snap index 0ca50ac62e93a..a6d86c9465586 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_inline_doubles_all.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_inline_doubles_all.py.snap @@ -12,7 +12,6 @@ doubles_all.py:3:28: Q000 [*] Double quotes found but single quotes preferred | = help: Replace double quotes with single quotes -ℹ Safe fix 1 1 | """This is a docstring.""" 2 2 | 3 |-this_is_an_inline_string = "double quote string" diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_multiline_doubles_all.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_multiline_doubles_all.py.snap index ddffe1bb80a5f..30f93b41d185d 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_multiline_doubles_all.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_multiline_doubles_all.py.snap @@ -13,7 +13,6 @@ doubles_all.py:5:30: Q001 [*] Double quote multiline found but single quotes pre | = help: Replace double multiline quotes with single quotes -ℹ Safe fix 2 2 | 3 3 | this_is_an_inline_string = "double quote string" 4 4 | diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles.py.snap index 771a4ddc2b45d..22759d13b7ff3 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles.py.snap @@ -14,7 +14,6 @@ docstring_doubles.py:5:1: Q001 [*] Double quote multiline found but single quote | = help: Replace double multiline quotes with single quotes -ℹ Safe fix 2 2 | Double quotes multiline module docstring 3 3 | """ 4 4 | @@ -41,7 +40,6 @@ docstring_doubles.py:16:5: Q001 [*] Double quote multiline found but single quot | = help: Replace double multiline quotes with single quotes -ℹ Safe fix 13 13 | Double quotes multiline class docstring 14 14 | """ 15 15 | @@ -66,7 +64,6 @@ docstring_doubles.py:21:21: Q001 [*] Double quote multiline found but single quo | = help: Replace double multiline quotes with single quotes -ℹ Safe fix 18 18 | """ 19 19 | 20 20 | # The colon in the list indexing below is an edge case for the docstring scanner @@ -92,7 +89,6 @@ docstring_doubles.py:30:9: Q001 [*] Double quote multiline found but single quot | = help: Replace double multiline quotes with single quotes -ℹ Safe fix 27 27 | 28 28 | some_expression = 'hello world' 29 29 | @@ -117,7 +113,6 @@ docstring_doubles.py:35:13: Q001 [*] Double quote multiline found but single quo | = help: Replace double multiline quotes with single quotes -ℹ Safe fix 32 32 | """ 33 33 | 34 34 | if l: @@ -127,5 +122,3 @@ docstring_doubles.py:35:13: Q001 [*] Double quote multiline found but single quo 37 |- """ 37 |+ ''' 38 38 | pass - - diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_class.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_class.py.snap index 5eb1e20892926..933d62feb81f4 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_class.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_class.py.snap @@ -12,7 +12,6 @@ docstring_doubles_class.py:3:5: Q001 [*] Double quote multiline found but single | = help: Replace double multiline quotes with single quotes -ℹ Safe fix 1 1 | class SingleLineDocstrings(): 2 2 | """ Double quotes single line class docstring """ 3 |- """ Not a docstring """ @@ -32,7 +31,6 @@ docstring_doubles_class.py:5:23: Q001 [*] Double quote multiline found but singl | = help: Replace double multiline quotes with single quotes -ℹ Safe fix 2 2 | """ Double quotes single line class docstring """ 3 3 | """ Not a docstring """ 4 4 | @@ -40,6 +38,4 @@ docstring_doubles_class.py:5:23: Q001 [*] Double quote multiline found but singl 5 |+ def foo(self, bar='''not a docstring'''): 6 6 | """ Double quotes single line method docstring""" 7 7 | pass -8 8 | - - +8 8 | diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_function.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_function.py.snap index b669528cd7451..afe4f05cef267 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_function.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_function.py.snap @@ -11,7 +11,6 @@ docstring_doubles_function.py:3:5: Q001 [*] Double quote multiline found but sin | = help: Replace double multiline quotes with single quotes -ℹ Safe fix 1 1 | def foo(): 2 2 | """function without params, single line docstring""" 3 |- """ not a docstring""" @@ -30,7 +29,6 @@ docstring_doubles_function.py:11:5: Q001 [*] Double quote multiline found but si | = help: Replace double multiline quotes with single quotes -ℹ Safe fix 8 8 | """ 9 9 | function without params, multiline docstring 10 10 | """ @@ -51,7 +49,6 @@ docstring_doubles_function.py:15:39: Q001 [*] Double quote multiline found but s | = help: Replace double multiline quotes with single quotes -ℹ Safe fix 12 12 | return 13 13 | 14 14 | @@ -74,7 +71,6 @@ docstring_doubles_function.py:17:5: Q001 [*] Double quote multiline found but si | = help: Replace double multiline quotes with single quotes -ℹ Safe fix 14 14 | 15 15 | def fun_with_params_no_docstring(a, b=""" 16 16 | not a @@ -93,7 +89,6 @@ docstring_doubles_function.py:22:5: Q001 [*] Double quote multiline found but si | = help: Replace double multiline quotes with single quotes -ℹ Safe fix 19 19 | 20 20 | 21 21 | def fun_with_params_no_docstring2(a, b=c[foo():], c=\ @@ -101,6 +96,4 @@ docstring_doubles_function.py:22:5: Q001 [*] Double quote multiline found but si 22 |+ ''' not a docstring '''): 23 23 | pass 24 24 | -25 25 | - - +25 25 | diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_module_multiline.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_module_multiline.py.snap index 058c60b92440b..1936be585d442 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_module_multiline.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_module_multiline.py.snap @@ -14,7 +14,6 @@ docstring_doubles_module_multiline.py:4:1: Q001 [*] Double quote multiline found | = help: Replace double multiline quotes with single quotes -ℹ Safe fix 1 1 | """ 2 2 | Double quotes multiline module docstring 3 3 | """ @@ -38,7 +37,6 @@ docstring_doubles_module_multiline.py:9:1: Q001 [*] Double quote multiline found | = help: Replace double multiline quotes with single quotes -ℹ Safe fix 6 6 | """ 7 7 | def foo(): 8 8 | pass @@ -47,5 +45,3 @@ docstring_doubles_module_multiline.py:9:1: Q001 [*] Double quote multiline found 10 10 | this is not a docstring 11 |-""" 11 |+''' - - diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_module_singleline.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_module_singleline.py.snap index 64f43441c8d3a..c37cd3aa5c995 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_module_singleline.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_module_singleline.py.snap @@ -11,7 +11,6 @@ docstring_doubles_module_singleline.py:2:1: Q001 [*] Double quote multiline foun | = help: Replace double multiline quotes with single quotes -ℹ Safe fix 1 1 | """ Double quotes singleline module docstring """ 2 |-""" this is not a docstring """ 2 |+''' this is not a docstring ''' @@ -28,11 +27,8 @@ docstring_doubles_module_singleline.py:6:1: Q001 [*] Double quote multiline foun | = help: Replace double multiline quotes with single quotes -ℹ Safe fix 3 3 | 4 4 | def foo(): 5 5 | pass 6 |-""" this is not a docstring """ 6 |+''' this is not a docstring ''' - - diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles.py.snap index c1c2f2c821599..662cab9336c96 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles.py.snap @@ -12,7 +12,6 @@ docstring_singles.py:1:1: Q002 [*] Single quote docstring found but double quote | = help: Replace single quotes docstring with double quotes -ℹ Safe fix 1 |-''' 1 |+""" 2 2 | Single quotes multiline module docstring @@ -36,7 +35,6 @@ docstring_singles.py:14:5: Q002 [*] Single quote docstring found but double quot | = help: Replace single quotes docstring with double quotes -ℹ Safe fix 11 11 | class Cls(MakeKlass(''' 12 12 | class params \t not a docstring 13 13 | ''')): @@ -63,7 +61,6 @@ docstring_singles.py:26:9: Q002 [*] Single quote docstring found but double quot | = help: Replace single quotes docstring with double quotes -ℹ Safe fix 23 23 | def f(self, bar=''' 24 24 | definitely not a docstring''', 25 25 | val=l[Cls():3]): @@ -74,6 +71,4 @@ docstring_singles.py:26:9: Q002 [*] Single quote docstring found but double quot 28 |+ """ 29 29 | 30 30 | some_expression = 'hello world' -31 31 | - - +31 31 | diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_class.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_class.py.snap index da70df063d6e5..1ea392555614e 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_class.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_class.py.snap @@ -10,7 +10,6 @@ docstring_singles_class.py:2:5: Q002 [*] Single quote docstring found but double | = help: Replace single quotes docstring with double quotes -ℹ Safe fix 1 1 | class SingleLineDocstrings(): 2 |- ''' Double quotes single line class docstring ''' 2 |+ """ Double quotes single line class docstring """ @@ -27,7 +26,6 @@ docstring_singles_class.py:6:9: Q002 [*] Single quote docstring found but double | = help: Replace single quotes docstring with double quotes -ℹ Safe fix 3 3 | ''' Not a docstring ''' 4 4 | 5 5 | def foo(self, bar='''not a docstring'''): @@ -46,11 +44,8 @@ docstring_singles_class.py:9:29: Q002 [*] Single quote docstring found but doubl | = help: Replace single quotes docstring with double quotes -ℹ Safe fix 6 6 | ''' Double quotes single line method docstring''' 7 7 | pass 8 8 | 9 |- class Nested(foo()[:]): ''' inline docstring '''; pass 9 |+ class Nested(foo()[:]): """ inline docstring """; pass - - diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_function.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_function.py.snap index cad7d15422ec7..c73e65d5e1c01 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_function.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_function.py.snap @@ -11,7 +11,6 @@ docstring_singles_function.py:2:5: Q002 [*] Single quote docstring found but dou | = help: Replace single quotes docstring with double quotes -ℹ Safe fix 1 1 | def foo(): 2 |- '''function without params, single line docstring''' 2 |+ """function without params, single line docstring""" @@ -32,7 +31,6 @@ docstring_singles_function.py:8:5: Q002 [*] Single quote docstring found but dou | = help: Replace single quotes docstring with double quotes -ℹ Safe fix 5 5 | 6 6 | 7 7 | def foo2(): @@ -53,7 +51,6 @@ docstring_singles_function.py:27:5: Q002 [*] Single quote docstring found but do | = help: Replace single quotes docstring with double quotes -ℹ Safe fix 24 24 | 25 25 | 26 26 | def function_with_single_docstring(a): @@ -62,5 +59,3 @@ docstring_singles_function.py:27:5: Q002 [*] Single quote docstring found but do 28 28 | 29 29 | 30 30 | def double_inside_single(a): - - diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_class_var_1.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_class_var_1.py.snap index 6d3aeaab93d71..e8730a4ca4920 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_class_var_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_class_var_1.py.snap @@ -19,7 +19,6 @@ docstring_singles_mixed_quotes_class_var_1.py:2:33: Q002 [*] Single quote docstr | = help: Replace single quotes docstring with double quotes -ℹ Safe fix 1 1 | class SingleLineDocstrings(): 2 |- ''"Start with empty string" ' and lint docstring safely' 2 |+ ''"Start with empty string" " and lint docstring safely" @@ -45,7 +44,6 @@ docstring_singles_mixed_quotes_class_var_1.py:6:37: Q002 [*] Single quote docstr | = help: Replace single quotes docstring with double quotes -ℹ Safe fix 3 3 | ''' Not a docstring ''' 4 4 | 5 5 | def foo(self, bar='''not a docstring'''): @@ -73,7 +71,6 @@ docstring_singles_mixed_quotes_class_var_1.py:9:57: Q002 [*] Single quote docstr | = help: Replace single quotes docstring with double quotes -ℹ Safe fix 6 6 | ''"Start with empty string" ' and lint docstring safely' 7 7 | pass 8 8 | diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_class_var_2.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_class_var_2.py.snap index 60ecc511e3e13..132881eb619fd 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_class_var_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_class_var_2.py.snap @@ -10,7 +10,6 @@ docstring_singles_mixed_quotes_class_var_2.py:2:5: Q002 [*] Single quote docstri | = help: Replace single quotes docstring with double quotes -ℹ Safe fix 1 1 | class SingleLineDocstrings(): 2 |- 'Do not'" start with empty string" ' and lint docstring safely' 2 |+ "Do not"" start with empty string" ' and lint docstring safely' @@ -27,7 +26,6 @@ docstring_singles_mixed_quotes_class_var_2.py:2:40: Q002 [*] Single quote docstr | = help: Replace single quotes docstring with double quotes -ℹ Safe fix 1 1 | class SingleLineDocstrings(): 2 |- 'Do not'" start with empty string" ' and lint docstring safely' 2 |+ 'Do not'" start with empty string" " and lint docstring safely" @@ -44,7 +42,6 @@ docstring_singles_mixed_quotes_class_var_2.py:6:9: Q002 [*] Single quote docstri | = help: Replace single quotes docstring with double quotes -ℹ Safe fix 3 3 | ''' Not a docstring ''' 4 4 | 5 5 | def foo(self, bar='''not a docstring'''): @@ -63,7 +60,6 @@ docstring_singles_mixed_quotes_class_var_2.py:6:44: Q002 [*] Single quote docstr | = help: Replace single quotes docstring with double quotes -ℹ Safe fix 3 3 | ''' Not a docstring ''' 4 4 | 5 5 | def foo(self, bar='''not a docstring'''): @@ -82,7 +78,6 @@ docstring_singles_mixed_quotes_class_var_2.py:9:29: Q002 [*] Single quote docstr | = help: Replace single quotes docstring with double quotes -ℹ Safe fix 6 6 | 'Do not'" start with empty string" ' and lint docstring safely' 7 7 | pass 8 8 | @@ -98,7 +93,6 @@ docstring_singles_mixed_quotes_class_var_2.py:9:64: Q002 [*] Single quote docstr | = help: Replace single quotes docstring with double quotes -ℹ Safe fix 6 6 | 'Do not'" start with empty string" ' and lint docstring safely' 7 7 | pass 8 8 | diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_module_singleline_var_1.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_module_singleline_var_1.py.snap index d8a027bcd0919..cc7879f513c1b 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_module_singleline_var_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_module_singleline_var_1.py.snap @@ -19,7 +19,6 @@ docstring_singles_mixed_quotes_module_singleline_var_1.py:1:29: Q002 [*] Single | = help: Replace single quotes docstring with double quotes -ℹ Safe fix 1 |-''"Start with empty string" ' and lint docstring safely' 1 |+''"Start with empty string" " and lint docstring safely" 2 2 | @@ -35,7 +34,6 @@ docstring_singles_mixed_quotes_module_singleline_var_1.py:5:1: Q001 [*] Double q | = help: Replace double multiline quotes with single quotes -ℹ Safe fix 2 2 | 3 3 | def foo(): 4 4 | pass diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_module_singleline_var_2.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_module_singleline_var_2.py.snap index 5ffafe0ffd2b6..dd03d90af373f 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_module_singleline_var_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_module_singleline_var_2.py.snap @@ -10,7 +10,6 @@ docstring_singles_mixed_quotes_module_singleline_var_2.py:1:1: Q002 [*] Single q | = help: Replace single quotes docstring with double quotes -ℹ Safe fix 1 |-'Do not'" start with empty string" ' and lint docstring safely' 1 |+"Do not"" start with empty string" ' and lint docstring safely' 2 2 | @@ -26,7 +25,6 @@ docstring_singles_mixed_quotes_module_singleline_var_2.py:1:36: Q002 [*] Single | = help: Replace single quotes docstring with double quotes -ℹ Safe fix 1 |-'Do not'" start with empty string" ' and lint docstring safely' 1 |+'Do not'" start with empty string" " and lint docstring safely" 2 2 | @@ -42,7 +40,6 @@ docstring_singles_mixed_quotes_module_singleline_var_2.py:5:1: Q001 [*] Double q | = help: Replace double multiline quotes with single quotes -ℹ Safe fix 2 2 | 3 3 | def foo(): 4 4 | pass diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_module_multiline.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_module_multiline.py.snap index 3924f21233c1f..22daa9d2756a8 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_module_multiline.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_module_multiline.py.snap @@ -12,7 +12,6 @@ docstring_singles_module_multiline.py:1:1: Q002 [*] Single quote docstring found | = help: Replace single quotes docstring with double quotes -ℹ Safe fix 1 |-''' 1 |+""" 2 2 | Double quotes multiline module docstring @@ -21,5 +20,3 @@ docstring_singles_module_multiline.py:1:1: Q002 [*] Single quote docstring found 4 4 | ''' 5 5 | this is not a docstring 6 6 | ''' - - diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_module_singleline.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_module_singleline.py.snap index c1c3012212b24..0da94c050ba7a 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_module_singleline.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_module_singleline.py.snap @@ -9,11 +9,8 @@ docstring_singles_module_singleline.py:1:1: Q002 [*] Single quote docstring foun | = help: Replace single quotes docstring with double quotes -ℹ Safe fix 1 |-''' Double quotes singleline module docstring ''' 1 |+""" Double quotes singleline module docstring """ 2 2 | ''' this is not a docstring ''' 3 3 | 4 4 | def foo(): - - diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles.py.snap index 8e031c7aab323..283c2483c6421 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles.py.snap @@ -12,7 +12,6 @@ docstring_doubles.py:1:1: Q002 [*] Double quote docstring found but single quote | = help: Replace double quotes docstring with single quotes -ℹ Safe fix 1 |-""" 1 |+''' 2 2 | Double quotes multiline module docstring @@ -35,7 +34,6 @@ docstring_doubles.py:12:5: Q002 [*] Double quote docstring found but single quot | = help: Replace double quotes docstring with single quotes -ℹ Safe fix 9 9 | l = [] 10 10 | 11 11 | class Cls: @@ -62,7 +60,6 @@ docstring_doubles.py:24:9: Q002 [*] Double quote docstring found but single quot | = help: Replace double quotes docstring with single quotes -ℹ Safe fix 21 21 | def f(self, bar=""" 22 22 | definitely not a docstring""", 23 23 | val=l[Cls():3]): @@ -73,6 +70,4 @@ docstring_doubles.py:24:9: Q002 [*] Double quote docstring found but single quot 26 |+ ''' 27 27 | 28 28 | some_expression = 'hello world' -29 29 | - - +29 29 | diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_class.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_class.py.snap index 18e358b897580..d93c335700506 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_class.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_class.py.snap @@ -10,7 +10,6 @@ docstring_doubles_class.py:2:5: Q002 [*] Double quote docstring found but single | = help: Replace double quotes docstring with single quotes -ℹ Safe fix 1 1 | class SingleLineDocstrings(): 2 |- """ Double quotes single line class docstring """ 2 |+ ''' Double quotes single line class docstring ''' @@ -27,7 +26,6 @@ docstring_doubles_class.py:6:9: Q002 [*] Double quote docstring found but single | = help: Replace double quotes docstring with single quotes -ℹ Safe fix 3 3 | """ Not a docstring """ 4 4 | 5 5 | def foo(self, bar="""not a docstring"""): @@ -46,11 +44,8 @@ docstring_doubles_class.py:9:29: Q002 [*] Double quote docstring found but singl | = help: Replace double quotes docstring with single quotes -ℹ Safe fix 6 6 | """ Double quotes single line method docstring""" 7 7 | pass 8 8 | 9 |- class Nested(foo()[:]): """ inline docstring """; pass 9 |+ class Nested(foo()[:]): ''' inline docstring '''; pass - - diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_function.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_function.py.snap index 3758fc2a7bd1b..62c1fec0a3ba2 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_function.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_function.py.snap @@ -11,7 +11,6 @@ docstring_doubles_function.py:2:5: Q002 [*] Double quote docstring found but sin | = help: Replace double quotes docstring with single quotes -ℹ Safe fix 1 1 | def foo(): 2 |- """function without params, single line docstring""" 2 |+ '''function without params, single line docstring''' @@ -32,7 +31,6 @@ docstring_doubles_function.py:8:5: Q002 [*] Double quote docstring found but sin | = help: Replace double quotes docstring with single quotes -ℹ Safe fix 5 5 | 6 6 | 7 7 | def foo2(): @@ -53,7 +51,6 @@ docstring_doubles_function.py:27:5: Q002 [*] Double quote docstring found but si | = help: Replace double quotes docstring with single quotes -ℹ Safe fix 24 24 | 25 25 | 26 26 | def function_with_single_docstring(a): @@ -62,5 +59,3 @@ docstring_doubles_function.py:27:5: Q002 [*] Double quote docstring found but si 28 28 | 29 29 | 30 30 | def double_inside_single(a): - - diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_class_var_2.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_class_var_2.py.snap index e02c3c17c1e3e..ac71c3259f667 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_class_var_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_class_var_2.py.snap @@ -10,7 +10,6 @@ docstring_doubles_mixed_quotes_class_var_2.py:2:5: Q002 [*] Double quote docstri | = help: Replace double quotes docstring with single quotes -ℹ Safe fix 1 1 | class SingleLineDocstrings(): 2 |- "Do not"' start with empty string' ' and lint docstring safely' 2 |+ 'Do not'' start with empty string' ' and lint docstring safely' @@ -27,7 +26,6 @@ docstring_doubles_mixed_quotes_class_var_2.py:6:9: Q002 [*] Double quote docstri | = help: Replace double quotes docstring with single quotes -ℹ Safe fix 3 3 | """ Not a docstring """ 4 4 | 5 5 | def foo(self, bar="""not a docstring"""): @@ -46,7 +44,6 @@ docstring_doubles_mixed_quotes_class_var_2.py:9:29: Q002 [*] Double quote docstr | = help: Replace double quotes docstring with single quotes -ℹ Safe fix 6 6 | "Do not"' start with empty string' ' and lint docstring safely' 7 7 | pass 8 8 | diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_module_singleline_var_2.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_module_singleline_var_2.py.snap index 31efd169aff73..2e99077b01ec2 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_module_singleline_var_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_module_singleline_var_2.py.snap @@ -10,7 +10,6 @@ docstring_doubles_mixed_quotes_module_singleline_var_2.py:1:1: Q002 [*] Double q | = help: Replace double quotes docstring with single quotes -ℹ Safe fix 1 |-"Do not"' start with empty string' ' and lint docstring safely' 1 |+'Do not'' start with empty string' ' and lint docstring safely' 2 2 | diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_module_multiline.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_module_multiline.py.snap index f66291915dcde..06be325d4916e 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_module_multiline.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_module_multiline.py.snap @@ -12,7 +12,6 @@ docstring_doubles_module_multiline.py:1:1: Q002 [*] Double quote docstring found | = help: Replace double quotes docstring with single quotes -ℹ Safe fix 1 |-""" 1 |+''' 2 2 | Double quotes multiline module docstring @@ -21,5 +20,3 @@ docstring_doubles_module_multiline.py:1:1: Q002 [*] Double quote docstring found 4 4 | """ 5 5 | this is not a docstring 6 6 | """ - - diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_module_singleline.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_module_singleline.py.snap index 025add5fdd0bc..c1be22b069894 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_module_singleline.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_module_singleline.py.snap @@ -9,11 +9,8 @@ docstring_doubles_module_singleline.py:1:1: Q002 [*] Double quote docstring foun | = help: Replace double quotes docstring with single quotes -ℹ Safe fix 1 |-""" Double quotes singleline module docstring """ 1 |+''' Double quotes singleline module docstring ''' 2 2 | """ this is not a docstring """ 3 3 | 4 4 | def foo(): - - diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles.py.snap index 2a790da62fac4..a508f5360bab1 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles.py.snap @@ -14,7 +14,6 @@ docstring_singles.py:5:1: Q001 [*] Single quote multiline found but double quote | = help: Replace single multiline quotes with double quotes -ℹ Safe fix 2 2 | Single quotes multiline module docstring 3 3 | ''' 4 4 | @@ -41,7 +40,6 @@ docstring_singles.py:11:21: Q001 [*] Single quote multiline found but double quo | = help: Replace single multiline quotes with double quotes -ℹ Safe fix 8 8 | 9 9 | l = [] 10 10 | @@ -68,7 +66,6 @@ docstring_singles.py:18:5: Q001 [*] Single quote multiline found but double quot | = help: Replace single multiline quotes with double quotes -ℹ Safe fix 15 15 | Single quotes multiline class docstring 16 16 | ''' 17 17 | @@ -93,7 +90,6 @@ docstring_singles.py:23:21: Q001 [*] Single quote multiline found but double quo | = help: Replace single multiline quotes with double quotes -ℹ Safe fix 20 20 | ''' 21 21 | 22 22 | # The colon in the list indexing below is an edge case for the docstring scanner @@ -119,7 +115,6 @@ docstring_singles.py:32:9: Q001 [*] Single quote multiline found but double quot | = help: Replace single multiline quotes with double quotes -ℹ Safe fix 29 29 | 30 30 | some_expression = 'hello world' 31 31 | @@ -144,7 +139,6 @@ docstring_singles.py:37:13: Q001 [*] Single quote multiline found but double quo | = help: Replace single multiline quotes with double quotes -ℹ Safe fix 34 34 | ''' 35 35 | 36 36 | if l: @@ -154,5 +148,3 @@ docstring_singles.py:37:13: Q001 [*] Single quote multiline found but double quo 39 |- ''' 39 |+ """ 40 40 | pass - - diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_class.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_class.py.snap index a3a5bcf66ec88..2f1e42198ab79 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_class.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_class.py.snap @@ -12,7 +12,6 @@ docstring_singles_class.py:3:5: Q001 [*] Single quote multiline found but double | = help: Replace single multiline quotes with double quotes -ℹ Safe fix 1 1 | class SingleLineDocstrings(): 2 2 | ''' Double quotes single line class docstring ''' 3 |- ''' Not a docstring ''' @@ -32,7 +31,6 @@ docstring_singles_class.py:5:23: Q001 [*] Single quote multiline found but doubl | = help: Replace single multiline quotes with double quotes -ℹ Safe fix 2 2 | ''' Double quotes single line class docstring ''' 3 3 | ''' Not a docstring ''' 4 4 | @@ -40,6 +38,4 @@ docstring_singles_class.py:5:23: Q001 [*] Single quote multiline found but doubl 5 |+ def foo(self, bar="""not a docstring"""): 6 6 | ''' Double quotes single line method docstring''' 7 7 | pass -8 8 | - - +8 8 | diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_function.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_function.py.snap index afede01c5e111..877994a441dda 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_function.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_function.py.snap @@ -11,7 +11,6 @@ docstring_singles_function.py:3:5: Q001 [*] Single quote multiline found but dou | = help: Replace single multiline quotes with double quotes -ℹ Safe fix 1 1 | def foo(): 2 2 | '''function without params, single line docstring''' 3 |- ''' not a docstring''' @@ -30,7 +29,6 @@ docstring_singles_function.py:11:5: Q001 [*] Single quote multiline found but do | = help: Replace single multiline quotes with double quotes -ℹ Safe fix 8 8 | ''' 9 9 | function without params, multiline docstring 10 10 | ''' @@ -51,7 +49,6 @@ docstring_singles_function.py:15:39: Q001 [*] Single quote multiline found but d | = help: Replace single multiline quotes with double quotes -ℹ Safe fix 12 12 | return 13 13 | 14 14 | @@ -74,7 +71,6 @@ docstring_singles_function.py:17:5: Q001 [*] Single quote multiline found but do | = help: Replace single multiline quotes with double quotes -ℹ Safe fix 14 14 | 15 15 | def fun_with_params_no_docstring(a, b=''' 16 16 | not a @@ -93,7 +89,6 @@ docstring_singles_function.py:22:5: Q001 [*] Single quote multiline found but do | = help: Replace single multiline quotes with double quotes -ℹ Safe fix 19 19 | 20 20 | 21 21 | def fun_with_params_no_docstring2(a, b=c[foo():], c=\ @@ -101,6 +96,4 @@ docstring_singles_function.py:22:5: Q001 [*] Single quote multiline found but do 22 |+ """ not a docstring """): 23 23 | pass 24 24 | -25 25 | - - +25 25 | diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_module_multiline.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_module_multiline.py.snap index 3cefd7eb4a27a..dbd7badb95500 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_module_multiline.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_module_multiline.py.snap @@ -14,7 +14,6 @@ docstring_singles_module_multiline.py:4:1: Q001 [*] Single quote multiline found | = help: Replace single multiline quotes with double quotes -ℹ Safe fix 1 1 | ''' 2 2 | Double quotes multiline module docstring 3 3 | ''' @@ -38,7 +37,6 @@ docstring_singles_module_multiline.py:9:1: Q001 [*] Single quote multiline found | = help: Replace single multiline quotes with double quotes -ℹ Safe fix 6 6 | ''' 7 7 | def foo(): 8 8 | pass @@ -47,5 +45,3 @@ docstring_singles_module_multiline.py:9:1: Q001 [*] Single quote multiline found 10 10 | this is not a docstring 11 |-''' 11 |+""" - - diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_module_singleline.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_module_singleline.py.snap index f92fff71dba70..2db9abdf142b5 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_module_singleline.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_module_singleline.py.snap @@ -11,7 +11,6 @@ docstring_singles_module_singleline.py:2:1: Q001 [*] Single quote multiline foun | = help: Replace single multiline quotes with double quotes -ℹ Safe fix 1 1 | ''' Double quotes singleline module docstring ''' 2 |-''' this is not a docstring ''' 2 |+""" this is not a docstring """ @@ -28,11 +27,8 @@ docstring_singles_module_singleline.py:6:1: Q001 [*] Single quote multiline foun | = help: Replace single multiline quotes with double quotes -ℹ Safe fix 3 3 | 4 4 | def foo(): 5 5 | pass 6 |-''' this is not a docstring ''' 6 |+""" this is not a docstring """ - - diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles.py.snap index 81b0fdf4da700..4201889023305 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles.py.snap @@ -10,7 +10,6 @@ singles.py:1:25: Q000 [*] Single quotes found but double quotes preferred | = help: Replace single quotes with double quotes -ℹ Safe fix 1 |-this_should_be_linted = 'single quote string' 1 |+this_should_be_linted = "single quote string" 2 2 | this_should_be_linted = u'double quote string' @@ -27,7 +26,6 @@ singles.py:2:25: Q000 [*] Single quotes found but double quotes preferred | = help: Replace single quotes with double quotes -ℹ Safe fix 1 1 | this_should_be_linted = 'single quote string' 2 |-this_should_be_linted = u'double quote string' 2 |+this_should_be_linted = u"double quote string" @@ -45,7 +43,6 @@ singles.py:3:25: Q000 [*] Single quotes found but double quotes preferred | = help: Replace single quotes with double quotes -ℹ Safe fix 1 1 | this_should_be_linted = 'single quote string' 2 2 | this_should_be_linted = u'double quote string' 3 |-this_should_be_linted = f'double quote string' diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped.py.snap index 4cc1920e73b72..46993510447d5 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped.py.snap @@ -10,7 +10,6 @@ singles_escaped.py:1:26: Q003 [*] Change outer quotes to avoid escaping inner qu | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 1 |-this_should_raise_Q003 = "This is a \"string\"" 1 |+this_should_raise_Q003 = 'This is a "string"' 2 2 | this_is_fine = "'This' is a \"string\"" @@ -27,7 +26,6 @@ singles_escaped.py:9:5: Q003 [*] Change outer quotes to avoid escaping inner quo | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 6 6 | this_is_fine = R"This is a \"string\"" 7 7 | this_should_raise = ( 8 8 | "This is a" @@ -47,7 +45,6 @@ singles_escaped.py:13:1: Q003 [*] Change outer quotes to avoid escaping inner qu | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 10 10 | ) 11 11 | 12 12 | # Same as above, but with f-strings @@ -67,7 +64,6 @@ singles_escaped.py:21:5: Q003 [*] Change outer quotes to avoid escaping inner qu | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 18 18 | fR"This is a \"string\"" 19 19 | foo = ( 20 20 | f"This is a" @@ -88,7 +84,6 @@ singles_escaped.py:31:1: Q003 [*] Change outer quotes to avoid escaping inner qu | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 28 28 | # f'"foo" {"nested"}' 29 29 | # 30 30 | # but as the actual string itself is invalid pre 3.12, we don't catch it. @@ -108,7 +103,6 @@ singles_escaped.py:32:1: Q003 [*] Change outer quotes to avoid escaping inner qu | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 29 29 | # 30 30 | # but as the actual string itself is invalid pre 3.12, we don't catch it. 31 31 | f"\"foo\" {"foo"}" # Q003 @@ -129,7 +123,6 @@ singles_escaped.py:33:1: Q003 [*] Change outer quotes to avoid escaping inner qu | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 30 30 | # but as the actual string itself is invalid pre 3.12, we don't catch it. 31 31 | f"\"foo\" {"foo"}" # Q003 32 32 | f"\"foo\" {f"foo"}" # Q003 @@ -150,7 +143,6 @@ singles_escaped.py:33:12: Q003 [*] Change outer quotes to avoid escaping inner q | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 30 30 | # but as the actual string itself is invalid pre 3.12, we don't catch it. 31 31 | f"\"foo\" {"foo"}" # Q003 32 32 | f"\"foo\" {f"foo"}" # Q003 @@ -170,7 +162,6 @@ singles_escaped.py:36:1: Q003 [*] Change outer quotes to avoid escaping inner qu | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 33 33 | f"\"foo\" {f"\"foo\""} \"\"" # Q003 34 34 | 35 35 | f"normal {f"nested"} normal" @@ -190,7 +181,6 @@ singles_escaped.py:38:15: Q003 [*] Change outer quotes to avoid escaping inner q | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 35 35 | f"normal {f"nested"} normal" 36 36 | f"\"normal\" {f"nested"} normal" # Q003 37 37 | f"\"normal\" {f"nested"} 'single quotes'" @@ -207,11 +197,8 @@ singles_escaped.py:39:1: Q003 [*] Change outer quotes to avoid escaping inner qu | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 36 36 | f"\"normal\" {f"nested"} normal" # Q003 37 37 | f"\"normal\" {f"nested"} 'single quotes'" 38 38 | f"\"normal\" {f"\"nested\" {"other"} normal"} 'single quotes'" # Q003 39 |-f"\"normal\" {f"\"nested\" {"other"} 'single quotes'"} normal" # Q003 39 |+f'"normal" {f"\"nested\" {"other"} 'single quotes'"} normal' # Q003 - - diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped_py311.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped_py311.snap index e3d039ba634e7..ff59285296e73 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped_py311.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped_py311.snap @@ -10,7 +10,6 @@ singles_escaped.py:1:26: Q003 [*] Change outer quotes to avoid escaping inner qu | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 1 |-this_should_raise_Q003 = "This is a \"string\"" 1 |+this_should_raise_Q003 = 'This is a "string"' 2 2 | this_is_fine = "'This' is a \"string\"" @@ -27,7 +26,6 @@ singles_escaped.py:9:5: Q003 [*] Change outer quotes to avoid escaping inner quo | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 6 6 | this_is_fine = R"This is a \"string\"" 7 7 | this_should_raise = ( 8 8 | "This is a" @@ -47,7 +45,6 @@ singles_escaped.py:13:1: Q003 [*] Change outer quotes to avoid escaping inner qu | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 10 10 | ) 11 11 | 12 12 | # Same as above, but with f-strings @@ -67,7 +64,6 @@ singles_escaped.py:21:5: Q003 [*] Change outer quotes to avoid escaping inner qu | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 18 18 | fR"This is a \"string\"" 19 19 | foo = ( 20 20 | f"This is a" @@ -76,5 +72,3 @@ singles_escaped.py:21:5: Q003 [*] Change outer quotes to avoid escaping inner qu 22 22 | ) 23 23 | 24 24 | # Nested f-strings (Python 3.12+) - - diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped_unnecessary.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped_unnecessary.py.snap index 5408f3962565a..8d76df92468b5 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped_unnecessary.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped_unnecessary.py.snap @@ -10,7 +10,6 @@ singles_escaped_unnecessary.py:1:26: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 1 |-this_should_raise_Q004 = "This is a \'string\'" 1 |+this_should_raise_Q004 = "This is a 'string'" 2 2 | this_should_raise_Q004 = "'This' is a \'string\'" @@ -27,7 +26,6 @@ singles_escaped_unnecessary.py:2:26: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 1 1 | this_should_raise_Q004 = "This is a \'string\'" 2 |-this_should_raise_Q004 = "'This' is a \'string\'" 2 |+this_should_raise_Q004 = "'This' is a 'string'" @@ -45,7 +43,6 @@ singles_escaped_unnecessary.py:9:5: Q004 [*] Unnecessary escape on inner quote c | = help: Remove backslash -ℹ Safe fix 6 6 | this_is_fine = R"This is a \'string\'" 7 7 | this_should_raise_Q004 = ( 8 8 | "This is a" @@ -65,7 +62,6 @@ singles_escaped_unnecessary.py:13:1: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 10 10 | ) 11 11 | 12 12 | # Same as above, but with f-strings @@ -86,7 +82,6 @@ singles_escaped_unnecessary.py:14:1: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 11 11 | 12 12 | # Same as above, but with f-strings 13 13 | f"This is a \'string\'" # Q004 @@ -106,7 +101,6 @@ singles_escaped_unnecessary.py:21:5: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 18 18 | fR"This is a \'string\'" 19 19 | this_should_raise_Q004 = ( 20 20 | f"This is a" @@ -127,7 +121,6 @@ singles_escaped_unnecessary.py:31:1: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 28 28 | # f'"foo" {"nested"}' 29 29 | # 30 30 | # but as the actual string itself is invalid pre 3.12, we don't catch it. @@ -147,7 +140,6 @@ singles_escaped_unnecessary.py:32:1: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 29 29 | # 30 30 | # but as the actual string itself is invalid pre 3.12, we don't catch it. 31 31 | f"\'foo\' {"foo"}" # Q004 @@ -168,7 +160,6 @@ singles_escaped_unnecessary.py:33:1: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 30 30 | # but as the actual string itself is invalid pre 3.12, we don't catch it. 31 31 | f"\'foo\' {"foo"}" # Q004 32 32 | f"\'foo\' {f"foo"}" # Q004 @@ -189,7 +180,6 @@ singles_escaped_unnecessary.py:33:12: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 30 30 | # but as the actual string itself is invalid pre 3.12, we don't catch it. 31 31 | f"\'foo\' {"foo"}" # Q004 32 32 | f"\'foo\' {f"foo"}" # Q004 @@ -209,7 +199,6 @@ singles_escaped_unnecessary.py:36:1: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 33 33 | f"\'foo\' {f"\'foo\'"} \'\'" # Q004 34 34 | 35 35 | f"normal {f"nested"} normal" @@ -230,7 +219,6 @@ singles_escaped_unnecessary.py:37:1: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 34 34 | 35 35 | f"normal {f"nested"} normal" 36 36 | f"\'normal\' {f"nested"} normal" # Q004 @@ -250,7 +238,6 @@ singles_escaped_unnecessary.py:38:1: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 35 35 | f"normal {f"nested"} normal" 36 36 | f"\'normal\' {f"nested"} normal" # Q004 37 37 | f"\'normal\' {f"nested"} 'single quotes'" @@ -270,7 +257,6 @@ singles_escaped_unnecessary.py:38:15: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 35 35 | f"normal {f"nested"} normal" 36 36 | f"\'normal\' {f"nested"} normal" # Q004 37 37 | f"\'normal\' {f"nested"} 'single quotes'" @@ -291,7 +277,6 @@ singles_escaped_unnecessary.py:39:1: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 36 36 | f"\'normal\' {f"nested"} normal" # Q004 37 37 | f"\'normal\' {f"nested"} 'single quotes'" 38 38 | f"\'normal\' {f"\'nested\' {"other"} normal"} 'single quotes'" # Q004 @@ -312,7 +297,6 @@ singles_escaped_unnecessary.py:39:15: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 36 36 | f"\'normal\' {f"nested"} normal" # Q004 37 37 | f"\'normal\' {f"nested"} 'single quotes'" 38 38 | f"\'normal\' {f"\'nested\' {"other"} normal"} 'single quotes'" # Q004 @@ -333,7 +317,6 @@ singles_escaped_unnecessary.py:43:26: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 40 40 | 41 41 | # Make sure we do not unescape quotes 42 42 | this_is_fine = "This is an \\'escaped\\' quote" @@ -351,7 +334,6 @@ singles_escaped_unnecessary.py:46:5: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 43 43 | this_should_raise_Q004 = "This is an \\\'escaped\\\' quote with an extra backslash" # Q004 44 44 | 45 45 | # Invalid escapes in bytestrings are also triggered: diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_implicit.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_implicit.py.snap index e85c35c669cf9..bcee6ae217bda 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_implicit.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_implicit.py.snap @@ -11,7 +11,6 @@ singles_implicit.py:2:5: Q000 [*] Single quotes found but double quotes preferre | = help: Replace single quotes with double quotes -ℹ Safe fix 1 1 | x = ( 2 |- 'This' 2 |+ "This" @@ -30,7 +29,6 @@ singles_implicit.py:3:5: Q000 [*] Single quotes found but double quotes preferre | = help: Replace single quotes with double quotes -ℹ Safe fix 1 1 | x = ( 2 2 | 'This' 3 |- 'is' @@ -49,7 +47,6 @@ singles_implicit.py:4:5: Q000 [*] Single quotes found but double quotes preferre | = help: Replace single quotes with double quotes -ℹ Safe fix 1 1 | x = ( 2 2 | 'This' 3 3 | 'is' @@ -69,7 +66,6 @@ singles_implicit.py:8:5: Q000 [*] Single quotes found but double quotes preferre | = help: Replace single quotes with double quotes -ℹ Safe fix 5 5 | ) 6 6 | 7 7 | x = ( @@ -90,7 +86,6 @@ singles_implicit.py:9:5: Q000 [*] Single quotes found but double quotes preferre | = help: Replace single quotes with double quotes -ℹ Safe fix 6 6 | 7 7 | x = ( 8 8 | 'This' \ @@ -110,7 +105,6 @@ singles_implicit.py:10:5: Q000 [*] Single quotes found but double quotes preferr | = help: Replace single quotes with double quotes -ℹ Safe fix 7 7 | x = ( 8 8 | 'This' \ 9 9 | 'is' \ @@ -129,11 +123,8 @@ singles_implicit.py:27:1: Q000 [*] Single quotes found but double quotes preferr | = help: Replace single quotes with double quotes -ℹ Safe fix 24 24 | 25 25 | if True: 26 26 | 'This can use "single" quotes' 27 |-'But this needs to be changed' 27 |+"But this needs to be changed" - - diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_multiline_string.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_multiline_string.py.snap index 3fdadee4d83e4..53a2c785f3210 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_multiline_string.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_multiline_string.py.snap @@ -13,7 +13,6 @@ singles_multiline_string.py:1:5: Q001 [*] Single quote multiline found but doubl | = help: Replace single multiline quotes with double quotes -ℹ Safe fix 1 |-s = ''' This 'should' 1 |+s = """ This 'should' 2 2 | be @@ -22,5 +21,3 @@ singles_multiline_string.py:1:5: Q001 [*] Single quote multiline found but doubl 4 4 | 5 5 | s = """ This 'should' 6 6 | 'not' be - - diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_would_be_triple_quotes.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_would_be_triple_quotes.py.snap index 3c5b35cd44202..0db76851b068c 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_would_be_triple_quotes.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_would_be_triple_quotes.py.snap @@ -17,7 +17,6 @@ singles_would_be_triple_quotes.py:1:33: Q000 [*] Single quotes found but double | = help: Replace single quotes with double quotes -ℹ Safe fix 1 |-s = ''"Start with empty string" ' and lint docstring safely' 1 |+s = ''"Start with empty string" " and lint docstring safely" 2 2 | s = 'Do not'" start with empty string" ' and lint docstring safely' @@ -30,7 +29,6 @@ singles_would_be_triple_quotes.py:2:5: Q000 [*] Single quotes found but double q | = help: Replace single quotes with double quotes -ℹ Safe fix 1 1 | s = ''"Start with empty string" ' and lint docstring safely' 2 |-s = 'Do not'" start with empty string" ' and lint docstring safely' 2 |+s = "Do not"" start with empty string" ' and lint docstring safely' @@ -43,7 +41,6 @@ singles_would_be_triple_quotes.py:2:40: Q000 [*] Single quotes found but double | = help: Replace single quotes with double quotes -ℹ Safe fix 1 1 | s = ''"Start with empty string" ' and lint docstring safely' 2 |-s = 'Do not'" start with empty string" ' and lint docstring safely' 2 |+s = 'Do not'" start with empty string" " and lint docstring safely" diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles.py.snap index 594f620909e59..59cf683bee285 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles.py.snap @@ -10,7 +10,6 @@ doubles.py:1:25: Q000 [*] Double quotes found but single quotes preferred | = help: Replace double quotes with single quotes -ℹ Safe fix 1 |-this_should_be_linted = "double quote string" 1 |+this_should_be_linted = 'double quote string' 2 2 | this_should_be_linted = u"double quote string" @@ -27,7 +26,6 @@ doubles.py:2:25: Q000 [*] Double quotes found but single quotes preferred | = help: Replace double quotes with single quotes -ℹ Safe fix 1 1 | this_should_be_linted = "double quote string" 2 |-this_should_be_linted = u"double quote string" 2 |+this_should_be_linted = u'double quote string' @@ -44,11 +42,8 @@ doubles.py:3:25: Q000 [*] Double quotes found but single quotes preferred | = help: Replace double quotes with single quotes -ℹ Safe fix 1 1 | this_should_be_linted = "double quote string" 2 2 | this_should_be_linted = u"double quote string" 3 |-this_should_be_linted = f"double quote string" 3 |+this_should_be_linted = f'double quote string' 4 4 | this_should_be_linted = f"double {'quote'} string" - - diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped.py.snap index e93b1aab9a1b3..718db1258a20c 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped.py.snap @@ -10,7 +10,6 @@ doubles_escaped.py:1:26: Q003 [*] Change outer quotes to avoid escaping inner qu | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 1 |-this_should_raise_Q003 = 'This is a \'string\'' 1 |+this_should_raise_Q003 = "This is a 'string'" 2 2 | this_should_raise_Q003 = 'This is \\ a \\\'string\'' @@ -27,7 +26,6 @@ doubles_escaped.py:2:26: Q003 [*] Change outer quotes to avoid escaping inner qu | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 1 1 | this_should_raise_Q003 = 'This is a \'string\'' 2 |-this_should_raise_Q003 = 'This is \\ a \\\'string\'' 2 |+this_should_raise_Q003 = "This is \\ a \\'string'" @@ -45,7 +43,6 @@ doubles_escaped.py:10:5: Q003 [*] Change outer quotes to avoid escaping inner qu | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 7 7 | this_is_fine = R'This is a \'string\'' 8 8 | this_should_raise = ( 9 9 | 'This is a' @@ -65,7 +62,6 @@ doubles_escaped.py:14:1: Q003 [*] Change outer quotes to avoid escaping inner qu | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 11 11 | ) 12 12 | 13 13 | # Same as above, but with f-strings @@ -86,7 +82,6 @@ doubles_escaped.py:15:1: Q003 [*] Change outer quotes to avoid escaping inner qu | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 12 12 | 13 13 | # Same as above, but with f-strings 14 14 | f'This is a \'string\'' # Q003 @@ -106,7 +101,6 @@ doubles_escaped.py:23:5: Q003 [*] Change outer quotes to avoid escaping inner qu | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 20 20 | fR'This is a \'string\'' 21 21 | foo = ( 22 22 | f'This is a' @@ -127,7 +121,6 @@ doubles_escaped.py:33:1: Q003 [*] Change outer quotes to avoid escaping inner qu | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 30 30 | # f"'foo' {'nested'}" 31 31 | # 32 32 | # but as the actual string itself is invalid pre 3.12, we don't catch it. @@ -147,7 +140,6 @@ doubles_escaped.py:34:1: Q003 [*] Change outer quotes to avoid escaping inner qu | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 31 31 | # 32 32 | # but as the actual string itself is invalid pre 3.12, we don't catch it. 33 33 | f'\'foo\' {'nested'}' # Q003 @@ -168,7 +160,6 @@ doubles_escaped.py:35:1: Q003 [*] Change outer quotes to avoid escaping inner qu | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 32 32 | # but as the actual string itself is invalid pre 3.12, we don't catch it. 33 33 | f'\'foo\' {'nested'}' # Q003 34 34 | f'\'foo\' {f'nested'}' # Q003 @@ -189,7 +180,6 @@ doubles_escaped.py:35:12: Q003 [*] Change outer quotes to avoid escaping inner q | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 32 32 | # but as the actual string itself is invalid pre 3.12, we don't catch it. 33 33 | f'\'foo\' {'nested'}' # Q003 34 34 | f'\'foo\' {f'nested'}' # Q003 @@ -209,7 +199,6 @@ doubles_escaped.py:38:1: Q003 [*] Change outer quotes to avoid escaping inner qu | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 35 35 | f'\'foo\' {f'\'nested\''} \'\'' # Q003 36 36 | 37 37 | f'normal {f'nested'} normal' @@ -229,7 +218,6 @@ doubles_escaped.py:40:15: Q003 [*] Change outer quotes to avoid escaping inner q | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 37 37 | f'normal {f'nested'} normal' 38 38 | f'\'normal\' {f'nested'} normal' # Q003 39 39 | f'\'normal\' {f'nested'} "double quotes"' @@ -246,11 +234,8 @@ doubles_escaped.py:41:1: Q003 [*] Change outer quotes to avoid escaping inner qu | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 38 38 | f'\'normal\' {f'nested'} normal' # Q003 39 39 | f'\'normal\' {f'nested'} "double quotes"' 40 40 | f'\'normal\' {f'\'nested\' {'other'} normal'} "double quotes"' # Q003 41 |-f'\'normal\' {f'\'nested\' {'other'} "double quotes"'} normal' # Q00l 41 |+f"'normal' {f'\'nested\' {'other'} "double quotes"'} normal" # Q00l - - diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped_py311.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped_py311.snap index 375eaacc4625e..8348b37ec9937 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped_py311.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped_py311.snap @@ -10,7 +10,6 @@ doubles_escaped.py:1:26: Q003 [*] Change outer quotes to avoid escaping inner qu | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 1 |-this_should_raise_Q003 = 'This is a \'string\'' 1 |+this_should_raise_Q003 = "This is a 'string'" 2 2 | this_should_raise_Q003 = 'This is \\ a \\\'string\'' @@ -27,7 +26,6 @@ doubles_escaped.py:2:26: Q003 [*] Change outer quotes to avoid escaping inner qu | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 1 1 | this_should_raise_Q003 = 'This is a \'string\'' 2 |-this_should_raise_Q003 = 'This is \\ a \\\'string\'' 2 |+this_should_raise_Q003 = "This is \\ a \\'string'" @@ -45,7 +43,6 @@ doubles_escaped.py:10:5: Q003 [*] Change outer quotes to avoid escaping inner qu | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 7 7 | this_is_fine = R'This is a \'string\'' 8 8 | this_should_raise = ( 9 9 | 'This is a' @@ -65,7 +62,6 @@ doubles_escaped.py:14:1: Q003 [*] Change outer quotes to avoid escaping inner qu | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 11 11 | ) 12 12 | 13 13 | # Same as above, but with f-strings @@ -86,7 +82,6 @@ doubles_escaped.py:15:1: Q003 [*] Change outer quotes to avoid escaping inner qu | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 12 12 | 13 13 | # Same as above, but with f-strings 14 14 | f'This is a \'string\'' # Q003 @@ -106,7 +101,6 @@ doubles_escaped.py:23:5: Q003 [*] Change outer quotes to avoid escaping inner qu | = help: Change outer quotes to avoid escaping inner quotes -ℹ Safe fix 20 20 | fR'This is a \'string\'' 21 21 | foo = ( 22 22 | f'This is a' @@ -115,5 +109,3 @@ doubles_escaped.py:23:5: Q003 [*] Change outer quotes to avoid escaping inner qu 24 24 | ) 25 25 | 26 26 | # Nested f-strings (Python 3.12+) - - diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped_unnecessary.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped_unnecessary.py.snap index 4e7c09e9cd981..3dc984ea895cf 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped_unnecessary.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped_unnecessary.py.snap @@ -10,7 +10,6 @@ doubles_escaped_unnecessary.py:1:26: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 1 |-this_should_raise_Q004 = 'This is a \"string\"' 1 |+this_should_raise_Q004 = 'This is a "string"' 2 2 | this_should_raise_Q004 = 'This is \\ a \\\"string\"' @@ -27,7 +26,6 @@ doubles_escaped_unnecessary.py:2:26: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 1 1 | this_should_raise_Q004 = 'This is a \"string\"' 2 |-this_should_raise_Q004 = 'This is \\ a \\\"string\"' 2 |+this_should_raise_Q004 = 'This is \\ a \\"string"' @@ -46,7 +44,6 @@ doubles_escaped_unnecessary.py:3:16: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 1 1 | this_should_raise_Q004 = 'This is a \"string\"' 2 2 | this_should_raise_Q004 = 'This is \\ a \\\"string\"' 3 |-this_is_fine = '"This" is a \"string\"' @@ -65,7 +62,6 @@ doubles_escaped_unnecessary.py:10:5: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 7 7 | this_is_fine = R'This is a \"string\"' 8 8 | this_should_raise_Q004 = ( 9 9 | 'This is a' @@ -85,7 +81,6 @@ doubles_escaped_unnecessary.py:14:1: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 11 11 | ) 12 12 | 13 13 | # Same as above, but with f-strings @@ -106,7 +101,6 @@ doubles_escaped_unnecessary.py:15:1: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 12 12 | 13 13 | # Same as above, but with f-strings 14 14 | f'This is a \"string\"' # Q004 @@ -127,7 +121,6 @@ doubles_escaped_unnecessary.py:16:1: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 13 13 | # Same as above, but with f-strings 14 14 | f'This is a \"string\"' # Q004 15 15 | f'This is \\ a \\\"string\"' # Q004 @@ -147,7 +140,6 @@ doubles_escaped_unnecessary.py:23:5: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 20 20 | fR'This is a \"string\"' 21 21 | this_should_raise_Q004 = ( 22 22 | f'This is a' @@ -168,7 +160,6 @@ doubles_escaped_unnecessary.py:33:1: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 30 30 | # f"'foo' {'nested'}" 31 31 | # 32 32 | # but as the actual string itself is invalid pre 3.12, we don't catch it. @@ -188,7 +179,6 @@ doubles_escaped_unnecessary.py:34:1: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 31 31 | # 32 32 | # but as the actual string itself is invalid pre 3.12, we don't catch it. 33 33 | f'\"foo\" {'nested'}' # Q004 @@ -209,7 +199,6 @@ doubles_escaped_unnecessary.py:35:1: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 32 32 | # but as the actual string itself is invalid pre 3.12, we don't catch it. 33 33 | f'\"foo\" {'nested'}' # Q004 34 34 | f'\"foo\" {f'nested'}' # Q004 @@ -230,7 +219,6 @@ doubles_escaped_unnecessary.py:35:12: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 32 32 | # but as the actual string itself is invalid pre 3.12, we don't catch it. 33 33 | f'\"foo\" {'nested'}' # Q004 34 34 | f'\"foo\" {f'nested'}' # Q004 @@ -250,7 +238,6 @@ doubles_escaped_unnecessary.py:38:1: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 35 35 | f'\"foo\" {f'\"nested\"'} \"\"' # Q004 36 36 | 37 37 | f'normal {f'nested'} normal' @@ -271,7 +258,6 @@ doubles_escaped_unnecessary.py:39:1: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 36 36 | 37 37 | f'normal {f'nested'} normal' 38 38 | f'\"normal\" {f'nested'} normal' # Q004 @@ -291,7 +277,6 @@ doubles_escaped_unnecessary.py:40:1: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 37 37 | f'normal {f'nested'} normal' 38 38 | f'\"normal\" {f'nested'} normal' # Q004 39 39 | f'\"normal\" {f'nested'} "double quotes"' @@ -311,7 +296,6 @@ doubles_escaped_unnecessary.py:40:15: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 37 37 | f'normal {f'nested'} normal' 38 38 | f'\"normal\" {f'nested'} normal' # Q004 39 39 | f'\"normal\" {f'nested'} "double quotes"' @@ -332,7 +316,6 @@ doubles_escaped_unnecessary.py:41:1: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 38 38 | f'\"normal\" {f'nested'} normal' # Q004 39 39 | f'\"normal\" {f'nested'} "double quotes"' 40 40 | f'\"normal\" {f'\"nested\" {'other'} normal'} "double quotes"' # Q004 @@ -353,7 +336,6 @@ doubles_escaped_unnecessary.py:41:15: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 38 38 | f'\"normal\" {f'nested'} normal' # Q004 39 39 | f'\"normal\" {f'nested'} "double quotes"' 40 40 | f'\"normal\" {f'\"nested\" {'other'} normal'} "double quotes"' # Q004 @@ -372,11 +354,8 @@ doubles_escaped_unnecessary.py:45:26: Q004 [*] Unnecessary escape on inner quote | = help: Remove backslash -ℹ Safe fix 42 42 | 43 43 | # Make sure we do not unescape quotes 44 44 | this_is_fine = 'This is an \\"escaped\\" quote' 45 |-this_should_raise_Q004 = 'This is an \\\"escaped\\\" quote with an extra backslash' 45 |+this_should_raise_Q004 = 'This is an \\"escaped\\" quote with an extra backslash' - - diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_implicit.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_implicit.py.snap index a44c07a17cf94..50d91feae44a2 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_implicit.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_implicit.py.snap @@ -11,7 +11,6 @@ doubles_implicit.py:2:5: Q000 [*] Double quotes found but single quotes preferre | = help: Replace double quotes with single quotes -ℹ Safe fix 1 1 | x = ( 2 |- "This" 2 |+ 'This' @@ -30,7 +29,6 @@ doubles_implicit.py:3:5: Q000 [*] Double quotes found but single quotes preferre | = help: Replace double quotes with single quotes -ℹ Safe fix 1 1 | x = ( 2 2 | "This" 3 |- "is" @@ -49,7 +47,6 @@ doubles_implicit.py:4:5: Q000 [*] Double quotes found but single quotes preferre | = help: Replace double quotes with single quotes -ℹ Safe fix 1 1 | x = ( 2 2 | "This" 3 3 | "is" @@ -69,7 +66,6 @@ doubles_implicit.py:8:5: Q000 [*] Double quotes found but single quotes preferre | = help: Replace double quotes with single quotes -ℹ Safe fix 5 5 | ) 6 6 | 7 7 | x = ( @@ -90,7 +86,6 @@ doubles_implicit.py:9:5: Q000 [*] Double quotes found but single quotes preferre | = help: Replace double quotes with single quotes -ℹ Safe fix 6 6 | 7 7 | x = ( 8 8 | "This" \ @@ -110,7 +105,6 @@ doubles_implicit.py:10:5: Q000 [*] Double quotes found but single quotes preferr | = help: Replace double quotes with single quotes -ℹ Safe fix 7 7 | x = ( 8 8 | "This" \ 9 9 | "is" \ @@ -129,11 +123,8 @@ doubles_implicit.py:27:1: Q000 [*] Double quotes found but single quotes preferr | = help: Replace double quotes with single quotes -ℹ Safe fix 24 24 | 25 25 | if True: 26 26 | "This can use 'double' quotes" 27 |-"But this needs to be changed" 27 |+'But this needs to be changed' - - diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_multiline_string.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_multiline_string.py.snap index bb0ef317cba48..e2bc6f44a4d2e 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_multiline_string.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_multiline_string.py.snap @@ -13,7 +13,6 @@ doubles_multiline_string.py:1:5: Q001 [*] Double quote multiline found but singl | = help: Replace double multiline quotes with single quotes -ℹ Safe fix 1 |-s = """ This "should" 1 |+s = ''' This "should" 2 2 | be @@ -22,5 +21,3 @@ doubles_multiline_string.py:1:5: Q001 [*] Double quote multiline found but singl 4 4 | 5 5 | s = ''' This "should" 6 6 | "not" be - - diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_would_be_triple_quotes.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_would_be_triple_quotes.py.snap index 031164bad78ba..3f8c5b15f00ff 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_would_be_triple_quotes.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_would_be_triple_quotes.py.snap @@ -17,7 +17,6 @@ doubles_would_be_triple_quotes.py:2:5: Q000 [*] Double quotes found but single q | = help: Replace double quotes with single quotes -ℹ Safe fix 1 1 | s = ""'Start with empty string' ' and lint docstring safely' 2 |-s = "Do not"' start with empty string' ' and lint docstring safely' 2 |+s = 'Do not'' start with empty string' ' and lint docstring safely' diff --git a/crates/ruff_linter/src/rules/flake8_raise/snapshots/ruff_linter__rules__flake8_raise__tests__unnecessary-paren-on-raise-exception_RSE102.py.snap b/crates/ruff_linter/src/rules/flake8_raise/snapshots/ruff_linter__rules__flake8_raise__tests__unnecessary-paren-on-raise-exception_RSE102.py.snap index d0dd2b4084b53..10baa41587ec3 100644 --- a/crates/ruff_linter/src/rules/flake8_raise/snapshots/ruff_linter__rules__flake8_raise__tests__unnecessary-paren-on-raise-exception_RSE102.py.snap +++ b/crates/ruff_linter/src/rules/flake8_raise/snapshots/ruff_linter__rules__flake8_raise__tests__unnecessary-paren-on-raise-exception_RSE102.py.snap @@ -12,7 +12,6 @@ RSE102.py:5:21: RSE102 [*] Unnecessary parentheses on raised exception | = help: Remove unnecessary parentheses -ℹ Safe fix 2 2 | y = 6 + "7" 3 3 | except TypeError: 4 4 | # RSE102 @@ -32,7 +31,6 @@ RSE102.py:13:16: RSE102 [*] Unnecessary parentheses on raised exception | = help: Remove unnecessary parentheses -ℹ Safe fix 10 10 | raise 11 11 | 12 12 | # RSE102 @@ -52,7 +50,6 @@ RSE102.py:16:17: RSE102 [*] Unnecessary parentheses on raised exception | = help: Remove unnecessary parentheses -ℹ Safe fix 13 13 | raise TypeError() 14 14 | 15 15 | # RSE102 @@ -73,7 +70,6 @@ RSE102.py:20:5: RSE102 [*] Unnecessary parentheses on raised exception | = help: Remove unnecessary parentheses -ℹ Safe fix 17 17 | 18 18 | # RSE102 19 19 | raise TypeError \ @@ -94,7 +90,6 @@ RSE102.py:24:5: RSE102 [*] Unnecessary parentheses on raised exception | = help: Remove unnecessary parentheses -ℹ Safe fix 21 21 | 22 22 | # RSE102 23 23 | raise TypeError \ @@ -117,7 +112,6 @@ RSE102.py:27:16: RSE102 [*] Unnecessary parentheses on raised exception | = help: Remove unnecessary parentheses -ℹ Safe fix 24 24 | (); 25 25 | 26 26 | # RSE102 @@ -142,7 +136,6 @@ RSE102.py:32:19: RSE102 [*] Unnecessary parentheses on raised exception | = help: Remove unnecessary parentheses -ℹ Safe fix 29 29 | ) 30 30 | 31 31 | # RSE102 @@ -167,7 +160,6 @@ RSE102.py:37:16: RSE102 [*] Unnecessary parentheses on raised exception | = help: Remove unnecessary parentheses -ℹ Safe fix 34 34 | ) 35 35 | 36 36 | # RSE102 @@ -189,7 +181,6 @@ RSE102.py:74:17: RSE102 [*] Unnecessary parentheses on raised exception | = help: Remove unnecessary parentheses -ℹ Safe fix 71 71 | 72 72 | 73 73 | # RSE102 @@ -209,7 +200,6 @@ RSE102.py:76:17: RSE102 [*] Unnecessary parentheses on raised exception | = help: Remove unnecessary parentheses -ℹ Safe fix 73 73 | # RSE102 74 74 | raise IndexError()from ZeroDivisionError 75 75 | @@ -230,7 +220,6 @@ RSE102.py:79:17: RSE102 [*] Unnecessary parentheses on raised exception | = help: Remove unnecessary parentheses -ℹ Safe fix 76 76 | raise IndexError()\ 77 77 | from ZeroDivisionError 78 78 | @@ -251,7 +240,6 @@ RSE102.py:81:17: RSE102 [*] Unnecessary parentheses on raised exception | = help: Remove unnecessary parentheses -ℹ Safe fix 78 78 | 79 79 | raise IndexError() from ZeroDivisionError 80 80 | @@ -271,15 +259,6 @@ RSE102.py:84:10: RSE102 [*] Unnecessary parentheses on raised exception | = help: Remove unnecessary parentheses -ℹ Unsafe fix -81 81 | raise IndexError(); -82 82 | -83 83 | # RSE102 -84 |-raise Foo() - 84 |+raise Foo -85 85 | -86 86 | # OK -87 87 | raise ctypes.WinError() RSE102.py:107:27: RSE102 [*] Unnecessary parentheses on raised exception | @@ -289,10 +268,3 @@ RSE102.py:107:27: RSE102 [*] Unnecessary parentheses on raised exception | ^^ RSE102 | = help: Remove unnecessary parentheses - -ℹ Unsafe fix -104 104 | # RSE102 -105 105 | future = executor.submit(float, "a") -106 106 | if future.exception(): -107 |- raise future.Exception() - 107 |+ raise future.Exception diff --git a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET501_RET501.py.snap b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET501_RET501.py.snap index 889492cab6623..26539cff3b8c7 100644 --- a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET501_RET501.py.snap +++ b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET501_RET501.py.snap @@ -10,7 +10,6 @@ RET501.py:4:5: RET501 [*] Do not explicitly `return None` in function if it is t | = help: Remove explicit `return None` -ℹ Safe fix 1 1 | def x(y): 2 2 | if not y: 3 3 | return @@ -31,7 +30,6 @@ RET501.py:14:9: RET501 [*] Do not explicitly `return None` in function if it is | = help: Remove explicit `return None` -ℹ Safe fix 11 11 | 12 12 | def get(self, key: str) -> None: 13 13 | print(f"{key} not found") diff --git a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET502_RET502.py.snap b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET502_RET502.py.snap index 01d5a439dbaab..fbdf01325e9fc 100644 --- a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET502_RET502.py.snap +++ b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET502_RET502.py.snap @@ -11,13 +11,10 @@ RET502.py:3:9: RET502 [*] Do not implicitly `return None` in function able to re | = help: Add explicit `None` return value -ℹ Safe fix 1 1 | def x(y): 2 2 | if not y: 3 |- return # error 3 |+ return None # error 4 4 | return 1 5 5 | -6 6 | - - +6 6 | diff --git a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET503_RET503.py.snap b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET503_RET503.py.snap index 27e3258087d4b..13d52d14c41b8 100644 --- a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET503_RET503.py.snap +++ b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET503_RET503.py.snap @@ -13,14 +13,6 @@ RET503.py:21:5: RET503 [*] Missing explicit `return` at the end of function able | = help: Add explicit `return` statement -ℹ Unsafe fix -20 20 | def x(y): -21 21 | if not y: -22 22 | return 1 - 23 |+ return None -23 24 | # error -24 25 | -25 26 | RET503.py:28:9: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | @@ -33,14 +25,6 @@ RET503.py:28:9: RET503 [*] Missing explicit `return` at the end of function able | = help: Add explicit `return` statement -ℹ Unsafe fix -26 26 | def x(y): -27 27 | if not y: -28 28 | print() # error - 29 |+ return None -29 30 | else: -30 31 | return 2 -31 32 | RET503.py:37:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | @@ -51,14 +35,6 @@ RET503.py:37:5: RET503 [*] Missing explicit `return` at the end of function able | = help: Add explicit `return` statement -ℹ Unsafe fix -35 35 | return 1 -36 36 | -37 37 | print() # error - 38 |+ return None -38 39 | -39 40 | -40 41 | # for RET503.py:42:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | @@ -73,14 +49,6 @@ RET503.py:42:5: RET503 [*] Missing explicit `return` at the end of function able | = help: Add explicit `return` statement -ℹ Unsafe fix -42 42 | for i in range(10): -43 43 | if i > 10: -44 44 | return i - 45 |+ return None -45 46 | # error -46 47 | -47 48 | RET503.py:53:9: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | @@ -91,14 +59,6 @@ RET503.py:53:9: RET503 [*] Missing explicit `return` at the end of function able | = help: Add explicit `return` statement -ℹ Unsafe fix -51 51 | return i -52 52 | else: -53 53 | print() # error - 54 |+ return None -54 55 | -55 56 | -56 57 | # A nonexistent function RET503.py:60:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | @@ -109,14 +69,6 @@ RET503.py:60:5: RET503 [*] Missing explicit `return` at the end of function able | = help: Add explicit `return` statement -ℹ Unsafe fix -58 58 | if x > 0: -59 59 | return False -60 60 | no_such_function() # error - 61 |+ return None -61 62 | -62 63 | -63 64 | # A function that does return the control RET503.py:67:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | @@ -127,14 +79,6 @@ RET503.py:67:5: RET503 [*] Missing explicit `return` at the end of function able | = help: Add explicit `return` statement -ℹ Unsafe fix -65 65 | if x > 0: -66 66 | return False -67 67 | print("", end="") # error - 68 |+ return None -68 69 | -69 70 | -70 71 | ### RET503.py:83:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | @@ -149,14 +93,6 @@ RET503.py:83:5: RET503 [*] Missing explicit `return` at the end of function able | = help: Add explicit `return` statement -ℹ Unsafe fix -84 84 | if y > 0: -85 85 | return 1 -86 86 | y += 1 - 87 |+ return None -87 88 | -88 89 | -89 90 | # exclude empty functions RET503.py:114:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | @@ -171,14 +107,6 @@ RET503.py:114:5: RET503 [*] Missing explicit `return` at the end of function abl | = help: Add explicit `return` statement -ℹ Unsafe fix -115 115 | if i > y: -116 116 | break -117 117 | return z - 118 |+ return None -118 119 | -119 120 | -120 121 | def bar3(x, y, z): RET503.py:121:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | @@ -195,14 +123,6 @@ RET503.py:121:5: RET503 [*] Missing explicit `return` at the end of function abl | = help: Add explicit `return` statement -ℹ Unsafe fix -125 125 | else: -126 126 | return z -127 127 | return None - 128 |+ return None -128 129 | -129 130 | -130 131 | def bar1(x, y, z): RET503.py:131:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | @@ -216,14 +136,6 @@ RET503.py:131:5: RET503 [*] Missing explicit `return` at the end of function abl | = help: Add explicit `return` statement -ℹ Unsafe fix -132 132 | if i < y: -133 133 | continue -134 134 | return z - 135 |+ return None -135 136 | -136 137 | -137 138 | def bar3(x, y, z): RET503.py:138:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | @@ -240,14 +152,6 @@ RET503.py:138:5: RET503 [*] Missing explicit `return` at the end of function abl | = help: Add explicit `return` statement -ℹ Unsafe fix -142 142 | else: -143 143 | return z -144 144 | return None - 145 |+ return None -145 146 | -146 147 | -147 148 | def prompts(self, foo): RET503.py:275:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | @@ -260,14 +164,6 @@ RET503.py:275:5: RET503 [*] Missing explicit `return` at the end of function abl | = help: Add explicit `return` statement -ℹ Unsafe fix -274 274 | -275 275 | for value in values: -276 276 | print(value) - 277 |+ return None -277 278 | -278 279 | -279 280 | def while_true(): RET503.py:292:13: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | @@ -278,14 +174,6 @@ RET503.py:292:13: RET503 [*] Missing explicit `return` at the end of function ab | = help: Add explicit `return` statement -ℹ Unsafe fix -290 290 | return 1 -291 291 | case 1: -292 292 | print() # error - 293 |+ return None -293 294 | -294 295 | -295 296 | def foo(baz: str) -> str: RET503.py:301:9: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | @@ -298,14 +186,6 @@ RET503.py:301:9: RET503 [*] Missing explicit `return` at the end of function abl | = help: Add explicit `return` statement -ℹ Unsafe fix -300 300 | def example(): -301 301 | if True: -302 302 | return "" - 303 |+ return None -303 304 | -304 305 | -305 306 | def example(): RET503.py:306:9: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | @@ -317,14 +197,6 @@ RET503.py:306:9: RET503 [*] Missing explicit `return` at the end of function abl | = help: Add explicit `return` statement -ℹ Unsafe fix -305 305 | def example(): -306 306 | if True: -307 307 | return "" - 308 |+ return None -308 309 | -309 310 | -310 311 | def example(): RET503.py:311:9: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | @@ -336,14 +208,6 @@ RET503.py:311:9: RET503 [*] Missing explicit `return` at the end of function abl | = help: Add explicit `return` statement -ℹ Unsafe fix -310 310 | def example(): -311 311 | if True: -312 312 | return "" # type: ignore - 313 |+ return None -313 314 | -314 315 | -315 316 | def example(): RET503.py:316:9: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | @@ -355,14 +219,6 @@ RET503.py:316:9: RET503 [*] Missing explicit `return` at the end of function abl | = help: Add explicit `return` statement -ℹ Unsafe fix -315 315 | def example(): -316 316 | if True: -317 317 | return "" ; - 318 |+ return None -318 319 | -319 320 | -320 321 | def example(): RET503.py:321:9: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | @@ -375,14 +231,6 @@ RET503.py:321:9: RET503 [*] Missing explicit `return` at the end of function abl | = help: Add explicit `return` statement -ℹ Unsafe fix -321 321 | if True: -322 322 | return "" \ -323 323 | ; # type: ignore - 324 |+ return None -324 325 | -325 326 | -326 327 | def end_of_file(): RET503.py:329:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | @@ -393,14 +241,6 @@ RET503.py:329:5: RET503 [*] Missing explicit `return` at the end of function abl | = help: Add explicit `return` statement -ℹ Unsafe fix -328 328 | return 1 -329 329 | x = 2 \ -330 330 | - 331 |+ return None -331 332 | -332 333 | -333 334 | # function return type annotation NoReturn RET503.py:339:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | @@ -411,14 +251,6 @@ RET503.py:339:5: RET503 [*] Missing explicit `return` at the end of function abl | = help: Add explicit `return` statement -ℹ Unsafe fix -337 337 | if x == 5: -338 338 | return 5 -339 339 | bar() - 340 |+ return None -340 341 | -341 342 | -342 343 | def foo(string: str) -> str: RET503.py:354:13: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | @@ -429,14 +261,6 @@ RET503.py:354:13: RET503 [*] Missing explicit `return` at the end of function ab | = help: Add explicit `return` statement -ℹ Unsafe fix -352 352 | return "third" -353 353 | case _: -354 354 | raises(string) - 355 |+ return None -355 356 | -356 357 | -357 358 | def foo() -> int: RET503.py:370:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value | @@ -446,11 +270,3 @@ RET503.py:370:5: RET503 [*] Missing explicit `return` at the end of function abl | ^^^^^ RET503 | = help: Add explicit `return` statement - -ℹ Unsafe fix -368 368 | if baz() > 3: -369 369 | return 1 -370 370 | bar() - 371 |+ return None - - diff --git a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET504_RET504.py.snap b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET504_RET504.py.snap index 46ffb2df68b29..e3196b1753b29 100644 --- a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET504_RET504.py.snap +++ b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET504_RET504.py.snap @@ -10,16 +10,6 @@ RET504.py:6:12: RET504 [*] Unnecessary assignment to `a` before `return` stateme | = help: Remove unnecessary assignment -ℹ Unsafe fix -2 2 | # Errors -3 3 | ### -4 4 | def x(): -5 |- a = 1 -6 |- return a # RET504 - 5 |+ return 1 -7 6 | -8 7 | -9 8 | # Can be refactored false positives RET504.py:23:12: RET504 [*] Unnecessary assignment to `formatted` before `return` statement | @@ -30,16 +20,6 @@ RET504.py:23:12: RET504 [*] Unnecessary assignment to `formatted` before `return | = help: Remove unnecessary assignment -ℹ Unsafe fix -19 19 | def x(): -20 20 | formatted = _USER_AGENT_FORMATTER.format(format_string, **values) -21 21 | # clean up after any blank components -22 |- formatted = formatted.replace("()", "").replace(" ", " ").strip() -23 |- return formatted - 22 |+ return formatted.replace("()", "").replace(" ", " ").strip() -24 23 | -25 24 | -26 25 | # https://github.com/afonasev/flake8-return/issues/47#issue-641117366 RET504.py:246:12: RET504 [*] Unnecessary assignment to `queryset` before `return` statement | @@ -50,16 +30,6 @@ RET504.py:246:12: RET504 [*] Unnecessary assignment to `queryset` before `return | = help: Remove unnecessary assignment -ℹ Unsafe fix -242 242 | -243 243 | def get_queryset(): -244 244 | queryset = Model.filter(a=1) -245 |- queryset = queryset.filter(c=3) -246 |- return queryset - 245 |+ return queryset.filter(c=3) -247 246 | -248 247 | -249 248 | def get_queryset(): RET504.py:251:12: RET504 [*] Unnecessary assignment to `queryset` before `return` statement | @@ -70,16 +40,6 @@ RET504.py:251:12: RET504 [*] Unnecessary assignment to `queryset` before `return | = help: Remove unnecessary assignment -ℹ Unsafe fix -247 247 | -248 248 | -249 249 | def get_queryset(): -250 |- queryset = Model.filter(a=1) -251 |- return queryset # RET504 - 250 |+ return Model.filter(a=1) -252 251 | -253 252 | -254 253 | # Function arguments RET504.py:269:12: RET504 [*] Unnecessary assignment to `val` before `return` statement | @@ -90,16 +50,6 @@ RET504.py:269:12: RET504 [*] Unnecessary assignment to `val` before `return` sta | = help: Remove unnecessary assignment -ℹ Unsafe fix -265 265 | def str_to_bool(val): -266 266 | if isinstance(val, bool): -267 267 | return val -268 |- val = 1 -269 |- return val # RET504 - 268 |+ return 1 -270 269 | -271 270 | -272 271 | def str_to_bool(val): RET504.py:321:12: RET504 [*] Unnecessary assignment to `x` before `return` statement | @@ -110,16 +60,6 @@ RET504.py:321:12: RET504 [*] Unnecessary assignment to `x` before `return` state | = help: Remove unnecessary assignment -ℹ Unsafe fix -317 317 | # `with` statements -318 318 | def foo(): -319 319 | with open("foo.txt", "r") as f: -320 |- x = f.read() -321 |- return x # RET504 - 320 |+ return f.read() -322 321 | -323 322 | -324 323 | def foo(): RET504.py:342:12: RET504 [*] Unnecessary assignment to `b` before `return` statement | @@ -130,16 +70,6 @@ RET504.py:342:12: RET504 [*] Unnecessary assignment to `b` before `return` state | = help: Remove unnecessary assignment -ℹ Unsafe fix -338 338 | # Fix cases -339 339 | def foo(): -340 340 | a = 1 -341 |- b=a -342 |- return b # RET504 - 341 |+ return a -343 342 | -344 343 | -345 344 | def foo(): RET504.py:348:12: RET504 [*] Unnecessary assignment to `b` before `return` statement | @@ -150,16 +80,6 @@ RET504.py:348:12: RET504 [*] Unnecessary assignment to `b` before `return` state | = help: Remove unnecessary assignment -ℹ Unsafe fix -344 344 | -345 345 | def foo(): -346 346 | a = 1 -347 |- b =a -348 |- return b # RET504 - 347 |+ return a -349 348 | -350 349 | -351 350 | def foo(): RET504.py:354:12: RET504 [*] Unnecessary assignment to `b` before `return` statement | @@ -170,16 +90,6 @@ RET504.py:354:12: RET504 [*] Unnecessary assignment to `b` before `return` state | = help: Remove unnecessary assignment -ℹ Unsafe fix -350 350 | -351 351 | def foo(): -352 352 | a = 1 -353 |- b= a -354 |- return b # RET504 - 353 |+ return a -355 354 | -356 355 | -357 356 | def foo(): RET504.py:359:12: RET504 [*] Unnecessary assignment to `a` before `return` statement | @@ -190,16 +100,6 @@ RET504.py:359:12: RET504 [*] Unnecessary assignment to `a` before `return` state | = help: Remove unnecessary assignment -ℹ Unsafe fix -355 355 | -356 356 | -357 357 | def foo(): -358 |- a = 1 # Comment -359 |- return a - 358 |+ return 1 # Comment -360 359 | -361 360 | -362 361 | # Regression test for: https://github.com/astral-sh/ruff/issues/7098 RET504.py:365:12: RET504 [*] Unnecessary assignment to `D` before `return` statement | @@ -210,16 +110,6 @@ RET504.py:365:12: RET504 [*] Unnecessary assignment to `D` before `return` state | = help: Remove unnecessary assignment -ℹ Unsafe fix -361 361 | -362 362 | # Regression test for: https://github.com/astral-sh/ruff/issues/7098 -363 363 | def mavko_debari(P_kbar): -364 |- D=0.4853881 + 3.6006116*P - 0.0117368*(P-1.3822)**2 -365 |- return D - 364 |+ return 0.4853881 + 3.6006116*P - 0.0117368*(P-1.3822)**2 -366 365 | -367 366 | -368 367 | # contextlib suppress in with statement RET504.py:400:12: RET504 [*] Unnecessary assignment to `y` before `return` statement | @@ -230,16 +120,6 @@ RET504.py:400:12: RET504 [*] Unnecessary assignment to `y` before `return` state | = help: Remove unnecessary assignment -ℹ Unsafe fix -396 396 | x = 2 -397 397 | with contextlib.suppress(Exception): -398 398 | x = 1 -399 |- y = y + 2 -400 |- return y # RET504 - 399 |+ return y + 2 -401 400 | -402 401 | -403 402 | def foo(): RET504.py:423:16: RET504 [*] Unnecessary assignment to `services` before `return` statement | @@ -249,11 +129,3 @@ RET504.py:423:16: RET504 [*] Unnecessary assignment to `services` before `return | ^^^^^^^^ RET504 | = help: Remove unnecessary assignment - -ℹ Unsafe fix -419 419 | # See: https://github.com/astral-sh/ruff/issues/10732 -420 420 | def func(a: dict[str, int]) -> list[dict[str, int]]: -421 421 | if "services" in a: -422 |- services = a["services"] -423 |- return services - 422 |+ return a["services"] diff --git a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__preview__RET505_RET505.py.snap b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__preview__RET505_RET505.py.snap index 21a3d2efc6fd3..679e149862df0 100644 --- a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__preview__RET505_RET505.py.snap +++ b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__preview__RET505_RET505.py.snap @@ -12,7 +12,6 @@ RET505.py:8:5: RET505 [*] Unnecessary `elif` after `return` statement | = help: Remove unnecessary `elif` -ℹ Safe fix 5 5 | if x: # [no-else-return] 6 6 | a = 1 7 7 | return y @@ -33,7 +32,6 @@ RET505.py:23:5: RET505 [*] Unnecessary `elif` after `return` statement | = help: Remove unnecessary `elif` -ℹ Safe fix 20 20 | else: 21 21 | b = 2 22 22 | return @@ -54,7 +52,6 @@ RET505.py:41:5: RET505 [*] Unnecessary `elif` after `return` statement | = help: Remove unnecessary `elif` -ℹ Safe fix 38 38 | if x: # [no-else-return] 39 39 | a = 1 40 40 | return y @@ -75,7 +72,6 @@ RET505.py:53:5: RET505 [*] Unnecessary `else` after `return` statement | = help: Remove unnecessary `else` -ℹ Safe fix 50 50 | if x: # [no-else-return] 51 51 | a = 1 52 52 | return y @@ -99,7 +95,6 @@ RET505.py:64:9: RET505 [*] Unnecessary `else` after `return` statement | = help: Remove unnecessary `else` -ℹ Safe fix 61 61 | if y: # [no-else-return] 62 62 | b = 2 63 63 | return y @@ -123,7 +118,6 @@ RET505.py:79:5: RET505 [*] Unnecessary `else` after `return` statement | = help: Remove unnecessary `else` -ℹ Safe fix 76 76 | else: 77 77 | b = 2 78 78 | return @@ -145,7 +139,6 @@ RET505.py:89:9: RET505 [*] Unnecessary `else` after `return` statement | = help: Remove unnecessary `else` -ℹ Safe fix 86 86 | if y: # [no-else-return] 87 87 | a = 4 88 88 | return @@ -167,7 +160,6 @@ RET505.py:99:5: RET505 [*] Unnecessary `else` after `return` statement | = help: Remove unnecessary `else` -ℹ Safe fix 96 96 | def bar4(x): 97 97 | if x: # [no-else-return] 98 98 | return True @@ -195,7 +187,6 @@ RET505.py:109:5: RET505 [*] Unnecessary `else` after `return` statement | = help: Remove unnecessary `else` -ℹ Safe fix 106 106 | def fibo(n): 107 107 | if n<2: 108 108 | return n; @@ -219,7 +210,6 @@ RET505.py:145:5: RET505 [*] Unnecessary `else` after `return` statement | = help: Remove unnecessary `else` -ℹ Safe fix 142 142 | def bar4(x): 143 143 | if True: 144 144 | return @@ -242,7 +232,6 @@ RET505.py:153:5: RET505 [*] Unnecessary `else` after `return` statement | = help: Remove unnecessary `else` -ℹ Safe fix 150 150 | def bar5(): 151 151 | if True: 152 152 | return @@ -265,7 +254,6 @@ RET505.py:160:5: RET505 [*] Unnecessary `else` after `return` statement | = help: Remove unnecessary `else` -ℹ Safe fix 157 157 | def bar6(): 158 158 | if True: 159 159 | return @@ -290,7 +278,6 @@ RET505.py:169:5: RET505 [*] Unnecessary `else` after `return` statement | = help: Remove unnecessary `else` -ℹ Safe fix 166 166 | def bar7(): 167 167 | if True: 168 168 | return @@ -312,7 +299,6 @@ RET505.py:177:5: RET505 [*] Unnecessary `else` after `return` statement | = help: Remove unnecessary `else` -ℹ Safe fix 174 174 | def bar8(): 175 175 | if True: 176 176 | return @@ -332,7 +318,6 @@ RET505.py:183:5: RET505 [*] Unnecessary `else` after `return` statement | = help: Remove unnecessary `else` -ℹ Safe fix 180 180 | def bar9(): 181 181 | if True: 182 182 | return @@ -352,7 +337,6 @@ RET505.py:200:5: RET505 [*] Unnecessary `else` after `return` statement | = help: Remove unnecessary `else` -ℹ Safe fix 197 197 | # Regression test for: https://github.com/astral-sh/ruff/issues/9732 198 198 | def sb(self): 199 199 | if self._sb is not None: return self._sb @@ -373,7 +357,6 @@ RET505.py:207:5: RET505 [*] Unnecessary `else` after `return` statement | = help: Remove unnecessary `else` -ℹ Safe fix 204 204 | if x: # [no-else-return] 205 205 | a = 1 206 206 | return y @@ -398,7 +381,6 @@ RET505.py:217:5: RET505 [*] Unnecessary `else` after `return` statement | = help: Remove unnecessary `else` -ℹ Safe fix 214 214 | if x: # [no-else-return] 215 215 | a = 1 216 216 | return y @@ -424,7 +406,6 @@ RET505.py:227:5: RET505 [*] Unnecessary `else` after `return` statement | = help: Remove unnecessary `else` -ℹ Safe fix 224 224 | if x: # [no-else-return] 225 225 | a = 1 226 226 | return y @@ -450,7 +431,6 @@ RET505.py:237:5: RET505 [*] Unnecessary `else` after `return` statement | = help: Remove unnecessary `else` -ℹ Safe fix 234 234 | if x: # [no-else-return] 235 235 | a = 1 236 236 | return y @@ -460,5 +440,3 @@ RET505.py:237:5: RET505 [*] Unnecessary `else` after `return` statement 240 |- return z 238 |+ c = 3 239 |+ return z - - diff --git a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__preview__RET506_RET506.py.snap b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__preview__RET506_RET506.py.snap index 549850ee8d25b..1cc1f0d924f34 100644 --- a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__preview__RET506_RET506.py.snap +++ b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__preview__RET506_RET506.py.snap @@ -12,7 +12,6 @@ RET506.py:8:5: RET506 [*] Unnecessary `elif` after `raise` statement | = help: Remove unnecessary `elif` -ℹ Safe fix 5 5 | if x: # [no-else-raise] 6 6 | a = 1 7 7 | raise Exception(y) @@ -33,7 +32,6 @@ RET506.py:23:5: RET506 [*] Unnecessary `elif` after `raise` statement | = help: Remove unnecessary `elif` -ℹ Safe fix 20 20 | else: 21 21 | b = 2 22 22 | raise Exception(x) @@ -54,7 +52,6 @@ RET506.py:34:5: RET506 [*] Unnecessary `else` after `raise` statement | = help: Remove unnecessary `else` -ℹ Safe fix 31 31 | if x: # [no-else-raise] 32 32 | a = 1 33 33 | raise Exception(y) @@ -78,7 +75,6 @@ RET506.py:45:9: RET506 [*] Unnecessary `else` after `raise` statement | = help: Remove unnecessary `else` -ℹ Safe fix 42 42 | if y: # [no-else-raise] 43 43 | b = 2 44 44 | raise Exception(y) @@ -102,7 +98,6 @@ RET506.py:60:5: RET506 [*] Unnecessary `else` after `raise` statement | = help: Remove unnecessary `else` -ℹ Safe fix 57 57 | else: 58 58 | b = 2 59 59 | raise Exception(x) @@ -124,7 +119,6 @@ RET506.py:70:9: RET506 [*] Unnecessary `else` after `raise` statement | = help: Remove unnecessary `else` -ℹ Safe fix 67 67 | if y: # [no-else-raise] 68 68 | a = 4 69 69 | raise Exception(x) @@ -146,7 +140,6 @@ RET506.py:80:5: RET506 [*] Unnecessary `else` after `raise` statement | = help: Remove unnecessary `else` -ℹ Safe fix 77 77 | def bar4(x): 78 78 | if x: # [no-else-raise] 79 79 | raise Exception(True) @@ -162,5 +155,3 @@ RET506.py:80:5: RET506 [*] Unnecessary `else` after `raise` statement 85 84 | 86 85 | 87 86 | ### - - diff --git a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__preview__RET507_RET507.py.snap b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__preview__RET507_RET507.py.snap index 1a745fc2f576f..6421c05419e56 100644 --- a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__preview__RET507_RET507.py.snap +++ b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__preview__RET507_RET507.py.snap @@ -12,7 +12,6 @@ RET507.py:8:9: RET507 [*] Unnecessary `elif` after `continue` statement | = help: Remove unnecessary `elif` -ℹ Safe fix 5 5 | for i in x: 6 6 | if i < y: # [no-else-continue] 7 7 | continue @@ -33,7 +32,6 @@ RET507.py:22:9: RET507 [*] Unnecessary `elif` after `continue` statement | = help: Remove unnecessary `elif` -ℹ Safe fix 19 19 | else: 20 20 | b = 2 21 21 | continue @@ -53,7 +51,6 @@ RET507.py:36:9: RET507 [*] Unnecessary `else` after `continue` statement | = help: Remove unnecessary `else` -ℹ Safe fix 33 33 | for i in x: 34 34 | if i < y: # [no-else-continue] 35 35 | continue @@ -75,7 +72,6 @@ RET507.py:47:13: RET507 [*] Unnecessary `else` after `continue` statement | = help: Remove unnecessary `else` -ℹ Safe fix 44 44 | if z: # [no-else-continue] 45 45 | b = 2 46 46 | continue @@ -99,7 +95,6 @@ RET507.py:63:9: RET507 [*] Unnecessary `else` after `continue` statement | = help: Remove unnecessary `else` -ℹ Safe fix 60 60 | else: 61 61 | b = 2 62 62 | continue @@ -121,7 +116,6 @@ RET507.py:74:13: RET507 [*] Unnecessary `else` after `continue` statement | = help: Remove unnecessary `else` -ℹ Safe fix 71 71 | if y: # [no-else-continue] 72 72 | a = 4 73 73 | continue @@ -143,7 +137,6 @@ RET507.py:85:9: RET507 [*] Unnecessary `else` after `continue` statement | = help: Remove unnecessary `else` -ℹ Safe fix 82 82 | for i in range(10): 83 83 | if x: # [no-else-continue] 84 84 | continue @@ -159,5 +152,3 @@ RET507.py:85:9: RET507 [*] Unnecessary `else` after `continue` statement 90 89 | 91 90 | 92 91 | def bar1(x, y, z): - - diff --git a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__preview__RET508_RET508.py.snap b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__preview__RET508_RET508.py.snap index f35bda0f4e39e..a25572f8d1596 100644 --- a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__preview__RET508_RET508.py.snap +++ b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__preview__RET508_RET508.py.snap @@ -12,7 +12,6 @@ RET508.py:8:9: RET508 [*] Unnecessary `elif` after `break` statement | = help: Remove unnecessary `elif` -ℹ Safe fix 5 5 | for i in x: 6 6 | if i > y: # [no-else-break] 7 7 | break @@ -33,7 +32,6 @@ RET508.py:22:9: RET508 [*] Unnecessary `elif` after `break` statement | = help: Remove unnecessary `elif` -ℹ Safe fix 19 19 | else: 20 20 | b = 2 21 21 | break @@ -53,7 +51,6 @@ RET508.py:33:9: RET508 [*] Unnecessary `else` after `break` statement | = help: Remove unnecessary `else` -ℹ Safe fix 30 30 | for i in x: 31 31 | if i > y: # [no-else-break] 32 32 | break @@ -75,7 +72,6 @@ RET508.py:44:13: RET508 [*] Unnecessary `else` after `break` statement | = help: Remove unnecessary `else` -ℹ Safe fix 41 41 | if z: # [no-else-break] 42 42 | b = 2 43 43 | break @@ -99,7 +95,6 @@ RET508.py:60:9: RET508 [*] Unnecessary `else` after `break` statement | = help: Remove unnecessary `else` -ℹ Safe fix 57 57 | else: 58 58 | b = 2 59 59 | break @@ -121,7 +116,6 @@ RET508.py:71:13: RET508 [*] Unnecessary `else` after `break` statement | = help: Remove unnecessary `else` -ℹ Safe fix 68 68 | if y: # [no-else-break] 69 69 | a = 4 70 70 | break @@ -143,7 +137,6 @@ RET508.py:82:9: RET508 [*] Unnecessary `else` after `break` statement | = help: Remove unnecessary `else` -ℹ Safe fix 79 79 | for i in range(10): 80 80 | if x: # [no-else-break] 81 81 | break @@ -170,12 +163,9 @@ RET508.py:158:13: RET508 [*] Unnecessary `else` after `break` statement | = help: Remove unnecessary `else` -ℹ Safe fix 155 155 | else: 156 156 | if i > w: 157 157 | break 158 |- else: 159 |- a = z 158 |+ a = z - - diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM101_SIM101.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM101_SIM101.py.snap index 7fe5ffe88ba0b..855928910d903 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM101_SIM101.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM101_SIM101.py.snap @@ -9,12 +9,6 @@ SIM101.py:1:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a sing | = help: Merge `isinstance` calls for `a` -ℹ Unsafe fix -1 |-if isinstance(a, int) or isinstance(a, float): # SIM101 - 1 |+if isinstance(a, (int, float)): # SIM101 -2 2 | pass -3 3 | -4 4 | if isinstance(a, (int, float)) or isinstance(a, bool): # SIM101 SIM101.py:4:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call | @@ -26,15 +20,6 @@ SIM101.py:4:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a sing | = help: Merge `isinstance` calls for `a` -ℹ Unsafe fix -1 1 | if isinstance(a, int) or isinstance(a, float): # SIM101 -2 2 | pass -3 3 | -4 |-if isinstance(a, (int, float)) or isinstance(a, bool): # SIM101 - 4 |+if isinstance(a, (int, float, bool)): # SIM101 -5 5 | pass -6 6 | -7 7 | if isinstance(a, int) or isinstance(a, float) or isinstance(b, bool): # SIM101 SIM101.py:7:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call | @@ -46,15 +31,6 @@ SIM101.py:7:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a sing | = help: Merge `isinstance` calls for `a` -ℹ Unsafe fix -4 4 | if isinstance(a, (int, float)) or isinstance(a, bool): # SIM101 -5 5 | pass -6 6 | -7 |-if isinstance(a, int) or isinstance(a, float) or isinstance(b, bool): # SIM101 - 7 |+if isinstance(a, (int, float)) or isinstance(b, bool): # SIM101 -8 8 | pass -9 9 | -10 10 | if isinstance(b, bool) or isinstance(a, int) or isinstance(a, float): # SIM101 SIM101.py:10:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call | @@ -66,15 +42,6 @@ SIM101.py:10:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a sin | = help: Merge `isinstance` calls for `a` -ℹ Unsafe fix -7 7 | if isinstance(a, int) or isinstance(a, float) or isinstance(b, bool): # SIM101 -8 8 | pass -9 9 | -10 |-if isinstance(b, bool) or isinstance(a, int) or isinstance(a, float): # SIM101 - 10 |+if isinstance(b, bool) or isinstance(a, (int, float)): # SIM101 -11 11 | pass -12 12 | -13 13 | if isinstance(a, int) or isinstance(b, bool) or isinstance(a, float): # SIM101 SIM101.py:16:5: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call | @@ -86,15 +53,6 @@ SIM101.py:16:5: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a sin | = help: Merge `isinstance` calls for `a` -ℹ Unsafe fix -13 13 | if isinstance(a, int) or isinstance(b, bool) or isinstance(a, float): # SIM101 -14 14 | pass -15 15 | -16 |-if (isinstance(a, int) or isinstance(a, float)) and isinstance(b, bool): # SIM101 - 16 |+if (isinstance(a, (int, float))) and isinstance(b, bool): # SIM101 -17 17 | pass -18 18 | -19 19 | if isinstance(a.b, int) or isinstance(a.b, float): # SIM101 SIM101.py:19:4: SIM101 [*] Multiple `isinstance` calls for expression, merge into a single call | @@ -106,15 +64,6 @@ SIM101.py:19:4: SIM101 [*] Multiple `isinstance` calls for expression, merge int | = help: Merge `isinstance` calls -ℹ Unsafe fix -16 16 | if (isinstance(a, int) or isinstance(a, float)) and isinstance(b, bool): # SIM101 -17 17 | pass -18 18 | -19 |-if isinstance(a.b, int) or isinstance(a.b, float): # SIM101 - 19 |+if isinstance(a.b, (int, float)): # SIM101 -20 20 | pass -21 21 | -22 22 | if isinstance(a(), int) or isinstance(a(), float): # SIM101 SIM101.py:22:4: SIM101 Multiple `isinstance` calls for expression, merge into a single call | @@ -136,15 +85,6 @@ SIM101.py:38:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a sin | = help: Merge `isinstance` calls for `a` -ℹ Unsafe fix -35 35 | if isinstance(a, int) or unrelated_condition or isinstance(a, float): -36 36 | pass -37 37 | -38 |-if x or isinstance(a, int) or isinstance(a, float): - 38 |+if x or isinstance(a, (int, float)): -39 39 | pass -40 40 | -41 41 | if x or y or isinstance(a, int) or isinstance(a, float) or z: SIM101.py:41:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call | @@ -156,15 +96,6 @@ SIM101.py:41:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a sin | = help: Merge `isinstance` calls for `a` -ℹ Unsafe fix -38 38 | if x or isinstance(a, int) or isinstance(a, float): -39 39 | pass -40 40 | -41 |-if x or y or isinstance(a, int) or isinstance(a, float) or z: - 41 |+if x or y or isinstance(a, (int, float)) or z: -42 42 | pass -43 43 | -44 44 | def f(): SIM101.py:53:3: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call | @@ -174,11 +105,3 @@ SIM101.py:53:3: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a sin 54 | pass | = help: Merge `isinstance` calls for `a` - -ℹ Unsafe fix -50 50 | pass -51 51 | -52 52 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722460483 -53 |-if(isinstance(a, int)) or (isinstance(a, float)): - 53 |+if isinstance(a, (int, float)): -54 54 | pass diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM102_SIM102.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM102_SIM102.py.snap index 480bd0fa4cc66..f1ea338bdf3c1 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM102_SIM102.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM102_SIM102.py.snap @@ -11,16 +11,6 @@ SIM102.py:2:1: SIM102 [*] Use a single `if` statement instead of nested `if` sta | = help: Combine `if` statements using `and` -ℹ Unsafe fix -1 1 | # SIM102 -2 |-if a: -3 |- if b: -4 |- c - 2 |+if a and b: - 3 |+ c -5 4 | -6 5 | # SIM102 -7 6 | if a: SIM102.py:7:1: SIM102 [*] Use a single `if` statement instead of nested `if` statements | @@ -33,20 +23,6 @@ SIM102.py:7:1: SIM102 [*] Use a single `if` statement instead of nested `if` sta | = help: Combine `if` statements using `and` -ℹ Unsafe fix -4 4 | c -5 5 | -6 6 | # SIM102 -7 |-if a: -8 |- if b: -9 |- if c: -10 |- d - 7 |+if a and b: - 8 |+ if c: - 9 |+ d -11 10 | -12 11 | # SIM102 -13 12 | if a: SIM102.py:8:5: SIM102 [*] Use a single `if` statement instead of nested `if` statements | @@ -60,18 +36,6 @@ SIM102.py:8:5: SIM102 [*] Use a single `if` statement instead of nested `if` sta | = help: Combine `if` statements using `and` -ℹ Unsafe fix -5 5 | -6 6 | # SIM102 -7 7 | if a: -8 |- if b: -9 |- if c: -10 |- d - 8 |+ if b and c: - 9 |+ d -11 10 | -12 11 | # SIM102 -13 12 | if a: SIM102.py:15:1: SIM102 [*] Use a single `if` statement instead of nested `if` statements | @@ -84,18 +48,6 @@ SIM102.py:15:1: SIM102 [*] Use a single `if` statement instead of nested `if` st | = help: Combine `if` statements using `and` -ℹ Unsafe fix -12 12 | # SIM102 -13 13 | if a: -14 14 | pass -15 |-elif b: -16 |- if c: -17 |- d - 15 |+elif b and c: - 16 |+ d -18 17 | -19 18 | # SIM102 -20 19 | if a: SIM102.py:20:1: SIM102 Use a single `if` statement instead of nested `if` statements | @@ -119,20 +71,6 @@ SIM102.py:26:1: SIM102 [*] Use a single `if` statement instead of nested `if` st | = help: Combine `if` statements using `and` -ℹ Unsafe fix -23 23 | c -24 24 | -25 25 | # SIM102 -26 |-if a: -27 |- if b: -28 |- # Fixable due to placement of this comment. -29 |- c - 26 |+if a and b: - 27 |+ # Fixable due to placement of this comment. - 28 |+ c -30 29 | -31 30 | # OK -32 31 | if a: SIM102.py:51:5: SIM102 [*] Use a single `if` statement instead of nested `if` statements | @@ -147,30 +85,6 @@ SIM102.py:51:5: SIM102 [*] Use a single `if` statement instead of nested `if` st | = help: Combine `if` statements using `and` -ℹ Unsafe fix -48 48 | -49 49 | while x > 0: -50 50 | # SIM102 -51 |- if y > 0: -52 |- if z > 0: -53 |- """this - 51 |+ if y > 0 and z > 0: - 52 |+ """this -54 53 | is valid""" -55 54 | -56 |- """the indentation on - 55 |+ """the indentation on -57 56 | this line is significant""" -58 57 | -59 |- "this is" \ - 58 |+ "this is" \ -60 59 | "allowed too" -61 60 | -62 |- ("so is" - 61 |+ ("so is" -63 62 | "this for some reason") -64 63 | -65 64 | SIM102.py:67:1: SIM102 [*] Use a single `if` statement instead of nested `if` statements | @@ -183,30 +97,6 @@ SIM102.py:67:1: SIM102 [*] Use a single `if` statement instead of nested `if` st | = help: Combine `if` statements using `and` -ℹ Unsafe fix -64 64 | -65 65 | -66 66 | # SIM102 -67 |-if x > 0: -68 |- if y > 0: -69 |- """this - 67 |+if x > 0 and y > 0: - 68 |+ """this -70 69 | is valid""" -71 70 | -72 |- """the indentation on - 71 |+ """the indentation on -73 72 | this line is significant""" -74 73 | -75 |- "this is" \ - 74 |+ "this is" \ -76 75 | "allowed too" -77 76 | -78 |- ("so is" - 77 |+ ("so is" -79 78 | "this for some reason") -80 79 | -81 80 | while x > 0: SIM102.py:83:5: SIM102 [*] Use a single `if` statement instead of nested `if` statements | @@ -222,22 +112,6 @@ SIM102.py:83:5: SIM102 [*] Use a single `if` statement instead of nested `if` st | = help: Combine `if` statements using `and` -ℹ Unsafe fix -80 80 | -81 81 | while x > 0: -82 82 | # SIM102 -83 |- if node.module: -84 |- if node.module == "multiprocessing" or node.module.startswith( -85 |- "multiprocessing." -86 |- ): -87 |- print("Bad module!") - 83 |+ if node.module and (node.module == "multiprocessing" or node.module.startswith( - 84 |+ "multiprocessing." - 85 |+ )): - 86 |+ print("Bad module!") -88 87 | -89 88 | # SIM102 (auto-fixable) -90 89 | if node.module012345678: SIM102.py:90:1: SIM102 [*] Use a single `if` statement instead of nested `if` statements | @@ -251,22 +125,6 @@ SIM102.py:90:1: SIM102 [*] Use a single `if` statement instead of nested `if` st | = help: Combine `if` statements using `and` -ℹ Unsafe fix -87 87 | print("Bad module!") -88 88 | -89 89 | # SIM102 (auto-fixable) -90 |-if node.module012345678: -91 |- if node.module == "multiprocß9💣2ℝ" or node.module.startswith( -92 |- "multiprocessing." -93 |- ): -94 |- print("Bad module!") - 90 |+if node.module012345678 and (node.module == "multiprocß9💣2ℝ" or node.module.startswith( - 91 |+ "multiprocessing." - 92 |+)): - 93 |+ print("Bad module!") -95 94 | -96 95 | # SIM102 (not auto-fixable) -97 96 | if node.module0123456789: SIM102.py:97:1: SIM102 Use a single `if` statement instead of nested `if` statements | @@ -293,18 +151,6 @@ SIM102.py:106:5: SIM102 [*] Use a single `if` statement instead of nested `if` s | = help: Combine `if` statements using `and` -ℹ Unsafe fix -103 103 | # SIM102 -104 104 | # Regression test for https://github.com/apache/airflow/blob/145b16caaa43f0c42bffd97344df916c602cddde/airflow/configuration.py#L1161 -105 105 | if a: -106 |- if b: -107 |- if c: -108 |- print("if") - 106 |+ if b and c: - 107 |+ print("if") -109 108 | elif d: -110 109 | print("elif") -111 110 | SIM102.py:132:5: SIM102 [*] Use a single `if` statement instead of nested `if` statements | @@ -319,18 +165,6 @@ SIM102.py:132:5: SIM102 [*] Use a single `if` statement instead of nested `if` s | = help: Combine `if` statements using `and` -ℹ Unsafe fix -129 129 | # OK -130 130 | if a: -131 131 | # SIM 102 -132 |- if b: -133 |- if c: -134 |- print("foo") - 132 |+ if b and c: - 133 |+ print("foo") -135 134 | else: -136 135 | print("bar") -137 136 | SIM102.py:165:5: SIM102 [*] Use a single `if` statement instead of nested `if` statements | @@ -343,15 +177,3 @@ SIM102.py:165:5: SIM102 [*] Use a single `if` statement instead of nested `if` s 167 | d | = help: Combine `if` statements using `and` - -ℹ Unsafe fix -162 162 | def f(): -163 163 | if a: -164 164 | pass -165 |- elif b: -166 |- if c: -167 |- d - 165 |+ elif b and c: - 166 |+ d - - diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM103_SIM103.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM103_SIM103.py.snap index 1b44533abc17b..d1dd4d8dbd63c 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM103_SIM103.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM103_SIM103.py.snap @@ -14,17 +14,6 @@ SIM103.py:3:5: SIM103 [*] Return the condition `bool(a)` directly | = help: Replace with `return bool(a)` -ℹ Unsafe fix -1 1 | def f(): -2 2 | # SIM103 -3 |- if a: -4 |- return True -5 |- else: -6 |- return False - 3 |+ return bool(a) -7 4 | -8 5 | -9 6 | def f(): SIM103.py:11:5: SIM103 [*] Return the condition `a == b` directly | @@ -39,18 +28,6 @@ SIM103.py:11:5: SIM103 [*] Return the condition `a == b` directly | = help: Replace with `return a == b` -ℹ Unsafe fix -8 8 | -9 9 | def f(): -10 10 | # SIM103 -11 |- if a == b: -12 |- return True -13 |- else: -14 |- return False - 11 |+ return a == b -15 12 | -16 13 | -17 14 | def f(): SIM103.py:21:5: SIM103 [*] Return the condition `bool(b)` directly | @@ -65,18 +42,6 @@ SIM103.py:21:5: SIM103 [*] Return the condition `bool(b)` directly | = help: Replace with `return bool(b)` -ℹ Unsafe fix -18 18 | # SIM103 -19 19 | if a: -20 20 | return 1 -21 |- elif b: -22 |- return True -23 |- else: -24 |- return False - 21 |+ return bool(b) -25 22 | -26 23 | -27 24 | def f(): SIM103.py:32:9: SIM103 [*] Return the condition `bool(b)` directly | @@ -91,18 +56,6 @@ SIM103.py:32:9: SIM103 [*] Return the condition `bool(b)` directly | = help: Replace with `return bool(b)` -ℹ Unsafe fix -29 29 | if a: -30 30 | return 1 -31 31 | else: -32 |- if b: -33 |- return True -34 |- else: -35 |- return False - 32 |+ return bool(b) -36 33 | -37 34 | -38 35 | def f(): SIM103.py:57:5: SIM103 [*] Return the condition `not a` directly | @@ -117,18 +70,6 @@ SIM103.py:57:5: SIM103 [*] Return the condition `not a` directly | = help: Replace with `return not a` -ℹ Unsafe fix -54 54 | -55 55 | def f(): -56 56 | # SIM103 -57 |- if a: -58 |- return False -59 |- else: -60 |- return True - 57 |+ return not a -61 58 | -62 59 | -63 60 | def f(): SIM103.py:83:5: SIM103 Return the condition directly | @@ -156,18 +97,6 @@ SIM103.py:91:5: SIM103 [*] Return the condition `not (keys is not None and notic | = help: Replace with `return not (keys is not None and notice.key not in keys)` -ℹ Unsafe fix -88 88 | -89 89 | def f(): -90 90 | # SIM103 -91 |- if keys is not None and notice.key not in keys: -92 |- return False -93 |- else: -94 |- return True - 91 |+ return not (keys is not None and notice.key not in keys) -95 92 | -96 93 | -97 94 | ### SIM103.py:104:5: SIM103 [*] Return the condition `bool(a)` directly | @@ -181,17 +110,6 @@ SIM103.py:104:5: SIM103 [*] Return the condition `bool(a)` directly | = help: Replace with `return bool(a)` -ℹ Unsafe fix -101 101 | -102 102 | def f(): -103 103 | # SIM103 -104 |- if a: -105 |- return True -106 |- return False - 104 |+ return bool(a) -107 105 | -108 106 | -109 107 | def f(): SIM103.py:111:5: SIM103 [*] Return the condition `not a` directly | @@ -205,17 +123,6 @@ SIM103.py:111:5: SIM103 [*] Return the condition `not a` directly | = help: Replace with `return not a` -ℹ Unsafe fix -108 108 | -109 109 | def f(): -110 110 | # SIM103 -111 |- if a: -112 |- return False -113 |- return True - 111 |+ return not a -114 112 | -115 113 | -116 114 | def f(): SIM103.py:117:5: SIM103 [*] Return the condition `10 < a` directly | @@ -228,17 +135,6 @@ SIM103.py:117:5: SIM103 [*] Return the condition `10 < a` directly | = help: Replace with `return 10 < a` -ℹ Unsafe fix -114 114 | -115 115 | -116 116 | def f(): -117 |- if not 10 < a: -118 |- return False -119 |- return True - 117 |+ return 10 < a -120 118 | -121 119 | -122 120 | def f(): SIM103.py:123:5: SIM103 [*] Return the condition `not 10 < a` directly | @@ -250,12 +146,3 @@ SIM103.py:123:5: SIM103 [*] Return the condition `not 10 < a` directly | |_______________^ SIM103 | = help: Replace with `return not 10 < a` - -ℹ Unsafe fix -120 120 | -121 121 | -122 122 | def f(): -123 |- if 10 < a: -124 |- return False -125 |- return True - 123 |+ return not 10 < a diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_0.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_0.py.snap index dfd257b8a0ec9..5e54c31651859 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_0.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_0.py.snap @@ -12,21 +12,6 @@ SIM105_0.py:6:1: SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `tr | = help: Replace with `contextlib.suppress(ValueError)` -ℹ Unsafe fix - 1 |+import contextlib -1 2 | def foo(): -2 3 | pass -3 4 | -4 5 | -5 6 | # SIM105 -6 |-try: - 7 |+with contextlib.suppress(ValueError): -7 8 | foo() -8 |-except ValueError: -9 |- pass -10 9 | -11 10 | -12 11 | # SIM105 SIM105_0.py:13:1: SIM105 [*] Use `contextlib.suppress(ValueError, OSError)` instead of `try`-`except`-`pass` | @@ -41,23 +26,6 @@ SIM105_0.py:13:1: SIM105 [*] Use `contextlib.suppress(ValueError, OSError)` inst | = help: Replace with `contextlib.suppress(ValueError, OSError)` -ℹ Unsafe fix - 1 |+import contextlib -1 2 | def foo(): -2 3 | pass -3 4 | --------------------------------------------------------------------------------- -10 11 | -11 12 | -12 13 | # SIM105 -13 |-try: - 14 |+with contextlib.suppress(ValueError, OSError): -14 15 | foo() -15 |-except (ValueError, OSError): -16 |- pass -17 16 | -18 17 | # SIM105 -19 18 | try: SIM105_0.py:19:1: SIM105 [*] Use `contextlib.suppress(ValueError, OSError)` instead of `try`-`except`-`pass` | @@ -72,23 +40,6 @@ SIM105_0.py:19:1: SIM105 [*] Use `contextlib.suppress(ValueError, OSError)` inst | = help: Replace with `contextlib.suppress(ValueError, OSError)` -ℹ Unsafe fix - 1 |+import contextlib -1 2 | def foo(): -2 3 | pass -3 4 | --------------------------------------------------------------------------------- -16 17 | pass -17 18 | -18 19 | # SIM105 -19 |-try: - 20 |+with contextlib.suppress(ValueError, OSError): -20 21 | foo() -21 |-except (ValueError, OSError) as e: -22 |- pass -23 22 | -24 23 | # SIM105 -25 24 | try: SIM105_0.py:25:1: SIM105 [*] Use `contextlib.suppress(Exception)` instead of `try`-`except`-`pass` | @@ -103,23 +54,6 @@ SIM105_0.py:25:1: SIM105 [*] Use `contextlib.suppress(Exception)` instead of `tr | = help: Replace with `contextlib.suppress(Exception)` -ℹ Unsafe fix - 1 |+import contextlib -1 2 | def foo(): -2 3 | pass -3 4 | --------------------------------------------------------------------------------- -22 23 | pass -23 24 | -24 25 | # SIM105 -25 |-try: - 26 |+with contextlib.suppress(Exception): -26 27 | foo() -27 |-except: -28 |- pass -29 28 | -30 29 | # SIM105 -31 30 | try: SIM105_0.py:31:1: SIM105 [*] Use `contextlib.suppress(a.Error, b.Error)` instead of `try`-`except`-`pass` | @@ -134,23 +68,6 @@ SIM105_0.py:31:1: SIM105 [*] Use `contextlib.suppress(a.Error, b.Error)` instead | = help: Replace with `contextlib.suppress(a.Error, b.Error)` -ℹ Unsafe fix - 1 |+import contextlib -1 2 | def foo(): -2 3 | pass -3 4 | --------------------------------------------------------------------------------- -28 29 | pass -29 30 | -30 31 | # SIM105 -31 |-try: - 32 |+with contextlib.suppress(a.Error, b.Error): -32 33 | foo() -33 |-except (a.Error, b.Error): -34 |- pass -35 34 | -36 35 | # OK -37 36 | try: SIM105_0.py:85:5: SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `try`-`except`-`pass` | @@ -165,23 +82,6 @@ SIM105_0.py:85:5: SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `t | = help: Replace with `contextlib.suppress(ValueError)` -ℹ Unsafe fix - 1 |+import contextlib -1 2 | def foo(): -2 3 | pass -3 4 | --------------------------------------------------------------------------------- -82 83 | -83 84 | def with_ellipsis(): -84 85 | # OK -85 |- try: - 86 |+ with contextlib.suppress(ValueError): -86 87 | foo() -87 |- except ValueError: -88 |- ... -89 88 | -90 89 | -91 90 | def with_ellipsis_and_return(): SIM105_0.py:100:5: SIM105 Use `contextlib.suppress(ValueError, OSError)` instead of `try`-`except`-`pass` | @@ -212,23 +112,6 @@ SIM105_0.py:117:5: SIM105 [*] Use `contextlib.suppress(OSError)` instead of `try | = help: Replace with `contextlib.suppress(OSError)` -ℹ Unsafe fix - 1 |+import contextlib -1 2 | def foo(): -2 3 | pass -3 4 | --------------------------------------------------------------------------------- -114 115 | -115 116 | # Regression test for: https://github.com/astral-sh/ruff/issues/7123 -116 117 | def write_models(directory, Models): -117 |- try: - 118 |+ with contextlib.suppress(OSError): -118 119 | os.makedirs(model_dir); -119 |- except OSError: -120 |- pass; -121 120 | -122 121 | try: os.makedirs(model_dir); -123 122 | except OSError: SIM105_0.py:122:5: SIM105 [*] Use `contextlib.suppress(OSError)` instead of `try`-`except`-`pass` | @@ -244,22 +127,6 @@ SIM105_0.py:122:5: SIM105 [*] Use `contextlib.suppress(OSError)` instead of `try | = help: Replace with `contextlib.suppress(OSError)` -ℹ Unsafe fix - 1 |+import contextlib -1 2 | def foo(): -2 3 | pass -3 4 | --------------------------------------------------------------------------------- -119 120 | except OSError: -120 121 | pass; -121 122 | -122 |- try: os.makedirs(model_dir); -123 |- except OSError: -124 |- pass; - 123 |+ with contextlib.suppress(OSError): os.makedirs(model_dir); -125 124 | -126 125 | try: os.makedirs(model_dir); -127 126 | except OSError: SIM105_0.py:126:5: SIM105 [*] Use `contextlib.suppress(OSError)` instead of `try`-`except`-`pass` | @@ -274,21 +141,3 @@ SIM105_0.py:126:5: SIM105 [*] Use `contextlib.suppress(OSError)` instead of `try 130 | # | = help: Replace with `contextlib.suppress(OSError)` - -ℹ Unsafe fix - 1 |+import contextlib -1 2 | def foo(): -2 3 | pass -3 4 | --------------------------------------------------------------------------------- -123 124 | except OSError: -124 125 | pass; -125 126 | -126 |- try: os.makedirs(model_dir); -127 |- except OSError: -128 |- pass; \ - 127 |+ with contextlib.suppress(OSError): os.makedirs(model_dir); -129 128 | \ -130 129 | # - - diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_1.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_1.py.snap index 65f4991e1752c..7c33fa3a21ed6 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_1.py.snap @@ -11,17 +11,3 @@ SIM105_1.py:5:1: SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `tr | |________^ SIM105 | = help: Replace with `contextlib.suppress(ValueError)` - -ℹ Unsafe fix -1 1 | """Case: There's a random import, so it should add `contextlib` after it.""" -2 2 | import math - 3 |+import contextlib -3 4 | -4 5 | # SIM105 -5 |-try: - 6 |+with contextlib.suppress(ValueError): -6 7 | math.sqrt(-1) -7 |-except ValueError: -8 |- pass - - diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_2.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_2.py.snap index 1963b91bc8c1f..7a9e1604d1fee 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_2.py.snap @@ -11,15 +11,3 @@ SIM105_2.py:10:1: SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `t | |________^ SIM105 | = help: Replace with `contextlib.suppress(ValueError)` - -ℹ Unsafe fix -7 7 | -8 8 | -9 9 | # SIM105 -10 |-try: - 10 |+with contextlib.suppress(ValueError): -11 11 | foo() -12 |-except ValueError: -13 |- pass - - diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_4.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_4.py.snap index 1389a2ce4fdbe..9f05de1188be1 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_4.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_4.py.snap @@ -10,13 +10,3 @@ SIM105_4.py:2:1: SIM105 [*] Use `contextlib.suppress(ImportError)` instead of `t | |___________________________^ SIM105 | = help: Replace with `contextlib.suppress(ImportError)` - -ℹ Unsafe fix -1 1 | #!/usr/bin/env python -2 |-try: - 2 |+import contextlib - 3 |+with contextlib.suppress(ImportError): -3 4 | from __builtin__ import bytes, str, open, super, range, zip, round, int, pow, object, input -4 |-except ImportError: pass - - diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM108_SIM108.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM108_SIM108.py.snap index 71cede1631308..5eb801f924702 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM108_SIM108.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM108_SIM108.py.snap @@ -14,16 +14,6 @@ SIM108.py:2:1: SIM108 [*] Use ternary operator `b = c if a else d` instead of `i | = help: Replace `if`-`else`-block with `b = c if a else d` -ℹ Unsafe fix -1 1 | # SIM108 -2 |-if a: -3 |- b = c -4 |-else: -5 |- b = d - 2 |+b = c if a else d -6 3 | -7 4 | # OK -8 5 | b = c if a else d SIM108.py:30:5: SIM108 [*] Use ternary operator `b = 1 if a else 2` instead of `if`-`else`-block | @@ -38,18 +28,6 @@ SIM108.py:30:5: SIM108 [*] Use ternary operator `b = 1 if a else 2` instead of ` | = help: Replace `if`-`else`-block with `b = 1 if a else 2` -ℹ Unsafe fix -27 27 | if True: -28 28 | pass -29 29 | else: -30 |- if a: -31 |- b = 1 -32 |- else: -33 |- b = 2 - 30 |+ b = 1 if a else 2 -34 31 | -35 32 | -36 33 | import sys SIM108.py:58:1: SIM108 Use ternary operator `abc = x if x > 0 else -x` instead of `if`-`else`-block | @@ -75,18 +53,6 @@ SIM108.py:82:1: SIM108 [*] Use ternary operator `b = "cccccccccccccccccccccccccc | = help: Replace `if`-`else`-block with `b = "cccccccccccccccccccccccccccccccccß" if a else "ddddddddddddddddddddddddddddddddd💣"` -ℹ Unsafe fix -79 79 | -80 80 | -81 81 | # SIM108 -82 |-if a: -83 |- b = "cccccccccccccccccccccccccccccccccß" -84 |-else: -85 |- b = "ddddddddddddddddddddddddddddddddd💣" - 82 |+b = "cccccccccccccccccccccccccccccccccß" if a else "ddddddddddddddddddddddddddddddddd💣" -86 83 | -87 84 | -88 85 | # OK (too long) SIM108.py:105:1: SIM108 Use ternary operator `exitcode = 0 if True else 1` instead of `if`-`else`-block | @@ -118,5 +84,3 @@ SIM108.py:117:1: SIM108 Use ternary operator `x = 3 if True else 5` instead of ` | |_________^ SIM108 | = help: Replace `if`-`else`-block with `x = 3 if True else 5` - - diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM109_SIM109.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM109_SIM109.py.snap index 760f432942328..aa234174d3172 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM109_SIM109.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM109_SIM109.py.snap @@ -10,13 +10,6 @@ SIM109.py:2:4: SIM109 [*] Use `a in (b, c)` instead of multiple equality compari | = help: Replace with `a in (b, c)` -ℹ Unsafe fix -1 1 | # SIM109 -2 |-if a == b or a == c: - 2 |+if a in (b, c): -3 3 | d -4 4 | -5 5 | # SIM109 SIM109.py:6:5: SIM109 [*] Use `a in (b, c)` instead of multiple equality comparisons | @@ -27,15 +20,6 @@ SIM109.py:6:5: SIM109 [*] Use `a in (b, c)` instead of multiple equality compari | = help: Replace with `a in (b, c)` -ℹ Unsafe fix -3 3 | d -4 4 | -5 5 | # SIM109 -6 |-if (a == b or a == c) and None: - 6 |+if (a in (b, c)) and None: -7 7 | d -8 8 | -9 9 | # SIM109 SIM109.py:10:4: SIM109 [*] Use `a in (b, c)` instead of multiple equality comparisons | @@ -46,15 +30,6 @@ SIM109.py:10:4: SIM109 [*] Use `a in (b, c)` instead of multiple equality compar | = help: Replace with `a in (b, c)` -ℹ Unsafe fix -7 7 | d -8 8 | -9 9 | # SIM109 -10 |-if a == b or a == c or None: - 10 |+if a in (b, c) or None: -11 11 | d -12 12 | -13 13 | # SIM109 SIM109.py:14:4: SIM109 [*] Use `a in (b, c)` instead of multiple equality comparisons | @@ -64,15 +39,3 @@ SIM109.py:14:4: SIM109 [*] Use `a in (b, c)` instead of multiple equality compar 15 | d | = help: Replace with `a in (b, c)` - -ℹ Unsafe fix -11 11 | d -12 12 | -13 13 | # SIM109 -14 |-if a == b or None or a == c: - 14 |+if a in (b, c) or None: -15 15 | d -16 16 | -17 17 | # OK - - diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM110_SIM110.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM110_SIM110.py.snap index f23d9000363ee..a626d2e09d28b 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM110_SIM110.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM110_SIM110.py.snap @@ -14,17 +14,6 @@ SIM110.py:3:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead o | = help: Replace with `return any(check(x) for x in iterable)` -ℹ Unsafe fix -1 1 | def f(): -2 2 | # SIM110 -3 |- for x in iterable: -4 |- if check(x): -5 |- return True -6 |- return False - 3 |+ return any(check(x) for x in iterable) -7 4 | -8 5 | -9 6 | def f(): SIM110.py:25:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop | @@ -39,18 +28,6 @@ SIM110.py:25:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` inst | = help: Replace with `return all(not check(x) for x in iterable)` -ℹ Unsafe fix -22 22 | -23 23 | def f(): -24 24 | # SIM111 -25 |- for x in iterable: -26 |- if check(x): -27 |- return False -28 |- return True - 25 |+ return all(not check(x) for x in iterable) -29 26 | -30 27 | -31 28 | def f(): SIM110.py:33:5: SIM110 [*] Use `return all(x.is_empty() for x in iterable)` instead of `for` loop | @@ -65,18 +42,6 @@ SIM110.py:33:5: SIM110 [*] Use `return all(x.is_empty() for x in iterable)` inst | = help: Replace with `return all(x.is_empty() for x in iterable)` -ℹ Unsafe fix -30 30 | -31 31 | def f(): -32 32 | # SIM111 -33 |- for x in iterable: -34 |- if not x.is_empty(): -35 |- return False -36 |- return True - 33 |+ return all(x.is_empty() for x in iterable) -37 34 | -38 35 | -39 36 | def f(): SIM110.py:55:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop | @@ -92,19 +57,6 @@ SIM110.py:55:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead | = help: Replace with `return any(check(x) for x in iterable)` -ℹ Unsafe fix -52 52 | -53 53 | def f(): -54 54 | # SIM110 -55 |- for x in iterable: -56 |- if check(x): -57 |- return True -58 |- else: -59 |- return False - 55 |+ return any(check(x) for x in iterable) -60 56 | -61 57 | -62 58 | def f(): SIM110.py:64:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop | @@ -120,19 +72,6 @@ SIM110.py:64:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` inst | = help: Replace with `return all(not check(x) for x in iterable)` -ℹ Unsafe fix -61 61 | -62 62 | def f(): -63 63 | # SIM111 -64 |- for x in iterable: -65 |- if check(x): -66 |- return False -67 |- else: -68 |- return True - 64 |+ return all(not check(x) for x in iterable) -69 65 | -70 66 | -71 67 | def f(): SIM110.py:73:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop | @@ -149,19 +88,6 @@ SIM110.py:73:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead | = help: Replace with `return any(check(x) for x in iterable)` -ℹ Unsafe fix -70 70 | -71 71 | def f(): -72 72 | # SIM110 -73 |- for x in iterable: -74 |- if check(x): -75 |- return True -76 |- else: -77 |- return False - 73 |+ return any(check(x) for x in iterable) -78 74 | return True -79 75 | -80 76 | SIM110.py:83:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop | @@ -178,19 +104,6 @@ SIM110.py:83:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` inst | = help: Replace with `return all(not check(x) for x in iterable)` -ℹ Unsafe fix -80 80 | -81 81 | def f(): -82 82 | # SIM111 -83 |- for x in iterable: -84 |- if check(x): -85 |- return False -86 |- else: -87 |- return True - 83 |+ return all(not check(x) for x in iterable) -88 84 | return False -89 85 | -90 86 | SIM110.py:124:5: SIM110 Use `return any(check(x) for x in iterable)` instead of `for` loop | @@ -230,18 +143,6 @@ SIM110.py:144:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead | = help: Replace with `return any(check(x) for x in iterable)` -ℹ Unsafe fix -141 141 | x = 1 -142 142 | -143 143 | # SIM110 -144 |- for x in iterable: -145 |- if check(x): -146 |- return True -147 |- return False - 144 |+ return any(check(x) for x in iterable) -148 145 | -149 146 | -150 147 | def f(): SIM110.py:154:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop | @@ -255,18 +156,6 @@ SIM110.py:154:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` ins | = help: Replace with `return all(not check(x) for x in iterable)` -ℹ Unsafe fix -151 151 | x = 1 -152 152 | -153 153 | # SIM111 -154 |- for x in iterable: -155 |- if check(x): -156 |- return False -157 |- return True - 154 |+ return all(not check(x) for x in iterable) -158 155 | -159 156 | -160 157 | def f(): SIM110.py:162:5: SIM110 [*] Use `return any(x.isdigit() for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ")` instead of `for` loop | @@ -281,18 +170,6 @@ SIM110.py:162:5: SIM110 [*] Use `return any(x.isdigit() for x in "012ß9💣2ℝ | = help: Replace with `return any(x.isdigit() for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ")` -ℹ Unsafe fix -159 159 | -160 160 | def f(): -161 161 | # SIM110 -162 |- for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ": -163 |- if x.isdigit(): -164 |- return True -165 |- return False - 162 |+ return any(x.isdigit() for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ") -166 163 | -167 164 | -168 165 | def f(): SIM110.py:184:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop | @@ -309,18 +186,6 @@ SIM110.py:184:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead | = help: Replace with `return any(check(x) for x in iterable)` -ℹ Unsafe fix -181 181 | -182 182 | async def f(): -183 183 | # SIM110 -184 |- for x in iterable: -185 |- if check(x): -186 |- return True -187 |- return False - 184 |+ return any(check(x) for x in iterable) -188 185 | -189 186 | async def f(): -190 187 | # SIM110 SIM110.py:191:5: SIM110 [*] Use `return any(check(x) for x in await iterable)` instead of `for` loop | @@ -336,18 +201,3 @@ SIM110.py:191:5: SIM110 [*] Use `return any(check(x) for x in await iterable)` i 196 | def f(): | = help: Replace with `return any(check(x) for x in await iterable)` - -ℹ Unsafe fix -188 188 | -189 189 | async def f(): -190 190 | # SIM110 -191 |- for x in await iterable: -192 |- if check(x): -193 |- return True -194 |- return False - 191 |+ return any(check(x) for x in await iterable) -195 192 | -196 193 | def f(): -197 194 | # OK (can't turn this into any() because the yield would end up inside a genexp) - - diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM110_SIM111.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM110_SIM111.py.snap index 9b59955fe1eb6..aa40b964a1c97 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM110_SIM111.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM110_SIM111.py.snap @@ -14,17 +14,6 @@ SIM111.py:3:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead o | = help: Replace with `return any(check(x) for x in iterable)` -ℹ Unsafe fix -1 1 | def f(): -2 2 | # SIM110 -3 |- for x in iterable: -4 |- if check(x): -5 |- return True -6 |- return False - 3 |+ return any(check(x) for x in iterable) -7 4 | -8 5 | -9 6 | def f(): SIM111.py:25:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop | @@ -39,18 +28,6 @@ SIM111.py:25:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` inst | = help: Replace with `return all(not check(x) for x in iterable)` -ℹ Unsafe fix -22 22 | -23 23 | def f(): -24 24 | # SIM111 -25 |- for x in iterable: -26 |- if check(x): -27 |- return False -28 |- return True - 25 |+ return all(not check(x) for x in iterable) -29 26 | -30 27 | -31 28 | def f(): SIM111.py:33:5: SIM110 [*] Use `return all(x.is_empty() for x in iterable)` instead of `for` loop | @@ -65,18 +42,6 @@ SIM111.py:33:5: SIM110 [*] Use `return all(x.is_empty() for x in iterable)` inst | = help: Replace with `return all(x.is_empty() for x in iterable)` -ℹ Unsafe fix -30 30 | -31 31 | def f(): -32 32 | # SIM111 -33 |- for x in iterable: -34 |- if not x.is_empty(): -35 |- return False -36 |- return True - 33 |+ return all(x.is_empty() for x in iterable) -37 34 | -38 35 | -39 36 | def f(): SIM111.py:55:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop | @@ -92,19 +57,6 @@ SIM111.py:55:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead | = help: Replace with `return any(check(x) for x in iterable)` -ℹ Unsafe fix -52 52 | -53 53 | def f(): -54 54 | # SIM110 -55 |- for x in iterable: -56 |- if check(x): -57 |- return True -58 |- else: -59 |- return False - 55 |+ return any(check(x) for x in iterable) -60 56 | -61 57 | -62 58 | def f(): SIM111.py:64:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop | @@ -120,19 +72,6 @@ SIM111.py:64:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` inst | = help: Replace with `return all(not check(x) for x in iterable)` -ℹ Unsafe fix -61 61 | -62 62 | def f(): -63 63 | # SIM111 -64 |- for x in iterable: -65 |- if check(x): -66 |- return False -67 |- else: -68 |- return True - 64 |+ return all(not check(x) for x in iterable) -69 65 | -70 66 | -71 67 | def f(): SIM111.py:73:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop | @@ -149,19 +88,6 @@ SIM111.py:73:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead | = help: Replace with `return any(check(x) for x in iterable)` -ℹ Unsafe fix -70 70 | -71 71 | def f(): -72 72 | # SIM110 -73 |- for x in iterable: -74 |- if check(x): -75 |- return True -76 |- else: -77 |- return False - 73 |+ return any(check(x) for x in iterable) -78 74 | return True -79 75 | -80 76 | SIM111.py:83:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop | @@ -178,19 +104,6 @@ SIM111.py:83:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` inst | = help: Replace with `return all(not check(x) for x in iterable)` -ℹ Unsafe fix -80 80 | -81 81 | def f(): -82 82 | # SIM111 -83 |- for x in iterable: -84 |- if check(x): -85 |- return False -86 |- else: -87 |- return True - 83 |+ return all(not check(x) for x in iterable) -88 84 | return False -89 85 | -90 86 | SIM111.py:124:5: SIM110 Use `return any(check(x) for x in iterable)` instead of `for` loop | @@ -230,18 +143,6 @@ SIM111.py:144:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead | = help: Replace with `return any(check(x) for x in iterable)` -ℹ Unsafe fix -141 141 | x = 1 -142 142 | -143 143 | # SIM110 -144 |- for x in iterable: -145 |- if check(x): -146 |- return True -147 |- return False - 144 |+ return any(check(x) for x in iterable) -148 145 | -149 146 | -150 147 | def f(): SIM111.py:154:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop | @@ -255,18 +156,6 @@ SIM111.py:154:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` ins | = help: Replace with `return all(not check(x) for x in iterable)` -ℹ Unsafe fix -151 151 | x = 1 -152 152 | -153 153 | # SIM111 -154 |- for x in iterable: -155 |- if check(x): -156 |- return False -157 |- return True - 154 |+ return all(not check(x) for x in iterable) -158 155 | -159 156 | -160 157 | def f(): SIM111.py:162:5: SIM110 [*] Use `return all(x in y for x in iterable)` instead of `for` loop | @@ -281,18 +170,6 @@ SIM111.py:162:5: SIM110 [*] Use `return all(x in y for x in iterable)` instead o | = help: Replace with `return all(x in y for x in iterable)` -ℹ Unsafe fix -159 159 | -160 160 | def f(): -161 161 | # SIM111 -162 |- for x in iterable: -163 |- if x not in y: -164 |- return False -165 |- return True - 162 |+ return all(x in y for x in iterable) -166 163 | -167 164 | -168 165 | def f(): SIM111.py:170:5: SIM110 [*] Use `return all(x <= y for x in iterable)` instead of `for` loop | @@ -307,18 +184,6 @@ SIM111.py:170:5: SIM110 [*] Use `return all(x <= y for x in iterable)` instead o | = help: Replace with `return all(x <= y for x in iterable)` -ℹ Unsafe fix -167 167 | -168 168 | def f(): -169 169 | # SIM111 -170 |- for x in iterable: -171 |- if x > y: -172 |- return False -173 |- return True - 170 |+ return all(x <= y for x in iterable) -174 171 | -175 172 | -176 173 | def f(): SIM111.py:178:5: SIM110 [*] Use `return all(not x.isdigit() for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9")` instead of `for` loop | @@ -332,18 +197,3 @@ SIM111.py:178:5: SIM110 [*] Use `return all(not x.isdigit() for x in "012ß9💣 | |_______________^ SIM110 | = help: Replace with `return all(not x.isdigit() for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9")` - -ℹ Unsafe fix -175 175 | -176 176 | def f(): -177 177 | # SIM111 -178 |- for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9": -179 |- if x.isdigit(): -180 |- return False -181 |- return True - 178 |+ return all(not x.isdigit() for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9") -182 179 | -183 180 | -184 181 | def f(): - - diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM112_SIM112.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM112_SIM112.py.snap index fb82814e61b59..8ca5f6f7b09c9 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM112_SIM112.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM112_SIM112.py.snap @@ -11,15 +11,6 @@ SIM112.py:4:12: SIM112 [*] Use capitalized environment variable `FOO` instead of | = help: Replace `foo` with `FOO` -ℹ Unsafe fix -1 1 | import os -2 2 | -3 3 | # Bad -4 |-os.environ['foo'] - 4 |+os.environ['FOO'] -5 5 | -6 6 | os.environ.get('foo') -7 7 | SIM112.py:6:16: SIM112 Use capitalized environment variable `FOO` instead of `foo` | @@ -76,15 +67,6 @@ SIM112.py:14:18: SIM112 [*] Use capitalized environment variable `FOO` instead o | = help: Replace `foo` with `FOO` -ℹ Unsafe fix -11 11 | -12 12 | env = os.environ.get('foo') -13 13 | -14 |-env = os.environ['foo'] - 14 |+env = os.environ['FOO'] -15 15 | -16 16 | if env := os.environ.get('foo'): -17 17 | pass SIM112.py:16:26: SIM112 Use capitalized environment variable `FOO` instead of `foo` | @@ -105,15 +87,3 @@ SIM112.py:19:22: SIM112 [*] Use capitalized environment variable `FOO` instead o 20 | pass | = help: Replace `foo` with `FOO` - -ℹ Unsafe fix -16 16 | if env := os.environ.get('foo'): -17 17 | pass -18 18 | -19 |-if env := os.environ['foo']: - 19 |+if env := os.environ['FOO']: -20 20 | pass -21 21 | -22 22 | - - diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM114_SIM114.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM114_SIM114.py.snap index eaf2057160b39..05d1857f40d93 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM114_SIM114.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM114_SIM114.py.snap @@ -14,7 +14,6 @@ SIM114.py:2:1: SIM114 [*] Combine `if` branches using logical `or` operator | = help: Combine `if` branches -ℹ Safe fix 1 1 | # Errors 2 |-if a: 3 |- b @@ -38,7 +37,6 @@ SIM114.py:7:1: SIM114 [*] Combine `if` branches using logical `or` operator | = help: Combine `if` branches -ℹ Safe fix 4 4 | elif c: 5 5 | b 6 6 | @@ -66,7 +64,6 @@ SIM114.py:12:1: SIM114 [*] Combine `if` branches using logical `or` operator | = help: Combine `if` branches -ℹ Safe fix 9 9 | elif c: # but not on the second branch 10 10 | b 11 11 | @@ -97,7 +94,6 @@ SIM114.py:19:1: SIM114 [*] Combine `if` branches using logical `or` operator | = help: Combine `if` branches -ℹ Safe fix 16 16 | for _ in range(20): 17 17 | print("hello") 18 18 | @@ -135,7 +131,6 @@ SIM114.py:28:1: SIM114 [*] Combine `if` branches using logical `or` operator | = help: Combine `if` branches -ℹ Safe fix 25 25 | for _ in range(20): 26 26 | print("hello") 27 27 | @@ -168,7 +163,6 @@ SIM114.py:29:5: SIM114 [*] Combine `if` branches using logical `or` operator | = help: Combine `if` branches -ℹ Safe fix 26 26 | print("hello") 27 27 | 28 28 | if x == 1: @@ -198,7 +192,6 @@ SIM114.py:36:5: SIM114 [*] Combine `if` branches using logical `or` operator | = help: Combine `if` branches -ℹ Safe fix 33 33 | for _ in range(20): 34 34 | print("hello") 35 35 | elif x == 2: @@ -240,7 +233,6 @@ SIM114.py:43:1: SIM114 [*] Combine `if` branches using logical `or` operator | = help: Combine `if` branches -ℹ Safe fix 55 55 | and i == 12 56 56 | and j == 13 57 57 | and k == 14 @@ -266,7 +258,6 @@ SIM114.py:67:1: SIM114 [*] Combine `if` branches using logical `or` operator | = help: Combine `if` branches -ℹ Safe fix 64 64 | pass 65 65 | elif result.eofs == "S": 66 66 | skipped = 1 @@ -292,7 +283,6 @@ SIM114.py:69:1: SIM114 [*] Combine `if` branches using logical `or` operator | = help: Combine `if` branches -ℹ Safe fix 66 66 | skipped = 1 67 67 | elif result.eofs == "F": 68 68 | errors = 1 @@ -316,7 +306,6 @@ SIM114.py:71:1: SIM114 [*] Combine `if` branches using logical `or` operator | = help: Combine `if` branches -ℹ Safe fix 68 68 | errors = 1 69 69 | elif result.eofs == "E": 70 70 | errors = 1 @@ -343,7 +332,6 @@ SIM114.py:118:5: SIM114 [*] Combine `if` branches using logical `or` operator | = help: Combine `if` branches -ℹ Safe fix 115 115 | def func(): 116 116 | a = True 117 117 | b = False @@ -368,7 +356,6 @@ SIM114.py:122:5: SIM114 [*] Combine `if` branches using logical `or` operator | = help: Combine `if` branches -ℹ Safe fix 119 119 | return 3 120 120 | elif a == b: 121 121 | return 3 @@ -393,7 +380,6 @@ SIM114.py:132:5: SIM114 [*] Combine `if` branches using logical `or` operator | = help: Combine `if` branches -ℹ Safe fix 129 129 | """Ensure that the named expression is parenthesized when merged.""" 130 130 | a = True 131 131 | b = False @@ -415,7 +401,6 @@ SIM114.py:138:1: SIM114 [*] Combine `if` branches using logical `or` operator | = help: Combine `if` branches -ℹ Safe fix 135 135 | return 3 136 136 | 137 137 | @@ -435,7 +420,6 @@ SIM114.py:144:1: SIM114 [*] Combine `if` branches using logical `or` operator | = help: Combine `if` branches -ℹ Safe fix 141 141 | b 142 142 | 143 143 | @@ -455,7 +439,6 @@ SIM114.py:148:1: SIM114 [*] Combine `if` branches using logical `or` operator | = help: Combine `if` branches -ℹ Safe fix 145 145 | elif c: b 146 146 | 147 147 | @@ -463,5 +446,3 @@ SIM114.py:148:1: SIM114 [*] Combine `if` branches using logical `or` operator 149 |-elif(100 < x and x < 200 and 300 < y and y < 800): 150 |- pass 148 |+if(x > 200) or (100 < x and x < 200 and 300 < y and y < 800): pass - - diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM117_SIM117.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM117_SIM117.py.snap index 597f19d7fdce8..073172ec5276b 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM117_SIM117.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM117_SIM117.py.snap @@ -11,16 +11,6 @@ SIM117.py:2:1: SIM117 [*] Use a single `with` statement with multiple contexts i | = help: Combine `with` statements -ℹ Unsafe fix -1 1 | # SIM117 -2 |-with A() as a: -3 |- with B() as b: -4 |- print("hello") - 2 |+with A() as a, B() as b: - 3 |+ print("hello") -5 4 | -6 5 | # SIM117 -7 6 | with A(): SIM117.py:7:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements | @@ -33,20 +23,6 @@ SIM117.py:7:1: SIM117 [*] Use a single `with` statement with multiple contexts i | = help: Combine `with` statements -ℹ Unsafe fix -4 4 | print("hello") -5 5 | -6 6 | # SIM117 -7 |-with A(): -8 |- with B(): -9 |- with C(): -10 |- print("hello") - 7 |+with A(), B(): - 8 |+ with C(): - 9 |+ print("hello") -11 10 | -12 11 | # SIM117 -13 12 | with A() as a: SIM117.py:13:1: SIM117 Use a single `with` statement with multiple contexts instead of nested `with` statements | @@ -70,20 +46,6 @@ SIM117.py:19:1: SIM117 [*] Use a single `with` statement with multiple contexts | = help: Combine `with` statements -ℹ Unsafe fix -16 16 | print("hello") -17 17 | -18 18 | # SIM117 -19 |-with A() as a: -20 |- with B() as b: -21 |- # Fixable due to placement of this comment. -22 |- print("hello") - 19 |+with A() as a, B() as b: - 20 |+ # Fixable due to placement of this comment. - 21 |+ print("hello") -23 22 | -24 23 | # OK -25 24 | with A() as a: SIM117.py:47:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements | @@ -95,18 +57,6 @@ SIM117.py:47:1: SIM117 [*] Use a single `with` statement with multiple contexts | = help: Combine `with` statements -ℹ Unsafe fix -44 44 | print("hello") -45 45 | -46 46 | # SIM117 -47 |-async with A() as a: -48 |- async with B() as b: -49 |- print("hello") - 47 |+async with A() as a, B() as b: - 48 |+ print("hello") -50 49 | -51 50 | while True: -52 51 | # SIM117 SIM117.py:53:5: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements | @@ -121,30 +71,6 @@ SIM117.py:53:5: SIM117 [*] Use a single `with` statement with multiple contexts | = help: Combine `with` statements -ℹ Unsafe fix -50 50 | -51 51 | while True: -52 52 | # SIM117 -53 |- with A() as a: -54 |- with B() as b: -55 |- """this - 53 |+ with A() as a, B() as b: - 54 |+ """this -56 55 | is valid""" -57 56 | -58 |- """the indentation on - 57 |+ """the indentation on -59 58 | this line is significant""" -60 59 | -61 |- "this is" \ - 60 |+ "this is" \ -62 61 | "allowed too" -63 62 | -64 |- ("so is" - 63 |+ ("so is" -65 64 | "this for some reason") -66 65 | -67 66 | # SIM117 SIM117.py:68:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements | @@ -159,19 +85,6 @@ SIM117.py:68:1: SIM117 [*] Use a single `with` statement with multiple contexts | = help: Combine `with` statements -ℹ Unsafe fix -67 67 | # SIM117 -68 68 | with ( -69 69 | A() as a, -70 |- B() as b, - 70 |+ B() as b,C() as c -71 71 | ): -72 |- with C() as c: -73 |- print("hello") - 72 |+ print("hello") -74 73 | -75 74 | # SIM117 -76 75 | with A() as a: SIM117.py:76:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements | @@ -186,24 +99,6 @@ SIM117.py:76:1: SIM117 [*] Use a single `with` statement with multiple contexts | = help: Combine `with` statements -ℹ Unsafe fix -73 73 | print("hello") -74 74 | -75 75 | # SIM117 -76 |-with A() as a: -77 |- with ( -78 |- B() as b, -79 |- C() as c, -80 |- ): -81 |- print("hello") - 76 |+with ( - 77 |+ A() as a, B() as b, - 78 |+ C() as c, - 79 |+): - 80 |+ print("hello") -82 81 | -83 82 | # SIM117 -84 83 | with ( SIM117.py:84:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements | @@ -221,23 +116,6 @@ SIM117.py:84:1: SIM117 [*] Use a single `with` statement with multiple contexts | = help: Combine `with` statements -ℹ Unsafe fix -83 83 | # SIM117 -84 84 | with ( -85 85 | A() as a, -86 |- B() as b, - 86 |+ B() as b,C() as c, - 87 |+ D() as d, -87 88 | ): -88 |- with ( -89 |- C() as c, -90 |- D() as d, -91 |- ): -92 |- print("hello") - 89 |+ print("hello") -93 90 | -94 91 | # SIM117 (auto-fixable) -95 92 | with A("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ89") as a: SIM117.py:95:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements | @@ -249,18 +127,6 @@ SIM117.py:95:1: SIM117 [*] Use a single `with` statement with multiple contexts | = help: Combine `with` statements -ℹ Unsafe fix -92 92 | print("hello") -93 93 | -94 94 | # SIM117 (auto-fixable) -95 |-with A("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ89") as a: -96 |- with B("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ89") as b: -97 |- print("hello") - 95 |+with A("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ89") as a, B("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ89") as b: - 96 |+ print("hello") -98 97 | -99 98 | # SIM117 (not auto-fixable too long) -100 99 | with A("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ890") as a: SIM117.py:100:1: SIM117 Use a single `with` statement with multiple contexts instead of nested `with` statements | @@ -294,31 +160,6 @@ SIM117.py:126:1: SIM117 [*] Use a single `with` statement with multiple contexts | = help: Combine `with` statements -ℹ Unsafe fix -123 123 | f(b2, c2, d2) -124 124 | -125 125 | # SIM117 -126 |-with A() as a: -127 |- with B() as b: -128 |- type ListOrSet[T] = list[T] | set[T] - 126 |+with A() as a, B() as b: - 127 |+ type ListOrSet[T] = list[T] | set[T] -129 128 | -130 |- class ClassA[T: str]: -131 |- def method1(self) -> T: -132 |- ... - 129 |+ class ClassA[T: str]: - 130 |+ def method1(self) -> T: - 131 |+ ... -133 132 | -134 |- f" something { my_dict["key"] } something else " - 133 |+ f" something { my_dict["key"] } something else " -135 134 | -136 |- f"foo {f"bar {x}"} baz" - 135 |+ f"foo {f"bar {x}"} baz" -137 136 | -138 137 | # Allow cascading for some statements. -139 138 | import anyio SIM117.py:163:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements | @@ -329,15 +170,3 @@ SIM117.py:163:1: SIM117 [*] Use a single `with` statement with multiple contexts 165 | pass | = help: Combine `with` statements - -ℹ Unsafe fix -160 160 | pass -161 161 | -162 162 | # Do not suppress combination, if a context manager is already combined with another. -163 |-async with asyncio.timeout(1), A(): -164 |- async with B(): -165 |- pass - 163 |+async with asyncio.timeout(1), A(), B(): - 164 |+ pass - - diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM118_SIM118.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM118_SIM118.py.snap index 8acd4d438bc9e..a227662d2142a 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM118_SIM118.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM118_SIM118.py.snap @@ -12,7 +12,6 @@ SIM118.py:3:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | = help: Remove `.keys()` -ℹ Safe fix 1 1 | obj = {} 2 2 | 3 |-key in obj.keys() # SIM118 @@ -32,7 +31,6 @@ SIM118.py:5:1: SIM118 [*] Use `key not in dict` instead of `key not in dict.keys | = help: Remove `.keys()` -ℹ Safe fix 2 2 | 3 3 | key in obj.keys() # SIM118 4 4 | @@ -53,7 +51,6 @@ SIM118.py:7:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | = help: Remove `.keys()` -ℹ Safe fix 4 4 | 5 5 | key not in obj.keys() # SIM118 6 6 | @@ -74,7 +71,6 @@ SIM118.py:9:1: SIM118 [*] Use `key not in dict` instead of `key not in dict.keys | = help: Remove `.keys()` -ℹ Safe fix 6 6 | 7 7 | foo["bar"] in obj.keys() # SIM118 8 8 | @@ -95,7 +91,6 @@ SIM118.py:11:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | = help: Remove `.keys()` -ℹ Safe fix 8 8 | 9 9 | foo["bar"] not in obj.keys() # SIM118 10 10 | @@ -116,7 +111,6 @@ SIM118.py:13:1: SIM118 [*] Use `key not in dict` instead of `key not in dict.key | = help: Remove `.keys()` -ℹ Safe fix 10 10 | 11 11 | foo['bar'] in obj.keys() # SIM118 12 12 | @@ -137,7 +131,6 @@ SIM118.py:15:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | = help: Remove `.keys()` -ℹ Safe fix 12 12 | 13 13 | foo['bar'] not in obj.keys() # SIM118 14 14 | @@ -158,7 +151,6 @@ SIM118.py:17:1: SIM118 [*] Use `key not in dict` instead of `key not in dict.key | = help: Remove `.keys()` -ℹ Safe fix 14 14 | 15 15 | foo() in obj.keys() # SIM118 16 16 | @@ -178,7 +170,6 @@ SIM118.py:19:5: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | = help: Remove `.keys()` -ℹ Safe fix 16 16 | 17 17 | foo() not in obj.keys() # SIM118 18 18 | @@ -199,7 +190,6 @@ SIM118.py:26:8: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | = help: Remove `.keys()` -ℹ Safe fix 23 23 | if some_property(key): 24 24 | del obj[key] 25 25 | @@ -220,7 +210,6 @@ SIM118.py:28:8: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | = help: Remove `.keys()` -ℹ Safe fix 25 25 | 26 26 | [k for k in obj.keys()] # SIM118 27 27 | @@ -241,7 +230,6 @@ SIM118.py:30:11: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | = help: Remove `.keys()` -ℹ Safe fix 27 27 | 28 28 | {k for k in obj.keys()} # SIM118 29 29 | @@ -262,7 +250,6 @@ SIM118.py:32:8: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | = help: Remove `.keys()` -ℹ Safe fix 29 29 | 30 30 | {k: k for k in obj.keys()} # SIM118 31 31 | @@ -283,15 +270,6 @@ SIM118.py:34:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | = help: Remove `.keys()` -ℹ Unsafe fix -31 31 | -32 32 | (k for k in obj.keys()) # SIM118 -33 33 | -34 |-key in (obj or {}).keys() # SIM118 - 34 |+key in (obj or {}) # SIM118 -35 35 | -36 36 | (key) in (obj or {}).keys() # SIM118 -37 37 | SIM118.py:36:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | @@ -304,15 +282,6 @@ SIM118.py:36:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | = help: Remove `.keys()` -ℹ Unsafe fix -33 33 | -34 34 | key in (obj or {}).keys() # SIM118 -35 35 | -36 |-(key) in (obj or {}).keys() # SIM118 - 36 |+(key) in (obj or {}) # SIM118 -37 37 | -38 38 | from typing import KeysView -39 39 | SIM118.py:50:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | @@ -324,7 +293,6 @@ SIM118.py:50:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | = help: Remove `.keys()` -ℹ Safe fix 47 47 | 48 48 | 49 49 | # Regression test for: https://github.com/astral-sh/ruff/issues/7124 @@ -344,7 +312,6 @@ SIM118.py:51:2: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | = help: Remove `.keys()` -ℹ Safe fix 48 48 | 49 49 | # Regression test for: https://github.com/astral-sh/ruff/issues/7124 50 50 | key in obj.keys()and foo @@ -365,7 +332,6 @@ SIM118.py:52:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | = help: Remove `.keys()` -ℹ Safe fix 49 49 | # Regression test for: https://github.com/astral-sh/ruff/issues/7124 50 50 | key in obj.keys()and foo 51 51 | (key in obj.keys())and foo @@ -389,15 +355,6 @@ SIM118.py:55:5: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | = help: Remove `.keys()` -ℹ Unsafe fix -55 55 | for key in ( -56 56 | self.experiment.surveys[0] -57 57 | .stations[0] -58 |- .keys() - 58 |+ -59 59 | ): -60 60 | continue -61 61 | SIM118.py:65:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | @@ -407,7 +364,6 @@ SIM118.py:65:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | = help: Remove `.keys()` -ℹ Safe fix 62 62 | from builtins import dict as SneakyDict 63 63 | 64 64 | d = SneakyDict() diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM201_SIM201.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM201_SIM201.py.snap index 7bc978ae96e5a..cf0079a7716b5 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM201_SIM201.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM201_SIM201.py.snap @@ -10,7 +10,6 @@ SIM201.py:2:4: SIM201 [*] Use `a != b` instead of `not a == b` | = help: Replace with `!=` operator -ℹ Safe fix 1 1 | # SIM201 2 |-if not a == b: 2 |+if a != b: @@ -27,7 +26,6 @@ SIM201.py:6:4: SIM201 [*] Use `a != b + c` instead of `not a == b + c` | = help: Replace with `!=` operator -ℹ Safe fix 3 3 | pass 4 4 | 5 5 | # SIM201 @@ -46,7 +44,6 @@ SIM201.py:10:4: SIM201 [*] Use `a + b != c` instead of `not a + b == c` | = help: Replace with `!=` operator -ℹ Safe fix 7 7 | pass 8 8 | 9 9 | # SIM201 @@ -55,5 +52,3 @@ SIM201.py:10:4: SIM201 [*] Use `a + b != c` instead of `not a + b == c` 11 11 | pass 12 12 | 13 13 | # OK - - diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM202_SIM202.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM202_SIM202.py.snap index 46e9c368fa1b0..9d74f2c101355 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM202_SIM202.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM202_SIM202.py.snap @@ -10,7 +10,6 @@ SIM202.py:2:4: SIM202 [*] Use `a == b` instead of `not a != b` | = help: Replace with `==` operator -ℹ Safe fix 1 1 | # SIM202 2 |-if not a != b: 2 |+if a == b: @@ -27,7 +26,6 @@ SIM202.py:6:4: SIM202 [*] Use `a == b + c` instead of `not a != b + c` | = help: Replace with `==` operator -ℹ Safe fix 3 3 | pass 4 4 | 5 5 | # SIM202 @@ -46,7 +44,6 @@ SIM202.py:10:4: SIM202 [*] Use `a + b == c` instead of `not a + b != c` | = help: Replace with `==` operator -ℹ Safe fix 7 7 | pass 8 8 | 9 9 | # SIM202 @@ -55,5 +52,3 @@ SIM202.py:10:4: SIM202 [*] Use `a + b == c` instead of `not a + b != c` 11 11 | pass 12 12 | 13 13 | # OK - - diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM208_SIM208.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM208_SIM208.py.snap index fa96fedd5098c..7571197d0ae23 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM208_SIM208.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM208_SIM208.py.snap @@ -9,7 +9,6 @@ SIM208.py:1:4: SIM208 [*] Use `a` instead of `not (not a)` | = help: Replace with `a` -ℹ Safe fix 1 |-if not (not a): # SIM208 1 |+if a: # SIM208 2 2 | pass @@ -26,7 +25,6 @@ SIM208.py:4:4: SIM208 [*] Use `a == b` instead of `not (not a == b)` | = help: Replace with `a == b` -ℹ Safe fix 1 1 | if not (not a): # SIM208 2 2 | pass 3 3 | @@ -47,7 +45,6 @@ SIM208.py:16:5: SIM208 [*] Use `b` instead of `not (not b)` | = help: Replace with `b` -ℹ Safe fix 13 13 | if not a != b: # OK 14 14 | pass 15 15 | @@ -68,7 +65,6 @@ SIM208.py:18:3: SIM208 [*] Use `a` instead of `not (not a)` | = help: Replace with `a` -ℹ Safe fix 15 15 | 16 16 | a = not not b # SIM208 17 17 | @@ -88,12 +84,9 @@ SIM208.py:20:9: SIM208 [*] Use `a` instead of `not (not a)` | = help: Replace with `a` -ℹ Safe fix 17 17 | 18 18 | f(not not a) # SIM208 19 19 | 20 |-if 1 + (not (not a)): # SIM208 20 |+if 1 + (bool(a)): # SIM208 21 21 | pass - - diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM210_SIM210.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM210_SIM210.py.snap index 50c7b4ebe93d1..30ca3453494b9 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM210_SIM210.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM210_SIM210.py.snap @@ -10,12 +10,6 @@ SIM210.py:1:5: SIM210 [*] Use `bool(...)` instead of `True if ... else False` | = help: Replace with `bool(...) -ℹ Unsafe fix -1 |-a = True if b else False # SIM210 - 1 |+a = bool(b) # SIM210 -2 2 | -3 3 | a = True if b != c else False # SIM210 -4 4 | SIM210.py:3:5: SIM210 [*] Remove unnecessary `True if ... else False` | @@ -28,14 +22,6 @@ SIM210.py:3:5: SIM210 [*] Remove unnecessary `True if ... else False` | = help: Remove unnecessary `True if ... else False` -ℹ Unsafe fix -1 1 | a = True if b else False # SIM210 -2 2 | -3 |-a = True if b != c else False # SIM210 - 3 |+a = b != c # SIM210 -4 4 | -5 5 | a = True if b + c else False # SIM210 -6 6 | SIM210.py:5:5: SIM210 [*] Use `bool(...)` instead of `True if ... else False` | @@ -48,15 +34,6 @@ SIM210.py:5:5: SIM210 [*] Use `bool(...)` instead of `True if ... else False` | = help: Replace with `bool(...) -ℹ Unsafe fix -2 2 | -3 3 | a = True if b != c else False # SIM210 -4 4 | -5 |-a = True if b + c else False # SIM210 - 5 |+a = bool(b + c) # SIM210 -6 6 | -7 7 | a = False if b else True # OK -8 8 | SIM210.py:15:9: SIM210 Use `bool(...)` instead of `True if ... else False` | @@ -76,14 +53,3 @@ SIM210.py:19:11: SIM210 [*] Remove unnecessary `True if ... else False` | |____________________________________________________________________________^ SIM210 | = help: Remove unnecessary `True if ... else False` - -ℹ Unsafe fix -16 16 | -17 17 | -18 18 | # Regression test for: https://github.com/astral-sh/ruff/issues/7076 -19 |-samesld = True if (psl.privatesuffix(urlparse(response.url).netloc) == -20 |- psl.privatesuffix(src.netloc)) else False - 19 |+samesld = (psl.privatesuffix(urlparse(response.url).netloc) == - 20 |+ psl.privatesuffix(src.netloc)) - - diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM211_SIM211.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM211_SIM211.py.snap index 8e3650b7e5723..e0a749c7289bd 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM211_SIM211.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM211_SIM211.py.snap @@ -10,12 +10,6 @@ SIM211.py:1:5: SIM211 [*] Use `not ...` instead of `False if ... else True` | = help: Replace with `not ...` -ℹ Unsafe fix -1 |-a = False if b else True # SIM211 - 1 |+a = not b # SIM211 -2 2 | -3 3 | a = False if b != c else True # SIM211 -4 4 | SIM211.py:3:5: SIM211 [*] Use `not ...` instead of `False if ... else True` | @@ -28,14 +22,6 @@ SIM211.py:3:5: SIM211 [*] Use `not ...` instead of `False if ... else True` | = help: Replace with `not ...` -ℹ Unsafe fix -1 1 | a = False if b else True # SIM211 -2 2 | -3 |-a = False if b != c else True # SIM211 - 3 |+a = not b != c # SIM211 -4 4 | -5 5 | a = False if b + c else True # SIM211 -6 6 | SIM211.py:5:5: SIM211 [*] Use `not ...` instead of `False if ... else True` | @@ -47,14 +33,3 @@ SIM211.py:5:5: SIM211 [*] Use `not ...` instead of `False if ... else True` 7 | a = True if b else False # OK | = help: Replace with `not ...` - -ℹ Unsafe fix -2 2 | -3 3 | a = False if b != c else True # SIM211 -4 4 | -5 |-a = False if b + c else True # SIM211 - 5 |+a = not b + c # SIM211 -6 6 | -7 7 | a = True if b else False # OK - - diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM212_SIM212.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM212_SIM212.py.snap index 35b8bc12a55e4..0778d7b612524 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM212_SIM212.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM212_SIM212.py.snap @@ -10,12 +10,6 @@ SIM212.py:1:5: SIM212 [*] Use `a if a else b` instead of `b if not a else a` | = help: Replace with `a if a else b` -ℹ Unsafe fix -1 |-c = b if not a else a # SIM212 - 1 |+c = a if a else b # SIM212 -2 2 | -3 3 | c = b + c if not a else a # SIM212 -4 4 | SIM212.py:3:5: SIM212 [*] Use `a if a else b + c` instead of `b + c if not a else a` | @@ -27,14 +21,3 @@ SIM212.py:3:5: SIM212 [*] Use `a if a else b + c` instead of `b + c if not a els 5 | c = b if not x else a # OK | = help: Replace with `a if a else b + c` - -ℹ Unsafe fix -1 1 | c = b if not a else a # SIM212 -2 2 | -3 |-c = b + c if not a else a # SIM212 - 3 |+c = a if a else b + c # SIM212 -4 4 | -5 5 | c = b if not x else a # OK -6 6 | - - diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM220_SIM220.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM220_SIM220.py.snap index b0c23c954c721..c4d65920b12e0 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM220_SIM220.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM220_SIM220.py.snap @@ -9,12 +9,6 @@ SIM220.py:1:4: SIM220 [*] Use `False` instead of `a and not a` | = help: Replace with `False` -ℹ Unsafe fix -1 |-if a and not a: - 1 |+if False: -2 2 | pass -3 3 | -4 4 | if (a and not a) and b: SIM220.py:4:5: SIM220 [*] Use `False` instead of `a and not a` | @@ -26,15 +20,6 @@ SIM220.py:4:5: SIM220 [*] Use `False` instead of `a and not a` | = help: Replace with `False` -ℹ Unsafe fix -1 1 | if a and not a: -2 2 | pass -3 3 | -4 |-if (a and not a) and b: - 4 |+if (False) and b: -5 5 | pass -6 6 | -7 7 | if (a and not a) or b: SIM220.py:7:5: SIM220 [*] Use `False` instead of `a and not a` | @@ -45,15 +30,3 @@ SIM220.py:7:5: SIM220 [*] Use `False` instead of `a and not a` 8 | pass | = help: Replace with `False` - -ℹ Unsafe fix -4 4 | if (a and not a) and b: -5 5 | pass -6 6 | -7 |-if (a and not a) or b: - 7 |+if (False) or b: -8 8 | pass -9 9 | -10 10 | if a: - - diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM221_SIM221.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM221_SIM221.py.snap index 038e5fcf64a24..2e32453e6fd10 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM221_SIM221.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM221_SIM221.py.snap @@ -9,12 +9,6 @@ SIM221.py:1:4: SIM221 [*] Use `True` instead of `a or not a` | = help: Replace with `True` -ℹ Unsafe fix -1 |-if a or not a: - 1 |+if True: -2 2 | pass -3 3 | -4 4 | if (a or not a) or b: SIM221.py:4:5: SIM221 [*] Use `True` instead of `a or not a` | @@ -26,15 +20,6 @@ SIM221.py:4:5: SIM221 [*] Use `True` instead of `a or not a` | = help: Replace with `True` -ℹ Unsafe fix -1 1 | if a or not a: -2 2 | pass -3 3 | -4 |-if (a or not a) or b: - 4 |+if (True) or b: -5 5 | pass -6 6 | -7 7 | if (a or not a) and b: SIM221.py:7:5: SIM221 [*] Use `True` instead of `a or not a` | @@ -45,15 +30,3 @@ SIM221.py:7:5: SIM221 [*] Use `True` instead of `a or not a` 8 | pass | = help: Replace with `True` - -ℹ Unsafe fix -4 4 | if (a or not a) or b: -5 5 | pass -6 6 | -7 |-if (a or not a) and b: - 7 |+if (True) and b: -8 8 | pass -9 9 | -10 10 | if a: - - diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM222_SIM222.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM222_SIM222.py.snap index ddf4598e13b59..bd452aa42df99 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM222_SIM222.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM222_SIM222.py.snap @@ -9,12 +9,6 @@ SIM222.py:1:4: SIM222 [*] Use `True` instead of `... or True` | = help: Replace with `True` -ℹ Unsafe fix -1 |-if a or True: # SIM222 - 1 |+if True: # SIM222 -2 2 | pass -3 3 | -4 4 | if (a or b) or True: # SIM222 SIM222.py:4:4: SIM222 [*] Use `True` instead of `... or True` | @@ -26,15 +20,6 @@ SIM222.py:4:4: SIM222 [*] Use `True` instead of `... or True` | = help: Replace with `True` -ℹ Unsafe fix -1 1 | if a or True: # SIM222 -2 2 | pass -3 3 | -4 |-if (a or b) or True: # SIM222 - 4 |+if True: # SIM222 -5 5 | pass -6 6 | -7 7 | if a or (b or True): # SIM222 SIM222.py:7:10: SIM222 [*] Use `True` instead of `... or True` | @@ -46,15 +31,6 @@ SIM222.py:7:10: SIM222 [*] Use `True` instead of `... or True` | = help: Replace with `True` -ℹ Unsafe fix -4 4 | if (a or b) or True: # SIM222 -5 5 | pass -6 6 | -7 |-if a or (b or True): # SIM222 - 7 |+if a or (True): # SIM222 -8 8 | pass -9 9 | -10 10 | if a and True: # OK SIM222.py:24:16: SIM222 [*] Use `True` instead of `True or ...` | @@ -66,15 +42,6 @@ SIM222.py:24:16: SIM222 [*] Use `True` instead of `True or ...` | = help: Replace with `True` -ℹ Unsafe fix -21 21 | if a or f() or b or g() or True: # OK -22 22 | pass -23 23 | -24 |-if a or f() or True or g() or b: # SIM222 - 24 |+if a or f() or True: # SIM222 -25 25 | pass -26 26 | -27 27 | if True or f() or a or g() or b: # SIM222 SIM222.py:27:4: SIM222 [*] Use `True` instead of `True or ...` | @@ -86,15 +53,6 @@ SIM222.py:27:4: SIM222 [*] Use `True` instead of `True or ...` | = help: Replace with `True` -ℹ Unsafe fix -24 24 | if a or f() or True or g() or b: # SIM222 -25 25 | pass -26 26 | -27 |-if True or f() or a or g() or b: # SIM222 - 27 |+if True: # SIM222 -28 28 | pass -29 29 | -30 30 | if a or True or f() or b or g(): # SIM222 SIM222.py:30:4: SIM222 [*] Use `True` instead of `... or True or ...` | @@ -106,15 +64,6 @@ SIM222.py:30:4: SIM222 [*] Use `True` instead of `... or True or ...` | = help: Replace with `True` -ℹ Unsafe fix -27 27 | if True or f() or a or g() or b: # SIM222 -28 28 | pass -29 29 | -30 |-if a or True or f() or b or g(): # SIM222 - 30 |+if True: # SIM222 -31 31 | pass -32 32 | -33 33 | SIM222.py:47:6: SIM222 [*] Use `True` instead of `... or True` | @@ -125,15 +74,6 @@ SIM222.py:47:6: SIM222 [*] Use `True` instead of `... or True` | = help: Replace with `True` -ℹ Unsafe fix -44 44 | pass -45 45 | -46 46 | -47 |-a or "" or True # SIM222 - 47 |+a or True # SIM222 -48 48 | -49 49 | a or "foo" or True or "bar" # SIM222 -50 50 | SIM222.py:49:6: SIM222 [*] Use `"foo"` instead of `"foo" or ...` | @@ -146,15 +86,6 @@ SIM222.py:49:6: SIM222 [*] Use `"foo"` instead of `"foo" or ...` | = help: Replace with `"foo"` -ℹ Unsafe fix -46 46 | -47 47 | a or "" or True # SIM222 -48 48 | -49 |-a or "foo" or True or "bar" # SIM222 - 49 |+a or "foo" # SIM222 -50 50 | -51 51 | a or 0 or True # SIM222 -52 52 | SIM222.py:51:6: SIM222 [*] Use `True` instead of `... or True` | @@ -167,15 +98,6 @@ SIM222.py:51:6: SIM222 [*] Use `True` instead of `... or True` | = help: Replace with `True` -ℹ Unsafe fix -48 48 | -49 49 | a or "foo" or True or "bar" # SIM222 -50 50 | -51 |-a or 0 or True # SIM222 - 51 |+a or True # SIM222 -52 52 | -53 53 | a or 1 or True or 2 # SIM222 -54 54 | SIM222.py:53:6: SIM222 [*] Use `1` instead of `1 or ...` | @@ -188,15 +110,6 @@ SIM222.py:53:6: SIM222 [*] Use `1` instead of `1 or ...` | = help: Replace with `1` -ℹ Unsafe fix -50 50 | -51 51 | a or 0 or True # SIM222 -52 52 | -53 |-a or 1 or True or 2 # SIM222 - 53 |+a or 1 # SIM222 -54 54 | -55 55 | a or 0.0 or True # SIM222 -56 56 | SIM222.py:55:6: SIM222 [*] Use `True` instead of `... or True` | @@ -209,15 +122,6 @@ SIM222.py:55:6: SIM222 [*] Use `True` instead of `... or True` | = help: Replace with `True` -ℹ Unsafe fix -52 52 | -53 53 | a or 1 or True or 2 # SIM222 -54 54 | -55 |-a or 0.0 or True # SIM222 - 55 |+a or True # SIM222 -56 56 | -57 57 | a or 0.1 or True or 0.2 # SIM222 -58 58 | SIM222.py:57:6: SIM222 [*] Use `0.1` instead of `0.1 or ...` | @@ -230,15 +134,6 @@ SIM222.py:57:6: SIM222 [*] Use `0.1` instead of `0.1 or ...` | = help: Replace with `0.1` -ℹ Unsafe fix -54 54 | -55 55 | a or 0.0 or True # SIM222 -56 56 | -57 |-a or 0.1 or True or 0.2 # SIM222 - 57 |+a or 0.1 # SIM222 -58 58 | -59 59 | a or [] or True # SIM222 -60 60 | SIM222.py:59:6: SIM222 [*] Use `True` instead of `... or True` | @@ -251,15 +146,6 @@ SIM222.py:59:6: SIM222 [*] Use `True` instead of `... or True` | = help: Replace with `True` -ℹ Unsafe fix -56 56 | -57 57 | a or 0.1 or True or 0.2 # SIM222 -58 58 | -59 |-a or [] or True # SIM222 - 59 |+a or True # SIM222 -60 60 | -61 61 | a or list([]) or True # SIM222 -62 62 | SIM222.py:61:6: SIM222 [*] Use `True` instead of `... or True` | @@ -272,15 +158,6 @@ SIM222.py:61:6: SIM222 [*] Use `True` instead of `... or True` | = help: Replace with `True` -ℹ Unsafe fix -58 58 | -59 59 | a or [] or True # SIM222 -60 60 | -61 |-a or list([]) or True # SIM222 - 61 |+a or True # SIM222 -62 62 | -63 63 | a or [1] or True or [2] # SIM222 -64 64 | SIM222.py:63:6: SIM222 [*] Use `[1]` instead of `[1] or ...` | @@ -293,15 +170,6 @@ SIM222.py:63:6: SIM222 [*] Use `[1]` instead of `[1] or ...` | = help: Replace with `[1]` -ℹ Unsafe fix -60 60 | -61 61 | a or list([]) or True # SIM222 -62 62 | -63 |-a or [1] or True or [2] # SIM222 - 63 |+a or [1] # SIM222 -64 64 | -65 65 | a or list([1]) or True or list([2]) # SIM222 -66 66 | SIM222.py:65:6: SIM222 [*] Use `list([1])` instead of `list([1]) or ...` | @@ -314,15 +182,6 @@ SIM222.py:65:6: SIM222 [*] Use `list([1])` instead of `list([1]) or ...` | = help: Replace with `list([1])` -ℹ Unsafe fix -62 62 | -63 63 | a or [1] or True or [2] # SIM222 -64 64 | -65 |-a or list([1]) or True or list([2]) # SIM222 - 65 |+a or list([1]) # SIM222 -66 66 | -67 67 | a or {} or True # SIM222 -68 68 | SIM222.py:67:6: SIM222 [*] Use `True` instead of `... or True` | @@ -335,15 +194,6 @@ SIM222.py:67:6: SIM222 [*] Use `True` instead of `... or True` | = help: Replace with `True` -ℹ Unsafe fix -64 64 | -65 65 | a or list([1]) or True or list([2]) # SIM222 -66 66 | -67 |-a or {} or True # SIM222 - 67 |+a or True # SIM222 -68 68 | -69 69 | a or dict() or True # SIM222 -70 70 | SIM222.py:69:6: SIM222 [*] Use `True` instead of `... or True` | @@ -356,15 +206,6 @@ SIM222.py:69:6: SIM222 [*] Use `True` instead of `... or True` | = help: Replace with `True` -ℹ Unsafe fix -66 66 | -67 67 | a or {} or True # SIM222 -68 68 | -69 |-a or dict() or True # SIM222 - 69 |+a or True # SIM222 -70 70 | -71 71 | a or {1: 1} or True or {2: 2} # SIM222 -72 72 | SIM222.py:71:6: SIM222 [*] Use `{1: 1}` instead of `{1: 1} or ...` | @@ -377,15 +218,6 @@ SIM222.py:71:6: SIM222 [*] Use `{1: 1}` instead of `{1: 1} or ...` | = help: Replace with `{1: 1}` -ℹ Unsafe fix -68 68 | -69 69 | a or dict() or True # SIM222 -70 70 | -71 |-a or {1: 1} or True or {2: 2} # SIM222 - 71 |+a or {1: 1} # SIM222 -72 72 | -73 73 | a or dict({1: 1}) or True or dict({2: 2}) # SIM222 -74 74 | SIM222.py:73:6: SIM222 [*] Use `dict({1: 1})` instead of `dict({1: 1}) or ...` | @@ -398,15 +230,6 @@ SIM222.py:73:6: SIM222 [*] Use `dict({1: 1})` instead of `dict({1: 1}) or ...` | = help: Replace with `dict({1: 1})` -ℹ Unsafe fix -70 70 | -71 71 | a or {1: 1} or True or {2: 2} # SIM222 -72 72 | -73 |-a or dict({1: 1}) or True or dict({2: 2}) # SIM222 - 73 |+a or dict({1: 1}) # SIM222 -74 74 | -75 75 | a or set() or True # SIM222 -76 76 | SIM222.py:75:6: SIM222 [*] Use `True` instead of `... or True` | @@ -419,15 +242,6 @@ SIM222.py:75:6: SIM222 [*] Use `True` instead of `... or True` | = help: Replace with `True` -ℹ Unsafe fix -72 72 | -73 73 | a or dict({1: 1}) or True or dict({2: 2}) # SIM222 -74 74 | -75 |-a or set() or True # SIM222 - 75 |+a or True # SIM222 -76 76 | -77 77 | a or set(set()) or True # SIM222 -78 78 | SIM222.py:77:6: SIM222 [*] Use `True` instead of `... or True` | @@ -440,15 +254,6 @@ SIM222.py:77:6: SIM222 [*] Use `True` instead of `... or True` | = help: Replace with `True` -ℹ Unsafe fix -74 74 | -75 75 | a or set() or True # SIM222 -76 76 | -77 |-a or set(set()) or True # SIM222 - 77 |+a or True # SIM222 -78 78 | -79 79 | a or {1} or True or {2} # SIM222 -80 80 | SIM222.py:79:6: SIM222 [*] Use `{1}` instead of `{1} or ...` | @@ -461,15 +266,6 @@ SIM222.py:79:6: SIM222 [*] Use `{1}` instead of `{1} or ...` | = help: Replace with `{1}` -ℹ Unsafe fix -76 76 | -77 77 | a or set(set()) or True # SIM222 -78 78 | -79 |-a or {1} or True or {2} # SIM222 - 79 |+a or {1} # SIM222 -80 80 | -81 81 | a or set({1}) or True or set({2}) # SIM222 -82 82 | SIM222.py:81:6: SIM222 [*] Use `set({1})` instead of `set({1}) or ...` | @@ -482,15 +278,6 @@ SIM222.py:81:6: SIM222 [*] Use `set({1})` instead of `set({1}) or ...` | = help: Replace with `set({1})` -ℹ Unsafe fix -78 78 | -79 79 | a or {1} or True or {2} # SIM222 -80 80 | -81 |-a or set({1}) or True or set({2}) # SIM222 - 81 |+a or set({1}) # SIM222 -82 82 | -83 83 | a or () or True # SIM222 -84 84 | SIM222.py:83:6: SIM222 [*] Use `True` instead of `... or True` | @@ -503,15 +290,6 @@ SIM222.py:83:6: SIM222 [*] Use `True` instead of `... or True` | = help: Replace with `True` -ℹ Unsafe fix -80 80 | -81 81 | a or set({1}) or True or set({2}) # SIM222 -82 82 | -83 |-a or () or True # SIM222 - 83 |+a or True # SIM222 -84 84 | -85 85 | a or tuple(()) or True # SIM222 -86 86 | SIM222.py:85:6: SIM222 [*] Use `True` instead of `... or True` | @@ -524,15 +302,6 @@ SIM222.py:85:6: SIM222 [*] Use `True` instead of `... or True` | = help: Replace with `True` -ℹ Unsafe fix -82 82 | -83 83 | a or () or True # SIM222 -84 84 | -85 |-a or tuple(()) or True # SIM222 - 85 |+a or True # SIM222 -86 86 | -87 87 | a or (1,) or True or (2,) # SIM222 -88 88 | SIM222.py:87:6: SIM222 [*] Use `(1,)` instead of `(1,) or ...` | @@ -545,15 +314,6 @@ SIM222.py:87:6: SIM222 [*] Use `(1,)` instead of `(1,) or ...` | = help: Replace with `(1,)` -ℹ Unsafe fix -84 84 | -85 85 | a or tuple(()) or True # SIM222 -86 86 | -87 |-a or (1,) or True or (2,) # SIM222 - 87 |+a or (1,) # SIM222 -88 88 | -89 89 | a or tuple((1,)) or True or tuple((2,)) # SIM222 -90 90 | SIM222.py:89:6: SIM222 [*] Use `tuple((1,))` instead of `tuple((1,)) or ...` | @@ -566,15 +326,6 @@ SIM222.py:89:6: SIM222 [*] Use `tuple((1,))` instead of `tuple((1,)) or ...` | = help: Replace with `tuple((1,))` -ℹ Unsafe fix -86 86 | -87 87 | a or (1,) or True or (2,) # SIM222 -88 88 | -89 |-a or tuple((1,)) or True or tuple((2,)) # SIM222 - 89 |+a or tuple((1,)) # SIM222 -90 90 | -91 91 | a or frozenset() or True # SIM222 -92 92 | SIM222.py:91:6: SIM222 [*] Use `True` instead of `... or True` | @@ -587,15 +338,6 @@ SIM222.py:91:6: SIM222 [*] Use `True` instead of `... or True` | = help: Replace with `True` -ℹ Unsafe fix -88 88 | -89 89 | a or tuple((1,)) or True or tuple((2,)) # SIM222 -90 90 | -91 |-a or frozenset() or True # SIM222 - 91 |+a or True # SIM222 -92 92 | -93 93 | a or frozenset(frozenset()) or True # SIM222 -94 94 | SIM222.py:93:6: SIM222 [*] Use `True` instead of `... or True` | @@ -608,15 +350,6 @@ SIM222.py:93:6: SIM222 [*] Use `True` instead of `... or True` | = help: Replace with `True` -ℹ Unsafe fix -90 90 | -91 91 | a or frozenset() or True # SIM222 -92 92 | -93 |-a or frozenset(frozenset()) or True # SIM222 - 93 |+a or True # SIM222 -94 94 | -95 95 | a or frozenset({1}) or True or frozenset({2}) # SIM222 -96 96 | SIM222.py:95:6: SIM222 [*] Use `frozenset({1})` instead of `frozenset({1}) or ...` | @@ -629,15 +362,6 @@ SIM222.py:95:6: SIM222 [*] Use `frozenset({1})` instead of `frozenset({1}) or .. | = help: Replace with `frozenset({1})` -ℹ Unsafe fix -92 92 | -93 93 | a or frozenset(frozenset()) or True # SIM222 -94 94 | -95 |-a or frozenset({1}) or True or frozenset({2}) # SIM222 - 95 |+a or frozenset({1}) # SIM222 -96 96 | -97 97 | a or frozenset(frozenset({1})) or True or frozenset(frozenset({2})) # SIM222 -98 98 | SIM222.py:97:6: SIM222 [*] Use `frozenset(frozenset({1}))` instead of `frozenset(frozenset({1})) or ...` | @@ -648,15 +372,6 @@ SIM222.py:97:6: SIM222 [*] Use `frozenset(frozenset({1}))` instead of `frozenset | = help: Replace with `frozenset(frozenset({1}))` -ℹ Unsafe fix -94 94 | -95 95 | a or frozenset({1}) or True or frozenset({2}) # SIM222 -96 96 | -97 |-a or frozenset(frozenset({1})) or True or frozenset(frozenset({2})) # SIM222 - 97 |+a or frozenset(frozenset({1})) # SIM222 -98 98 | -99 99 | -100 100 | # Inside test `a` is simplified. SIM222.py:102:6: SIM222 [*] Use `True` instead of `... or True or ...` | @@ -669,15 +384,6 @@ SIM222.py:102:6: SIM222 [*] Use `True` instead of `... or True or ...` | = help: Replace with `True` -ℹ Unsafe fix -99 99 | -100 100 | # Inside test `a` is simplified. -101 101 | -102 |-bool(a or [1] or True or [2]) # SIM222 - 102 |+bool(True) # SIM222 -103 103 | -104 104 | assert a or [1] or True or [2] # SIM222 -105 105 | SIM222.py:104:8: SIM222 [*] Use `True` instead of `... or True or ...` | @@ -690,15 +396,6 @@ SIM222.py:104:8: SIM222 [*] Use `True` instead of `... or True or ...` | = help: Replace with `True` -ℹ Unsafe fix -101 101 | -102 102 | bool(a or [1] or True or [2]) # SIM222 -103 103 | -104 |-assert a or [1] or True or [2] # SIM222 - 104 |+assert True # SIM222 -105 105 | -106 106 | if (a or [1] or True or [2]) and (a or [1] or True or [2]): # SIM222 -107 107 | pass SIM222.py:106:5: SIM222 [*] Use `True` instead of `... or True or ...` | @@ -710,15 +407,6 @@ SIM222.py:106:5: SIM222 [*] Use `True` instead of `... or True or ...` | = help: Replace with `True` -ℹ Unsafe fix -103 103 | -104 104 | assert a or [1] or True or [2] # SIM222 -105 105 | -106 |-if (a or [1] or True or [2]) and (a or [1] or True or [2]): # SIM222 - 106 |+if (True) and (a or [1] or True or [2]): # SIM222 -107 107 | pass -108 108 | -109 109 | 0 if a or [1] or True or [2] else 1 # SIM222 SIM222.py:106:35: SIM222 [*] Use `True` instead of `... or True or ...` | @@ -730,15 +418,6 @@ SIM222.py:106:35: SIM222 [*] Use `True` instead of `... or True or ...` | = help: Replace with `True` -ℹ Unsafe fix -103 103 | -104 104 | assert a or [1] or True or [2] # SIM222 -105 105 | -106 |-if (a or [1] or True or [2]) and (a or [1] or True or [2]): # SIM222 - 106 |+if (a or [1] or True or [2]) and (True): # SIM222 -107 107 | pass -108 108 | -109 109 | 0 if a or [1] or True or [2] else 1 # SIM222 SIM222.py:109:6: SIM222 [*] Use `True` instead of `... or True or ...` | @@ -751,15 +430,6 @@ SIM222.py:109:6: SIM222 [*] Use `True` instead of `... or True or ...` | = help: Replace with `True` -ℹ Unsafe fix -106 106 | if (a or [1] or True or [2]) and (a or [1] or True or [2]): # SIM222 -107 107 | pass -108 108 | -109 |-0 if a or [1] or True or [2] else 1 # SIM222 - 109 |+0 if True else 1 # SIM222 -110 110 | -111 111 | while a or [1] or True or [2]: # SIM222 -112 112 | pass SIM222.py:111:7: SIM222 [*] Use `True` instead of `... or True or ...` | @@ -771,15 +441,6 @@ SIM222.py:111:7: SIM222 [*] Use `True` instead of `... or True or ...` | = help: Replace with `True` -ℹ Unsafe fix -108 108 | -109 109 | 0 if a or [1] or True or [2] else 1 # SIM222 -110 110 | -111 |-while a or [1] or True or [2]: # SIM222 - 111 |+while True: # SIM222 -112 112 | pass -113 113 | -114 114 | [ SIM222.py:118:8: SIM222 [*] Use `True` instead of `... or True or ...` | @@ -792,15 +453,6 @@ SIM222.py:118:8: SIM222 [*] Use `True` instead of `... or True or ...` | = help: Replace with `True` -ℹ Unsafe fix -115 115 | 0 -116 116 | for a in range(10) -117 117 | for b in range(10) -118 |- if a or [1] or True or [2] # SIM222 - 118 |+ if True # SIM222 -119 119 | if b or [1] or True or [2] # SIM222 -120 120 | ] -121 121 | SIM222.py:119:8: SIM222 [*] Use `True` instead of `... or True or ...` | @@ -812,15 +464,6 @@ SIM222.py:119:8: SIM222 [*] Use `True` instead of `... or True or ...` | = help: Replace with `True` -ℹ Unsafe fix -116 116 | for a in range(10) -117 117 | for b in range(10) -118 118 | if a or [1] or True or [2] # SIM222 -119 |- if b or [1] or True or [2] # SIM222 - 119 |+ if True # SIM222 -120 120 | ] -121 121 | -122 122 | { SIM222.py:126:8: SIM222 [*] Use `True` instead of `... or True or ...` | @@ -833,15 +476,6 @@ SIM222.py:126:8: SIM222 [*] Use `True` instead of `... or True or ...` | = help: Replace with `True` -ℹ Unsafe fix -123 123 | 0 -124 124 | for a in range(10) -125 125 | for b in range(10) -126 |- if a or [1] or True or [2] # SIM222 - 126 |+ if True # SIM222 -127 127 | if b or [1] or True or [2] # SIM222 -128 128 | } -129 129 | SIM222.py:127:8: SIM222 [*] Use `True` instead of `... or True or ...` | @@ -853,15 +487,6 @@ SIM222.py:127:8: SIM222 [*] Use `True` instead of `... or True or ...` | = help: Replace with `True` -ℹ Unsafe fix -124 124 | for a in range(10) -125 125 | for b in range(10) -126 126 | if a or [1] or True or [2] # SIM222 -127 |- if b or [1] or True or [2] # SIM222 - 127 |+ if True # SIM222 -128 128 | } -129 129 | -130 130 | { SIM222.py:134:8: SIM222 [*] Use `True` instead of `... or True or ...` | @@ -874,15 +499,6 @@ SIM222.py:134:8: SIM222 [*] Use `True` instead of `... or True or ...` | = help: Replace with `True` -ℹ Unsafe fix -131 131 | 0: 0 -132 132 | for a in range(10) -133 133 | for b in range(10) -134 |- if a or [1] or True or [2] # SIM222 - 134 |+ if True # SIM222 -135 135 | if b or [1] or True or [2] # SIM222 -136 136 | } -137 137 | SIM222.py:135:8: SIM222 [*] Use `True` instead of `... or True or ...` | @@ -894,15 +510,6 @@ SIM222.py:135:8: SIM222 [*] Use `True` instead of `... or True or ...` | = help: Replace with `True` -ℹ Unsafe fix -132 132 | for a in range(10) -133 133 | for b in range(10) -134 134 | if a or [1] or True or [2] # SIM222 -135 |- if b or [1] or True or [2] # SIM222 - 135 |+ if True # SIM222 -136 136 | } -137 137 | -138 138 | ( SIM222.py:142:8: SIM222 [*] Use `True` instead of `... or True or ...` | @@ -915,15 +522,6 @@ SIM222.py:142:8: SIM222 [*] Use `True` instead of `... or True or ...` | = help: Replace with `True` -ℹ Unsafe fix -139 139 | 0 -140 140 | for a in range(10) -141 141 | for b in range(10) -142 |- if a or [1] or True or [2] # SIM222 - 142 |+ if True # SIM222 -143 143 | if b or [1] or True or [2] # SIM222 -144 144 | ) -145 145 | SIM222.py:143:8: SIM222 [*] Use `True` instead of `... or True or ...` | @@ -935,15 +533,6 @@ SIM222.py:143:8: SIM222 [*] Use `True` instead of `... or True or ...` | = help: Replace with `True` -ℹ Unsafe fix -140 140 | for a in range(10) -141 141 | for b in range(10) -142 142 | if a or [1] or True or [2] # SIM222 -143 |- if b or [1] or True or [2] # SIM222 - 143 |+ if True # SIM222 -144 144 | ) -145 145 | -146 146 | # Outside test `a` is not simplified. SIM222.py:148:6: SIM222 [*] Use `[1]` instead of `[1] or ...` | @@ -956,15 +545,6 @@ SIM222.py:148:6: SIM222 [*] Use `[1]` instead of `[1] or ...` | = help: Replace with `[1]` -ℹ Unsafe fix -145 145 | -146 146 | # Outside test `a` is not simplified. -147 147 | -148 |-a or [1] or True or [2] # SIM222 - 148 |+a or [1] # SIM222 -149 149 | -150 150 | if (a or [1] or True or [2]) == (a or [1]): # SIM222 -151 151 | pass SIM222.py:150:10: SIM222 [*] Use `[1]` instead of `[1] or ...` | @@ -976,15 +556,6 @@ SIM222.py:150:10: SIM222 [*] Use `[1]` instead of `[1] or ...` | = help: Replace with `[1]` -ℹ Unsafe fix -147 147 | -148 148 | a or [1] or True or [2] # SIM222 -149 149 | -150 |-if (a or [1] or True or [2]) == (a or [1]): # SIM222 - 150 |+if (a or [1]) == (a or [1]): # SIM222 -151 151 | pass -152 152 | -153 153 | if f(a or [1] or True or [2]): # SIM222 SIM222.py:153:11: SIM222 [*] Use `[1]` instead of `[1] or ...` | @@ -996,15 +567,6 @@ SIM222.py:153:11: SIM222 [*] Use `[1]` instead of `[1] or ...` | = help: Replace with `[1]` -ℹ Unsafe fix -150 150 | if (a or [1] or True or [2]) == (a or [1]): # SIM222 -151 151 | pass -152 152 | -153 |-if f(a or [1] or True or [2]): # SIM222 - 153 |+if f(a or [1]): # SIM222 -154 154 | pass -155 155 | -156 156 | # Regression test for: https://github.com/astral-sh/ruff/issues/7099 SIM222.py:157:30: SIM222 [*] Use `(int, int, int)` instead of `(int, int, int) or ...` | @@ -1015,15 +577,6 @@ SIM222.py:157:30: SIM222 [*] Use `(int, int, int)` instead of `(int, int, int) o | = help: Replace with `(int, int, int)` -ℹ Unsafe fix -154 154 | pass -155 155 | -156 156 | # Regression test for: https://github.com/astral-sh/ruff/issues/7099 -157 |-def secondToTime(s0: int) -> (int, int, int) or str: - 157 |+def secondToTime(s0: int) -> (int, int, int): -158 158 | m, s = divmod(s0, 60) -159 159 | -160 160 | SIM222.py:161:31: SIM222 [*] Use `(int, int, int)` instead of `(int, int, int) or ...` | @@ -1033,15 +586,6 @@ SIM222.py:161:31: SIM222 [*] Use `(int, int, int)` instead of `(int, int, int) o | = help: Replace with `(int, int, int)` -ℹ Unsafe fix -158 158 | m, s = divmod(s0, 60) -159 159 | -160 160 | -161 |-def secondToTime(s0: int) -> ((int, int, int) or str): - 161 |+def secondToTime(s0: int) -> ((int, int, int)): -162 162 | m, s = divmod(s0, 60) -163 163 | -164 164 | SIM222.py:168:7: SIM222 [*] Use `"bar"` instead of `... or "bar"` | @@ -1052,13 +596,3 @@ SIM222.py:168:7: SIM222 [*] Use `"bar"` instead of `... or "bar"` 169 | print(f"{1}{''}" or "bar") | = help: Replace with `"bar"` - -ℹ Unsafe fix -165 165 | # Regression test for: https://github.com/astral-sh/ruff/issues/9479 -166 166 | print(f"{a}{b}" or "bar") -167 167 | print(f"{a}{''}" or "bar") -168 |-print(f"{''}{''}" or "bar") - 168 |+print("bar") -169 169 | print(f"{1}{''}" or "bar") - - diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM223_SIM223.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM223_SIM223.py.snap index 855b2091823cb..17969b1850550 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM223_SIM223.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM223_SIM223.py.snap @@ -9,12 +9,6 @@ SIM223.py:1:4: SIM223 [*] Use `False` instead of `... and False` | = help: Replace with `False` -ℹ Unsafe fix -1 |-if a and False: # SIM223 - 1 |+if False: # SIM223 -2 2 | pass -3 3 | -4 4 | if (a or b) and False: # SIM223 SIM223.py:4:4: SIM223 [*] Use `False` instead of `... and False` | @@ -26,15 +20,6 @@ SIM223.py:4:4: SIM223 [*] Use `False` instead of `... and False` | = help: Replace with `False` -ℹ Unsafe fix -1 1 | if a and False: # SIM223 -2 2 | pass -3 3 | -4 |-if (a or b) and False: # SIM223 - 4 |+if False: # SIM223 -5 5 | pass -6 6 | -7 7 | if a or (b and False): # SIM223 SIM223.py:7:10: SIM223 [*] Use `False` instead of `... and False` | @@ -46,15 +31,6 @@ SIM223.py:7:10: SIM223 [*] Use `False` instead of `... and False` | = help: Replace with `False` -ℹ Unsafe fix -4 4 | if (a or b) and False: # SIM223 -5 5 | pass -6 6 | -7 |-if a or (b and False): # SIM223 - 7 |+if a or (False): # SIM223 -8 8 | pass -9 9 | -10 10 | if a or False: SIM223.py:19:18: SIM223 [*] Use `False` instead of `False and ...` | @@ -66,15 +42,6 @@ SIM223.py:19:18: SIM223 [*] Use `False` instead of `False and ...` | = help: Replace with `False` -ℹ Unsafe fix -16 16 | if a and f() and b and g() and False: # OK -17 17 | pass -18 18 | -19 |-if a and f() and False and g() and b: # SIM223 - 19 |+if a and f() and False: # SIM223 -20 20 | pass -21 21 | -22 22 | if False and f() and a and g() and b: # SIM223 SIM223.py:22:4: SIM223 [*] Use `False` instead of `False and ...` | @@ -86,15 +53,6 @@ SIM223.py:22:4: SIM223 [*] Use `False` instead of `False and ...` | = help: Replace with `False` -ℹ Unsafe fix -19 19 | if a and f() and False and g() and b: # SIM223 -20 20 | pass -21 21 | -22 |-if False and f() and a and g() and b: # SIM223 - 22 |+if False: # SIM223 -23 23 | pass -24 24 | -25 25 | if a and False and f() and b and g(): # SIM223 SIM223.py:25:4: SIM223 [*] Use `False` instead of `... and False and ...` | @@ -106,15 +64,6 @@ SIM223.py:25:4: SIM223 [*] Use `False` instead of `... and False and ...` | = help: Replace with `False` -ℹ Unsafe fix -22 22 | if False and f() and a and g() and b: # SIM223 -23 23 | pass -24 24 | -25 |-if a and False and f() and b and g(): # SIM223 - 25 |+if False: # SIM223 -26 26 | pass -27 27 | -28 28 | SIM223.py:42:7: SIM223 [*] Use `""` instead of `"" and ...` | @@ -125,15 +74,6 @@ SIM223.py:42:7: SIM223 [*] Use `""` instead of `"" and ...` | = help: Replace with `""` -ℹ Unsafe fix -39 39 | pass -40 40 | -41 41 | -42 |-a and "" and False # SIM223 - 42 |+a and "" # SIM223 -43 43 | -44 44 | a and "foo" and False and "bar" # SIM223 -45 45 | SIM223.py:44:7: SIM223 [*] Use `False` instead of `... and False and ...` | @@ -146,15 +86,6 @@ SIM223.py:44:7: SIM223 [*] Use `False` instead of `... and False and ...` | = help: Replace with `False` -ℹ Unsafe fix -41 41 | -42 42 | a and "" and False # SIM223 -43 43 | -44 |-a and "foo" and False and "bar" # SIM223 - 44 |+a and False # SIM223 -45 45 | -46 46 | a and 0 and False # SIM223 -47 47 | SIM223.py:46:7: SIM223 [*] Use `0` instead of `0 and ...` | @@ -167,15 +98,6 @@ SIM223.py:46:7: SIM223 [*] Use `0` instead of `0 and ...` | = help: Replace with `0` -ℹ Unsafe fix -43 43 | -44 44 | a and "foo" and False and "bar" # SIM223 -45 45 | -46 |-a and 0 and False # SIM223 - 46 |+a and 0 # SIM223 -47 47 | -48 48 | a and 1 and False and 2 # SIM223 -49 49 | SIM223.py:48:7: SIM223 [*] Use `False` instead of `... and False and ...` | @@ -188,15 +110,6 @@ SIM223.py:48:7: SIM223 [*] Use `False` instead of `... and False and ...` | = help: Replace with `False` -ℹ Unsafe fix -45 45 | -46 46 | a and 0 and False # SIM223 -47 47 | -48 |-a and 1 and False and 2 # SIM223 - 48 |+a and False # SIM223 -49 49 | -50 50 | a and 0.0 and False # SIM223 -51 51 | SIM223.py:50:7: SIM223 [*] Use `0.0` instead of `0.0 and ...` | @@ -209,15 +122,6 @@ SIM223.py:50:7: SIM223 [*] Use `0.0` instead of `0.0 and ...` | = help: Replace with `0.0` -ℹ Unsafe fix -47 47 | -48 48 | a and 1 and False and 2 # SIM223 -49 49 | -50 |-a and 0.0 and False # SIM223 - 50 |+a and 0.0 # SIM223 -51 51 | -52 52 | a and 0.1 and False and 0.2 # SIM223 -53 53 | SIM223.py:52:7: SIM223 [*] Use `False` instead of `... and False and ...` | @@ -230,15 +134,6 @@ SIM223.py:52:7: SIM223 [*] Use `False` instead of `... and False and ...` | = help: Replace with `False` -ℹ Unsafe fix -49 49 | -50 50 | a and 0.0 and False # SIM223 -51 51 | -52 |-a and 0.1 and False and 0.2 # SIM223 - 52 |+a and False # SIM223 -53 53 | -54 54 | a and [] and False # SIM223 -55 55 | SIM223.py:54:7: SIM223 [*] Use `[]` instead of `[] and ...` | @@ -251,15 +146,6 @@ SIM223.py:54:7: SIM223 [*] Use `[]` instead of `[] and ...` | = help: Replace with `[]` -ℹ Unsafe fix -51 51 | -52 52 | a and 0.1 and False and 0.2 # SIM223 -53 53 | -54 |-a and [] and False # SIM223 - 54 |+a and [] # SIM223 -55 55 | -56 56 | a and list([]) and False # SIM223 -57 57 | SIM223.py:56:7: SIM223 [*] Use `list([])` instead of `list([]) and ...` | @@ -272,15 +158,6 @@ SIM223.py:56:7: SIM223 [*] Use `list([])` instead of `list([]) and ...` | = help: Replace with `list([])` -ℹ Unsafe fix -53 53 | -54 54 | a and [] and False # SIM223 -55 55 | -56 |-a and list([]) and False # SIM223 - 56 |+a and list([]) # SIM223 -57 57 | -58 58 | a and [1] and False and [2] # SIM223 -59 59 | SIM223.py:58:7: SIM223 [*] Use `False` instead of `... and False and ...` | @@ -293,15 +170,6 @@ SIM223.py:58:7: SIM223 [*] Use `False` instead of `... and False and ...` | = help: Replace with `False` -ℹ Unsafe fix -55 55 | -56 56 | a and list([]) and False # SIM223 -57 57 | -58 |-a and [1] and False and [2] # SIM223 - 58 |+a and False # SIM223 -59 59 | -60 60 | a and list([1]) and False and list([2]) # SIM223 -61 61 | SIM223.py:60:7: SIM223 [*] Use `False` instead of `... and False and ...` | @@ -314,15 +182,6 @@ SIM223.py:60:7: SIM223 [*] Use `False` instead of `... and False and ...` | = help: Replace with `False` -ℹ Unsafe fix -57 57 | -58 58 | a and [1] and False and [2] # SIM223 -59 59 | -60 |-a and list([1]) and False and list([2]) # SIM223 - 60 |+a and False # SIM223 -61 61 | -62 62 | a and {} and False # SIM223 -63 63 | SIM223.py:62:7: SIM223 [*] Use `{}` instead of `{} and ...` | @@ -335,15 +194,6 @@ SIM223.py:62:7: SIM223 [*] Use `{}` instead of `{} and ...` | = help: Replace with `{}` -ℹ Unsafe fix -59 59 | -60 60 | a and list([1]) and False and list([2]) # SIM223 -61 61 | -62 |-a and {} and False # SIM223 - 62 |+a and {} # SIM223 -63 63 | -64 64 | a and dict() and False # SIM223 -65 65 | SIM223.py:64:7: SIM223 [*] Use `dict()` instead of `dict() and ...` | @@ -356,15 +206,6 @@ SIM223.py:64:7: SIM223 [*] Use `dict()` instead of `dict() and ...` | = help: Replace with `dict()` -ℹ Unsafe fix -61 61 | -62 62 | a and {} and False # SIM223 -63 63 | -64 |-a and dict() and False # SIM223 - 64 |+a and dict() # SIM223 -65 65 | -66 66 | a and {1: 1} and False and {2: 2} # SIM223 -67 67 | SIM223.py:66:7: SIM223 [*] Use `False` instead of `... and False and ...` | @@ -377,15 +218,6 @@ SIM223.py:66:7: SIM223 [*] Use `False` instead of `... and False and ...` | = help: Replace with `False` -ℹ Unsafe fix -63 63 | -64 64 | a and dict() and False # SIM223 -65 65 | -66 |-a and {1: 1} and False and {2: 2} # SIM223 - 66 |+a and False # SIM223 -67 67 | -68 68 | a and dict({1: 1}) and False and dict({2: 2}) # SIM223 -69 69 | SIM223.py:68:7: SIM223 [*] Use `False` instead of `... and False and ...` | @@ -398,15 +230,6 @@ SIM223.py:68:7: SIM223 [*] Use `False` instead of `... and False and ...` | = help: Replace with `False` -ℹ Unsafe fix -65 65 | -66 66 | a and {1: 1} and False and {2: 2} # SIM223 -67 67 | -68 |-a and dict({1: 1}) and False and dict({2: 2}) # SIM223 - 68 |+a and False # SIM223 -69 69 | -70 70 | a and set() and False # SIM223 -71 71 | SIM223.py:70:7: SIM223 [*] Use `set()` instead of `set() and ...` | @@ -419,15 +242,6 @@ SIM223.py:70:7: SIM223 [*] Use `set()` instead of `set() and ...` | = help: Replace with `set()` -ℹ Unsafe fix -67 67 | -68 68 | a and dict({1: 1}) and False and dict({2: 2}) # SIM223 -69 69 | -70 |-a and set() and False # SIM223 - 70 |+a and set() # SIM223 -71 71 | -72 72 | a and set(set()) and False # SIM223 -73 73 | SIM223.py:72:7: SIM223 [*] Use `set(set())` instead of `set(set()) and ...` | @@ -440,15 +254,6 @@ SIM223.py:72:7: SIM223 [*] Use `set(set())` instead of `set(set()) and ...` | = help: Replace with `set(set())` -ℹ Unsafe fix -69 69 | -70 70 | a and set() and False # SIM223 -71 71 | -72 |-a and set(set()) and False # SIM223 - 72 |+a and set(set()) # SIM223 -73 73 | -74 74 | a and {1} and False and {2} # SIM223 -75 75 | SIM223.py:74:7: SIM223 [*] Use `False` instead of `... and False and ...` | @@ -461,15 +266,6 @@ SIM223.py:74:7: SIM223 [*] Use `False` instead of `... and False and ...` | = help: Replace with `False` -ℹ Unsafe fix -71 71 | -72 72 | a and set(set()) and False # SIM223 -73 73 | -74 |-a and {1} and False and {2} # SIM223 - 74 |+a and False # SIM223 -75 75 | -76 76 | a and set({1}) and False and set({2}) # SIM223 -77 77 | SIM223.py:76:7: SIM223 [*] Use `False` instead of `... and False and ...` | @@ -482,15 +278,6 @@ SIM223.py:76:7: SIM223 [*] Use `False` instead of `... and False and ...` | = help: Replace with `False` -ℹ Unsafe fix -73 73 | -74 74 | a and {1} and False and {2} # SIM223 -75 75 | -76 |-a and set({1}) and False and set({2}) # SIM223 - 76 |+a and False # SIM223 -77 77 | -78 78 | a and () and False # SIM222 -79 79 | SIM223.py:78:7: SIM223 [*] Use `()` instead of `() and ...` | @@ -503,15 +290,6 @@ SIM223.py:78:7: SIM223 [*] Use `()` instead of `() and ...` | = help: Replace with `()` -ℹ Unsafe fix -75 75 | -76 76 | a and set({1}) and False and set({2}) # SIM223 -77 77 | -78 |-a and () and False # SIM222 - 78 |+a and () # SIM222 -79 79 | -80 80 | a and tuple(()) and False # SIM222 -81 81 | SIM223.py:80:7: SIM223 [*] Use `tuple(())` instead of `tuple(()) and ...` | @@ -524,15 +302,6 @@ SIM223.py:80:7: SIM223 [*] Use `tuple(())` instead of `tuple(()) and ...` | = help: Replace with `tuple(())` -ℹ Unsafe fix -77 77 | -78 78 | a and () and False # SIM222 -79 79 | -80 |-a and tuple(()) and False # SIM222 - 80 |+a and tuple(()) # SIM222 -81 81 | -82 82 | a and (1,) and False and (2,) # SIM222 -83 83 | SIM223.py:82:7: SIM223 [*] Use `False` instead of `... and False and ...` | @@ -545,15 +314,6 @@ SIM223.py:82:7: SIM223 [*] Use `False` instead of `... and False and ...` | = help: Replace with `False` -ℹ Unsafe fix -79 79 | -80 80 | a and tuple(()) and False # SIM222 -81 81 | -82 |-a and (1,) and False and (2,) # SIM222 - 82 |+a and False # SIM222 -83 83 | -84 84 | a and tuple((1,)) and False and tuple((2,)) # SIM222 -85 85 | SIM223.py:84:7: SIM223 [*] Use `False` instead of `... and False and ...` | @@ -566,15 +326,6 @@ SIM223.py:84:7: SIM223 [*] Use `False` instead of `... and False and ...` | = help: Replace with `False` -ℹ Unsafe fix -81 81 | -82 82 | a and (1,) and False and (2,) # SIM222 -83 83 | -84 |-a and tuple((1,)) and False and tuple((2,)) # SIM222 - 84 |+a and False # SIM222 -85 85 | -86 86 | a and frozenset() and False # SIM222 -87 87 | SIM223.py:86:7: SIM223 [*] Use `frozenset()` instead of `frozenset() and ...` | @@ -587,15 +338,6 @@ SIM223.py:86:7: SIM223 [*] Use `frozenset()` instead of `frozenset() and ...` | = help: Replace with `frozenset()` -ℹ Unsafe fix -83 83 | -84 84 | a and tuple((1,)) and False and tuple((2,)) # SIM222 -85 85 | -86 |-a and frozenset() and False # SIM222 - 86 |+a and frozenset() # SIM222 -87 87 | -88 88 | a and frozenset(frozenset()) and False # SIM222 -89 89 | SIM223.py:88:7: SIM223 [*] Use `frozenset(frozenset())` instead of `frozenset(frozenset()) and ...` | @@ -608,15 +350,6 @@ SIM223.py:88:7: SIM223 [*] Use `frozenset(frozenset())` instead of `frozenset(fr | = help: Replace with `frozenset(frozenset())` -ℹ Unsafe fix -85 85 | -86 86 | a and frozenset() and False # SIM222 -87 87 | -88 |-a and frozenset(frozenset()) and False # SIM222 - 88 |+a and frozenset(frozenset()) # SIM222 -89 89 | -90 90 | a and frozenset({1}) and False and frozenset({2}) # SIM222 -91 91 | SIM223.py:90:7: SIM223 [*] Use `False` instead of `... and False and ...` | @@ -629,15 +362,6 @@ SIM223.py:90:7: SIM223 [*] Use `False` instead of `... and False and ...` | = help: Replace with `False` -ℹ Unsafe fix -87 87 | -88 88 | a and frozenset(frozenset()) and False # SIM222 -89 89 | -90 |-a and frozenset({1}) and False and frozenset({2}) # SIM222 - 90 |+a and False # SIM222 -91 91 | -92 92 | a and frozenset(frozenset({1})) and False and frozenset(frozenset({2})) # SIM222 -93 93 | SIM223.py:92:7: SIM223 [*] Use `False` instead of `... and False and ...` | @@ -648,15 +372,6 @@ SIM223.py:92:7: SIM223 [*] Use `False` instead of `... and False and ...` | = help: Replace with `False` -ℹ Unsafe fix -89 89 | -90 90 | a and frozenset({1}) and False and frozenset({2}) # SIM222 -91 91 | -92 |-a and frozenset(frozenset({1})) and False and frozenset(frozenset({2})) # SIM222 - 92 |+a and False # SIM222 -93 93 | -94 94 | -95 95 | # Inside test `a` is simplified. SIM223.py:97:6: SIM223 [*] Use `False` instead of `... and False and ...` | @@ -669,15 +384,6 @@ SIM223.py:97:6: SIM223 [*] Use `False` instead of `... and False and ...` | = help: Replace with `False` -ℹ Unsafe fix -94 94 | -95 95 | # Inside test `a` is simplified. -96 96 | -97 |-bool(a and [] and False and []) # SIM223 - 97 |+bool(False) # SIM223 -98 98 | -99 99 | assert a and [] and False and [] # SIM223 -100 100 | SIM223.py:99:8: SIM223 [*] Use `False` instead of `... and False and ...` | @@ -690,15 +396,6 @@ SIM223.py:99:8: SIM223 [*] Use `False` instead of `... and False and ...` | = help: Replace with `False` -ℹ Unsafe fix -96 96 | -97 97 | bool(a and [] and False and []) # SIM223 -98 98 | -99 |-assert a and [] and False and [] # SIM223 - 99 |+assert False # SIM223 -100 100 | -101 101 | if (a and [] and False and []) or (a and [] and False and []): # SIM223 -102 102 | pass SIM223.py:101:5: SIM223 [*] Use `False` instead of `... and False and ...` | @@ -710,15 +407,6 @@ SIM223.py:101:5: SIM223 [*] Use `False` instead of `... and False and ...` | = help: Replace with `False` -ℹ Unsafe fix -98 98 | -99 99 | assert a and [] and False and [] # SIM223 -100 100 | -101 |-if (a and [] and False and []) or (a and [] and False and []): # SIM223 - 101 |+if (False) or (a and [] and False and []): # SIM223 -102 102 | pass -103 103 | -104 104 | 0 if a and [] and False and [] else 1 # SIM222 SIM223.py:101:36: SIM223 [*] Use `False` instead of `... and False and ...` | @@ -730,15 +418,6 @@ SIM223.py:101:36: SIM223 [*] Use `False` instead of `... and False and ...` | = help: Replace with `False` -ℹ Unsafe fix -98 98 | -99 99 | assert a and [] and False and [] # SIM223 -100 100 | -101 |-if (a and [] and False and []) or (a and [] and False and []): # SIM223 - 101 |+if (a and [] and False and []) or (False): # SIM223 -102 102 | pass -103 103 | -104 104 | 0 if a and [] and False and [] else 1 # SIM222 SIM223.py:104:6: SIM223 [*] Use `False` instead of `... and False and ...` | @@ -751,15 +430,6 @@ SIM223.py:104:6: SIM223 [*] Use `False` instead of `... and False and ...` | = help: Replace with `False` -ℹ Unsafe fix -101 101 | if (a and [] and False and []) or (a and [] and False and []): # SIM223 -102 102 | pass -103 103 | -104 |-0 if a and [] and False and [] else 1 # SIM222 - 104 |+0 if False else 1 # SIM222 -105 105 | -106 106 | while a and [] and False and []: # SIM223 -107 107 | pass SIM223.py:106:7: SIM223 [*] Use `False` instead of `... and False and ...` | @@ -771,15 +441,6 @@ SIM223.py:106:7: SIM223 [*] Use `False` instead of `... and False and ...` | = help: Replace with `False` -ℹ Unsafe fix -103 103 | -104 104 | 0 if a and [] and False and [] else 1 # SIM222 -105 105 | -106 |-while a and [] and False and []: # SIM223 - 106 |+while False: # SIM223 -107 107 | pass -108 108 | -109 109 | [ SIM223.py:113:8: SIM223 [*] Use `False` instead of `... and False and ...` | @@ -792,15 +453,6 @@ SIM223.py:113:8: SIM223 [*] Use `False` instead of `... and False and ...` | = help: Replace with `False` -ℹ Unsafe fix -110 110 | 0 -111 111 | for a in range(10) -112 112 | for b in range(10) -113 |- if a and [] and False and [] # SIM223 - 113 |+ if False # SIM223 -114 114 | if b and [] and False and [] # SIM223 -115 115 | ] -116 116 | SIM223.py:114:8: SIM223 [*] Use `False` instead of `... and False and ...` | @@ -812,15 +464,6 @@ SIM223.py:114:8: SIM223 [*] Use `False` instead of `... and False and ...` | = help: Replace with `False` -ℹ Unsafe fix -111 111 | for a in range(10) -112 112 | for b in range(10) -113 113 | if a and [] and False and [] # SIM223 -114 |- if b and [] and False and [] # SIM223 - 114 |+ if False # SIM223 -115 115 | ] -116 116 | -117 117 | { SIM223.py:121:8: SIM223 [*] Use `False` instead of `... and False and ...` | @@ -833,15 +476,6 @@ SIM223.py:121:8: SIM223 [*] Use `False` instead of `... and False and ...` | = help: Replace with `False` -ℹ Unsafe fix -118 118 | 0 -119 119 | for a in range(10) -120 120 | for b in range(10) -121 |- if a and [] and False and [] # SIM223 - 121 |+ if False # SIM223 -122 122 | if b and [] and False and [] # SIM223 -123 123 | } -124 124 | SIM223.py:122:8: SIM223 [*] Use `False` instead of `... and False and ...` | @@ -853,15 +487,6 @@ SIM223.py:122:8: SIM223 [*] Use `False` instead of `... and False and ...` | = help: Replace with `False` -ℹ Unsafe fix -119 119 | for a in range(10) -120 120 | for b in range(10) -121 121 | if a and [] and False and [] # SIM223 -122 |- if b and [] and False and [] # SIM223 - 122 |+ if False # SIM223 -123 123 | } -124 124 | -125 125 | { SIM223.py:129:8: SIM223 [*] Use `False` instead of `... and False and ...` | @@ -874,15 +499,6 @@ SIM223.py:129:8: SIM223 [*] Use `False` instead of `... and False and ...` | = help: Replace with `False` -ℹ Unsafe fix -126 126 | 0: 0 -127 127 | for a in range(10) -128 128 | for b in range(10) -129 |- if a and [] and False and [] # SIM223 - 129 |+ if False # SIM223 -130 130 | if b and [] and False and [] # SIM223 -131 131 | } -132 132 | SIM223.py:130:8: SIM223 [*] Use `False` instead of `... and False and ...` | @@ -894,15 +510,6 @@ SIM223.py:130:8: SIM223 [*] Use `False` instead of `... and False and ...` | = help: Replace with `False` -ℹ Unsafe fix -127 127 | for a in range(10) -128 128 | for b in range(10) -129 129 | if a and [] and False and [] # SIM223 -130 |- if b and [] and False and [] # SIM223 - 130 |+ if False # SIM223 -131 131 | } -132 132 | -133 133 | ( SIM223.py:137:8: SIM223 [*] Use `False` instead of `... and False and ...` | @@ -915,15 +522,6 @@ SIM223.py:137:8: SIM223 [*] Use `False` instead of `... and False and ...` | = help: Replace with `False` -ℹ Unsafe fix -134 134 | 0 -135 135 | for a in range(10) -136 136 | for b in range(10) -137 |- if a and [] and False and [] # SIM223 - 137 |+ if False # SIM223 -138 138 | if b and [] and False and [] # SIM223 -139 139 | ) -140 140 | SIM223.py:138:8: SIM223 [*] Use `False` instead of `... and False and ...` | @@ -935,15 +533,6 @@ SIM223.py:138:8: SIM223 [*] Use `False` instead of `... and False and ...` | = help: Replace with `False` -ℹ Unsafe fix -135 135 | for a in range(10) -136 136 | for b in range(10) -137 137 | if a and [] and False and [] # SIM223 -138 |- if b and [] and False and [] # SIM223 - 138 |+ if False # SIM223 -139 139 | ) -140 140 | -141 141 | # Outside test `a` is not simplified. SIM223.py:143:7: SIM223 [*] Use `[]` instead of `[] and ...` | @@ -956,15 +545,6 @@ SIM223.py:143:7: SIM223 [*] Use `[]` instead of `[] and ...` | = help: Replace with `[]` -ℹ Unsafe fix -140 140 | -141 141 | # Outside test `a` is not simplified. -142 142 | -143 |-a and [] and False and [] # SIM223 - 143 |+a and [] # SIM223 -144 144 | -145 145 | if (a and [] and False and []) == (a and []): # SIM223 -146 146 | pass SIM223.py:145:11: SIM223 [*] Use `[]` instead of `[] and ...` | @@ -976,15 +556,6 @@ SIM223.py:145:11: SIM223 [*] Use `[]` instead of `[] and ...` | = help: Replace with `[]` -ℹ Unsafe fix -142 142 | -143 143 | a and [] and False and [] # SIM223 -144 144 | -145 |-if (a and [] and False and []) == (a and []): # SIM223 - 145 |+if (a and []) == (a and []): # SIM223 -146 146 | pass -147 147 | -148 148 | if f(a and [] and False and []): # SIM223 SIM223.py:148:12: SIM223 [*] Use `[]` instead of `[] and ...` | @@ -996,15 +567,6 @@ SIM223.py:148:12: SIM223 [*] Use `[]` instead of `[] and ...` | = help: Replace with `[]` -ℹ Unsafe fix -145 145 | if (a and [] and False and []) == (a and []): # SIM223 -146 146 | pass -147 147 | -148 |-if f(a and [] and False and []): # SIM223 - 148 |+if f(a and []): # SIM223 -149 149 | pass -150 150 | -151 151 | # Regression test for: https://github.com/astral-sh/ruff/issues/9479 SIM223.py:154:7: SIM223 [*] Use `f"{''}{''}"` instead of `f"{''}{''}" and ...` | @@ -1015,13 +577,3 @@ SIM223.py:154:7: SIM223 [*] Use `f"{''}{''}"` instead of `f"{''}{''}" and ...` 155 | print(f"{1}{''}" and "bar") | = help: Replace with `f"{''}{''}"` - -ℹ Unsafe fix -151 151 | # Regression test for: https://github.com/astral-sh/ruff/issues/9479 -152 152 | print(f"{a}{b}" and "bar") -153 153 | print(f"{a}{''}" and "bar") -154 |-print(f"{''}{''}" and "bar") - 154 |+print(f"{''}{''}") -155 155 | print(f"{1}{''}" and "bar") - - diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM300_SIM300.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM300_SIM300.py.snap index 8af686ef8545f..cf1b63ffdbfd7 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM300_SIM300.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM300_SIM300.py.snap @@ -11,7 +11,6 @@ SIM300.py:2:1: SIM300 [*] Yoda condition detected | = help: Rewrite as `compare == "yoda"` -ℹ Safe fix 1 1 | # Errors 2 |-"yoda" == compare # SIM300 2 |+compare == "yoda" # SIM300 @@ -30,7 +29,6 @@ SIM300.py:3:1: SIM300 [*] Yoda condition detected | = help: Rewrite as `age == 42` -ℹ Safe fix 1 1 | # Errors 2 2 | "yoda" == compare # SIM300 3 |-42 == age # SIM300 @@ -50,7 +48,6 @@ SIM300.py:4:1: SIM300 [*] Yoda condition detected | = help: Rewrite as `compare == ("a", "b")` -ℹ Safe fix 1 1 | # Errors 2 2 | "yoda" == compare # SIM300 3 3 | 42 == age # SIM300 @@ -71,7 +68,6 @@ SIM300.py:5:1: SIM300 [*] Yoda condition detected | = help: Rewrite as `compare >= "yoda"` -ℹ Safe fix 2 2 | "yoda" == compare # SIM300 3 3 | 42 == age # SIM300 4 4 | ("a", "b") == compare # SIM300 @@ -92,7 +88,6 @@ SIM300.py:6:1: SIM300 [*] Yoda condition detected | = help: Rewrite as `compare > "yoda"` -ℹ Safe fix 3 3 | 42 == age # SIM300 4 4 | ("a", "b") == compare # SIM300 5 5 | "yoda" <= compare # SIM300 @@ -113,7 +108,6 @@ SIM300.py:7:1: SIM300 [*] Yoda condition detected | = help: Rewrite as `age < 42` -ℹ Safe fix 4 4 | ("a", "b") == compare # SIM300 5 5 | "yoda" <= compare # SIM300 6 6 | "yoda" < compare # SIM300 @@ -134,7 +128,6 @@ SIM300.py:8:1: SIM300 [*] Yoda condition detected | = help: Rewrite as `age < -42` -ℹ Safe fix 5 5 | "yoda" <= compare # SIM300 6 6 | "yoda" < compare # SIM300 7 7 | 42 > age # SIM300 @@ -155,7 +148,6 @@ SIM300.py:9:1: SIM300 [*] Yoda condition detected | = help: Rewrite as `age < +42` -ℹ Safe fix 6 6 | "yoda" < compare # SIM300 7 7 | 42 > age # SIM300 8 8 | -42 > age # SIM300 @@ -176,7 +168,6 @@ SIM300.py:10:1: SIM300 [*] Yoda condition detected | = help: Rewrite as `age == YODA` -ℹ Safe fix 7 7 | 42 > age # SIM300 8 8 | -42 > age # SIM300 9 9 | +42 > age # SIM300 @@ -197,7 +188,6 @@ SIM300.py:11:1: SIM300 [*] Yoda condition detected | = help: Rewrite as `age < YODA` -ℹ Safe fix 8 8 | -42 > age # SIM300 9 9 | +42 > age # SIM300 10 10 | YODA == age # SIM300 @@ -218,7 +208,6 @@ SIM300.py:12:1: SIM300 [*] Yoda condition detected | = help: Rewrite as `age <= YODA` -ℹ Safe fix 9 9 | +42 > age # SIM300 10 10 | YODA == age # SIM300 11 11 | YODA > age # SIM300 @@ -239,7 +228,6 @@ SIM300.py:13:1: SIM300 [*] Yoda condition detected | = help: Rewrite as `age == JediOrder.YODA` -ℹ Safe fix 10 10 | YODA == age # SIM300 11 11 | YODA > age # SIM300 12 12 | YODA >= age # SIM300 @@ -260,7 +248,6 @@ SIM300.py:14:1: SIM300 [*] Yoda condition detected | = help: Rewrite as `(number - 100) > 0` -ℹ Safe fix 11 11 | YODA > age # SIM300 12 12 | YODA >= age # SIM300 13 13 | JediOrder.YODA == age # SIM300 @@ -280,7 +267,6 @@ SIM300.py:15:1: SIM300 [*] Yoda condition detected | = help: Rewrite as `A[0][0] > B` -ℹ Safe fix 12 12 | YODA >= age # SIM300 13 13 | JediOrder.YODA == age # SIM300 14 14 | 0 < (number - 100) # SIM300 @@ -301,7 +287,6 @@ SIM300.py:16:5: SIM300 [*] Yoda condition detected | = help: Rewrite as `A[0][0] > (B)` -ℹ Safe fix 13 13 | JediOrder.YODA == age # SIM300 14 14 | 0 < (number - 100) # SIM300 15 15 | B:8:5: TCH002 [*] Move third-party import `pandas.Series` into a type-checking block | @@ -38,23 +21,3 @@ source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs 9 | ) | = help: Move into type-checking block - -ℹ Unsafe fix -3 3 | -4 4 | from typing import TYPE_CHECKING -5 5 | -6 |-from pandas import ( -7 |- DataFrame, # DataFrame -8 |- Series, # Series -9 |-) -10 6 | - 7 |+if TYPE_CHECKING: - 8 |+ from pandas import ( - 9 |+ DataFrame, # DataFrame - 10 |+ Series, # Series - 11 |+ ) - 12 |+ -11 13 | def f(x: DataFrame, y: Series): -12 14 | pass - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_modules_different_types.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_modules_different_types.snap index 567f695f25eef..64a7244c84aff 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_modules_different_types.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_modules_different_types.snap @@ -12,18 +12,6 @@ source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs | = help: Move into type-checking block -ℹ Unsafe fix -3 3 | -4 4 | from typing import TYPE_CHECKING -5 5 | -6 |-import os, pandas - 6 |+import pandas - 7 |+ - 8 |+if TYPE_CHECKING: - 9 |+ import os -7 10 | -8 11 | def f(x: os, y: pandas): -9 12 | pass :6:12: TCH002 [*] Move third-party import `pandas` into a type-checking block | @@ -35,18 +23,3 @@ source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs 8 | def f(x: os, y: pandas): | = help: Move into type-checking block - -ℹ Unsafe fix -3 3 | -4 4 | from typing import TYPE_CHECKING -5 5 | -6 |-import os, pandas - 6 |+import os - 7 |+ - 8 |+if TYPE_CHECKING: - 9 |+ import pandas -7 10 | -8 11 | def f(x: os, y: pandas): -9 12 | pass - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_modules_same_type.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_modules_same_type.snap index 6814710f481d8..65744f4157e2b 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_modules_same_type.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_modules_same_type.snap @@ -12,17 +12,6 @@ source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs | = help: Move into type-checking block -ℹ Unsafe fix -3 3 | -4 4 | from typing import TYPE_CHECKING -5 5 | -6 |-import os, sys -7 6 | - 7 |+if TYPE_CHECKING: - 8 |+ import os, sys - 9 |+ -8 10 | def f(x: os, y: sys): -9 11 | pass :6:12: TCH003 [*] Move standard library import `sys` into a type-checking block | @@ -34,17 +23,3 @@ source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs 8 | def f(x: os, y: sys): | = help: Move into type-checking block - -ℹ Unsafe fix -3 3 | -4 4 | from typing import TYPE_CHECKING -5 5 | -6 |-import os, sys -7 6 | - 7 |+if TYPE_CHECKING: - 8 |+ import os, sys - 9 |+ -8 10 | def f(x: os, y: sys): -9 11 | pass - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__no_typing_import.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__no_typing_import.snap index 3f9c1fb4f77a0..5c8b66e2457d5 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__no_typing_import.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__no_typing_import.snap @@ -11,18 +11,3 @@ source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs 6 | def f(x: pd.DataFrame): | = help: Move into type-checking block - -ℹ Unsafe fix -1 1 | -2 2 | from __future__ import annotations -3 3 | -4 |-import pandas as pd - 4 |+from typing import TYPE_CHECKING - 5 |+ - 6 |+if TYPE_CHECKING: - 7 |+ import pandas as pd -5 8 | -6 9 | def f(x: pd.DataFrame): -7 10 | pass - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_runtime-import-in-type-checking-block_quote.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_runtime-import-in-type-checking-block_quote.py.snap index ae71c56c8195a..ea08d5bd9548d 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_runtime-import-in-type-checking-block_quote.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_runtime-import-in-type-checking-block_quote.py.snap @@ -10,15 +10,3 @@ quote.py:64:28: TCH004 [*] Quote references to `pandas.DataFrame`. Import is in 66 | def func(value: DataFrame): | = help: Quote references - -ℹ Unsafe fix -63 63 | if TYPE_CHECKING: -64 64 | from pandas import DataFrame -65 65 | -66 |- def func(value: DataFrame): - 66 |+ def func(value: "DataFrame"): -67 67 | ... -68 68 | -69 69 | - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_typing-only-third-party-import_quote.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_typing-only-third-party-import_quote.py.snap index d9bb6a9824812..55c685aa034f9 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_typing-only-third-party-import_quote.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_typing-only-third-party-import_quote.py.snap @@ -11,19 +11,6 @@ quote.py:2:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a type | = help: Move into type-checking block -ℹ Unsafe fix -1 |-def f(): - 1 |+from typing import TYPE_CHECKING - 2 |+ - 3 |+if TYPE_CHECKING: -2 4 | from pandas import DataFrame - 5 |+def f(): -3 6 | -4 |- def baz() -> DataFrame: - 7 |+ def baz() -> "DataFrame": -5 8 | ... -6 9 | -7 10 | quote.py:9:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block | @@ -35,25 +22,6 @@ quote.py:9:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a type | = help: Move into type-checking block -ℹ Unsafe fix - 1 |+from typing import TYPE_CHECKING - 2 |+ - 3 |+if TYPE_CHECKING: - 4 |+ from pandas import DataFrame -1 5 | def f(): -2 6 | from pandas import DataFrame -3 7 | --------------------------------------------------------------------------------- -6 10 | -7 11 | -8 12 | def f(): -9 |- from pandas import DataFrame -10 13 | -11 |- def baz() -> DataFrame[int]: - 14 |+ def baz() -> "DataFrame[int]": -12 15 | ... -13 16 | -14 17 | quote.py:16:24: TCH002 Move third-party import `pandas.DataFrame` into a type-checking block | @@ -75,25 +43,6 @@ quote.py:23:22: TCH002 [*] Move third-party import `pandas` into a type-checking | = help: Move into type-checking block -ℹ Unsafe fix - 1 |+from typing import TYPE_CHECKING - 2 |+ - 3 |+if TYPE_CHECKING: - 4 |+ import pandas as pd -1 5 | def f(): -2 6 | from pandas import DataFrame -3 7 | --------------------------------------------------------------------------------- -20 24 | -21 25 | -22 26 | def f(): -23 |- import pandas as pd -24 27 | -25 |- def baz() -> pd.DataFrame: - 28 |+ def baz() -> "pd.DataFrame": -26 29 | ... -27 30 | -28 31 | quote.py:30:22: TCH002 [*] Move third-party import `pandas` into a type-checking block | @@ -105,25 +54,6 @@ quote.py:30:22: TCH002 [*] Move third-party import `pandas` into a type-checking | = help: Move into type-checking block -ℹ Unsafe fix - 1 |+from typing import TYPE_CHECKING - 2 |+ - 3 |+if TYPE_CHECKING: - 4 |+ import pandas as pd -1 5 | def f(): -2 6 | from pandas import DataFrame -3 7 | --------------------------------------------------------------------------------- -27 31 | -28 32 | -29 33 | def f(): -30 |- import pandas as pd -31 34 | -32 |- def baz() -> pd.DataFrame.Extra: - 35 |+ def baz() -> "pd.DataFrame.Extra": -33 36 | ... -34 37 | -35 38 | quote.py:37:22: TCH002 [*] Move third-party import `pandas` into a type-checking block | @@ -135,25 +65,6 @@ quote.py:37:22: TCH002 [*] Move third-party import `pandas` into a type-checking | = help: Move into type-checking block -ℹ Unsafe fix - 1 |+from typing import TYPE_CHECKING - 2 |+ - 3 |+if TYPE_CHECKING: - 4 |+ import pandas as pd -1 5 | def f(): -2 6 | from pandas import DataFrame -3 7 | --------------------------------------------------------------------------------- -34 38 | -35 39 | -36 40 | def f(): -37 |- import pandas as pd -38 41 | -39 |- def baz() -> pd.DataFrame | int: - 42 |+ def baz() -> "pd.DataFrame | int": -40 43 | ... -41 44 | -42 45 | quote.py:45:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block | @@ -165,25 +76,6 @@ quote.py:45:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a typ | = help: Move into type-checking block -ℹ Unsafe fix - 1 |+from typing import TYPE_CHECKING - 2 |+ - 3 |+if TYPE_CHECKING: - 4 |+ from pandas import DataFrame -1 5 | def f(): -2 6 | from pandas import DataFrame -3 7 | --------------------------------------------------------------------------------- -42 46 | -43 47 | -44 48 | def f(): -45 |- from pandas import DataFrame -46 49 | -47 |- def baz() -> DataFrame(): - 50 |+ def baz() -> "DataFrame()": -48 51 | ... -49 52 | -50 53 | quote.py:54:24: TCH002 Move third-party import `pandas.DataFrame` into a type-checking block | @@ -206,25 +98,6 @@ quote.py:71:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a typ | = help: Move into type-checking block -ℹ Unsafe fix - 1 |+from typing import TYPE_CHECKING - 2 |+ - 3 |+if TYPE_CHECKING: - 4 |+ from pandas import DataFrame, Series -1 5 | def f(): -2 6 | from pandas import DataFrame -3 7 | --------------------------------------------------------------------------------- -68 72 | -69 73 | -70 74 | def f(): -71 |- from pandas import DataFrame, Series -72 75 | -73 |- def baz() -> DataFrame | Series: - 76 |+ def baz() -> "DataFrame | Series": -74 77 | ... -75 78 | -76 79 | quote.py:71:35: TCH002 [*] Move third-party import `pandas.Series` into a type-checking block | @@ -236,25 +109,6 @@ quote.py:71:35: TCH002 [*] Move third-party import `pandas.Series` into a type-c | = help: Move into type-checking block -ℹ Unsafe fix - 1 |+from typing import TYPE_CHECKING - 2 |+ - 3 |+if TYPE_CHECKING: - 4 |+ from pandas import DataFrame, Series -1 5 | def f(): -2 6 | from pandas import DataFrame -3 7 | --------------------------------------------------------------------------------- -68 72 | -69 73 | -70 74 | def f(): -71 |- from pandas import DataFrame, Series -72 75 | -73 |- def baz() -> DataFrame | Series: - 76 |+ def baz() -> "DataFrame | Series": -74 77 | ... -75 78 | -76 79 | quote.py:78:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block | @@ -266,38 +120,6 @@ quote.py:78:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a typ | = help: Move into type-checking block -ℹ Unsafe fix - 1 |+from typing import TYPE_CHECKING - 2 |+ - 3 |+if TYPE_CHECKING: - 4 |+ from pandas import DataFrame, Series -1 5 | def f(): -2 6 | from pandas import DataFrame -3 7 | --------------------------------------------------------------------------------- -75 79 | -76 80 | -77 81 | def f(): -78 |- from pandas import DataFrame, Series -79 82 | -80 83 | def baz() -> ( -81 |- DataFrame | -82 |- Series - 84 |+ "DataFrame | Series" -83 85 | ): -84 86 | ... -85 87 | -86 88 | class C: -87 |- x: DataFrame[ -88 |- int -89 |- ] = 1 - 89 |+ x: "DataFrame[int]" = 1 -90 90 | -91 |- def func() -> DataFrame[[DataFrame[_P, _R]], DataFrame[_P, _R]]: - 91 |+ def func() -> "DataFrame[[DataFrame[_P, _R]], DataFrame[_P, _R]]": -92 92 | ... -93 93 | -94 94 | quote.py:78:35: TCH002 [*] Move third-party import `pandas.Series` into a type-checking block | @@ -309,38 +131,6 @@ quote.py:78:35: TCH002 [*] Move third-party import `pandas.Series` into a type-c | = help: Move into type-checking block -ℹ Unsafe fix - 1 |+from typing import TYPE_CHECKING - 2 |+ - 3 |+if TYPE_CHECKING: - 4 |+ from pandas import DataFrame, Series -1 5 | def f(): -2 6 | from pandas import DataFrame -3 7 | --------------------------------------------------------------------------------- -75 79 | -76 80 | -77 81 | def f(): -78 |- from pandas import DataFrame, Series -79 82 | -80 83 | def baz() -> ( -81 |- DataFrame | -82 |- Series - 84 |+ "DataFrame | Series" -83 85 | ): -84 86 | ... -85 87 | -86 88 | class C: -87 |- x: DataFrame[ -88 |- int -89 |- ] = 1 - 89 |+ x: "DataFrame[int]" = 1 -90 90 | -91 |- def func() -> DataFrame[[DataFrame[_P, _R]], DataFrame[_P, _R]]: - 91 |+ def func() -> "DataFrame[[DataFrame[_P, _R]], DataFrame[_P, _R]]": -92 92 | ... -93 93 | -94 94 | quote.py:96:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block | @@ -352,23 +142,6 @@ quote.py:96:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a typ | = help: Move into type-checking block -ℹ Unsafe fix - 1 |+from typing import TYPE_CHECKING - 2 |+ - 3 |+if TYPE_CHECKING: - 4 |+ from pandas import DataFrame, Series -1 5 | def f(): -2 6 | from pandas import DataFrame -3 7 | --------------------------------------------------------------------------------- -93 97 | -94 98 | -95 99 | def f(): -96 |- from pandas import DataFrame, Series -97 100 | -98 |- def func(self) -> DataFrame | list[Series]: - 101 |+ def func(self) -> "DataFrame | list[Series]": -99 102 | pass quote.py:96:35: TCH002 [*] Move third-party import `pandas.Series` into a type-checking block | @@ -379,21 +152,3 @@ quote.py:96:35: TCH002 [*] Move third-party import `pandas.Series` into a type-c 98 | def func(self) -> DataFrame | list[Series]: | = help: Move into type-checking block - -ℹ Unsafe fix - 1 |+from typing import TYPE_CHECKING - 2 |+ - 3 |+if TYPE_CHECKING: - 4 |+ from pandas import DataFrame, Series -1 5 | def f(): -2 6 | from pandas import DataFrame -3 7 | --------------------------------------------------------------------------------- -93 97 | -94 98 | -95 99 | def f(): -96 |- from pandas import DataFrame, Series -97 100 | -98 |- def func(self) -> DataFrame | list[Series]: - 101 |+ def func(self) -> "DataFrame | list[Series]": -99 102 | pass diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_1.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_1.py.snap index b11905593b5aa..22bc63a314f95 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_1.py.snap @@ -9,14 +9,3 @@ TCH004_1.py:4:26: TCH004 [*] Move import `datetime.datetime` out of type-checkin 5 | x = datetime | = help: Move out of type-checking block - -ℹ Unsafe fix -1 1 | from typing import TYPE_CHECKING - 2 |+from datetime import datetime -2 3 | -3 4 | if TYPE_CHECKING: -4 |- from datetime import datetime - 5 |+ pass -5 6 | x = datetime - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_11.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_11.py.snap index 1c4e1df589f8c..ba2fb649acad5 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_11.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_11.py.snap @@ -10,15 +10,3 @@ TCH004_11.py:4:24: TCH004 [*] Move import `typing.List` out of type-checking blo 6 | __all__ = ("List",) | = help: Move out of type-checking block - -ℹ Unsafe fix -1 1 | from typing import TYPE_CHECKING - 2 |+from typing import List -2 3 | -3 4 | if TYPE_CHECKING: -4 |- from typing import List - 5 |+ pass -5 6 | -6 7 | __all__ = ("List",) - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_12.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_12.py.snap index 8efe1fd384ac0..a649579e5c602 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_12.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_12.py.snap @@ -10,17 +10,3 @@ TCH004_12.py:6:33: TCH004 [*] Move import `collections.abc.Callable` out of type 8 | AnyCallable: TypeAlias = Callable[..., Any] | = help: Move out of type-checking block - -ℹ Unsafe fix -1 1 | from __future__ import annotations -2 2 | -3 3 | from typing import Any, TYPE_CHECKING, TypeAlias - 4 |+from collections.abc import Callable -4 5 | -5 6 | if TYPE_CHECKING: -6 |- from collections.abc import Callable - 7 |+ pass -7 8 | -8 9 | AnyCallable: TypeAlias = Callable[..., Any] - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_17.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_17.py.snap index 785c4c1d2e6c4..0b416a9abe182 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_17.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_17.py.snap @@ -8,18 +8,3 @@ TCH004_17.py:6:24: TCH004 [*] Move import `pandas.DataFrame` out of type-checkin | ^^^^^^^^^ TCH004 | = help: Move out of type-checking block - -ℹ Unsafe fix -1 1 | from __future__ import annotations -2 2 | -3 3 | from typing_extensions import TYPE_CHECKING - 4 |+from pandas import DataFrame -4 5 | -5 6 | if TYPE_CHECKING: -6 |- from pandas import DataFrame - 7 |+ pass -7 8 | -8 9 | -9 10 | def example() -> DataFrame: - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_2.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_2.py.snap index 7e49226762c46..6f38ed9a85068 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_2.py.snap @@ -8,16 +8,3 @@ TCH004_2.py:4:26: TCH004 [*] Move import `datetime.date` out of type-checking bl | ^^^^ TCH004 | = help: Move out of type-checking block - -ℹ Unsafe fix -1 1 | from typing import TYPE_CHECKING - 2 |+from datetime import date -2 3 | -3 4 | if TYPE_CHECKING: -4 |- from datetime import date - 5 |+ pass -5 6 | -6 7 | -7 8 | def example(): - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_4.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_4.py.snap index aa464d7840a11..fd1e2a77a7780 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_4.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_4.py.snap @@ -8,16 +8,3 @@ TCH004_4.py:4:24: TCH004 [*] Move import `typing.Any` out of type-checking block | ^^^ TCH004 | = help: Move out of type-checking block - -ℹ Unsafe fix -1 1 | from typing import TYPE_CHECKING, Type - 2 |+from typing import Any -2 3 | -3 4 | if TYPE_CHECKING: -4 |- from typing import Any - 5 |+ pass -5 6 | -6 7 | -7 8 | def example(*args: Any, **kwargs: Any): - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_5.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_5.py.snap index ff1e64f7b5304..c166caaed42e1 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_5.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_5.py.snap @@ -9,16 +9,6 @@ TCH004_5.py:4:24: TCH004 [*] Move import `typing.List` out of type-checking bloc | = help: Move out of type-checking block -ℹ Unsafe fix -1 1 | from typing import TYPE_CHECKING - 2 |+from typing import List, Sequence, Set -2 3 | -3 4 | if TYPE_CHECKING: -4 |- from typing import List, Sequence, Set - 5 |+ pass -5 6 | -6 7 | -7 8 | def example(a: List[int], /, b: Sequence[int], *, c: Set[int]): TCH004_5.py:4:30: TCH004 [*] Move import `typing.Sequence` out of type-checking block. Import is used for more than type hinting. | @@ -28,16 +18,6 @@ TCH004_5.py:4:30: TCH004 [*] Move import `typing.Sequence` out of type-checking | = help: Move out of type-checking block -ℹ Unsafe fix -1 1 | from typing import TYPE_CHECKING - 2 |+from typing import List, Sequence, Set -2 3 | -3 4 | if TYPE_CHECKING: -4 |- from typing import List, Sequence, Set - 5 |+ pass -5 6 | -6 7 | -7 8 | def example(a: List[int], /, b: Sequence[int], *, c: Set[int]): TCH004_5.py:4:40: TCH004 [*] Move import `typing.Set` out of type-checking block. Import is used for more than type hinting. | @@ -46,16 +26,3 @@ TCH004_5.py:4:40: TCH004 [*] Move import `typing.Set` out of type-checking block | ^^^ TCH004 | = help: Move out of type-checking block - -ℹ Unsafe fix -1 1 | from typing import TYPE_CHECKING - 2 |+from typing import List, Sequence, Set -2 3 | -3 4 | if TYPE_CHECKING: -4 |- from typing import List, Sequence, Set - 5 |+ pass -5 6 | -6 7 | -7 8 | def example(a: List[int], /, b: Sequence[int], *, c: Set[int]): - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_9.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_9.py.snap index 0c30f3a80053d..d512a0a7d9062 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_9.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_9.py.snap @@ -11,16 +11,6 @@ TCH004_9.py:4:24: TCH004 [*] Move import `typing.Tuple` out of type-checking blo | = help: Move out of type-checking block -ℹ Unsafe fix -1 1 | from typing import TYPE_CHECKING - 2 |+from typing import Tuple, List -2 3 | -3 4 | if TYPE_CHECKING: -4 |- from typing import Tuple, List, Dict - 5 |+ from typing import Dict -5 6 | -6 7 | x: Tuple -7 8 | TCH004_9.py:4:31: TCH004 [*] Move import `typing.List` out of type-checking block. Import is used for more than type hinting. | @@ -31,16 +21,3 @@ TCH004_9.py:4:31: TCH004 [*] Move import `typing.List` out of type-checking bloc 6 | x: Tuple | = help: Move out of type-checking block - -ℹ Unsafe fix -1 1 | from typing import TYPE_CHECKING - 2 |+from typing import Tuple, List -2 3 | -3 4 | if TYPE_CHECKING: -4 |- from typing import Tuple, List, Dict - 5 |+ from typing import Dict -5 6 | -6 7 | x: Tuple -7 8 | - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_quote.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_quote.py.snap index c09777853b97a..35f7f380284fd 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_quote.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_quote.py.snap @@ -10,20 +10,3 @@ quote.py:64:28: TCH004 [*] Move import `pandas.DataFrame` out of type-checking b 66 | def func(value: DataFrame): | = help: Move out of type-checking block - -ℹ Unsafe fix - 1 |+from pandas import DataFrame -1 2 | def f(): -2 3 | from pandas import DataFrame -3 4 | --------------------------------------------------------------------------------- -61 62 | from typing import TYPE_CHECKING -62 63 | -63 64 | if TYPE_CHECKING: -64 |- from pandas import DataFrame - 65 |+ pass -65 66 | -66 67 | def func(value: DataFrame): -67 68 | ... - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_runtime_evaluated_base_classes_1.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_runtime_evaluated_base_classes_1.py.snap index e3174cb4546f4..af88bce1ba9b6 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_runtime_evaluated_base_classes_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_runtime_evaluated_base_classes_1.py.snap @@ -10,17 +10,6 @@ runtime_evaluated_base_classes_1.py:10:12: TCH004 [*] Move import `datetime` out | = help: Move out of type-checking block -ℹ Unsafe fix -5 5 | -6 6 | import pydantic -7 7 | from pydantic import BaseModel - 8 |+import datetime -8 9 | -9 10 | if TYPE_CHECKING: -10 |- import datetime # TCH004 -11 11 | from array import array # TCH004 -12 12 | -13 13 | import pandas # TCH004 runtime_evaluated_base_classes_1.py:11:23: TCH004 [*] Move import `array.array` out of type-checking block. Import is used for more than type hinting. | @@ -33,18 +22,6 @@ runtime_evaluated_base_classes_1.py:11:23: TCH004 [*] Move import `array.array` | = help: Move out of type-checking block -ℹ Unsafe fix -5 5 | -6 6 | import pydantic -7 7 | from pydantic import BaseModel - 8 |+from array import array -8 9 | -9 10 | if TYPE_CHECKING: -10 11 | import datetime # TCH004 -11 |- from array import array # TCH004 -12 12 | -13 13 | import pandas # TCH004 -14 14 | import pyproj runtime_evaluated_base_classes_1.py:13:12: TCH004 [*] Move import `pandas` out of type-checking block. Import is used for more than type hinting. | @@ -55,20 +32,3 @@ runtime_evaluated_base_classes_1.py:13:12: TCH004 [*] Move import `pandas` out o 14 | import pyproj | = help: Move out of type-checking block - -ℹ Unsafe fix -5 5 | -6 6 | import pydantic -7 7 | from pydantic import BaseModel - 8 |+import pandas -8 9 | -9 10 | if TYPE_CHECKING: -10 11 | import datetime # TCH004 -11 12 | from array import array # TCH004 -12 13 | -13 |- import pandas # TCH004 -14 14 | import pyproj -15 15 | -16 16 | - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_runtime_evaluated_decorators_1.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_runtime_evaluated_decorators_1.py.snap index d229203c36788..e7f33bf116cdf 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_runtime_evaluated_decorators_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_runtime_evaluated_decorators_1.py.snap @@ -10,17 +10,6 @@ runtime_evaluated_decorators_1.py:12:12: TCH004 [*] Move import `datetime` out o | = help: Move out of type-checking block -ℹ Unsafe fix -7 7 | from attrs import frozen -8 8 | -9 9 | import numpy - 10 |+import datetime -10 11 | -11 12 | if TYPE_CHECKING: -12 |- import datetime # TCH004 -13 13 | from array import array # TCH004 -14 14 | -15 15 | import pandas # TCH004 runtime_evaluated_decorators_1.py:13:23: TCH004 [*] Move import `array.array` out of type-checking block. Import is used for more than type hinting. | @@ -33,18 +22,6 @@ runtime_evaluated_decorators_1.py:13:23: TCH004 [*] Move import `array.array` ou | = help: Move out of type-checking block -ℹ Unsafe fix -7 7 | from attrs import frozen -8 8 | -9 9 | import numpy - 10 |+from array import array -10 11 | -11 12 | if TYPE_CHECKING: -12 13 | import datetime # TCH004 -13 |- from array import array # TCH004 -14 14 | -15 15 | import pandas # TCH004 -16 16 | import pyproj runtime_evaluated_decorators_1.py:15:12: TCH004 [*] Move import `pandas` out of type-checking block. Import is used for more than type hinting. | @@ -55,20 +32,3 @@ runtime_evaluated_decorators_1.py:15:12: TCH004 [*] Move import `pandas` out of 16 | import pyproj | = help: Move out of type-checking block - -ℹ Unsafe fix -7 7 | from attrs import frozen -8 8 | -9 9 | import numpy - 10 |+import pandas -10 11 | -11 12 | if TYPE_CHECKING: -12 13 | import datetime # TCH004 -13 14 | from array import array # TCH004 -14 15 | -15 |- import pandas # TCH004 -16 16 | import pyproj -17 17 | -18 18 | - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict_typing-only-standard-library-import_init_var.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict_typing-only-standard-library-import_init_var.py.snap index 64ba87ffb395b..51398a2193da5 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict_typing-only-standard-library-import_init_var.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict_typing-only-standard-library-import_init_var.py.snap @@ -11,20 +11,6 @@ init_var.py:5:25: TCH003 [*] Move standard library import `dataclasses.FrozenIns | = help: Move into type-checking block -ℹ Unsafe fix -2 2 | -3 3 | from __future__ import annotations -4 4 | -5 |-from dataclasses import FrozenInstanceError, InitVar, dataclass - 5 |+from dataclasses import InitVar, dataclass -6 6 | from pathlib import Path - 7 |+from typing import TYPE_CHECKING - 8 |+ - 9 |+if TYPE_CHECKING: - 10 |+ from dataclasses import FrozenInstanceError -7 11 | -8 12 | -9 13 | @dataclass init_var.py:6:21: TCH003 [*] Move standard library import `pathlib.Path` into a type-checking block | @@ -33,18 +19,3 @@ init_var.py:6:21: TCH003 [*] Move standard library import `pathlib.Path` into a | ^^^^ TCH003 | = help: Move into type-checking block - -ℹ Unsafe fix -3 3 | from __future__ import annotations -4 4 | -5 5 | from dataclasses import FrozenInstanceError, InitVar, dataclass -6 |-from pathlib import Path - 6 |+from typing import TYPE_CHECKING - 7 |+ - 8 |+if TYPE_CHECKING: - 9 |+ from pathlib import Path -7 10 | -8 11 | -9 12 | @dataclass - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict_typing-only-third-party-import_strict.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict_typing-only-third-party-import_strict.py.snap index 99d8f413bb163..f7db2da0fc04b 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict_typing-only-third-party-import_strict.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict_typing-only-third-party-import_strict.py.snap @@ -12,23 +12,6 @@ strict.py:27:21: TCH002 [*] Move third-party import `pkg.A` into a type-checking | = help: Move into type-checking block -ℹ Unsafe fix -1 1 | from __future__ import annotations - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ from pkg import A -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -24 28 | def f(): -25 29 | # In un-strict mode, this shouldn't raise an error, since `pkg` is used at runtime. -26 30 | import pkg -27 |- from pkg import A -28 31 | -29 32 | def test(value: A): -30 33 | return pkg.B() strict.py:35:21: TCH002 [*] Move third-party import `pkg.A` into a type-checking block | @@ -41,24 +24,6 @@ strict.py:35:21: TCH002 [*] Move third-party import `pkg.A` into a type-checking | = help: Move into type-checking block -ℹ Unsafe fix -1 1 | from __future__ import annotations - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ from pkg import A -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -32 36 | -33 37 | def f(): -34 38 | # In un-strict mode, this shouldn't raise an error, since `pkg` is used at runtime. -35 |- from pkg import A, B - 39 |+ from pkg import B -36 40 | -37 41 | def test(value: A): -38 42 | return B() strict.py:54:25: TCH002 [*] Move third-party import `pkg.bar.A` into a type-checking block | @@ -71,23 +36,6 @@ strict.py:54:25: TCH002 [*] Move third-party import `pkg.bar.A` into a type-chec | = help: Move into type-checking block -ℹ Unsafe fix -1 1 | from __future__ import annotations - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ from pkg.bar import A -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -51 55 | def f(): -52 56 | # In un-strict mode, this _should_ raise an error, since `pkg.bar` isn't used at runtime -53 57 | import pkg -54 |- from pkg.bar import A -55 58 | -56 59 | def test(value: A): -57 60 | return pkg.B() strict.py:62:12: TCH002 [*] Move third-party import `pkg` into a type-checking block | @@ -99,23 +47,6 @@ strict.py:62:12: TCH002 [*] Move third-party import `pkg` into a type-checking b | = help: Move into type-checking block -ℹ Unsafe fix -1 1 | from __future__ import annotations - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ import pkg -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -59 63 | -60 64 | def f(): -61 65 | # In un-strict mode, this shouldn't raise an error, since `pkg.bar` is used at runtime. -62 |- import pkg -63 66 | import pkg.bar as B -64 67 | -65 68 | def test(value: pkg.A): strict.py:71:23: TCH002 [*] Move third-party import `pkg.foo` into a type-checking block | @@ -127,23 +58,6 @@ strict.py:71:23: TCH002 [*] Move third-party import `pkg.foo` into a type-checki | = help: Move into type-checking block -ℹ Unsafe fix -1 1 | from __future__ import annotations - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ import pkg.foo as F -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -68 72 | -69 73 | def f(): -70 74 | # In un-strict mode, this shouldn't raise an error, since `pkg.foo.bar` is used at runtime. -71 |- import pkg.foo as F -72 75 | import pkg.foo.bar as B -73 76 | -74 77 | def test(value: F.Foo): strict.py:80:12: TCH002 [*] Move third-party import `pkg` into a type-checking block | @@ -155,23 +69,6 @@ strict.py:80:12: TCH002 [*] Move third-party import `pkg` into a type-checking b | = help: Move into type-checking block -ℹ Unsafe fix -1 1 | from __future__ import annotations - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ import pkg -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -77 81 | -78 82 | def f(): -79 83 | # In un-strict mode, this shouldn't raise an error, since `pkg.foo.bar` is used at runtime. -80 |- import pkg -81 84 | import pkg.foo.bar as B -82 85 | -83 86 | def test(value: pkg.A): strict.py:91:12: TCH002 [*] Move third-party import `pkg` into a type-checking block | @@ -183,23 +80,6 @@ strict.py:91:12: TCH002 [*] Move third-party import `pkg` into a type-checking b | = help: Move into type-checking block -ℹ Unsafe fix -1 1 | from __future__ import annotations - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ import pkg -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -88 92 | # In un-strict mode, this _should_ raise an error, since `pkg` isn't used at runtime. -89 93 | # Note that `pkg` is a prefix of `pkgfoo` which are both different modules. This is -90 94 | # testing the implementation. -91 |- import pkg -92 95 | import pkgfoo.bar as B -93 96 | -94 97 | def test(value: pkg.A): strict.py:101:23: TCH002 [*] Move third-party import `pkg.foo` into a type-checking block | @@ -211,23 +91,3 @@ strict.py:101:23: TCH002 [*] Move third-party import `pkg.foo` into a type-check 103 | def test(value: F.Foo): | = help: Move into type-checking block - -ℹ Unsafe fix -1 1 | from __future__ import annotations - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ import pkg.foo as F -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -98 102 | def f(): -99 103 | # In un-strict mode, this shouldn't raise an error, since `pkg` is used at runtime. -100 104 | import pkg.bar as B -101 |- import pkg.foo as F -102 105 | -103 106 | def test(value: F.Foo): -104 107 | return B.Bar() - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_after_usage.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_after_usage.snap index da83b1545fffa..f603068e9b4eb 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_after_usage.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_after_usage.snap @@ -11,18 +11,3 @@ source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs 8 | def f(x: pd.DataFrame): | = help: Move into type-checking block - -ℹ Unsafe fix -3 3 | -4 4 | from typing import TYPE_CHECKING -5 5 | -6 |-import pandas as pd -7 6 | - 7 |+if TYPE_CHECKING: - 8 |+ import pandas as pd - 9 |+ -8 10 | def f(x: pd.DataFrame): -9 11 | pass -10 12 | - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_comment.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_comment.snap index 0cd80a368e5f1..2748312e25b1a 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_comment.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_comment.snap @@ -11,18 +11,3 @@ source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs 8 | if TYPE_CHECKING: | = help: Move into type-checking block - -ℹ Unsafe fix -3 3 | -4 4 | from typing import TYPE_CHECKING -5 5 | -6 |-import pandas as pd -7 6 | -8 7 | if TYPE_CHECKING: -9 8 | # This is a comment. - 9 |+ import pandas as pd -10 10 | import os -11 11 | -12 12 | def f(x: pd.DataFrame): - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_inline.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_inline.snap index c79f7c9e53dca..7a59ef7ca8cea 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_inline.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_inline.snap @@ -11,17 +11,3 @@ source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs 8 | if TYPE_CHECKING: import os | = help: Move into type-checking block - -ℹ Unsafe fix -3 3 | -4 4 | from typing import TYPE_CHECKING -5 5 | -6 |-import pandas as pd -7 6 | -8 |-if TYPE_CHECKING: import os - 7 |+if TYPE_CHECKING: import pandas as pd; import os -9 8 | -10 9 | def f(x: pd.DataFrame): -11 10 | pass - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_own_line.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_own_line.snap index bf141729eb56b..2748312e25b1a 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_own_line.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_own_line.snap @@ -11,17 +11,3 @@ source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs 8 | if TYPE_CHECKING: | = help: Move into type-checking block - -ℹ Unsafe fix -3 3 | -4 4 | from typing import TYPE_CHECKING -5 5 | -6 |-import pandas as pd -7 6 | -8 7 | if TYPE_CHECKING: - 8 |+ import pandas as pd -9 9 | import os -10 10 | -11 11 | def f(x: pd.DataFrame): - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-first-party-import_TCH001.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-first-party-import_TCH001.py.snap index 2c086380af453..96cb9ef4c23d8 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-first-party-import_TCH001.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-first-party-import_TCH001.py.snap @@ -10,25 +10,3 @@ TCH001.py:20:19: TCH001 [*] Move application import `.TYP001` into a type-checki 22 | x: TYP001 | = help: Move into type-checking block - -ℹ Unsafe fix -2 2 | -3 3 | For typing-only import detection tests, see `TCH002.py`. -4 4 | """ - 5 |+from typing import TYPE_CHECKING - 6 |+ - 7 |+if TYPE_CHECKING: - 8 |+ from . import TYP001 -5 9 | -6 10 | -7 11 | def f(): --------------------------------------------------------------------------------- -17 21 | -18 22 | -19 23 | def f(): -20 |- from . import TYP001 -21 24 | -22 25 | x: TYP001 -23 26 | - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_TCH003.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_TCH003.py.snap index a5016892c3fb2..347c44cfd0127 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_TCH003.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_TCH003.py.snap @@ -10,21 +10,3 @@ TCH003.py:8:12: TCH003 [*] Move standard library import `os` into a type-checkin 10 | x: os | = help: Move into type-checking block - -ℹ Unsafe fix -2 2 | -3 3 | For typing-only import detection tests, see `TCH002.py`. -4 4 | """ - 5 |+from typing import TYPE_CHECKING - 6 |+ - 7 |+if TYPE_CHECKING: - 8 |+ import os -5 9 | -6 10 | -7 11 | def f(): -8 |- import os -9 12 | -10 13 | x: os -11 14 | - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_1.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_1.py.snap index ca63f50e1fc0b..c0118b247f9e7 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_1.py.snap @@ -11,17 +11,3 @@ exempt_type_checking_1.py:5:20: TCH003 [*] Move standard library import `typing. 7 | Const: Final[dict] = {} | = help: Move into type-checking block - -ℹ Unsafe fix -2 2 | -3 3 | from __future__ import annotations -4 4 | -5 |-from typing import Final - 5 |+from typing import TYPE_CHECKING - 6 |+ - 7 |+if TYPE_CHECKING: - 8 |+ from typing import Final -6 9 | -7 10 | Const: Final[dict] = {} - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_2.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_2.py.snap index 82d27250c6c6a..11ff8aa52afbe 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_2.py.snap @@ -11,17 +11,3 @@ exempt_type_checking_2.py:5:20: TCH003 [*] Move standard library import `typing. 7 | Const: Final[dict] = {} | = help: Move into type-checking block - -ℹ Unsafe fix -2 2 | -3 3 | from __future__ import annotations -4 4 | -5 |-from typing import Final, TYPE_CHECKING - 5 |+from typing import TYPE_CHECKING - 6 |+ - 7 |+if TYPE_CHECKING: - 8 |+ from typing import Final -6 9 | -7 10 | Const: Final[dict] = {} - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_3.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_3.py.snap index 18b9b569ecd34..6ba25afff7a8b 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_3.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_3.py.snap @@ -11,18 +11,3 @@ exempt_type_checking_3.py:5:20: TCH003 [*] Move standard library import `typing. 7 | Const: Final[dict] = {} | = help: Move into type-checking block - -ℹ Unsafe fix -2 2 | -3 3 | from __future__ import annotations -4 4 | -5 |-from typing import Final, Mapping - 5 |+from typing import Mapping - 6 |+from typing import TYPE_CHECKING - 7 |+ - 8 |+if TYPE_CHECKING: - 9 |+ from typing import Final -6 10 | -7 11 | Const: Final[dict] = {} - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_init_var.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_init_var.py.snap index 08a45c92e134c..11096eb575c59 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_init_var.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_init_var.py.snap @@ -8,18 +8,3 @@ init_var.py:6:21: TCH003 [*] Move standard library import `pathlib.Path` into a | ^^^^ TCH003 | = help: Move into type-checking block - -ℹ Unsafe fix -3 3 | from __future__ import annotations -4 4 | -5 5 | from dataclasses import FrozenInstanceError, InitVar, dataclass -6 |-from pathlib import Path - 6 |+from typing import TYPE_CHECKING - 7 |+ - 8 |+if TYPE_CHECKING: - 9 |+ from pathlib import Path -7 10 | -8 11 | -9 12 | @dataclass - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_module__undefined.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_module__undefined.py.snap index b7f049eaa86ff..d4998f2b269e7 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_module__undefined.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_module__undefined.py.snap @@ -9,17 +9,3 @@ undefined.py:3:29: TCH003 [*] Move standard library import `collections.abc.Sequ | ^^^^^^^^ TCH003 | = help: Move into type-checking block - -ℹ Unsafe fix -1 1 | from __future__ import annotations -2 2 | -3 |-from collections.abc import Sequence - 3 |+from typing import TYPE_CHECKING - 4 |+ - 5 |+if TYPE_CHECKING: - 6 |+ from collections.abc import Sequence -4 7 | -5 8 | -6 9 | class Foo(MyBaseClass): - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_runtime_evaluated_base_classes_3.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_runtime_evaluated_base_classes_3.py.snap index 7eb6ba98775d0..af5246c83c46a 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_runtime_evaluated_base_classes_3.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_runtime_evaluated_base_classes_3.py.snap @@ -11,21 +11,3 @@ runtime_evaluated_base_classes_3.py:5:18: TCH003 [*] Move standard library impor 7 | import pydantic | = help: Move into type-checking block - -ℹ Unsafe fix -2 2 | -3 3 | import datetime -4 4 | import pathlib -5 |-from uuid import UUID # TCH003 -6 5 | -7 6 | import pydantic -8 7 | from pydantic import BaseModel - 8 |+from typing import TYPE_CHECKING - 9 |+ - 10 |+if TYPE_CHECKING: - 11 |+ from uuid import UUID -9 12 | -10 13 | -11 14 | class A(pydantic.BaseModel): - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_runtime_evaluated_decorators_3.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_runtime_evaluated_decorators_3.py.snap index 618928099681a..546a709a077b6 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_runtime_evaluated_decorators_3.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_runtime_evaluated_decorators_3.py.snap @@ -11,23 +11,3 @@ runtime_evaluated_decorators_3.py:6:18: TCH003 [*] Move standard library import 8 | from pydantic import validate_call | = help: Move into type-checking block - -ℹ Unsafe fix -3 3 | import datetime -4 4 | from array import array -5 5 | from dataclasses import dataclass -6 |-from uuid import UUID # TCH003 -7 6 | from collections.abc import Sequence -8 7 | from pydantic import validate_call -9 8 | -10 9 | import attrs -11 10 | from attrs import frozen - 11 |+from typing import TYPE_CHECKING - 12 |+ - 13 |+if TYPE_CHECKING: - 14 |+ from uuid import UUID -12 15 | -13 16 | -14 17 | @attrs.define(auto_attribs=True) - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_TCH002.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_TCH002.py.snap index 7d8365daa6ef9..bf6a12fff5984 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_TCH002.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_TCH002.py.snap @@ -11,19 +11,6 @@ TCH002.py:5:22: TCH002 [*] Move third-party import `pandas` into a type-checking | = help: Move into type-checking block -ℹ Unsafe fix -1 1 | """Tests to determine accurate detection of typing-only imports.""" - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ import pandas as pd -2 6 | -3 7 | -4 8 | def f(): -5 |- import pandas as pd # TCH002 -6 9 | -7 10 | x: pd.DataFrame -8 11 | TCH002.py:11:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block | @@ -35,23 +22,6 @@ TCH002.py:11:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a ty | = help: Move into type-checking block -ℹ Unsafe fix -1 1 | """Tests to determine accurate detection of typing-only imports.""" - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ from pandas import DataFrame -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -8 12 | -9 13 | -10 14 | def f(): -11 |- from pandas import DataFrame # TCH002 -12 15 | -13 16 | x: DataFrame -14 17 | TCH002.py:17:37: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block | @@ -63,23 +33,6 @@ TCH002.py:17:37: TCH002 [*] Move third-party import `pandas.DataFrame` into a ty | = help: Move into type-checking block -ℹ Unsafe fix -1 1 | """Tests to determine accurate detection of typing-only imports.""" - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ from pandas import DataFrame as df -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -14 18 | -15 19 | -16 20 | def f(): -17 |- from pandas import DataFrame as df # TCH002 -18 21 | -19 22 | x: df -20 23 | TCH002.py:23:22: TCH002 [*] Move third-party import `pandas` into a type-checking block | @@ -91,23 +44,6 @@ TCH002.py:23:22: TCH002 [*] Move third-party import `pandas` into a type-checkin | = help: Move into type-checking block -ℹ Unsafe fix -1 1 | """Tests to determine accurate detection of typing-only imports.""" - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ import pandas as pd -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -20 24 | -21 25 | -22 26 | def f(): -23 |- import pandas as pd # TCH002 -24 27 | -25 28 | x: pd.DataFrame = 1 -26 29 | TCH002.py:29:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block | @@ -119,23 +55,6 @@ TCH002.py:29:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a ty | = help: Move into type-checking block -ℹ Unsafe fix -1 1 | """Tests to determine accurate detection of typing-only imports.""" - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ from pandas import DataFrame -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -26 30 | -27 31 | -28 32 | def f(): -29 |- from pandas import DataFrame # TCH002 -30 33 | -31 34 | x: DataFrame = 2 -32 35 | TCH002.py:35:37: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block | @@ -147,23 +66,6 @@ TCH002.py:35:37: TCH002 [*] Move third-party import `pandas.DataFrame` into a ty | = help: Move into type-checking block -ℹ Unsafe fix -1 1 | """Tests to determine accurate detection of typing-only imports.""" - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ from pandas import DataFrame as df -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -32 36 | -33 37 | -34 38 | def f(): -35 |- from pandas import DataFrame as df # TCH002 -36 39 | -37 40 | x: df = 3 -38 41 | TCH002.py:41:22: TCH002 [*] Move third-party import `pandas` into a type-checking block | @@ -175,23 +77,6 @@ TCH002.py:41:22: TCH002 [*] Move third-party import `pandas` into a type-checkin | = help: Move into type-checking block -ℹ Unsafe fix -1 1 | """Tests to determine accurate detection of typing-only imports.""" - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ import pandas as pd -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -38 42 | -39 43 | -40 44 | def f(): -41 |- import pandas as pd # TCH002 -42 45 | -43 46 | x: "pd.DataFrame" = 1 -44 47 | TCH002.py:47:22: TCH002 [*] Move third-party import `pandas` into a type-checking block | @@ -203,23 +88,6 @@ TCH002.py:47:22: TCH002 [*] Move third-party import `pandas` into a type-checkin | = help: Move into type-checking block -ℹ Unsafe fix -1 1 | """Tests to determine accurate detection of typing-only imports.""" - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ import pandas as pd -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -44 48 | -45 49 | -46 50 | def f(): -47 |- import pandas as pd # TCH002 -48 51 | -49 52 | x = dict["pd.DataFrame", "pd.DataFrame"] -50 53 | TCH002.py:172:24: TCH002 [*] Move third-party import `module.Member` into a type-checking block | @@ -231,23 +99,3 @@ TCH002.py:172:24: TCH002 [*] Move third-party import `module.Member` into a type 174 | x: Member = 1 | = help: Move into type-checking block - -ℹ Unsafe fix -1 1 | """Tests to determine accurate detection of typing-only imports.""" - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ from module import Member -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -169 173 | def f(): -170 174 | global Member -171 175 | -172 |- from module import Member -173 176 | -174 177 | x: Member = 1 -175 178 | - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_runtime_evaluated_base_classes_2.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_runtime_evaluated_base_classes_2.py.snap index fdefb73be5917..361ef31c01b4b 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_runtime_evaluated_base_classes_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_runtime_evaluated_base_classes_2.py.snap @@ -12,22 +12,6 @@ runtime_evaluated_base_classes_2.py:3:21: TCH002 [*] Move third-party import `ge | = help: Move into type-checking block -ℹ Unsafe fix -1 1 | from __future__ import annotations -2 2 | -3 |-import geopandas as gpd # TCH002 -4 3 | import pydantic -5 4 | import pyproj # TCH002 -6 5 | from pydantic import BaseModel -7 6 | -8 7 | import numpy - 8 |+from typing import TYPE_CHECKING - 9 |+ - 10 |+if TYPE_CHECKING: - 11 |+ import geopandas as gpd -9 12 | -10 13 | -11 14 | class A(BaseModel): runtime_evaluated_base_classes_2.py:5:8: TCH002 [*] Move third-party import `pyproj` into a type-checking block | @@ -38,21 +22,3 @@ runtime_evaluated_base_classes_2.py:5:8: TCH002 [*] Move third-party import `pyp 6 | from pydantic import BaseModel | = help: Move into type-checking block - -ℹ Unsafe fix -2 2 | -3 3 | import geopandas as gpd # TCH002 -4 4 | import pydantic -5 |-import pyproj # TCH002 -6 5 | from pydantic import BaseModel -7 6 | -8 7 | import numpy - 8 |+from typing import TYPE_CHECKING - 9 |+ - 10 |+if TYPE_CHECKING: - 11 |+ import pyproj -9 12 | -10 13 | -11 14 | class A(BaseModel): - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_runtime_evaluated_decorators_2.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_runtime_evaluated_decorators_2.py.snap index 518edf55aac37..4b4c71f364469 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_runtime_evaluated_decorators_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_runtime_evaluated_decorators_2.py.snap @@ -9,18 +9,3 @@ runtime_evaluated_decorators_2.py:10:8: TCH002 [*] Move third-party import `nump | ^^^^^ TCH002 | = help: Move into type-checking block - -ℹ Unsafe fix -7 7 | import pyproj -8 8 | from attrs import frozen -9 9 | -10 |-import numpy # TCH002 - 10 |+from typing import TYPE_CHECKING - 11 |+ - 12 |+if TYPE_CHECKING: - 13 |+ import numpy -11 14 | -12 15 | -13 16 | @attrs.define(auto_attribs=True) - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_singledispatch.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_singledispatch.py.snap index 4ff84f8f0f66e..0162fe04cb7e5 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_singledispatch.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_singledispatch.py.snap @@ -11,15 +11,3 @@ singledispatch.py:11:20: TCH002 [*] Move third-party import `pandas.DataFrame` i 13 | if TYPE_CHECKING: | = help: Move into type-checking block - -ℹ Unsafe fix -8 8 | from numpy import asarray -9 9 | from numpy.typing import ArrayLike -10 10 | from scipy.sparse import spmatrix -11 |-from pandas import DataFrame -12 11 | -13 12 | if TYPE_CHECKING: - 13 |+ from pandas import DataFrame -14 14 | from numpy import ndarray -15 15 | -16 16 | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_strict.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_strict.py.snap index f9d6240613db2..df9ff203bcd5f 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_strict.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_strict.py.snap @@ -12,23 +12,6 @@ strict.py:54:25: TCH002 [*] Move third-party import `pkg.bar.A` into a type-chec | = help: Move into type-checking block -ℹ Unsafe fix -1 1 | from __future__ import annotations - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ from pkg.bar import A -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -51 55 | def f(): -52 56 | # In un-strict mode, this _should_ raise an error, since `pkg.bar` isn't used at runtime -53 57 | import pkg -54 |- from pkg.bar import A -55 58 | -56 59 | def test(value: A): -57 60 | return pkg.B() strict.py:91:12: TCH002 [*] Move third-party import `pkg` into a type-checking block | @@ -39,23 +22,3 @@ strict.py:91:12: TCH002 [*] Move third-party import `pkg` into a type-checking b 92 | import pkgfoo.bar as B | = help: Move into type-checking block - -ℹ Unsafe fix -1 1 | from __future__ import annotations - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ import pkg -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -88 92 | # In un-strict mode, this _should_ raise an error, since `pkg` isn't used at runtime. -89 93 | # Note that `pkg` is a prefix of `pkgfoo` which are both different modules. This is -90 94 | # testing the implementation. -91 |- import pkg -92 95 | import pkgfoo.bar as B -93 96 | -94 97 | def test(value: pkg.A): - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_typing_modules_1.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_typing_modules_1.py.snap index 3e758fc6c110d..ead3a6af005b9 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_typing_modules_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_typing_modules_1.py.snap @@ -10,20 +10,3 @@ typing_modules_1.py:7:24: TCH002 [*] Move third-party import `pandas.DataFrame` 9 | df: DataFrame | = help: Move into type-checking block - -ℹ Unsafe fix -1 1 | from __future__ import annotations -2 2 | -3 3 | from typing_extensions import Self - 4 |+from typing import TYPE_CHECKING - 5 |+ - 6 |+if TYPE_CHECKING: - 7 |+ from pandas import DataFrame -4 8 | -5 9 | -6 10 | def func(): -7 |- from pandas import DataFrame -8 11 | -9 12 | df: DataFrame - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_typing_modules_2.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_typing_modules_2.py.snap index 820be3f860f27..4448213c48a29 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_typing_modules_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_typing_modules_2.py.snap @@ -10,18 +10,3 @@ typing_modules_2.py:7:24: TCH002 [*] Move third-party import `pandas.DataFrame` 9 | df: DataFrame | = help: Move into type-checking block - -ℹ Unsafe fix -2 2 | -3 3 | import typing_extensions -4 4 | - 5 |+if typing_extensions.TYPE_CHECKING: - 6 |+ from pandas import DataFrame - 7 |+ -5 8 | -6 9 | def func(): -7 |- from pandas import DataFrame -8 10 | -9 11 | df: DataFrame - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_after_package_import.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_after_package_import.snap index d8f9298f51c31..c455bd863299e 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_after_package_import.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_after_package_import.snap @@ -11,19 +11,3 @@ source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs 6 | from typing import TYPE_CHECKING | = help: Move into type-checking block - -ℹ Unsafe fix -1 1 | -2 2 | from __future__ import annotations -3 3 | -4 |-import pandas as pd -5 4 | -6 5 | from typing import TYPE_CHECKING -7 6 | - 7 |+if TYPE_CHECKING: - 8 |+ import pandas as pd - 9 |+ -8 10 | def f(x: pd.DataFrame): -9 11 | pass - - diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_before_package_import.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_before_package_import.snap index d939819ed6214..f603068e9b4eb 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_before_package_import.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_before_package_import.snap @@ -11,17 +11,3 @@ source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs 8 | def f(x: pd.DataFrame): | = help: Move into type-checking block - -ℹ Unsafe fix -3 3 | -4 4 | from typing import TYPE_CHECKING -5 5 | -6 |-import pandas as pd -7 6 | - 7 |+if TYPE_CHECKING: - 8 |+ import pandas as pd - 9 |+ -8 10 | def f(x: pd.DataFrame): -9 11 | pass - - diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH201_PTH201.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH201_PTH201.py.snap index 045e8c733ec8c..9a8e805bba000 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH201_PTH201.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH201_PTH201.py.snap @@ -11,7 +11,6 @@ PTH201.py:5:10: PTH201 [*] Do not pass the current directory explicitly to `Path | = help: Remove the current directory argument -ℹ Safe fix 2 2 | from pathlib import Path as pth 3 3 | 4 4 | # match @@ -32,7 +31,6 @@ PTH201.py:6:9: PTH201 [*] Do not pass the current directory explicitly to `Path` | = help: Remove the current directory argument -ℹ Safe fix 3 3 | 4 4 | # match 5 5 | _ = Path(".") @@ -52,7 +50,6 @@ PTH201.py:7:14: PTH201 [*] Do not pass the current directory explicitly to `Path | = help: Remove the current directory argument -ℹ Safe fix 4 4 | # match 5 5 | _ = Path(".") 6 6 | _ = pth(".") @@ -73,7 +70,6 @@ PTH201.py:8:10: PTH201 [*] Do not pass the current directory explicitly to `Path | = help: Remove the current directory argument -ℹ Safe fix 5 5 | _ = Path(".") 6 6 | _ = pth(".") 7 7 | _ = PurePath(".") @@ -82,5 +78,3 @@ PTH201.py:8:10: PTH201 [*] Do not pass the current directory explicitly to `Path 9 9 | 10 10 | # no match 11 11 | _ = Path() - - diff --git a/crates/ruff_linter/src/rules/flynt/snapshots/ruff_linter__rules__flynt__tests__FLY002_FLY002.py.snap b/crates/ruff_linter/src/rules/flynt/snapshots/ruff_linter__rules__flynt__tests__FLY002_FLY002.py.snap index 5d531d603b2ab..ac8ff57e56a15 100644 --- a/crates/ruff_linter/src/rules/flynt/snapshots/ruff_linter__rules__flynt__tests__FLY002_FLY002.py.snap +++ b/crates/ruff_linter/src/rules/flynt/snapshots/ruff_linter__rules__flynt__tests__FLY002_FLY002.py.snap @@ -11,15 +11,6 @@ FLY002.py:5:7: FLY002 [*] Consider `f"{a} World"` instead of string join | = help: Replace with `f"{a} World"` -ℹ Unsafe fix -2 2 | from random import random, choice -3 3 | -4 4 | a = "Hello" -5 |-ok1 = " ".join([a, " World"]) # OK - 5 |+ok1 = f"{a} World" # OK -6 6 | ok2 = "".join(["Finally, ", a, " World"]) # OK -7 7 | ok3 = "x".join(("1", "2", "3")) # OK -8 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally FLY002.py:6:7: FLY002 [*] Consider `f"Finally, {a} World"` instead of string join | @@ -32,15 +23,6 @@ FLY002.py:6:7: FLY002 [*] Consider `f"Finally, {a} World"` instead of string joi | = help: Replace with `f"Finally, {a} World"` -ℹ Unsafe fix -3 3 | -4 4 | a = "Hello" -5 5 | ok1 = " ".join([a, " World"]) # OK -6 |-ok2 = "".join(["Finally, ", a, " World"]) # OK - 6 |+ok2 = f"Finally, {a} World" # OK -7 7 | ok3 = "x".join(("1", "2", "3")) # OK -8 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally -9 9 | ok5 = "a".join([random(), random()]) # OK (simple calls) FLY002.py:7:7: FLY002 [*] Consider `"1x2x3"` instead of string join | @@ -53,15 +35,6 @@ FLY002.py:7:7: FLY002 [*] Consider `"1x2x3"` instead of string join | = help: Replace with `"1x2x3"` -ℹ Unsafe fix -4 4 | a = "Hello" -5 5 | ok1 = " ".join([a, " World"]) # OK -6 6 | ok2 = "".join(["Finally, ", a, " World"]) # OK -7 |-ok3 = "x".join(("1", "2", "3")) # OK - 7 |+ok3 = "1x2x3" # OK -8 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally -9 9 | ok5 = "a".join([random(), random()]) # OK (simple calls) -10 10 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()]) # OK (attr calls) FLY002.py:8:7: FLY002 [*] Consider `f"{1}y{2}y{3}"` instead of string join | @@ -74,15 +47,6 @@ FLY002.py:8:7: FLY002 [*] Consider `f"{1}y{2}y{3}"` instead of string join | = help: Replace with `f"{1}y{2}y{3}"` -ℹ Unsafe fix -5 5 | ok1 = " ".join([a, " World"]) # OK -6 6 | ok2 = "".join(["Finally, ", a, " World"]) # OK -7 7 | ok3 = "x".join(("1", "2", "3")) # OK -8 |-ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally - 8 |+ok4 = f"{1}y{2}y{3}" # Technically OK, though would've been an error originally -9 9 | ok5 = "a".join([random(), random()]) # OK (simple calls) -10 10 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()]) # OK (attr calls) -11 11 | FLY002.py:9:7: FLY002 [*] Consider `f"{random()}a{random()}"` instead of string join | @@ -94,15 +58,6 @@ FLY002.py:9:7: FLY002 [*] Consider `f"{random()}a{random()}"` instead of string | = help: Replace with `f"{random()}a{random()}"` -ℹ Unsafe fix -6 6 | ok2 = "".join(["Finally, ", a, " World"]) # OK -7 7 | ok3 = "x".join(("1", "2", "3")) # OK -8 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally -9 |-ok5 = "a".join([random(), random()]) # OK (simple calls) - 9 |+ok5 = f"{random()}a{random()}" # OK (simple calls) -10 10 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()]) # OK (attr calls) -11 11 | -12 12 | nok1 = "x".join({"4", "5", "yee"}) # Not OK (set) FLY002.py:10:7: FLY002 [*] Consider `f"{secrets.token_urlsafe()}a{secrets.token_hex()}"` instead of string join | @@ -115,15 +70,6 @@ FLY002.py:10:7: FLY002 [*] Consider `f"{secrets.token_urlsafe()}a{secrets.token_ | = help: Replace with `f"{secrets.token_urlsafe()}a{secrets.token_hex()}"` -ℹ Unsafe fix -7 7 | ok3 = "x".join(("1", "2", "3")) # OK -8 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally -9 9 | ok5 = "a".join([random(), random()]) # OK (simple calls) -10 |-ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()]) # OK (attr calls) - 10 |+ok6 = f"{secrets.token_urlsafe()}a{secrets.token_hex()}" # OK (attr calls) -11 11 | -12 12 | nok1 = "x".join({"4", "5", "yee"}) # Not OK (set) -13 13 | nok2 = a.join(["1", "2", "3"]) # Not OK (not a static joiner) FLY002.py:23:11: FLY002 [*] Consider `f"{url}{filename}"` instead of string join | @@ -133,12 +79,3 @@ FLY002.py:23:11: FLY002 [*] Consider `f"{url}{filename}"` instead of string join | ^^^^^^^^^^^^^^^^^^^^^^^^ FLY002 | = help: Replace with `f"{url}{filename}"` - -ℹ Unsafe fix -20 20 | -21 21 | # Regression test for: https://github.com/astral-sh/ruff/issues/7197 -22 22 | def create_file_public_url(url, filename): -23 |- return''.join([url, filename]) - 23 |+ return f"{url}{filename}" - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__1_separate_subpackage_first_and_third_party_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__1_separate_subpackage_first_and_third_party_imports.py.snap index 68c6ab87ddf01..9b0ba3a1389c0 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__1_separate_subpackage_first_and_third_party_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__1_separate_subpackage_first_and_third_party_imports.py.snap @@ -14,7 +14,6 @@ separate_subpackage_first_and_third_party_imports.py:1:1: I001 [*] Import block | = help: Organize imports -ℹ Safe fix 1 1 | import sys 2 |+ 3 |+import foo @@ -29,5 +28,3 @@ separate_subpackage_first_and_third_party_imports.py:1:1: I001 [*] Import block 6 |-import foo 7 |-import foo.bar 8 |-import foo.bar.baz - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__2_separate_subpackage_first_and_third_party_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__2_separate_subpackage_first_and_third_party_imports.py.snap index 26039b8c93453..397e8d37efb50 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__2_separate_subpackage_first_and_third_party_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__2_separate_subpackage_first_and_third_party_imports.py.snap @@ -14,7 +14,6 @@ separate_subpackage_first_and_third_party_imports.py:1:1: I001 [*] Import block | = help: Organize imports -ℹ Safe fix 1 1 | import sys 2 |+ 2 3 | import baz @@ -28,5 +27,3 @@ separate_subpackage_first_and_third_party_imports.py:1:1: I001 [*] Import block 7 |-import foo.bar 8 |-import foo.bar.baz 10 |+from foo import bar, baz - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__add_newline_before_comments.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__add_newline_before_comments.py.snap index 95cca1454b583..4ef7e6e3a6493 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__add_newline_before_comments.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__add_newline_before_comments.py.snap @@ -13,7 +13,6 @@ add_newline_before_comments.py:1:1: I001 [*] Import block is un-sorted or un-for | = help: Organize imports -ℹ Safe fix 1 1 | import os 2 |+ 2 3 | # This is a comment in the same section, so we need to add one newline. @@ -24,5 +23,3 @@ add_newline_before_comments.py:1:1: I001 [*] Import block is un-sorted or un-for 5 8 | # This is a comment, but it starts a new section, so we don't need to add a newline 6 9 | # before it. 7 10 | import leading_prefix - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__as_imports_comments.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__as_imports_comments.py.snap index 4866de74a682e..64fbdbb0b7588 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__as_imports_comments.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__as_imports_comments.py.snap @@ -21,7 +21,6 @@ as_imports_comments.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 |-from foo import ( # Comment on `foo` 2 |- Member as Alias, # Comment on `Alias` 3 |-) diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__bom_unsorted.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__bom_unsorted.py.snap index d9c75d398f75b..50163d8f095a7 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__bom_unsorted.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__bom_unsorted.py.snap @@ -9,7 +9,6 @@ bom_unsorted.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 |-import foo 2 |-import bar 1 |+import bar diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__case_sensitive_case_sensitive.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__case_sensitive_case_sensitive.py.snap index 1374bd787f733..4d9b64eea98ac 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__case_sensitive_case_sensitive.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__case_sensitive_case_sensitive.py.snap @@ -15,7 +15,6 @@ case_sensitive.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 1 | import A 2 2 | import B 3 |+import C @@ -29,5 +28,3 @@ case_sensitive.py:1:1: I001 [*] Import block is un-sorted or un-formatted 9 |-from h import A, b, C 8 |+from g import B, a, c 9 |+from h import A, C, b - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__closest_to_furthest_relative_imports_order.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__closest_to_furthest_relative_imports_order.py.snap index 3c554a7eed595..e05f1953d2843 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__closest_to_furthest_relative_imports_order.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__closest_to_furthest_relative_imports_order.py.snap @@ -9,11 +9,8 @@ relative_imports_order.py:1:1: I001 [*] Import block is un-sorted or un-formatte | = help: Organize imports -ℹ Safe fix 1 |+from . import c 2 |+from .. import b 1 3 | from ... import a 2 |-from .. import b 3 |-from . import c - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_as_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_as_imports.py.snap index 7888f59e11d85..77cc2b9197585 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_as_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_as_imports.py.snap @@ -10,11 +10,8 @@ combine_as_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 |+from module import CONSTANT, function 1 2 | from module import Class as C 2 |-from module import CONSTANT 3 |-from module import function 4 3 | from module import function as f - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_as_imports_combine_as_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_as_imports_combine_as_imports.py.snap index 0ec3437a37641..078b4089e9027 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_as_imports_combine_as_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_as_imports_combine_as_imports.py.snap @@ -10,11 +10,8 @@ combine_as_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 |-from module import Class as C 2 |-from module import CONSTANT 3 |-from module import function 4 |-from module import function as f 1 |+from module import CONSTANT, Class as C, function, function as f - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_import_from.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_import_from.py.snap index b5783de363867..c0dce8d4e269f 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_import_from.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_import_from.py.snap @@ -11,7 +11,6 @@ combine_import_from.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 |-from collections import Awaitable 2 |-from collections import AsyncIterable 3 |-from collections import Collection @@ -25,5 +24,3 @@ combine_import_from.py:1:1: I001 [*] Import block is un-sorted or un-formatted 6 |+ MutableMapping, 7 |+ MutableSequence, 8 |+) - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__comments.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__comments.py.snap index 133ac942147ba..b35912cb27c87 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__comments.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__comments.py.snap @@ -39,7 +39,6 @@ comments.py:3:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 1 | # Comment 1 2 2 | # Comment 2 3 |-import D @@ -85,5 +84,3 @@ comments.py:3:1: I001 [*] Import block is un-sorted or un-formatted 23 |+ a, # Comment 1 24 |+ b, 25 |+) - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__deduplicate_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__deduplicate_imports.py.snap index 4ec8ce1b51b52..afb5c30a6dd71 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__deduplicate_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__deduplicate_imports.py.snap @@ -10,10 +10,7 @@ deduplicate_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 1 | import os 2 |-import os 3 2 | import os as os1 4 3 | import os as os2 - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__detect_same_package.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__detect_same_package.snap index 25d20bc8a59bd..89f7a96ca5f3c 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__detect_same_package.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__detect_same_package.snap @@ -9,11 +9,8 @@ bar.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 1 | import os 2 |+ 2 3 | import pandas 4 |+ 3 5 | import foo.baz - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__fit_line_length.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__fit_line_length.py.snap index e6ea05b4e429c..718d8abd25f76 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__fit_line_length.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__fit_line_length.py.snap @@ -15,7 +15,6 @@ fit_line_length.py:7:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 5 5 | 6 6 | if indented: 7 7 | from line_with_88 import aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa @@ -38,5 +37,3 @@ fit_line_length.py:7:1: I001 [*] Import block is un-sorted or un-formatted 12 20 | from line_with_93 import ( 13 21 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 14 22 | ) - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__fit_line_length_comment.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__fit_line_length_comment.py.snap index 5efdf7d3216fb..026918ee02669 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__fit_line_length_comment.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__fit_line_length_comment.py.snap @@ -14,7 +14,6 @@ fit_line_length_comment.py:1:1: I001 [*] Import block is un-sorted or un-formatt | = help: Organize imports -ℹ Safe fix 1 1 | import a 2 |+ 2 3 | # Don't take this comment into account when determining whether the next import can fit on one line. @@ -32,5 +31,3 @@ fit_line_length_comment.py:1:1: I001 [*] Import block is un-sorted or un-formatt 13 |+from h import ( 14 |+ i, # 012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9 15 |+) - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_single_line_force_single_line.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_single_line_force_single_line.py.snap index b7fa34f0e2562..ed7fe8d81639a 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_single_line_force_single_line.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_single_line_force_single_line.py.snap @@ -33,7 +33,6 @@ force_single_line.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 |-import sys, math 2 |-from os import path, uname 1 |+import math @@ -81,5 +80,3 @@ force_single_line.py:1:1: I001 [*] Import block is un-sorted or un-formatted 29 |+from third_party import lib5 30 |+from third_party import lib6 31 |+from third_party import lib7 - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections.py.snap index 43ecebee2265d..6bdef387c3bcd 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections.py.snap @@ -19,7 +19,6 @@ force_sort_within_sections.py:1:1: I001 [*] Import block is un-sorted or un-form | = help: Organize imports -ℹ Safe fix 1 |-from a import a1 # import_from 2 |-from c import * # import_from_star 3 1 | import a # import @@ -39,5 +38,3 @@ force_sort_within_sections.py:1:1: I001 [*] Import block is un-sorted or un-form 11 |-from . import my 12 13 | from .my.nested import fn2 13 |-from ...grandparent import fn3 - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections.py.snap index 412d6f38862d5..c02b4cee3ad47 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections.py.snap @@ -19,7 +19,6 @@ force_sort_within_sections.py:1:1: I001 [*] Import block is un-sorted or un-form | = help: Organize imports -ℹ Safe fix 1 |-from a import a1 # import_from 2 |-from c import * # import_from_star 1 |+import z @@ -40,5 +39,3 @@ force_sort_within_sections.py:1:1: I001 [*] Import block is un-sorted or un-form 11 |-from . import my 12 13 | from .my.nested import fn2 13 |-from ...grandparent import fn3 - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections_future.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections_future.py.snap index 6864d488b75ed..c9c5b69e499bb 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections_future.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections_future.py.snap @@ -8,9 +8,6 @@ force_sort_within_sections_future.py:1:1: I001 [*] Import block is un-sorted or | = help: Organize imports -ℹ Safe fix 1 |+from __future__ import annotations 1 2 | import __future__ 2 |-from __future__ import annotations - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections_with_as_names.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections_with_as_names.py.snap index b14f52ac659df..77778c0e9bf3e 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections_with_as_names.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections_with_as_names.py.snap @@ -11,7 +11,6 @@ force_sort_within_sections_with_as_names.py:1:1: I001 [*] Import block is un-sor | = help: Organize imports -ℹ Safe fix 1 |+import datetime 2 |+import datetime as dt 3 |+from datetime import timedelta @@ -21,5 +20,3 @@ force_sort_within_sections_with_as_names.py:1:1: I001 [*] Import block is un-sor 3 |-from datetime import timedelta 4 |-import datetime as dt 5 |-import datetime - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_to_top.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_to_top.py.snap index eccb76bc9efff..4f9bbefc52672 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_to_top.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_to_top.py.snap @@ -29,7 +29,6 @@ force_to_top.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 |-import lib6 1 |+import foo 2 |+import lib1 @@ -63,5 +62,3 @@ force_to_top.py:1:1: I001 [*] Import block is un-sorted or un-formatted 23 17 | from lib3.lib4.lib5 import foo 18 |+from lib4 import lib1, lib2 19 |+from lib5 import lib1, lib2 - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_to_top_force_to_top.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_to_top_force_to_top.py.snap index eb5678616bfb2..6a283fcc7e6ad 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_to_top_force_to_top.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_to_top_force_to_top.py.snap @@ -29,7 +29,6 @@ force_to_top.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 |-import lib6 2 |-import lib2 3 |-import lib5 @@ -66,5 +65,3 @@ force_to_top.py:1:1: I001 [*] Import block is un-sorted or un-formatted 17 |+from lib2 import foo 23 18 | from lib3.lib4.lib5 import foo 19 |+from lib4 import lib1, lib2 - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_wrap_aliases.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_wrap_aliases.py.snap index e19ca4942bfb8..aaaccf2b5bd76 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_wrap_aliases.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_wrap_aliases.py.snap @@ -9,11 +9,8 @@ force_wrap_aliases.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 |-from .a import a1 as a1, a2 as a2 1 |+from .a import a1 as a1 2 |+from .a import a2 as a2 2 3 | from .b import b1 as b1 3 4 | from .c import c1 - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_wrap_aliases_force_wrap_aliases.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_wrap_aliases_force_wrap_aliases.py.snap index d59c8a13d1e20..ead60c6fc003b 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_wrap_aliases_force_wrap_aliases.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_wrap_aliases_force_wrap_aliases.py.snap @@ -9,7 +9,6 @@ force_wrap_aliases.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 |-from .a import a1 as a1, a2 as a2 1 |+from .a import ( 2 |+ a1 as a1, @@ -17,5 +16,3 @@ force_wrap_aliases.py:1:1: I001 [*] Import block is un-sorted or un-formatted 4 |+) 2 5 | from .b import b1 as b1 3 6 | from .c import c1 - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__forced_separate.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__forced_separate.py.snap index ad410b015c2ec..9ff1bd1a0ae81 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__forced_separate.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__forced_separate.py.snap @@ -14,7 +14,6 @@ forced_separate.py:3:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 1 | # office_helper and tests are both first-party, 2 2 | # but we want tests and experiments to be separated, in that order 3 |+from office_helper.assistants import entity_registry as er @@ -26,5 +25,3 @@ forced_separate.py:3:1: I001 [*] Import block is un-sorted or un-formatted 6 9 | from experiments.starry import * 7 10 | from experiments.weird import varieties 8 |-from office_helper.assistants import entity_registry as er - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__future_from.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__future_from.py.snap index f3f5cd2a3574d..18506dc13b9ce 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__future_from.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__future_from.py.snap @@ -8,9 +8,6 @@ future_from.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 |+from __future__ import annotations 1 2 | import __future__ 2 |-from __future__ import annotations - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__glob_1_separate_subpackage_first_and_third_party_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__glob_1_separate_subpackage_first_and_third_party_imports.py.snap index 68c6ab87ddf01..9b0ba3a1389c0 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__glob_1_separate_subpackage_first_and_third_party_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__glob_1_separate_subpackage_first_and_third_party_imports.py.snap @@ -14,7 +14,6 @@ separate_subpackage_first_and_third_party_imports.py:1:1: I001 [*] Import block | = help: Organize imports -ℹ Safe fix 1 1 | import sys 2 |+ 3 |+import foo @@ -29,5 +28,3 @@ separate_subpackage_first_and_third_party_imports.py:1:1: I001 [*] Import block 6 |-import foo 7 |-import foo.bar 8 |-import foo.bar.baz - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__if_elif_else.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__if_elif_else.py.snap index 4a09c500c40be..dfa9b51299d1f 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__if_elif_else.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__if_elif_else.py.snap @@ -10,12 +10,9 @@ if_elif_else.py:6:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 3 3 | elif "setuptools" in sys.modules: 4 4 | from setuptools.command.sdist import sdist as _sdist 5 5 | else: 6 |+ from distutils.command.sdist import sdist as _sdist 6 7 | from setuptools.command.sdist import sdist as _sdist 7 |- from distutils.command.sdist import sdist as _sdist - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__import_from_after_import.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__import_from_after_import.py.snap index 09e2aa2a32542..c8a46fa6f015f 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__import_from_after_import.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__import_from_after_import.py.snap @@ -8,9 +8,6 @@ import_from_after_import.py:1:1: I001 [*] Import block is un-sorted or un-format | = help: Organize imports -ℹ Safe fix 1 |+import os 1 2 | from collections import Collection 2 |-import os - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__inline_comments.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__inline_comments.py.snap index bc6a07f6581b5..dab3435f9cb42 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__inline_comments.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__inline_comments.py.snap @@ -17,7 +17,6 @@ inline_comments.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 1 | from a.prometheus.metrics import ( # type:ignore[attr-defined] 2 2 | TERMINAL_CURRENTLY_RUNNING_TOTAL, 3 3 | ) @@ -36,5 +35,3 @@ inline_comments.py:1:1: I001 [*] Import block is un-sorted or un-formatted 11 |+ OTHER_RUNNING_TOTAL, 12 |+ TERMINAL_CURRENTLY_RUNNING_TOTAL, 13 |+) - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__insert_empty_lines.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__insert_empty_lines.py.snap index 238cb6092207f..e12d34100af3a 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__insert_empty_lines.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__insert_empty_lines.py.snap @@ -12,7 +12,6 @@ insert_empty_lines.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 1 | import a 2 2 | import b 3 |+ @@ -33,7 +32,6 @@ insert_empty_lines.py:4:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 3 3 | x = 1 4 4 | import os 5 5 | import sys @@ -56,7 +54,6 @@ insert_empty_lines.py:14:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 13 13 | y = 1 14 14 | import os 15 15 | import sys @@ -76,7 +73,6 @@ insert_empty_lines.py:52:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 51 51 | 52 52 | import os 53 53 | @@ -84,5 +80,3 @@ insert_empty_lines.py:52:1: I001 [*] Import block is un-sorted or un-formatted 54 55 | # Comment goes here. 55 56 | def f(): 56 57 | pass - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__insert_empty_lines.pyi.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__insert_empty_lines.pyi.snap index a2e262e7e8e18..7477eff347634 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__insert_empty_lines.pyi.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__insert_empty_lines.pyi.snap @@ -12,7 +12,6 @@ insert_empty_lines.pyi:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 1 | import a 2 2 | import b 3 |+ @@ -33,7 +32,6 @@ insert_empty_lines.pyi:4:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 3 3 | x = 1 4 4 | import os 5 5 | import sys @@ -55,7 +53,6 @@ insert_empty_lines.pyi:14:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 13 13 | y = 1 14 14 | import os 15 15 | import sys @@ -63,5 +60,3 @@ insert_empty_lines.pyi:14:1: I001 [*] Import block is un-sorted or un-formatted 16 17 | """Docstring""" 17 18 | 18 19 | if True: - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__known_local_folder_closest_separate_local_folder_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__known_local_folder_closest_separate_local_folder_imports.py.snap index 8eb419a4a4739..d9ac086db11ca 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__known_local_folder_closest_separate_local_folder_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__known_local_folder_closest_separate_local_folder_imports.py.snap @@ -13,7 +13,6 @@ separate_local_folder_imports.py:1:1: I001 [*] Import block is un-sorted or un-f | = help: Organize imports -ℹ Safe fix 1 |+import os 1 2 | import sys 3 |+ diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__known_local_folder_separate_local_folder_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__known_local_folder_separate_local_folder_imports.py.snap index 21ed77408c35c..2c3fc057889f3 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__known_local_folder_separate_local_folder_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__known_local_folder_separate_local_folder_imports.py.snap @@ -13,7 +13,6 @@ separate_local_folder_imports.py:1:1: I001 [*] Import block is un-sorted or un-f | = help: Organize imports -ℹ Safe fix 1 |+import os 1 2 | import sys 3 |+ diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_from_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_from_imports.py.snap index a2183e7de32c7..f6dd77343d256 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_from_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_from_imports.py.snap @@ -9,10 +9,7 @@ length_sort_from_imports.py:1:1: I001 [*] Import block is un-sorted or un-format | = help: Organize imports -ℹ Safe fix 1 |+from short import b 1 2 | from mediuuuuuuuuuuum import a 2 |-from short import b 3 3 | from loooooooooooooooooooooog import c - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_non_ascii_members.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_non_ascii_members.py.snap index d6cfc0e340920..f18648bb4e675 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_non_ascii_members.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_non_ascii_members.py.snap @@ -17,7 +17,6 @@ length_sort_non_ascii_members.py:1:1: I001 [*] Import block is un-sorted or un-f | = help: Organize imports -ℹ Safe fix 1 1 | from module1 import ( 2 |- loooooooooooooong, 2 |+ short, @@ -33,5 +32,3 @@ length_sort_non_ascii_members.py:1:1: I001 [*] Import block is un-sorted or un-f 10 9 | λοοοοοοοοοοοοοονγ, 10 |+ looooooooooooooong, 11 11 | ) - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_non_ascii_modules.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_non_ascii_modules.py.snap index e1d66bd9a7bb9..c9254b53a8d47 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_non_ascii_modules.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_non_ascii_modules.py.snap @@ -15,7 +15,6 @@ length_sort_non_ascii_modules.py:1:1: I001 [*] Import block is un-sorted or un-f | = help: Organize imports -ℹ Safe fix 1 |-import loooooooooooooong 2 |-import mediuuuuuum 3 1 | import short @@ -28,5 +27,3 @@ length_sort_non_ascii_modules.py:1:1: I001 [*] Import block is un-sorted or un-f 7 8 | import λοοοοοοοοοοοοοονγ 8 |-import μεδιυυυυυμ 9 9 | import looooooooooooooong - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_straight_and_from_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_straight_and_from_imports.py.snap index 7acc627804180..0e4fc9ccb0abc 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_straight_and_from_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_straight_and_from_imports.py.snap @@ -12,7 +12,6 @@ length_sort_straight_and_from_imports.py:1:1: I001 [*] Import block is un-sorted | = help: Organize imports -ℹ Safe fix 1 |+import short 1 2 | import mediuuuuuum 2 |-import short @@ -22,5 +21,3 @@ length_sort_straight_and_from_imports.py:1:1: I001 [*] Import block is un-sorted 5 5 | from mediuuuum import c 6 |-from short import b 6 |+from looooooooooooooong import a - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_straight_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_straight_imports.py.snap index 6c73af3a2a8fa..ae9ca1d0788c6 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_straight_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_straight_imports.py.snap @@ -10,12 +10,9 @@ length_sort_straight_imports.py:1:1: I001 [*] Import block is un-sorted or un-fo | = help: Organize imports -ℹ Safe fix 1 |+import short 2 |+import mediuuuuuuma 1 3 | import mediuuuuuumb 2 |-import short 3 4 | import looooooooooooooooong 4 |-import mediuuuuuuma - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_with_relative_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_with_relative_imports.py.snap index 20531ecd26d43..058257d87f64e 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_with_relative_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_with_relative_imports.py.snap @@ -13,7 +13,6 @@ length_sort_with_relative_imports.py:1:1: I001 [*] Import block is un-sorted or | = help: Organize imports -ℹ Safe fix 1 |-from ..looooooooooooooong import a 2 |-from ...mediuuuum import b 1 |+from . import d @@ -24,5 +23,3 @@ length_sort_with_relative_imports.py:1:1: I001 [*] Import block is un-sorted or 7 5 | from ......short import b 6 |+from ...mediuuuum import b 7 |+from ..looooooooooooooong import a - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_from_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_from_imports.py.snap index 35bdec18f120c..a04b6e8f69a3b 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_from_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_from_imports.py.snap @@ -9,10 +9,7 @@ length_sort_from_imports.py:1:1: I001 [*] Import block is un-sorted or un-format | = help: Organize imports -ℹ Safe fix 1 |+from loooooooooooooooooooooog import c 1 2 | from mediuuuuuuuuuuum import a 2 3 | from short import b 3 |-from loooooooooooooooooooooog import c - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_straight_and_from_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_straight_and_from_imports.py.snap index 3cd80a04effd9..66603a5f2426d 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_straight_and_from_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_straight_and_from_imports.py.snap @@ -12,12 +12,9 @@ length_sort_straight_and_from_imports.py:1:1: I001 [*] Import block is un-sorted | = help: Organize imports -ℹ Safe fix 1 |+import short 1 2 | import mediuuuuuum 2 |-import short 3 3 | import looooooooooooooooong 4 4 | from looooooooooooooong import a 5 5 | from mediuuuum import c - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_straight_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_straight_imports.py.snap index 6c73af3a2a8fa..ae9ca1d0788c6 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_straight_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_straight_imports.py.snap @@ -10,12 +10,9 @@ length_sort_straight_imports.py:1:1: I001 [*] Import block is un-sorted or un-fo | = help: Organize imports -ℹ Safe fix 1 |+import short 2 |+import mediuuuuuuma 1 3 | import mediuuuuuumb 2 |-import short 3 4 | import looooooooooooooooong 4 |-import mediuuuuuuma - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__line_ending_crlf.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__line_ending_crlf.py.snap index 07043dd802d27..584200cabf23a 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__line_ending_crlf.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__line_ending_crlf.py.snap @@ -9,7 +9,6 @@ line_ending_crlf.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 |-from long_module_name import member_one, member_two, member_three, member_four, member_five 1 |+from long_module_name import ( 2 |+ member_five, @@ -18,6 +17,4 @@ line_ending_crlf.py:1:1: I001 [*] Import block is un-sorted or un-formatted 5 |+ member_three, 6 |+ member_two, 7 |+) -2 8 | - - +2 8 | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__line_ending_lf.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__line_ending_lf.py.snap index 757fdaa9803b2..c073e72f04b9d 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__line_ending_lf.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__line_ending_lf.py.snap @@ -9,7 +9,6 @@ line_ending_lf.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 |-from long_module_name import member_one, member_two, member_three, member_four, member_five 1 |+from long_module_name import ( 2 |+ member_five, @@ -18,6 +17,4 @@ line_ending_lf.py:1:1: I001 [*] Import block is un-sorted or un-formatted 5 |+ member_three, 6 |+ member_two, 7 |+) -2 8 | - - +2 8 | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports.pyi.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports.pyi.snap index 3cb4eb573c315..204ccdd29758a 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports.pyi.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports.pyi.snap @@ -22,7 +22,6 @@ lines_after_imports.pyi:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 2 2 | 3 3 | from typing import Any 4 4 | @@ -37,5 +36,3 @@ lines_after_imports.pyi:1:1: I001 [*] Import block is un-sorted or un-formatted 12 9 | 13 10 | class Thing(object): 14 11 | name: str - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_class_after.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_class_after.py.snap index 8f5efb9988504..fedf97993c24b 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_class_after.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_class_after.py.snap @@ -19,7 +19,6 @@ lines_after_imports_class_after.py:1:1: I001 [*] Import block is un-sorted or un | = help: Organize imports -ℹ Safe fix 2 2 | 3 3 | from typing import Any 4 4 | @@ -34,5 +33,3 @@ lines_after_imports_class_after.py:1:1: I001 [*] Import block is un-sorted or un 10 11 | class Thing(object): 11 12 | name: str 12 13 | def __init__(self, name: str): - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_func_after.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_func_after.py.snap index 0f71f16f36243..14f99be4d9b64 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_func_after.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_func_after.py.snap @@ -29,7 +29,6 @@ lines_after_imports_func_after.py:1:1: I001 [*] Import block is un-sorted or un- | = help: Organize imports -ℹ Safe fix 2 2 | 3 3 | from typing import Any 4 4 | @@ -51,5 +50,3 @@ lines_after_imports_func_after.py:1:1: I001 [*] Import block is un-sorted or un- 19 9 | 20 10 | 21 11 | def main(): - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports.pyi.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports.pyi.snap index 3cb4eb573c315..204ccdd29758a 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports.pyi.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports.pyi.snap @@ -22,7 +22,6 @@ lines_after_imports.pyi:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 2 2 | 3 3 | from typing import Any 4 4 | @@ -37,5 +36,3 @@ lines_after_imports.pyi:1:1: I001 [*] Import block is un-sorted or un-formatted 12 9 | 13 10 | class Thing(object): 14 11 | name: str - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_class_after.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_class_after.py.snap index 747af3269a61a..2008ae3718271 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_class_after.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_class_after.py.snap @@ -19,7 +19,6 @@ lines_after_imports_class_after.py:1:1: I001 [*] Import block is un-sorted or un | = help: Organize imports -ℹ Safe fix 2 2 | 3 3 | from typing import Any 4 4 | @@ -35,5 +34,3 @@ lines_after_imports_class_after.py:1:1: I001 [*] Import block is un-sorted or un 10 12 | class Thing(object): 11 13 | name: str 12 14 | def __init__(self, name: str): - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_func_after.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_func_after.py.snap index ff312106a4d89..756113cac0e5f 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_func_after.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_func_after.py.snap @@ -29,7 +29,6 @@ lines_after_imports_func_after.py:1:1: I001 [*] Import block is un-sorted or un- | = help: Organize imports -ℹ Safe fix 2 2 | 3 3 | from typing import Any 4 4 | @@ -49,6 +48,4 @@ lines_after_imports_func_after.py:1:1: I001 [*] Import block is un-sorted or un- 17 |- 18 9 | 19 10 | -20 11 | - - +20 11 | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_nothing_after.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_nothing_after.py.snap index 37d9fca223fe2..38c56c44bb38a 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_nothing_after.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_nothing_after.py.snap @@ -15,7 +15,6 @@ lines_after_imports_nothing_after.py:1:1: I001 [*] Import block is un-sorted or | = help: Organize imports -ℹ Safe fix 2 2 | 3 3 | from typing import Any 4 4 | @@ -25,5 +24,3 @@ lines_after_imports_nothing_after.py:1:1: I001 [*] Import block is un-sorted or 6 |+from requests import Session 8 7 | 9 8 | from . import my_local_folder_object - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_between_typeslines_between_types.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_between_typeslines_between_types.py.snap index 09ff2aa19ea73..86d0542a4c56b 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_between_typeslines_between_types.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_between_typeslines_between_types.py.snap @@ -22,7 +22,6 @@ lines_between_types.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 9 9 | import requests 10 10 | 11 11 | @@ -32,5 +31,3 @@ lines_between_types.py:1:1: I001 [*] Import block is un-sorted or un-formatted 14 14 | 15 15 | from . import config 16 16 | from .data import Data - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__magic_trailing_comma.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__magic_trailing_comma.py.snap index 78c0456bcd7ff..7ca26fcafc547 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__magic_trailing_comma.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__magic_trailing_comma.py.snap @@ -44,7 +44,6 @@ magic_trailing_comma.py:2:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 1 | # This has a magic trailing comma, will be sorted, but not rolled into one line 2 |-from sys import ( 3 |- stderr, @@ -97,5 +96,3 @@ magic_trailing_comma.py:2:1: I001 [*] Import block is un-sorted or un-formatted 30 |+ member2, 37 31 | member3, 38 32 | ) - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__match_case.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__match_case.py.snap index d3a6f45d7e73b..db22eb279918e 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__match_case.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__match_case.py.snap @@ -14,7 +14,6 @@ match_case.py:3:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 1 | match 1: 2 2 | case 1: 3 |+ import os @@ -33,12 +32,9 @@ match_case.py:6:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 3 3 | import sys 4 4 | import os 5 5 | case 2: 6 |+ import abc 6 7 | import collections 7 |- import abc - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__natural_order.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__natural_order.py.snap index dbfade412a569..791a09ed227a6 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__natural_order.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__natural_order.py.snap @@ -22,7 +22,6 @@ natural_order.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 1 | import numpy1 2 |+import numpy2 2 3 | import numpy10 @@ -42,5 +41,3 @@ natural_order.py:1:1: I001 [*] Import block is un-sorted or un-formatted 14 14 | uint32, 15 15 | uint64, 16 16 | ) - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_detect_same_package.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_detect_same_package.snap index 391a603c79de1..22183c442d874 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_detect_same_package.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_detect_same_package.snap @@ -9,11 +9,8 @@ bar.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 1 | import os 2 |-import pandas 2 |+ 3 3 | import foo.baz 4 |+import pandas - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before.py.snap index 4947f22fef3c7..f701120ce44b5 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before.py.snap @@ -15,7 +15,6 @@ no_lines_before.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 2 2 | 3 3 | from typing import Any 4 4 | @@ -25,5 +24,3 @@ no_lines_before.py:1:1: I001 [*] Import block is un-sorted or un-formatted 6 |+from requests import Session 8 7 | 9 8 | from . import my_local_folder_object - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before.py_no_lines_before.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before.py_no_lines_before.py.snap index d85f8eb6c3754..1802d2fe9e7b1 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before.py_no_lines_before.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before.py_no_lines_before.py.snap @@ -15,7 +15,6 @@ no_lines_before.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 1 | from __future__ import annotations 2 |- 3 2 | from typing import Any @@ -26,5 +25,3 @@ no_lines_before.py:1:1: I001 [*] Import block is un-sorted or un-formatted 7 |-from my_first_party import my_first_party_object 8 |- 9 5 | from . import my_local_folder_object - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before_with_empty_sections.py_no_lines_before_with_empty_sections.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before_with_empty_sections.py_no_lines_before_with_empty_sections.py.snap index 0e8d39e7ca878..5bc74fd8e516a 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before_with_empty_sections.py_no_lines_before_with_empty_sections.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before_with_empty_sections.py_no_lines_before_with_empty_sections.py.snap @@ -9,10 +9,7 @@ no_lines_before_with_empty_sections.py:1:1: I001 [*] Import block is un-sorted o | = help: Organize imports -ℹ Safe fix 1 1 | from __future__ import annotations 2 2 | from typing import Any 3 |+ 3 4 | from . import my_local_folder_object - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_standard_library_no_standard_library.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_standard_library_no_standard_library.py.snap index 8dfcfe5183d0b..b70ede5e4b9d1 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_standard_library_no_standard_library.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_standard_library_no_standard_library.py.snap @@ -15,7 +15,6 @@ no_standard_library.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 1 | from __future__ import annotations 2 2 | 3 |-import os diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_wrap_star.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_wrap_star.py.snap index c99b0fdb4e60a..b054ab9c2c7f5 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_wrap_star.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_wrap_star.py.snap @@ -7,8 +7,5 @@ no_wrap_star.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 |-from .subscription import * # type: ignore # some very long comment explaining why this needs a type ignore 1 |+from .subscription import * # type: ignore # some very long comment explaining why this needs a type ignore - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type.py.snap index d8b56617063ed..62cd8b401d808 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type.py.snap @@ -18,7 +18,6 @@ order_by_type.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 |-import StringIO 2 1 | import glob 3 2 | import os @@ -37,5 +36,3 @@ order_by_type.py:1:1: I001 [*] Import block is un-sorted or un-formatted 11 |+import foo 12 |+import StringIO 13 |+from module import BASIC, CONSTANT, Apple, Class, function - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_false_order_by_type.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_false_order_by_type.py.snap index e529a09b24d32..0f611f4ccdc6b 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_false_order_by_type.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_false_order_by_type.py.snap @@ -18,7 +18,6 @@ order_by_type.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 |-import StringIO 2 1 | import glob 3 2 | import os @@ -36,5 +35,3 @@ order_by_type.py:1:1: I001 [*] Import block is un-sorted or un-formatted 11 |+import foo 12 |+import StringIO 13 |+from module import Apple, BASIC, Class, CONSTANT, function - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_classes.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_classes.py.snap index 63462bfd800b8..07a9dd245c83a 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_classes.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_classes.py.snap @@ -10,7 +10,6 @@ order_by_type_with_custom_classes.py:1:1: I001 [*] Import block is un-sorted or | = help: Organize imports -ℹ Safe fix 1 |-from sklearn.svm import func, SVC, CONST, Klass 2 |-from subprocess import N_CLASS, PIPE, Popen, STDOUT 3 |-from module import CLASS, Class, CONSTANT, function, BASIC, Apple @@ -20,5 +19,3 @@ order_by_type_with_custom_classes.py:1:1: I001 [*] Import block is un-sorted or 3 |+from module import BASIC, CLASS, CONSTANT, Apple, Class, function 4 |+from sklearn.svm import CONST, SVC, Klass, func 5 |+from torch.nn import A_CONSTANT, SELU, AClass - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_classes_order_by_type_with_custom_classes.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_classes_order_by_type_with_custom_classes.py.snap index 08c6f19ddeb7f..c62539eb0d119 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_classes_order_by_type_with_custom_classes.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_classes_order_by_type_with_custom_classes.py.snap @@ -10,7 +10,6 @@ order_by_type_with_custom_classes.py:1:1: I001 [*] Import block is un-sorted or | = help: Organize imports -ℹ Safe fix 1 |-from sklearn.svm import func, SVC, CONST, Klass 2 |-from subprocess import N_CLASS, PIPE, Popen, STDOUT 3 |-from module import CLASS, Class, CONSTANT, function, BASIC, Apple @@ -20,5 +19,3 @@ order_by_type_with_custom_classes.py:1:1: I001 [*] Import block is un-sorted or 3 |+from module import BASIC, CONSTANT, Apple, CLASS, Class, function 4 |+from sklearn.svm import CONST, Klass, SVC, func 5 |+from torch.nn import A_CONSTANT, AClass, SELU - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_constants.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_constants.py.snap index d935e7728606f..479ee6dbe7952 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_constants.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_constants.py.snap @@ -8,11 +8,8 @@ order_by_type_with_custom_constants.py:1:1: I001 [*] Import block is un-sorted o | = help: Organize imports -ℹ Safe fix 1 |-from sklearn.svm import XYZ, func, variable, Const, Klass, constant 2 |-from subprocess import First, var, func, Class, konst, A_constant, Last, STDOUT 1 |+from subprocess import STDOUT, A_constant, Class, First, Last, func, konst, var 2 |+ 3 |+from sklearn.svm import XYZ, Const, Klass, constant, func, variable - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_constants_order_by_type_with_custom_constants.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_constants_order_by_type_with_custom_constants.py.snap index ce509d7bdce6a..e7a5ebb82f2d2 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_constants_order_by_type_with_custom_constants.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_constants_order_by_type_with_custom_constants.py.snap @@ -8,11 +8,8 @@ order_by_type_with_custom_constants.py:1:1: I001 [*] Import block is un-sorted o | = help: Organize imports -ℹ Safe fix 1 |-from sklearn.svm import XYZ, func, variable, Const, Klass, constant 2 |-from subprocess import First, var, func, Class, konst, A_constant, Last, STDOUT 1 |+from subprocess import A_constant, First, konst, Last, STDOUT, Class, func, var 2 |+ 3 |+from sklearn.svm import Const, constant, XYZ, Klass, func, variable - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_variables.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_variables.py.snap index 5285c77bf82a5..936d50ae585c5 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_variables.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_variables.py.snap @@ -8,11 +8,8 @@ order_by_type_with_custom_variables.py:1:1: I001 [*] Import block is un-sorted o | = help: Organize imports -ℹ Safe fix 1 |-from sklearn.svm import VAR, Class, MyVar, CONST, abc 2 |-from subprocess import utils, var_ABC, Variable, Klass, CONSTANT, exe 1 |+from subprocess import CONSTANT, Klass, Variable, exe, utils, var_ABC 2 |+ 3 |+from sklearn.svm import CONST, VAR, Class, MyVar, abc - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_variables_order_by_type_with_custom_variables.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_variables_order_by_type_with_custom_variables.py.snap index ed6c44822c61b..af9c34af74cb4 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_variables_order_by_type_with_custom_variables.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_variables_order_by_type_with_custom_variables.py.snap @@ -8,11 +8,8 @@ order_by_type_with_custom_variables.py:1:1: I001 [*] Import block is un-sorted o | = help: Organize imports -ℹ Safe fix 1 |-from sklearn.svm import VAR, Class, MyVar, CONST, abc 2 |-from subprocess import utils, var_ABC, Variable, Klass, CONSTANT, exe 1 |+from subprocess import CONSTANT, Klass, exe, utils, var_ABC, Variable 2 |+ 3 |+from sklearn.svm import CONST, Class, abc, MyVar, VAR - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_relative_imports_by_level.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_relative_imports_by_level.py.snap index f1aad7edc0a5f..48dcb8c09ec61 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_relative_imports_by_level.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_relative_imports_by_level.py.snap @@ -10,11 +10,8 @@ order_relative_imports_by_level.py:1:1: I001 [*] Import block is un-sorted or un | = help: Organize imports -ℹ Safe fix 1 |-from .a import a 2 1 | from ..a import a 3 2 | from ..b import a 3 |+from .a import a 4 4 | from .b import a - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_comment_order.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_comment_order.py.snap index 375b252ccf4b0..25da9e5d46846 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_comment_order.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_comment_order.py.snap @@ -17,7 +17,6 @@ preserve_comment_order.py:1:1: I001 [*] Import block is un-sorted or un-formatte | = help: Organize imports -ℹ Safe fix 1 |+import abc 1 2 | import io 3 |+ @@ -29,5 +28,3 @@ preserve_comment_order.py:1:1: I001 [*] Import block is un-sorted or un-formatte 9 11 | # EIEIO 10 12 | from errno import EIO 11 |-import abc - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_import_star.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_import_star.py.snap index e44b824e4dc8b..93e2e8e3dd60c 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_import_star.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_import_star.py.snap @@ -12,7 +12,6 @@ preserve_import_star.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 |-from some_other_module import some_class 2 |-from some_other_module import * 3 1 | # Above @@ -24,5 +23,3 @@ preserve_import_star.py:1:1: I001 [*] Import block is un-sorted or un-formatted 5 |+from some_module import some_class # Aside 6 |+from some_other_module import * 7 |+from some_other_module import some_class - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_indentation.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_indentation.py.snap index d9117c89e61d0..e8dd02a0d5987 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_indentation.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_indentation.py.snap @@ -13,7 +13,6 @@ preserve_indentation.py:2:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 1 | if True: 2 |+ import os 2 3 | import sys @@ -31,12 +30,9 @@ preserve_indentation.py:5:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 2 2 | import sys 3 3 | import os 4 4 | else: 5 |+ import os 5 6 | import sys 6 |- import os - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__propagate_inline_comments_propagate_inline_comments.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__propagate_inline_comments_propagate_inline_comments.py.snap index 6346a04dd236c..29c7cc1378b61 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__propagate_inline_comments_propagate_inline_comments.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__propagate_inline_comments_propagate_inline_comments.py.snap @@ -10,11 +10,8 @@ propagate_inline_comments.py:1:1: I001 [*] Import block is un-sorted or un-forma | = help: Organize imports -ℹ Safe fix 1 1 | from mypackage.subpackage import ( # long comment that seems to be a problem 2 2 | a_long_variable_name_that_causes_problems, 3 |- items, 4 3 | ) 4 |+from mypackage.subpackage import items # long comment that seems to be a problem - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__reorder_within_section.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__reorder_within_section.py.snap index 23d95af3545c5..31f2eeee8d66e 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__reorder_within_section.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__reorder_within_section.py.snap @@ -8,9 +8,6 @@ reorder_within_section.py:1:1: I001 [*] Import block is un-sorted or un-formatte | = help: Organize imports -ℹ Safe fix 1 |+import os 1 2 | import sys 2 |-import os - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_comment.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_comment.py.snap index 313ec7cbb467d..111e55c92ae0b 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_comment.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_comment.py.snap @@ -2,7 +2,6 @@ source: crates/ruff_linter/src/rules/isort/mod.rs --- comment.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` -ℹ Safe fix 1 1 | #!/usr/bin/env python3 2 |+from __future__ import annotations 2 3 | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_comments_and_newlines.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_comments_and_newlines.py.snap index c5d92854a2864..a1b7ae8ae5bef 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_comments_and_newlines.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_comments_and_newlines.py.snap @@ -2,7 +2,6 @@ source: crates/ruff_linter/src/rules/isort/mod.rs --- comments_and_newlines.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` -ℹ Safe fix 2 2 | # A copyright notice could go here 3 3 | 4 4 | # A linter directive could go here diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring.py.snap index 4a513546859a8..dd8f942c7991b 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring.py.snap @@ -2,7 +2,6 @@ source: crates/ruff_linter/src/rules/isort/mod.rs --- docstring.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` -ℹ Safe fix 1 1 | """Hello, world!""" 2 |+from __future__ import annotations 2 3 | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring_with_continuation.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring_with_continuation.py.snap index c48ef63610db9..e7d5bdc7ca21b 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring_with_continuation.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring_with_continuation.py.snap @@ -2,7 +2,6 @@ source: crates/ruff_linter/src/rules/isort/mod.rs --- docstring_with_continuation.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` -ℹ Safe fix 1 |-"""Hello, world!"""; x = \ 1 |+"""Hello, world!"""; from __future__ import annotations; x = \ 2 2 | 1; y = 2 diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring_with_semicolon.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring_with_semicolon.py.snap index dfd35beb25140..73fa336e8e479 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring_with_semicolon.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring_with_semicolon.py.snap @@ -2,6 +2,5 @@ source: crates/ruff_linter/src/rules/isort/mod.rs --- docstring_with_semicolon.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` -ℹ Safe fix 1 |-"""Hello, world!"""; x = 1 1 |+"""Hello, world!"""; from __future__ import annotations; x = 1 diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_existing_import.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_existing_import.py.snap index 12ff6dbd5cc02..142ba1e62f1f5 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_existing_import.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_existing_import.py.snap @@ -2,7 +2,6 @@ source: crates/ruff_linter/src/rules/isort/mod.rs --- existing_import.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` -ℹ Safe fix 1 |+from __future__ import annotations 1 2 | from __future__ import generator_stop 2 3 | import os diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_multiline_docstring.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_multiline_docstring.py.snap index 18e6b94876b25..26a6e685119b5 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_multiline_docstring.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_multiline_docstring.py.snap @@ -2,7 +2,6 @@ source: crates/ruff_linter/src/rules/isort/mod.rs --- multiline_docstring.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` -ℹ Safe fix 1 1 | """a 2 2 | b""" 3 3 | # b diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_off.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_off.py.snap index 5107b912908db..f6bb06a3e2777 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_off.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_off.py.snap @@ -2,7 +2,6 @@ source: crates/ruff_linter/src/rules/isort/mod.rs --- off.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` -ℹ Safe fix 1 1 | # isort: off 2 |+from __future__ import annotations 2 3 | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_unused.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_unused.py.snap index 0d79276e0e4ff..b96040940c52b 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_unused.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_unused.py.snap @@ -11,7 +11,6 @@ unused.py:5:8: F401 [*] `sys` imported but unused | = help: Remove unused import: `sys` -ℹ Safe fix 2 2 | import os 3 3 | 4 4 | # Unused, _not_ marked as required. @@ -30,7 +29,6 @@ unused.py:8:19: F401 [*] `pathlib` imported but unused | = help: Remove unused import: `pathlib` -ℹ Safe fix 5 5 | import sys 6 6 | 7 7 | # Unused, _not_ marked as required (due to the alias). diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_comment.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_comment.py.snap index ea3f16c36b1e7..cb801feac24a2 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_comment.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_comment.py.snap @@ -2,7 +2,6 @@ source: crates/ruff_linter/src/rules/isort/mod.rs --- comment.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` -ℹ Safe fix 1 1 | #!/usr/bin/env python3 2 |+from __future__ import annotations as _annotations 2 3 | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_comments_and_newlines.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_comments_and_newlines.py.snap index 509094af63e6a..c1ebf24465746 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_comments_and_newlines.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_comments_and_newlines.py.snap @@ -2,7 +2,6 @@ source: crates/ruff_linter/src/rules/isort/mod.rs --- comments_and_newlines.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` -ℹ Safe fix 2 2 | # A copyright notice could go here 3 3 | 4 4 | # A linter directive could go here diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring.py.snap index 21c36c4e30461..2917021c4c0d5 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring.py.snap @@ -2,7 +2,6 @@ source: crates/ruff_linter/src/rules/isort/mod.rs --- docstring.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` -ℹ Safe fix 1 1 | """Hello, world!""" 2 |+from __future__ import annotations as _annotations 2 3 | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring_with_continuation.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring_with_continuation.py.snap index 0a40adb35a58c..930a88ae2f7a1 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring_with_continuation.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring_with_continuation.py.snap @@ -2,7 +2,6 @@ source: crates/ruff_linter/src/rules/isort/mod.rs --- docstring_with_continuation.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` -ℹ Safe fix 1 |-"""Hello, world!"""; x = \ 1 |+"""Hello, world!"""; from __future__ import annotations as _annotations; x = \ 2 2 | 1; y = 2 diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring_with_semicolon.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring_with_semicolon.py.snap index 3c61e64a8ba79..8e626440fab3f 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring_with_semicolon.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring_with_semicolon.py.snap @@ -2,6 +2,5 @@ source: crates/ruff_linter/src/rules/isort/mod.rs --- docstring_with_semicolon.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` -ℹ Safe fix 1 |-"""Hello, world!"""; x = 1 1 |+"""Hello, world!"""; from __future__ import annotations as _annotations; x = 1 diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_existing_import.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_existing_import.py.snap index 96e891413b4af..67ea2ef75c1f6 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_existing_import.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_existing_import.py.snap @@ -2,7 +2,6 @@ source: crates/ruff_linter/src/rules/isort/mod.rs --- existing_import.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` -ℹ Safe fix 1 |+from __future__ import annotations as _annotations 1 2 | from __future__ import generator_stop 2 3 | import os diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_multiline_docstring.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_multiline_docstring.py.snap index 6426ab3898496..ca9ef698b11e4 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_multiline_docstring.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_multiline_docstring.py.snap @@ -2,7 +2,6 @@ source: crates/ruff_linter/src/rules/isort/mod.rs --- multiline_docstring.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` -ℹ Safe fix 1 1 | """a 2 2 | b""" 3 3 | # b diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_off.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_off.py.snap index 4387774dddd69..b25529b6415ab 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_off.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_off.py.snap @@ -2,7 +2,6 @@ source: crates/ruff_linter/src/rules/isort/mod.rs --- off.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` -ℹ Safe fix 1 1 | # isort: off 2 |+from __future__ import annotations as _annotations 2 3 | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_imports_docstring.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_imports_docstring.py.snap index d65d89b7038d5..4e96d0038807b 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_imports_docstring.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_imports_docstring.py.snap @@ -2,14 +2,12 @@ source: crates/ruff_linter/src/rules/isort/mod.rs --- docstring.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` -ℹ Safe fix 1 1 | """Hello, world!""" 2 |+from __future__ import annotations 2 3 | 3 4 | x = 1 docstring.py:1:1: I002 [*] Missing required import: `from __future__ import generator_stop` -ℹ Safe fix 1 1 | """Hello, world!""" 2 |+from __future__ import generator_stop 2 3 | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__section_order_sections.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__section_order_sections.py.snap index 8643ef2443362..8be1f5d6df1a9 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__section_order_sections.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__section_order_sections.py.snap @@ -13,7 +13,6 @@ sections.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 1 | from __future__ import annotations 2 |+ 2 3 | import os @@ -26,5 +25,3 @@ sections.py:1:1: I001 [*] Import block is un-sorted or un-formatted 6 10 | from library import foo 11 |+ 7 12 | from . import local - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sections_main_first_party.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sections_main_first_party.py.snap index 404ad962cb670..ae2dd509cabef 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sections_main_first_party.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sections_main_first_party.py.snap @@ -17,7 +17,6 @@ main_first_party.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 1 | import os 2 2 | 3 |-import __main__ @@ -27,5 +26,3 @@ main_first_party.py:1:1: I001 [*] Import block is un-sorted or un-formatted 6 6 | import first_party 7 7 | 8 8 | os.a - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sections_sections.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sections_sections.py.snap index 15572d6be1f65..2548d5643e019 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sections_sections.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sections_sections.py.snap @@ -13,7 +13,6 @@ sections.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 1 | from __future__ import annotations 2 |+ 2 3 | import os @@ -26,5 +25,3 @@ sections.py:1:1: I001 [*] Import block is un-sorted or un-formatted 7 9 | from . import local 10 |+ 11 |+import django.settings - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_first_party_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_first_party_imports.py.snap index e1f4b5298d973..2e6b629d8f3a5 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_first_party_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_first_party_imports.py.snap @@ -11,7 +11,6 @@ separate_first_party_imports.py:1:1: I001 [*] Import block is un-sorted or un-fo | = help: Organize imports -ℹ Safe fix 1 |+import os 1 2 | import sys 3 |+ @@ -21,5 +20,3 @@ separate_first_party_imports.py:1:1: I001 [*] Import block is un-sorted or un-fo 3 |-import numpy as np 4 |-import os 5 7 | from leading_prefix import Class - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_future_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_future_imports.py.snap index 238a0b20f69e6..a72fd2ecccd8c 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_future_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_future_imports.py.snap @@ -9,12 +9,9 @@ separate_future_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatt | = help: Organize imports -ℹ Safe fix 1 |-import sys 2 |-import os 3 1 | from __future__ import annotations 2 |+ 3 |+import os 4 |+import sys - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_local_folder_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_local_folder_imports.py.snap index 88d2f3a1bcfa0..abfc091ac51d8 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_local_folder_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_local_folder_imports.py.snap @@ -13,7 +13,6 @@ separate_local_folder_imports.py:1:1: I001 [*] Import block is un-sorted or un-f | = help: Organize imports -ℹ Safe fix 1 |+import os 1 2 | import sys 3 |+ diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_third_party_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_third_party_imports.py.snap index 955c5421ff4ca..0d297f3ea244a 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_third_party_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_third_party_imports.py.snap @@ -10,7 +10,6 @@ separate_third_party_imports.py:1:1: I001 [*] Import block is un-sorted or un-fo | = help: Organize imports -ℹ Safe fix 1 |-import pandas as pd 1 |+import os 2 2 | import sys @@ -18,5 +17,3 @@ separate_third_party_imports.py:1:1: I001 [*] Import block is un-sorted or un-fo 3 4 | import numpy as np 4 |-import os 5 |+import pandas as pd - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__skip.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__skip.py.snap index acd83b5cbe271..6d593509006f9 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__skip.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__skip.py.snap @@ -14,7 +14,6 @@ skip.py:20:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 17 17 | def f(): 18 18 | import sys 19 19 | import os # isort: skip @@ -38,7 +37,6 @@ skip.py:27:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 24 24 | def f(): 25 25 | import sys 26 26 | import os # isort:skip @@ -57,12 +55,9 @@ skip.py:34:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 31 31 | def f(): 32 32 | import sys; import os # isort:skip 33 33 | import sys; import os # isort:skip # isort:skip 34 |- import sys; import os 34 |+ import os 35 |+ import sys - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sort_similar_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sort_similar_imports.py.snap index 588a1c9a97cbb..6e36eb9bde071 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sort_similar_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sort_similar_imports.py.snap @@ -32,7 +32,6 @@ sort_similar_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 |-from a import b 1 |+import A 2 |+import a @@ -73,5 +72,3 @@ sort_similar_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted 24 |-import x as Y 25 |-import x 26 |-import x as a - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__split.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__split.py.snap index a729c4efd6eb4..b0513669cc56c 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__split.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__split.py.snap @@ -12,7 +12,6 @@ split.py:15:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 12 12 | import b 13 13 | 14 14 | if True: @@ -36,7 +35,6 @@ split.py:20:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 17 17 | 18 18 | # isort: split 19 19 | @@ -56,12 +54,9 @@ split.py:30:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 27 27 | # isort: split 28 28 | # isort: split 29 29 | 30 |+import c 30 31 | import d 31 |-import c - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__split_on_trailing_comma_magic_trailing_comma.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__split_on_trailing_comma_magic_trailing_comma.py.snap index 87b842c9f89a7..c6037d1177f0b 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__split_on_trailing_comma_magic_trailing_comma.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__split_on_trailing_comma_magic_trailing_comma.py.snap @@ -44,7 +44,6 @@ magic_trailing_comma.py:2:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 1 | # This has a magic trailing comma, will be sorted, but not rolled into one line 2 |-from sys import ( 3 |- stderr, @@ -91,5 +90,3 @@ magic_trailing_comma.py:2:1: I001 [*] Import block is un-sorted or un-formatted 37 |- member3, 38 |-) 19 |+from module2 import member1, member2, member3 - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__star_before_others.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__star_before_others.py.snap index 98fadba6e6dbe..2facf09391b2c 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__star_before_others.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__star_before_others.py.snap @@ -9,10 +9,7 @@ star_before_others.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 1 | from .logging import config_logging 2 |+from .settings import * 2 3 | from .settings import ENV 3 |-from .settings import * - - diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__straight_required_import_docstring.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__straight_required_import_docstring.py.snap index 6ce4357615da8..47246a1ca22ab 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__straight_required_import_docstring.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__straight_required_import_docstring.py.snap @@ -2,7 +2,6 @@ source: crates/ruff_linter/src/rules/isort/mod.rs --- docstring.py:1:1: I002 [*] Missing required import: `import os` -ℹ Safe fix 1 1 | """Hello, world!""" 2 |+import os 2 3 | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__straight_required_import_docstring.pyi.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__straight_required_import_docstring.pyi.snap index 9c789cb79e5e0..c05d57c0fff8c 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__straight_required_import_docstring.pyi.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__straight_required_import_docstring.pyi.snap @@ -2,7 +2,6 @@ source: crates/ruff_linter/src/rules/isort/mod.rs --- docstring.pyi:1:1: I002 [*] Missing required import: `import os` -ℹ Safe fix 1 1 | """Hello, world!""" 2 |+import os 2 3 | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__trailing_comment.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__trailing_comment.py.snap index 8a1f7e61d3670..7dbecefe73d3b 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__trailing_comment.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__trailing_comment.py.snap @@ -19,7 +19,6 @@ trailing_comment.py:8:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 5 5 | 6 6 | pass 7 7 | @@ -55,7 +54,6 @@ trailing_comment.py:17:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 14 14 | 15 15 | pass 16 16 | @@ -83,7 +81,6 @@ trailing_comment.py:35:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 32 32 | 33 33 | pass 34 34 | @@ -112,7 +109,6 @@ trailing_comment.py:42:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 39 39 | 40 40 | pass 41 41 | @@ -136,7 +132,6 @@ trailing_comment.py:50:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 47 47 | pass 48 48 | 49 49 | # a diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__two_space.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__two_space.py.snap index 3d7aa735039ba..1ab10a3a94728 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__two_space.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__two_space.py.snap @@ -17,7 +17,6 @@ two_space.py:2:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 1 | # If the file doesn't contain a logical indent token, we should still detect two-space indentation on imports. 2 2 | from math import ( 3 |- sin, diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__unicode.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__unicode.py.snap index 0a6f035c6241d..3fdaf764e14df 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__unicode.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__unicode.py.snap @@ -13,7 +13,6 @@ unicode.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 |+import numpy as CƐgHHHhIILlNZΩZKÅBCeEFio 2 |+import numpy as ℂℇℊℋℌℍℎℐℑℒℓℕℤΩℨKÅℬℭℯℰℱℹℴ 1 3 | from astropy.constants import hbar as ℏ diff --git a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-deprecated-function_NPY003.py.snap b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-deprecated-function_NPY003.py.snap index d857a69203f2f..b507416813ddb 100644 --- a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-deprecated-function_NPY003.py.snap +++ b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-deprecated-function_NPY003.py.snap @@ -12,7 +12,6 @@ NPY003.py:4:5: NPY003 [*] `np.round_` is deprecated; use `np.round` instead | = help: Replace with `np.round` -ℹ Safe fix 1 1 | def func(): 2 2 | import numpy as np 3 3 | @@ -32,7 +31,6 @@ NPY003.py:5:5: NPY003 [*] `np.product` is deprecated; use `np.prod` instead | = help: Replace with `np.prod` -ℹ Safe fix 2 2 | import numpy as np 3 3 | 4 4 | np.round_(np.random.rand(5, 5), 2) @@ -53,7 +51,6 @@ NPY003.py:6:5: NPY003 [*] `np.cumproduct` is deprecated; use `np.cumprod` instea | = help: Replace with `np.cumprod` -ℹ Safe fix 3 3 | 4 4 | np.round_(np.random.rand(5, 5), 2) 5 5 | np.product(np.random.rand(5, 5)) @@ -73,7 +70,6 @@ NPY003.py:7:5: NPY003 [*] `np.sometrue` is deprecated; use `np.any` instead | = help: Replace with `np.any` -ℹ Safe fix 4 4 | np.round_(np.random.rand(5, 5), 2) 5 5 | np.product(np.random.rand(5, 5)) 6 6 | np.cumproduct(np.random.rand(5, 5)) @@ -92,7 +88,6 @@ NPY003.py:8:5: NPY003 [*] `np.alltrue` is deprecated; use `np.all` instead | = help: Replace with `np.all` -ℹ Safe fix 5 5 | np.product(np.random.rand(5, 5)) 6 6 | np.cumproduct(np.random.rand(5, 5)) 7 7 | np.sometrue(np.random.rand(5, 5)) @@ -113,7 +108,6 @@ NPY003.py:14:5: NPY003 [*] `np.round_` is deprecated; use `np.round` instead | = help: Replace with `np.round` -ℹ Safe fix 1 |+from numpy import round 1 2 | def func(): 2 3 | import numpy as np @@ -138,7 +132,6 @@ NPY003.py:15:5: NPY003 [*] `np.product` is deprecated; use `np.prod` instead | = help: Replace with `np.prod` -ℹ Safe fix 1 |+from numpy import prod 1 2 | def func(): 2 3 | import numpy as np @@ -164,7 +157,6 @@ NPY003.py:16:5: NPY003 [*] `np.cumproduct` is deprecated; use `np.cumprod` inste | = help: Replace with `np.cumprod` -ℹ Safe fix 1 |+from numpy import cumprod 1 2 | def func(): 2 3 | import numpy as np @@ -188,7 +180,6 @@ NPY003.py:17:5: NPY003 [*] `np.sometrue` is deprecated; use `np.any` instead | = help: Replace with `np.any` -ℹ Safe fix 1 |+from numpy import any 1 2 | def func(): 2 3 | import numpy as np @@ -210,7 +201,6 @@ NPY003.py:18:5: NPY003 [*] `np.alltrue` is deprecated; use `np.all` instead | = help: Replace with `np.all` -ℹ Safe fix 1 |+from numpy import all 1 2 | def func(): 2 3 | import numpy as np @@ -221,5 +211,3 @@ NPY003.py:18:5: NPY003 [*] `np.alltrue` is deprecated; use `np.all` instead 17 18 | sometrue(np.random.rand(5, 5)) 18 |- alltrue(np.random.rand(5, 5)) 19 |+ all(np.random.rand(5, 5)) - - diff --git a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-deprecated-type-alias_NPY001.py.snap b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-deprecated-type-alias_NPY001.py.snap index 6af2e8eac11cd..5b9437eb6462a 100644 --- a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-deprecated-type-alias_NPY001.py.snap +++ b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-deprecated-type-alias_NPY001.py.snap @@ -10,7 +10,6 @@ NPY001.py:6:1: NPY001 [*] Type alias `np.float` is deprecated, replace with buil | = help: Replace `np.float` with builtin type -ℹ Safe fix 3 3 | import numpy 4 4 | 5 5 | # Error @@ -31,7 +30,6 @@ NPY001.py:7:1: NPY001 [*] Type alias `np.int` is deprecated, replace with builti | = help: Replace `np.int` with builtin type -ℹ Safe fix 4 4 | 5 5 | # Error 6 6 | npy.float @@ -51,7 +49,6 @@ NPY001.py:9:13: NPY001 [*] Type alias `np.object` is deprecated, replace with bu | = help: Replace `np.object` with builtin type -ℹ Safe fix 6 6 | npy.float 7 7 | npy.int 8 8 | @@ -72,7 +69,6 @@ NPY001.py:12:72: NPY001 [*] Type alias `np.int` is deprecated, replace with buil | = help: Replace `np.int` with builtin type -ℹ Safe fix 9 9 | if dtype == np.object: 10 10 | ... 11 11 | @@ -93,7 +89,6 @@ NPY001.py:12:80: NPY001 [*] Type alias `np.complex` is deprecated, replace with | = help: Replace `np.complex` with builtin type -ℹ Safe fix 9 9 | if dtype == np.object: 10 10 | ... 11 11 | @@ -113,7 +108,6 @@ NPY001.py:17:11: NPY001 [*] Type alias `np.object` is deprecated, replace with b | = help: Replace `np.object` with builtin type -ℹ Safe fix 14 14 | pdf = pd.DataFrame( 15 15 | data=[[1, 2, 3]], 16 16 | columns=["a", "b", "c"], @@ -134,7 +128,6 @@ NPY001.py:20:16: NPY001 [*] Type alias `np.int` is deprecated, replace with buil | = help: Replace `np.int` with builtin type -ℹ Safe fix 17 17 | dtype=numpy.object, 18 18 | ) 19 19 | @@ -153,7 +146,6 @@ NPY001.py:25:1: NPY001 [*] Type alias `np.float` is deprecated, replace with bui | = help: Replace `np.float` with builtin type -ℹ Safe fix 21 21 | 22 22 | # Regression test for: https://github.com/astral-sh/ruff/issues/6952 23 23 | from numpy import float diff --git a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201.py.snap b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201.py.snap index 6941c9efc9aff..5de9f3e7ec781 100644 --- a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201.py.snap +++ b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201.py.snap @@ -12,7 +12,6 @@ NPY201.py:4:5: NPY201 [*] `np.add_docstring` will be removed in NumPy 2.0. Use ` | = help: Replace with `numpy.lib.add_docstring` -ℹ Safe fix 1 |+from numpy.lib import add_docstring 1 2 | def func(): 2 3 | import numpy as np @@ -34,7 +33,6 @@ NPY201.py:6:5: NPY201 [*] `np.add_newdoc` will be removed in NumPy 2.0. Use `num | = help: Replace with `numpy.lib.add_newdoc` -ℹ Safe fix 1 |+from numpy.lib import add_newdoc 1 2 | def func(): 2 3 | import numpy as np @@ -78,20 +76,6 @@ NPY201.py:12:5: NPY201 [*] `np.byte_bounds` will be removed in NumPy 2.0. Use `n | = help: Replace with `numpy.lib.array_utils.byte_bounds` (requires NumPy 2.0 or greater) -ℹ Unsafe fix - 1 |+from numpy.lib.array_utils import byte_bounds -1 2 | def func(): -2 3 | import numpy as np -3 4 | --------------------------------------------------------------------------------- -9 10 | -10 11 | np.asfarray([1,2,3]) -11 12 | -12 |- np.byte_bounds(np.array([1,2,3])) - 13 |+ byte_bounds(np.array([1,2,3])) -13 14 | -14 15 | np.cast -15 16 | NPY201.py:14:5: NPY201 `np.cast` will be removed in NumPy 2.0. Use `np.asarray(arr, dtype=dtype)` instead. | @@ -114,7 +98,6 @@ NPY201.py:16:5: NPY201 [*] `np.cfloat` will be removed in NumPy 2.0. Use `numpy. | = help: Replace with `numpy.complex128` -ℹ Safe fix 13 13 | 14 14 | np.cast 15 15 | @@ -135,7 +118,6 @@ NPY201.py:18:5: NPY201 [*] `np.clongfloat` will be removed in NumPy 2.0. Use `nu | = help: Replace with `numpy.clongdouble` -ℹ Safe fix 15 15 | 16 16 | np.cfloat(12+34j) 17 17 | @@ -166,7 +148,6 @@ NPY201.py:22:5: NPY201 [*] `np.complex_` will be removed in NumPy 2.0. Use `nump | = help: Replace with `numpy.complex128` -ℹ Safe fix 19 19 | 20 20 | np.compat 21 21 | @@ -187,7 +168,6 @@ NPY201.py:24:5: NPY201 [*] `np.DataSource` will be removed in NumPy 2.0. Use `nu | = help: Replace with `numpy.lib.npyio.DataSource` -ℹ Safe fix 1 |+from numpy.lib.npyio import DataSource 1 2 | def func(): 2 3 | import numpy as np @@ -273,7 +253,6 @@ NPY201.py:38:5: NPY201 [*] `np.float_` will be removed in NumPy 2.0. Use `numpy. | = help: Replace with `numpy.float64` -ℹ Safe fix 35 35 | 36 36 | np.get_array_wrap 37 37 | @@ -304,7 +283,6 @@ NPY201.py:42:5: NPY201 [*] `np.Inf` will be removed in NumPy 2.0. Use `numpy.inf | = help: Replace with `numpy.inf` -ℹ Safe fix 39 39 | 40 40 | np.geterrobj 41 41 | @@ -325,7 +303,6 @@ NPY201.py:44:5: NPY201 [*] `np.Infinity` will be removed in NumPy 2.0. Use `nump | = help: Replace with `numpy.inf` -ℹ Safe fix 41 41 | 42 42 | np.Inf 43 43 | @@ -346,7 +323,6 @@ NPY201.py:46:5: NPY201 [*] `np.infty` will be removed in NumPy 2.0. Use `numpy.i | = help: Replace with `numpy.inf` -ℹ Safe fix 43 43 | 44 44 | np.Infinity 45 45 | @@ -377,7 +353,6 @@ NPY201.py:50:5: NPY201 [*] `np.issubclass_` will be removed in NumPy 2.0. Use `i | = help: Replace with `issubclass` -ℹ Safe fix 47 47 | 48 48 | np.issctype 49 49 | @@ -398,7 +373,6 @@ NPY201.py:52:5: NPY201 [*] `np.issubsctype` will be removed in NumPy 2.0. Use `n | = help: Replace with `numpy.issubdtype` -ℹ Safe fix 49 49 | 50 50 | np.issubclass_(np.int32, np.integer) 51 51 | @@ -419,7 +393,6 @@ NPY201.py:54:5: NPY201 [*] `np.mat` will be removed in NumPy 2.0. Use `numpy.asm | = help: Replace with `numpy.asmatrix` -ℹ Safe fix 51 51 | 52 52 | np.issubsctype 53 53 | @@ -450,7 +423,6 @@ NPY201.py:58:5: NPY201 [*] `np.NaN` will be removed in NumPy 2.0. Use `numpy.nan | = help: Replace with `numpy.nan` -ℹ Safe fix 55 55 | 56 56 | np.maximum_sctype 57 57 | @@ -481,7 +453,6 @@ NPY201.py:62:5: NPY201 [*] `np.NINF` will be removed in NumPy 2.0. Use `-np.inf` | = help: Replace with `-np.inf` -ℹ Safe fix 59 59 | 60 60 | np.nbytes[np.int64] 61 61 | @@ -502,7 +473,6 @@ NPY201.py:64:5: NPY201 [*] `np.NZERO` will be removed in NumPy 2.0. Use `-0.0` i | = help: Replace with `-0.0` -ℹ Safe fix 61 61 | 62 62 | np.NINF 63 63 | @@ -523,7 +493,6 @@ NPY201.py:66:5: NPY201 [*] `np.longcomplex` will be removed in NumPy 2.0. Use `n | = help: Replace with `numpy.clongdouble` -ℹ Safe fix 63 63 | 64 64 | np.NZERO 65 65 | @@ -544,7 +513,6 @@ NPY201.py:68:5: NPY201 [*] `np.longfloat` will be removed in NumPy 2.0. Use `num | = help: Replace with `numpy.longdouble` -ℹ Safe fix 65 65 | 66 66 | np.longcomplex(12+34j) 67 67 | @@ -575,7 +543,6 @@ NPY201.py:72:5: NPY201 [*] `np.NAN` will be removed in NumPy 2.0. Use `numpy.nan | = help: Replace with `numpy.nan` -ℹ Safe fix 69 69 | 70 70 | np.lookfor 71 71 | diff --git a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201_2.py.snap b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201_2.py.snap index 56be229615aa6..15cf8189c1e22 100644 --- a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201_2.py.snap +++ b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201_2.py.snap @@ -22,7 +22,6 @@ NPY201_2.py:6:5: NPY201 [*] `np.PINF` will be removed in NumPy 2.0. Use `numpy.i | = help: Replace with `numpy.inf` -ℹ Safe fix 3 3 | 4 4 | np.obj2sctype(int) 5 5 | @@ -43,7 +42,6 @@ NPY201_2.py:8:5: NPY201 [*] `np.PZERO` will be removed in NumPy 2.0. Use `0.0` i | = help: Replace with `0.0` -ℹ Safe fix 5 5 | 6 6 | np.PINF 7 7 | @@ -84,7 +82,6 @@ NPY201_2.py:14:5: NPY201 [*] `np.round_` will be removed in NumPy 2.0. Use `nump | = help: Replace with `numpy.round` -ℹ Safe fix 11 11 | 12 12 | np.recfromtxt 13 13 | @@ -105,7 +102,6 @@ NPY201_2.py:16:5: NPY201 [*] `np.safe_eval` will be removed in NumPy 2.0. Use `a | = help: Replace with `ast.literal_eval` -ℹ Safe fix 1 |+from ast import literal_eval 1 2 | def func(): 2 3 | import numpy as np @@ -171,7 +167,6 @@ NPY201_2.py:28:5: NPY201 [*] `np.singlecomplex` will be removed in NumPy 2.0. Us | = help: Replace with `numpy.complex64` -ℹ Safe fix 25 25 | 26 26 | np.set_string_function 27 27 | @@ -192,7 +187,6 @@ NPY201_2.py:30:5: NPY201 [*] `np.string_` will be removed in NumPy 2.0. Use `num | = help: Replace with `numpy.bytes_` -ℹ Safe fix 27 27 | 28 28 | np.singlecomplex(12+1j) 29 29 | @@ -213,7 +207,6 @@ NPY201_2.py:32:5: NPY201 [*] `np.source` will be removed in NumPy 2.0. Use `insp | = help: Replace with `inspect.getsource` -ℹ Safe fix 1 |+from inspect import getsource 1 2 | def func(): 2 3 | import numpy as np @@ -239,7 +232,6 @@ NPY201_2.py:34:5: NPY201 [*] `np.tracemalloc_domain` will be removed in NumPy 2. | = help: Replace with `numpy.lib.tracemalloc_domain` -ℹ Safe fix 1 |+from numpy.lib import tracemalloc_domain 1 2 | def func(): 2 3 | import numpy as np @@ -265,7 +257,6 @@ NPY201_2.py:36:5: NPY201 [*] `np.unicode_` will be removed in NumPy 2.0. Use `nu | = help: Replace with `numpy.str_` -ℹ Safe fix 33 33 | 34 34 | np.tracemalloc_domain 35 35 | @@ -296,7 +287,6 @@ NPY201_2.py:40:5: NPY201 [*] `np.row_stack` will be removed in NumPy 2.0. Use `n | = help: Replace with `numpy.vstack` -ℹ Safe fix 37 37 | 38 38 | np.who() 39 39 | @@ -317,7 +307,6 @@ NPY201_2.py:42:5: NPY201 [*] `np.alltrue` will be removed in NumPy 2.0. Use `num | = help: Replace with `numpy.all` -ℹ Safe fix 39 39 | 40 40 | np.row_stack(([1,2], [3,4])) 41 41 | @@ -338,7 +327,6 @@ NPY201_2.py:44:5: NPY201 [*] `np.sometrue` will be removed in NumPy 2.0. Use `nu | = help: Replace with `numpy.any` -ℹ Safe fix 41 41 | 42 42 | np.alltrue([True, True]) 43 43 | @@ -359,7 +347,6 @@ NPY201_2.py:46:5: NPY201 [*] `np.cumproduct` will be removed in NumPy 2.0. Use ` | = help: Replace with `numpy.cumprod` -ℹ Safe fix 43 43 | 44 44 | np.sometrue([True, False]) 45 45 | @@ -380,7 +367,6 @@ NPY201_2.py:48:5: NPY201 [*] `np.product` will be removed in NumPy 2.0. Use `num | = help: Replace with `numpy.prod` -ℹ Safe fix 45 45 | 46 46 | np.cumproduct([1, 2, 3]) 47 47 | @@ -401,15 +387,6 @@ NPY201_2.py:50:5: NPY201 [*] `np.trapz` will be removed in NumPy 2.0. Use `numpy | = help: Replace with `numpy.trapezoid` (requires NumPy 2.0 or greater) -ℹ Unsafe fix -47 47 | -48 48 | np.product([1, 2, 3]) -49 49 | -50 |- np.trapz([1, 2, 3]) - 50 |+ np.trapezoid([1, 2, 3]) -51 51 | -52 52 | np.in1d([1, 2], [1, 3, 5]) -53 53 | NPY201_2.py:52:5: NPY201 [*] `np.in1d` will be removed in NumPy 2.0. Use `numpy.isin` instead. | @@ -422,7 +399,6 @@ NPY201_2.py:52:5: NPY201 [*] `np.in1d` will be removed in NumPy 2.0. Use `numpy. | = help: Replace with `numpy.isin` -ℹ Safe fix 49 49 | 50 50 | np.trapz([1, 2, 3]) 51 51 | @@ -443,7 +419,6 @@ NPY201_2.py:54:5: NPY201 [*] `np.AxisError` will be removed in NumPy 2.0. Use `n | = help: Replace with `numpy.exceptions.AxisError` -ℹ Safe fix 1 |+from numpy.exceptions import AxisError 1 2 | def func(): 2 3 | import numpy as np @@ -469,7 +444,6 @@ NPY201_2.py:56:5: NPY201 [*] `np.ComplexWarning` will be removed in NumPy 2.0. U | = help: Replace with `numpy.exceptions.ComplexWarning` -ℹ Safe fix 1 |+from numpy.exceptions import ComplexWarning 1 2 | def func(): 2 3 | import numpy as np @@ -495,7 +469,6 @@ NPY201_2.py:58:5: NPY201 [*] `np.compare_chararrays` will be removed in NumPy 2. | = help: Replace with `numpy.char.compare_chararrays` -ℹ Safe fix 1 |+from numpy.char import compare_chararrays 1 2 | def func(): 2 3 | import numpy as np @@ -521,7 +494,6 @@ NPY201_2.py:63:9: NPY201 [*] `np.alltrue` will be removed in NumPy 2.0. Use `num | = help: Replace with `numpy.all` -ℹ Safe fix 60 60 | try: 61 61 | np.all([True, True]) 62 62 | except TypeError: @@ -541,7 +513,6 @@ NPY201_2.py:68:9: NPY201 [*] `np.sometrue` will be removed in NumPy 2.0. Use `nu | = help: Replace with `numpy.any` -ℹ Safe fix 65 65 | try: 66 66 | np.anyyyy([True, True]) 67 67 | except AttributeError: diff --git a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201_3.py.snap b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201_3.py.snap index 2ba8e85fa30d1..d9bd7191b1dc3 100644 --- a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201_3.py.snap +++ b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201_3.py.snap @@ -12,7 +12,6 @@ NPY201_3.py:4:5: NPY201 [*] `np.DTypePromotionError` will be removed in NumPy 2. | = help: Replace with `numpy.exceptions.DTypePromotionError` -ℹ Safe fix 1 |+from numpy.exceptions import DTypePromotionError 1 2 | def func(): 2 3 | import numpy as np @@ -34,7 +33,6 @@ NPY201_3.py:6:5: NPY201 [*] `np.ModuleDeprecationWarning` will be removed in Num | = help: Replace with `numpy.exceptions.ModuleDeprecationWarning` -ℹ Safe fix 1 |+from numpy.exceptions import ModuleDeprecationWarning 1 2 | def func(): 2 3 | import numpy as np @@ -58,20 +56,6 @@ NPY201_3.py:8:5: NPY201 [*] `np.RankWarning` will be removed in NumPy 2.0. Use ` | = help: Replace with `numpy.exceptions.RankWarning` (requires NumPy 2.0 or greater) -ℹ Unsafe fix - 1 |+from numpy.exceptions import RankWarning -1 2 | def func(): -2 3 | import numpy as np -3 4 | --------------------------------------------------------------------------------- -5 6 | -6 7 | np.ModuleDeprecationWarning -7 8 | -8 |- np.RankWarning - 9 |+ RankWarning -9 10 | -10 11 | np.TooHardError -11 12 | NPY201_3.py:10:5: NPY201 [*] `np.TooHardError` will be removed in NumPy 2.0. Use `numpy.exceptions.TooHardError` instead. | @@ -84,7 +68,6 @@ NPY201_3.py:10:5: NPY201 [*] `np.TooHardError` will be removed in NumPy 2.0. Use | = help: Replace with `numpy.exceptions.TooHardError` -ℹ Safe fix 1 |+from numpy.exceptions import TooHardError 1 2 | def func(): 2 3 | import numpy as np @@ -110,7 +93,6 @@ NPY201_3.py:12:5: NPY201 [*] `np.VisibleDeprecationWarning` will be removed in N | = help: Replace with `numpy.exceptions.VisibleDeprecationWarning` -ℹ Safe fix 1 |+from numpy.exceptions import VisibleDeprecationWarning 1 2 | def func(): 2 3 | import numpy as np @@ -136,7 +118,6 @@ NPY201_3.py:14:5: NPY201 [*] `np.chararray` will be removed in NumPy 2.0. Use `n | = help: Replace with `numpy.char.chararray` -ℹ Safe fix 1 |+from numpy.char import chararray 1 2 | def func(): 2 3 | import numpy as np @@ -159,7 +140,6 @@ NPY201_3.py:16:5: NPY201 [*] `np.format_parser` will be removed in NumPy 2.0. Us | = help: Replace with `numpy.rec.format_parser` -ℹ Safe fix 1 |+from numpy.rec import format_parser 1 2 | def func(): 2 3 | import numpy as np diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD002_PD002.py.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD002_PD002.py.snap index 4b95a1c29a686..0d870e3d97df2 100644 --- a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD002_PD002.py.snap +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD002_PD002.py.snap @@ -12,15 +12,6 @@ PD002.py:5:23: PD002 [*] `inplace=True` should be avoided; it has inconsistent b | = help: Assign to variable; remove `inplace` arg -ℹ Unsafe fix -2 2 | -3 3 | x = pd.DataFrame() -4 4 | -5 |-x.drop(["a"], axis=1, inplace=True) - 5 |+x = x.drop(["a"], axis=1) -6 6 | -7 7 | x.y.drop(["a"], axis=1, inplace=True) -8 8 | PD002.py:7:25: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior | @@ -33,15 +24,6 @@ PD002.py:7:25: PD002 [*] `inplace=True` should be avoided; it has inconsistent b | = help: Assign to variable; remove `inplace` arg -ℹ Unsafe fix -4 4 | -5 5 | x.drop(["a"], axis=1, inplace=True) -6 6 | -7 |-x.y.drop(["a"], axis=1, inplace=True) - 7 |+x.y = x.y.drop(["a"], axis=1) -8 8 | -9 9 | x["y"].drop(["a"], axis=1, inplace=True) -10 10 | PD002.py:9:28: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior | @@ -54,15 +36,6 @@ PD002.py:9:28: PD002 [*] `inplace=True` should be avoided; it has inconsistent b | = help: Assign to variable; remove `inplace` arg -ℹ Unsafe fix -6 6 | -7 7 | x.y.drop(["a"], axis=1, inplace=True) -8 8 | -9 |-x["y"].drop(["a"], axis=1, inplace=True) - 9 |+x["y"] = x["y"].drop(["a"], axis=1) -10 10 | -11 11 | x.drop( -12 12 | inplace=True, PD002.py:12:5: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior | @@ -74,16 +47,6 @@ PD002.py:12:5: PD002 [*] `inplace=True` should be avoided; it has inconsistent b | = help: Assign to variable; remove `inplace` arg -ℹ Unsafe fix -8 8 | -9 9 | x["y"].drop(["a"], axis=1, inplace=True) -10 10 | -11 |-x.drop( -12 |- inplace=True, - 11 |+x = x.drop( -13 12 | columns=["a"], -14 13 | axis=1, -15 14 | ) PD002.py:19:9: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior | @@ -96,16 +59,6 @@ PD002.py:19:9: PD002 [*] `inplace=True` should be avoided; it has inconsistent b | = help: Assign to variable; remove `inplace` arg -ℹ Unsafe fix -15 15 | ) -16 16 | -17 17 | if True: -18 |- x.drop( -19 |- inplace=True, - 18 |+ x = x.drop( -20 19 | columns=["a"], -21 20 | axis=1, -22 21 | ) PD002.py:24:33: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior | @@ -118,15 +71,6 @@ PD002.py:24:33: PD002 [*] `inplace=True` should be avoided; it has inconsistent | = help: Assign to variable; remove `inplace` arg -ℹ Unsafe fix -21 21 | axis=1, -22 22 | ) -23 23 | -24 |-x.drop(["a"], axis=1, **kwargs, inplace=True) - 24 |+x = x.drop(["a"], axis=1, **kwargs) -25 25 | x.drop(["a"], axis=1, inplace=True, **kwargs) -26 26 | f(x.drop(["a"], axis=1, inplace=True)) -27 27 | PD002.py:25:23: PD002 `inplace=True` should be avoided; it has inconsistent behavior | @@ -168,15 +112,3 @@ PD002.py:33:24: PD002 [*] `inplace=True` should be avoided; it has inconsistent 35 | # This method doesn't take exist in Pandas, so ignore it. | = help: Assign to variable; remove `inplace` arg - -ℹ Unsafe fix -30 30 | -31 31 | torch.m.ReLU(inplace=True) # safe because this isn't a pandas call -32 32 | -33 |-(x.drop(["a"], axis=1, inplace=True)) - 33 |+x = (x.drop(["a"], axis=1)) -34 34 | -35 35 | # This method doesn't take exist in Pandas, so ignore it. -36 36 | x.rotate_z(45, inplace=True) - - diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD002_fail.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD002_fail.snap index f6335bd09177a..b0c143c7282bc 100644 --- a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD002_fail.snap +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD002_fail.snap @@ -9,12 +9,3 @@ source: crates/ruff_linter/src/rules/pandas_vet/mod.rs | ^^^^^^^^^^^^ PD002 | = help: Assign to variable; remove `inplace` arg - -ℹ Unsafe fix -1 1 | -2 2 | import pandas as pd -3 3 | x = pd.DataFrame() -4 |-x.drop(["a"], axis=1, inplace=True) - 4 |+x = x.drop(["a"], axis=1) - - diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N804_N804.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N804_N804.py.snap index ae7c7a8bc9c07..77934a65ee9e4 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N804_N804.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N804_N804.py.snap @@ -11,15 +11,6 @@ N804.py:30:27: N804 [*] First argument of a class method should be named `cls` | = help: Rename `self` to `cls` -ℹ Unsafe fix -27 27 | def __new__(cls, *args, **kwargs): -28 28 | ... -29 29 | -30 |- def __init_subclass__(self, default_name, **kwargs): - 30 |+ def __init_subclass__(cls, default_name, **kwargs): -31 31 | ... -32 32 | -33 33 | @classmethod N804.py:38:56: N804 [*] First argument of a class method should be named `cls` | @@ -30,15 +21,6 @@ N804.py:38:56: N804 [*] First argument of a class method should be named `cls` | = help: Rename `self` to `cls` -ℹ Unsafe fix -35 35 | ... -36 36 | -37 37 | @classmethod -38 |- def bad_class_method_with_positional_only_argument(self, x, /, other): - 38 |+ def bad_class_method_with_positional_only_argument(cls, x, /, other): -39 39 | ... -40 40 | -41 41 | N804.py:43:20: N804 [*] First argument of a class method should be named `cls` | @@ -49,15 +31,6 @@ N804.py:43:20: N804 [*] First argument of a class method should be named `cls` | = help: Rename `self` to `cls` -ℹ Unsafe fix -40 40 | -41 41 | -42 42 | class MetaClass(ABCMeta): -43 |- def bad_method(self): - 43 |+ def bad_method(cls): -44 44 | pass -45 45 | -46 46 | def good_method(cls): N804.py:54:25: N804 First argument of a class method should be named `cls` | @@ -118,19 +91,6 @@ N804.py:70:20: N804 [*] First argument of a class method should be named `cls` | = help: Rename `this` to `cls` -ℹ Unsafe fix -67 67 | pass -68 68 | -69 69 | class RenamingInMethodBodyClass(ABCMeta): -70 |- def bad_method(this): -71 |- this = this -72 |- this - 70 |+ def bad_method(cls): - 71 |+ cls = cls - 72 |+ cls -73 73 | -74 74 | def bad_method(this): -75 75 | self = this N804.py:74:20: N804 [*] First argument of a class method should be named `cls` | @@ -141,15 +101,3 @@ N804.py:74:20: N804 [*] First argument of a class method should be named `cls` 75 | self = this | = help: Rename `this` to `cls` - -ℹ Unsafe fix -71 71 | this = this -72 72 | this -73 73 | -74 |- def bad_method(this): -75 |- self = this - 74 |+ def bad_method(cls): - 75 |+ self = cls -76 76 | -77 77 | def func(x): -78 78 | return x diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N805_N805.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N805_N805.py.snap index dfc03bc7ba38e..68a7d3f1f2ebc 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N805_N805.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N805_N805.py.snap @@ -10,15 +10,6 @@ N805.py:7:20: N805 [*] First argument of a method should be named `self` | = help: Rename `this` to `self` -ℹ Unsafe fix -4 4 | -5 5 | -6 6 | class Class: -7 |- def bad_method(this): - 7 |+ def bad_method(self): -8 8 | pass -9 9 | -10 10 | if False: N805.py:11:30: N805 [*] First argument of a method should be named `self` | @@ -29,15 +20,6 @@ N805.py:11:30: N805 [*] First argument of a method should be named `self` | = help: Rename `this` to `self` -ℹ Unsafe fix -8 8 | pass -9 9 | -10 10 | if False: -11 |- def extra_bad_method(this): - 11 |+ def extra_bad_method(self): -12 12 | pass -13 13 | -14 14 | def good_method(self): N805.py:30:15: N805 [*] First argument of a method should be named `self` | @@ -48,15 +30,6 @@ N805.py:30:15: N805 [*] First argument of a method should be named `self` | = help: Rename `cls` to `self` -ℹ Unsafe fix -27 27 | return x -28 28 | -29 29 | @pydantic.validator -30 |- def lower(cls, my_field: str) -> str: - 30 |+ def lower(self, my_field: str) -> str: -31 31 | pass -32 32 | -33 33 | @pydantic.validator("my_field") N805.py:34:15: N805 [*] First argument of a method should be named `self` | @@ -67,15 +40,6 @@ N805.py:34:15: N805 [*] First argument of a method should be named `self` | = help: Rename `cls` to `self` -ℹ Unsafe fix -31 31 | pass -32 32 | -33 33 | @pydantic.validator("my_field") -34 |- def lower(cls, my_field: str) -> str: - 34 |+ def lower(self, my_field: str) -> str: -35 35 | pass -36 36 | -37 37 | def __init__(self): N805.py:63:29: N805 [*] First argument of a method should be named `self` | @@ -87,15 +51,6 @@ N805.py:63:29: N805 [*] First argument of a method should be named `self` | = help: Rename `this` to `self` -ℹ Unsafe fix -60 60 | def good_method_pos_only(self, blah, /, something: str): -61 61 | pass -62 62 | -63 |- def bad_method_pos_only(this, blah, /, something: str): - 63 |+ def bad_method_pos_only(self, blah, /, something: str): -64 64 | pass -65 65 | -66 66 | N805.py:69:13: N805 [*] First argument of a method should be named `self` | @@ -107,15 +62,6 @@ N805.py:69:13: N805 [*] First argument of a method should be named `self` | = help: Rename `cls` to `self` -ℹ Unsafe fix -66 66 | -67 67 | class ModelClass: -68 68 | @hybrid_property -69 |- def bad(cls): - 69 |+ def bad(self): -70 70 | pass -71 71 | -72 72 | @bad.expression N805.py:77:13: N805 [*] First argument of a method should be named `self` | @@ -126,15 +72,6 @@ N805.py:77:13: N805 [*] First argument of a method should be named `self` | = help: Rename `cls` to `self` -ℹ Unsafe fix -74 74 | pass -75 75 | -76 76 | @bad.wtf -77 |- def bad(cls): - 77 |+ def bad(self): -78 78 | pass -79 79 | -80 80 | @hybrid_property N805.py:85:14: N805 [*] First argument of a method should be named `self` | @@ -145,15 +82,6 @@ N805.py:85:14: N805 [*] First argument of a method should be named `self` | = help: Rename `cls` to `self` -ℹ Unsafe fix -82 82 | pass -83 83 | -84 84 | @good.expression -85 |- def good(cls): - 85 |+ def good(self): -86 86 | pass -87 87 | -88 88 | @good.wtf N805.py:93:19: N805 [*] First argument of a method should be named `self` | @@ -164,15 +92,6 @@ N805.py:93:19: N805 [*] First argument of a method should be named `self` | = help: Rename `foo` to `self` -ℹ Unsafe fix -90 90 | pass -91 91 | -92 92 | @foobar.thisisstatic -93 |- def badstatic(foo): - 93 |+ def badstatic(self): -94 94 | pass -95 95 | -96 96 | N805.py:98:26: N805 First argument of a method should be named `self` | @@ -233,19 +152,6 @@ N805.py:115:20: N805 [*] First argument of a method should be named `self` | = help: Rename `this` to `self` -ℹ Unsafe fix -112 112 | -113 113 | -114 114 | class RenamingInMethodBodyClass: -115 |- def bad_method(this): -116 |- this = this -117 |- this - 115 |+ def bad_method(self): - 116 |+ self = self - 117 |+ self -118 118 | -119 119 | def bad_method(this): -120 120 | self = this N805.py:119:20: N805 [*] First argument of a method should be named `self` | @@ -257,17 +163,6 @@ N805.py:119:20: N805 [*] First argument of a method should be named `self` | = help: Rename `this` to `self` -ℹ Unsafe fix -116 116 | this = this -117 117 | this -118 118 | -119 |- def bad_method(this): -120 |- self = this - 119 |+ def bad_method(self): - 120 |+ self = self -121 121 | -122 122 | -123 123 | class RenamingWithNFKC: N805.py:124:17: N805 [*] First argument of a method should be named `self` | @@ -277,12 +172,3 @@ N805.py:124:17: N805 [*] First argument of a method should be named `self` 125 | hºusehold(1) | = help: Rename `household` to `self` - -ℹ Unsafe fix -121 121 | -122 122 | -123 123 | class RenamingWithNFKC: -124 |- def formula(household): -125 |- hºusehold(1) - 124 |+ def formula(self): - 125 |+ self(1) diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__classmethod_decorators.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__classmethod_decorators.snap index 33143ab760a17..56471b288bf78 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__classmethod_decorators.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__classmethod_decorators.snap @@ -10,15 +10,6 @@ N805.py:7:20: N805 [*] First argument of a method should be named `self` | = help: Rename `this` to `self` -ℹ Unsafe fix -4 4 | -5 5 | -6 6 | class Class: -7 |- def bad_method(this): - 7 |+ def bad_method(self): -8 8 | pass -9 9 | -10 10 | if False: N805.py:11:30: N805 [*] First argument of a method should be named `self` | @@ -29,15 +20,6 @@ N805.py:11:30: N805 [*] First argument of a method should be named `self` | = help: Rename `this` to `self` -ℹ Unsafe fix -8 8 | pass -9 9 | -10 10 | if False: -11 |- def extra_bad_method(this): - 11 |+ def extra_bad_method(self): -12 12 | pass -13 13 | -14 14 | def good_method(self): N805.py:63:29: N805 [*] First argument of a method should be named `self` | @@ -49,15 +31,6 @@ N805.py:63:29: N805 [*] First argument of a method should be named `self` | = help: Rename `this` to `self` -ℹ Unsafe fix -60 60 | def good_method_pos_only(self, blah, /, something: str): -61 61 | pass -62 62 | -63 |- def bad_method_pos_only(this, blah, /, something: str): - 63 |+ def bad_method_pos_only(self, blah, /, something: str): -64 64 | pass -65 65 | -66 66 | N805.py:69:13: N805 [*] First argument of a method should be named `self` | @@ -69,15 +42,6 @@ N805.py:69:13: N805 [*] First argument of a method should be named `self` | = help: Rename `cls` to `self` -ℹ Unsafe fix -66 66 | -67 67 | class ModelClass: -68 68 | @hybrid_property -69 |- def bad(cls): - 69 |+ def bad(self): -70 70 | pass -71 71 | -72 72 | @bad.expression N805.py:77:13: N805 [*] First argument of a method should be named `self` | @@ -88,15 +52,6 @@ N805.py:77:13: N805 [*] First argument of a method should be named `self` | = help: Rename `cls` to `self` -ℹ Unsafe fix -74 74 | pass -75 75 | -76 76 | @bad.wtf -77 |- def bad(cls): - 77 |+ def bad(self): -78 78 | pass -79 79 | -80 80 | @hybrid_property N805.py:93:19: N805 [*] First argument of a method should be named `self` | @@ -107,15 +62,6 @@ N805.py:93:19: N805 [*] First argument of a method should be named `self` | = help: Rename `foo` to `self` -ℹ Unsafe fix -90 90 | pass -91 91 | -92 92 | @foobar.thisisstatic -93 |- def badstatic(foo): - 93 |+ def badstatic(self): -94 94 | pass -95 95 | -96 96 | N805.py:98:26: N805 First argument of a method should be named `self` | @@ -176,19 +122,6 @@ N805.py:115:20: N805 [*] First argument of a method should be named `self` | = help: Rename `this` to `self` -ℹ Unsafe fix -112 112 | -113 113 | -114 114 | class RenamingInMethodBodyClass: -115 |- def bad_method(this): -116 |- this = this -117 |- this - 115 |+ def bad_method(self): - 116 |+ self = self - 117 |+ self -118 118 | -119 119 | def bad_method(this): -120 120 | self = this N805.py:119:20: N805 [*] First argument of a method should be named `self` | @@ -200,17 +133,6 @@ N805.py:119:20: N805 [*] First argument of a method should be named `self` | = help: Rename `this` to `self` -ℹ Unsafe fix -116 116 | this = this -117 117 | this -118 118 | -119 |- def bad_method(this): -120 |- self = this - 119 |+ def bad_method(self): - 120 |+ self = self -121 121 | -122 122 | -123 123 | class RenamingWithNFKC: N805.py:124:17: N805 [*] First argument of a method should be named `self` | @@ -220,12 +142,3 @@ N805.py:124:17: N805 [*] First argument of a method should be named `self` 125 | hºusehold(1) | = help: Rename `household` to `self` - -ℹ Unsafe fix -121 121 | -122 122 | -123 123 | class RenamingWithNFKC: -124 |- def formula(household): -125 |- hºusehold(1) - 124 |+ def formula(self): - 125 |+ self(1) diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N804_N804.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N804_N804.py.snap index 678a2358c49ed..f3eb234d5687e 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N804_N804.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N804_N804.py.snap @@ -10,15 +10,6 @@ N804.py:5:27: N804 [*] First argument of a class method should be named `cls` | = help: Rename `self` to `cls` -ℹ Unsafe fix -2 2 | -3 3 | -4 4 | class Class: -5 |- def __init_subclass__(self, default_name, **kwargs): - 5 |+ def __init_subclass__(cls, default_name, **kwargs): -6 6 | ... -7 7 | -8 8 | @classmethod N804.py:9:20: N804 [*] First argument of a class method should be named `cls` | @@ -29,15 +20,6 @@ N804.py:9:20: N804 [*] First argument of a class method should be named `cls` | = help: Rename `self` to `cls` -ℹ Unsafe fix -6 6 | ... -7 7 | -8 8 | @classmethod -9 |- def badAllowed(self, x, /, other): - 9 |+ def badAllowed(cls, x, /, other): -10 10 | ... -11 11 | -12 12 | @classmethod N804.py:13:18: N804 [*] First argument of a class method should be named `cls` | @@ -48,15 +30,6 @@ N804.py:13:18: N804 [*] First argument of a class method should be named `cls` | = help: Rename `self` to `cls` -ℹ Unsafe fix -10 10 | ... -11 11 | -12 12 | @classmethod -13 |- def stillBad(self, x, /, other): - 13 |+ def stillBad(cls, x, /, other): -14 14 | ... -15 15 | -16 16 | N804.py:18:20: N804 [*] First argument of a class method should be named `cls` | @@ -67,15 +40,6 @@ N804.py:18:20: N804 [*] First argument of a class method should be named `cls` | = help: Rename `self` to `cls` -ℹ Unsafe fix -15 15 | -16 16 | -17 17 | class MetaClass(ABCMeta): -18 |- def badAllowed(self): - 18 |+ def badAllowed(cls): -19 19 | pass -20 20 | -21 21 | def stillBad(self): N804.py:21:18: N804 [*] First argument of a class method should be named `cls` | @@ -86,11 +50,3 @@ N804.py:21:18: N804 [*] First argument of a class method should be named `cls` 22 | pass | = help: Rename `self` to `cls` - -ℹ Unsafe fix -18 18 | def badAllowed(self): -19 19 | pass -20 20 | -21 |- def stillBad(self): - 21 |+ def stillBad(cls): -22 22 | pass diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N805_N805.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N805_N805.py.snap index 0d5d100f42e22..373381cb56898 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N805_N805.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N805_N805.py.snap @@ -10,15 +10,6 @@ N805.py:7:20: N805 [*] First argument of a method should be named `self` | = help: Rename `this` to `self` -ℹ Unsafe fix -4 4 | -5 5 | -6 6 | class Class: -7 |- def badAllowed(this): - 7 |+ def badAllowed(self): -8 8 | pass -9 9 | -10 10 | def stillBad(this): N805.py:10:18: N805 [*] First argument of a method should be named `self` | @@ -30,15 +21,6 @@ N805.py:10:18: N805 [*] First argument of a method should be named `self` | = help: Rename `this` to `self` -ℹ Unsafe fix -7 7 | def badAllowed(this): -8 8 | pass -9 9 | -10 |- def stillBad(this): - 10 |+ def stillBad(self): -11 11 | pass -12 12 | -13 13 | if False: N805.py:15:24: N805 [*] First argument of a method should be named `self` | @@ -50,15 +32,6 @@ N805.py:15:24: N805 [*] First argument of a method should be named `self` | = help: Rename `this` to `self` -ℹ Unsafe fix -12 12 | -13 13 | if False: -14 14 | -15 |- def badAllowed(this): - 15 |+ def badAllowed(self): -16 16 | pass -17 17 | -18 18 | def stillBad(this): N805.py:18:22: N805 [*] First argument of a method should be named `self` | @@ -70,15 +43,6 @@ N805.py:18:22: N805 [*] First argument of a method should be named `self` | = help: Rename `this` to `self` -ℹ Unsafe fix -15 15 | def badAllowed(this): -16 16 | pass -17 17 | -18 |- def stillBad(this): - 18 |+ def stillBad(self): -19 19 | pass -20 20 | -21 21 | @pydantic.validator N805.py:22:20: N805 [*] First argument of a method should be named `self` | @@ -89,15 +53,6 @@ N805.py:22:20: N805 [*] First argument of a method should be named `self` | = help: Rename `cls` to `self` -ℹ Unsafe fix -19 19 | pass -20 20 | -21 21 | @pydantic.validator -22 |- def badAllowed(cls, my_field: str) -> str: - 22 |+ def badAllowed(self, my_field: str) -> str: -23 23 | pass -24 24 | -25 25 | @pydantic.validator N805.py:26:18: N805 [*] First argument of a method should be named `self` | @@ -108,15 +63,6 @@ N805.py:26:18: N805 [*] First argument of a method should be named `self` | = help: Rename `cls` to `self` -ℹ Unsafe fix -23 23 | pass -24 24 | -25 25 | @pydantic.validator -26 |- def stillBad(cls, my_field: str) -> str: - 26 |+ def stillBad(self, my_field: str) -> str: -27 27 | pass -28 28 | -29 29 | @pydantic.validator("my_field") N805.py:30:20: N805 [*] First argument of a method should be named `self` | @@ -127,15 +73,6 @@ N805.py:30:20: N805 [*] First argument of a method should be named `self` | = help: Rename `cls` to `self` -ℹ Unsafe fix -27 27 | pass -28 28 | -29 29 | @pydantic.validator("my_field") -30 |- def badAllowed(cls, my_field: str) -> str: - 30 |+ def badAllowed(self, my_field: str) -> str: -31 31 | pass -32 32 | -33 33 | @pydantic.validator("my_field") N805.py:34:18: N805 [*] First argument of a method should be named `self` | @@ -146,15 +83,6 @@ N805.py:34:18: N805 [*] First argument of a method should be named `self` | = help: Rename `cls` to `self` -ℹ Unsafe fix -31 31 | pass -32 32 | -33 33 | @pydantic.validator("my_field") -34 |- def stillBad(cls, my_field: str) -> str: - 34 |+ def stillBad(self, my_field: str) -> str: -35 35 | pass -36 36 | -37 37 | @classmethod N805.py:55:20: N805 First argument of a method should be named `self` | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__staticmethod_decorators.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__staticmethod_decorators.snap index cac0d909d994e..3be135c82984c 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__staticmethod_decorators.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__staticmethod_decorators.snap @@ -10,15 +10,6 @@ N805.py:7:20: N805 [*] First argument of a method should be named `self` | = help: Rename `this` to `self` -ℹ Unsafe fix -4 4 | -5 5 | -6 6 | class Class: -7 |- def bad_method(this): - 7 |+ def bad_method(self): -8 8 | pass -9 9 | -10 10 | if False: N805.py:11:30: N805 [*] First argument of a method should be named `self` | @@ -29,15 +20,6 @@ N805.py:11:30: N805 [*] First argument of a method should be named `self` | = help: Rename `this` to `self` -ℹ Unsafe fix -8 8 | pass -9 9 | -10 10 | if False: -11 |- def extra_bad_method(this): - 11 |+ def extra_bad_method(self): -12 12 | pass -13 13 | -14 14 | def good_method(self): N805.py:30:15: N805 [*] First argument of a method should be named `self` | @@ -48,15 +30,6 @@ N805.py:30:15: N805 [*] First argument of a method should be named `self` | = help: Rename `cls` to `self` -ℹ Unsafe fix -27 27 | return x -28 28 | -29 29 | @pydantic.validator -30 |- def lower(cls, my_field: str) -> str: - 30 |+ def lower(self, my_field: str) -> str: -31 31 | pass -32 32 | -33 33 | @pydantic.validator("my_field") N805.py:34:15: N805 [*] First argument of a method should be named `self` | @@ -67,15 +40,6 @@ N805.py:34:15: N805 [*] First argument of a method should be named `self` | = help: Rename `cls` to `self` -ℹ Unsafe fix -31 31 | pass -32 32 | -33 33 | @pydantic.validator("my_field") -34 |- def lower(cls, my_field: str) -> str: - 34 |+ def lower(self, my_field: str) -> str: -35 35 | pass -36 36 | -37 37 | def __init__(self): N805.py:63:29: N805 [*] First argument of a method should be named `self` | @@ -87,15 +51,6 @@ N805.py:63:29: N805 [*] First argument of a method should be named `self` | = help: Rename `this` to `self` -ℹ Unsafe fix -60 60 | def good_method_pos_only(self, blah, /, something: str): -61 61 | pass -62 62 | -63 |- def bad_method_pos_only(this, blah, /, something: str): - 63 |+ def bad_method_pos_only(self, blah, /, something: str): -64 64 | pass -65 65 | -66 66 | N805.py:69:13: N805 [*] First argument of a method should be named `self` | @@ -107,15 +62,6 @@ N805.py:69:13: N805 [*] First argument of a method should be named `self` | = help: Rename `cls` to `self` -ℹ Unsafe fix -66 66 | -67 67 | class ModelClass: -68 68 | @hybrid_property -69 |- def bad(cls): - 69 |+ def bad(self): -70 70 | pass -71 71 | -72 72 | @bad.expression N805.py:77:13: N805 [*] First argument of a method should be named `self` | @@ -126,15 +72,6 @@ N805.py:77:13: N805 [*] First argument of a method should be named `self` | = help: Rename `cls` to `self` -ℹ Unsafe fix -74 74 | pass -75 75 | -76 76 | @bad.wtf -77 |- def bad(cls): - 77 |+ def bad(self): -78 78 | pass -79 79 | -80 80 | @hybrid_property N805.py:85:14: N805 [*] First argument of a method should be named `self` | @@ -145,15 +82,6 @@ N805.py:85:14: N805 [*] First argument of a method should be named `self` | = help: Rename `cls` to `self` -ℹ Unsafe fix -82 82 | pass -83 83 | -84 84 | @good.expression -85 |- def good(cls): - 85 |+ def good(self): -86 86 | pass -87 87 | -88 88 | @good.wtf N805.py:98:26: N805 First argument of a method should be named `self` | @@ -214,19 +142,6 @@ N805.py:115:20: N805 [*] First argument of a method should be named `self` | = help: Rename `this` to `self` -ℹ Unsafe fix -112 112 | -113 113 | -114 114 | class RenamingInMethodBodyClass: -115 |- def bad_method(this): -116 |- this = this -117 |- this - 115 |+ def bad_method(self): - 116 |+ self = self - 117 |+ self -118 118 | -119 119 | def bad_method(this): -120 120 | self = this N805.py:119:20: N805 [*] First argument of a method should be named `self` | @@ -238,17 +153,6 @@ N805.py:119:20: N805 [*] First argument of a method should be named `self` | = help: Rename `this` to `self` -ℹ Unsafe fix -116 116 | this = this -117 117 | this -118 118 | -119 |- def bad_method(this): -120 |- self = this - 119 |+ def bad_method(self): - 120 |+ self = self -121 121 | -122 122 | -123 123 | class RenamingWithNFKC: N805.py:124:17: N805 [*] First argument of a method should be named `self` | @@ -258,12 +162,3 @@ N805.py:124:17: N805 [*] First argument of a method should be named `self` 125 | hºusehold(1) | = help: Rename `household` to `self` - -ℹ Unsafe fix -121 121 | -122 122 | -123 123 | class RenamingWithNFKC: -124 |- def formula(household): -125 |- hºusehold(1) - 124 |+ def formula(self): - 125 |+ self(1) diff --git a/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF101_PERF101.py.snap b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF101_PERF101.py.snap index bf33ecd3e3457..5335ea781f005 100644 --- a/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF101_PERF101.py.snap +++ b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF101_PERF101.py.snap @@ -11,7 +11,6 @@ PERF101.py:7:10: PERF101 [*] Do not cast an iterable to `list` before iterating | = help: Remove `list()` cast -ℹ Safe fix 4 4 | foo_dict = {1: 2, 3: 4} 5 5 | foo_int = 123 6 6 | @@ -31,7 +30,6 @@ PERF101.py:10:10: PERF101 [*] Do not cast an iterable to `list` before iterating | = help: Remove `list()` cast -ℹ Safe fix 7 7 | for i in list(foo_tuple): # PERF101 8 8 | pass 9 9 | @@ -51,7 +49,6 @@ PERF101.py:13:10: PERF101 [*] Do not cast an iterable to `list` before iterating | = help: Remove `list()` cast -ℹ Safe fix 10 10 | for i in list(foo_list): # PERF101 11 11 | pass 12 12 | @@ -71,7 +68,6 @@ PERF101.py:16:10: PERF101 [*] Do not cast an iterable to `list` before iterating | = help: Remove `list()` cast -ℹ Safe fix 13 13 | for i in list(foo_set): # PERF101 14 14 | pass 15 15 | @@ -91,7 +87,6 @@ PERF101.py:19:10: PERF101 [*] Do not cast an iterable to `list` before iterating | = help: Remove `list()` cast -ℹ Safe fix 16 16 | for i in list((1, 2, 3)): # PERF101 17 17 | pass 18 18 | @@ -111,7 +106,6 @@ PERF101.py:22:10: PERF101 [*] Do not cast an iterable to `list` before iterating | = help: Remove `list()` cast -ℹ Safe fix 19 19 | for i in list([1, 2, 3]): # PERF101 20 20 | pass 21 21 | @@ -138,7 +132,6 @@ PERF101.py:25:10: PERF101 [*] Do not cast an iterable to `list` before iterating | = help: Remove `list()` cast -ℹ Safe fix 22 22 | for i in list({1, 2, 3}): # PERF101 23 23 | pass 24 24 | @@ -168,7 +161,6 @@ PERF101.py:34:10: PERF101 [*] Do not cast an iterable to `list` before iterating | = help: Remove `list()` cast -ℹ Safe fix 31 31 | ): 32 32 | pass 33 33 | @@ -191,7 +183,6 @@ PERF101.py:57:10: PERF101 [*] Do not cast an iterable to `list` before iterating | = help: Remove `list()` cast -ℹ Safe fix 54 54 | for i in list(foo_list): # OK 55 55 | foo_list.append(i + 1) 56 56 | @@ -211,7 +202,6 @@ PERF101.py:69:10: PERF101 [*] Do not cast an iterable to `list` before iterating | = help: Remove `list()` cast -ℹ Safe fix 66 66 | 67 67 | x, y, nested_tuple = (1, 2, (3, 4, 5)) 68 68 | @@ -231,7 +221,6 @@ PERF101.py:86:10: PERF101 [*] Do not cast an iterable to `list` before iterating | = help: Remove `list()` cast -ℹ Safe fix 83 83 | 84 84 | import builtins 85 85 | diff --git a/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF102_PERF102.py.snap b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF102_PERF102.py.snap index f572521714595..95a75793474ff 100644 --- a/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF102_PERF102.py.snap +++ b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF102_PERF102.py.snap @@ -10,15 +10,6 @@ PERF102.py:5:21: PERF102 [*] When using only the values of a dict use the `value | = help: Replace `.items()` with `.values()` -ℹ Unsafe fix -2 2 | -3 3 | -4 4 | def f(): -5 |- for _, value in some_dict.items(): # PERF102 - 5 |+ for value in some_dict.values(): # PERF102 -6 6 | print(value) -7 7 | -8 8 | PERF102.py:10:19: PERF102 [*] When using only the keys of a dict use the `keys()` method | @@ -29,15 +20,6 @@ PERF102.py:10:19: PERF102 [*] When using only the keys of a dict use the `keys() | = help: Replace `.items()` with `.keys()` -ℹ Unsafe fix -7 7 | -8 8 | -9 9 | def f(): -10 |- for key, _ in some_dict.items(): # PERF102 - 10 |+ for key in some_dict.keys(): # PERF102 -11 11 | print(key) -12 12 | -13 13 | PERF102.py:15:30: PERF102 [*] When using only the keys of a dict use the `keys()` method | @@ -48,15 +30,6 @@ PERF102.py:15:30: PERF102 [*] When using only the keys of a dict use the `keys() | = help: Replace `.items()` with `.keys()` -ℹ Unsafe fix -12 12 | -13 13 | -14 14 | def f(): -15 |- for weird_arg_name, _ in some_dict.items(): # PERF102 - 15 |+ for weird_arg_name in some_dict.keys(): # PERF102 -16 16 | print(weird_arg_name) -17 17 | -18 18 | PERF102.py:20:25: PERF102 [*] When using only the keys of a dict use the `keys()` method | @@ -67,15 +40,6 @@ PERF102.py:20:25: PERF102 [*] When using only the keys of a dict use the `keys() | = help: Replace `.items()` with `.keys()` -ℹ Unsafe fix -17 17 | -18 18 | -19 19 | def f(): -20 |- for name, (_, _) in some_dict.items(): # PERF102 - 20 |+ for name in some_dict.keys(): # PERF102 -21 21 | print(name) -22 22 | -23 23 | PERF102.py:30:30: PERF102 [*] When using only the keys of a dict use the `keys()` method | @@ -86,15 +50,6 @@ PERF102.py:30:30: PERF102 [*] When using only the keys of a dict use the `keys() | = help: Replace `.items()` with `.keys()` -ℹ Unsafe fix -27 27 | -28 28 | -29 29 | def f(): -30 |- for (key1, _), (_, _) in some_dict.items(): # PERF102 - 30 |+ for (key1, _) in some_dict.keys(): # PERF102 -31 31 | print(key1) -32 32 | -33 33 | PERF102.py:35:36: PERF102 [*] When using only the values of a dict use the `values()` method | @@ -105,15 +60,6 @@ PERF102.py:35:36: PERF102 [*] When using only the values of a dict use the `valu | = help: Replace `.items()` with `.values()` -ℹ Unsafe fix -32 32 | -33 33 | -34 34 | def f(): -35 |- for (_, (_, _)), (value, _) in some_dict.items(): # PERF102 - 35 |+ for (value, _) in some_dict.values(): # PERF102 -36 36 | print(value) -37 37 | -38 38 | PERF102.py:50:32: PERF102 [*] When using only the keys of a dict use the `keys()` method | @@ -124,15 +70,6 @@ PERF102.py:50:32: PERF102 [*] When using only the keys of a dict use the `keys() | = help: Replace `.items()` with `.keys()` -ℹ Unsafe fix -47 47 | -48 48 | -49 49 | def f(): -50 |- for ((_, key2), (_, _)) in some_dict.items(): # PERF102 - 50 |+ for (_, key2) in some_dict.keys(): # PERF102 -51 51 | print(key2) -52 52 | -53 53 | PERF102.py:85:25: PERF102 [*] When using only the keys of a dict use the `keys()` method | @@ -143,15 +80,6 @@ PERF102.py:85:25: PERF102 [*] When using only the keys of a dict use the `keys() | = help: Replace `.items()` with `.keys()` -ℹ Unsafe fix -82 82 | -83 83 | -84 84 | def f(): -85 |- for name, (_, _) in (some_function()).items(): # PERF102 - 85 |+ for name in (some_function()).keys(): # PERF102 -86 86 | print(name) -87 87 | -88 88 | PERF102.py:90:25: PERF102 [*] When using only the keys of a dict use the `keys()` method | @@ -162,15 +90,6 @@ PERF102.py:90:25: PERF102 [*] When using only the keys of a dict use the `keys() | = help: Replace `.items()` with `.keys()` -ℹ Unsafe fix -87 87 | -88 88 | -89 89 | def f(): -90 |- for name, (_, _) in (some_function().some_attribute).items(): # PERF102 - 90 |+ for name in (some_function().some_attribute).keys(): # PERF102 -91 91 | print(name) -92 92 | -93 93 | PERF102.py:95:31: PERF102 [*] When using only the keys of a dict use the `keys()` method | @@ -181,15 +100,6 @@ PERF102.py:95:31: PERF102 [*] When using only the keys of a dict use the `keys() | = help: Replace `.items()` with `.keys()` -ℹ Unsafe fix -92 92 | -93 93 | -94 94 | def f(): -95 |- for name, unused_value in some_dict.items(): # PERF102 - 95 |+ for name in some_dict.keys(): # PERF102 -96 96 | print(name) -97 97 | -98 98 | PERF102.py:100:31: PERF102 [*] When using only the values of a dict use the `values()` method | @@ -200,15 +110,6 @@ PERF102.py:100:31: PERF102 [*] When using only the values of a dict use the `val | = help: Replace `.items()` with `.values()` -ℹ Unsafe fix -97 97 | -98 98 | -99 99 | def f(): -100 |- for unused_name, value in some_dict.items(): # PERF102 - 100 |+ for value in some_dict.values(): # PERF102 -101 101 | print(value) -102 102 | -103 103 | PERF102.py:106:16: PERF102 [*] When using only the keys of a dict use the `keys()` method | @@ -219,13 +120,3 @@ PERF102.py:106:16: PERF102 [*] When using only the keys of a dict use the `keys( 107 | if(C:=name_to_value.get(B.name)):A.run(B.set,C) | = help: Replace `.items()` with `.keys()` - -ℹ Unsafe fix -103 103 | -104 104 | # Regression test for: https://github.com/astral-sh/ruff/issues/7097 -105 105 | def _create_context(name_to_value): -106 |- for(B,D)in A.items(): - 106 |+ for B in A.keys(): -107 107 | if(C:=name_to_value.get(B.name)):A.run(B.set,C) - - diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E201_E20.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E201_E20.py.snap index 4d0dbb264503b..9d839f41a5244 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E201_E20.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E201_E20.py.snap @@ -11,7 +11,6 @@ E20.py:2:6: E201 [*] Whitespace after '(' | = help: Remove whitespace before '(' -ℹ Safe fix 1 1 | #: E201:1:6 2 |-spam( ham[1], {eggs: 2}) 2 |+spam(ham[1], {eggs: 2}) @@ -30,7 +29,6 @@ E20.py:4:10: E201 [*] Whitespace after '[' | = help: Remove whitespace before '[' -ℹ Safe fix 1 1 | #: E201:1:6 2 2 | spam( ham[1], {eggs: 2}) 3 3 | #: E201:1:10 @@ -51,7 +49,6 @@ E20.py:6:15: E201 [*] Whitespace after '{' | = help: Remove whitespace before '{' -ℹ Safe fix 3 3 | #: E201:1:10 4 4 | spam(ham[ 1], {eggs: 2}) 5 5 | #: E201:1:15 @@ -72,7 +69,6 @@ E20.py:8:6: E201 [*] Whitespace after '(' | = help: Remove whitespace before '(' -ℹ Safe fix 5 5 | #: E201:1:15 6 6 | spam(ham[1], { eggs: 2}) 7 7 | #: E201:1:6 @@ -93,7 +89,6 @@ E20.py:10:10: E201 [*] Whitespace after '[' | = help: Remove whitespace before '[' -ℹ Safe fix 7 7 | #: E201:1:6 8 8 | spam( ham[1], {eggs: 2}) 9 9 | #: E201:1:10 @@ -114,7 +109,6 @@ E20.py:12:15: E201 [*] Whitespace after '{' | = help: Remove whitespace before '{' -ℹ Safe fix 9 9 | #: E201:1:10 10 10 | spam(ham[ 1], {eggs: 2}) 11 11 | #: E201:1:15 @@ -134,7 +128,6 @@ E20.py:107:6: E201 [*] Whitespace after '[' | = help: Remove whitespace before '[' -ℹ Safe fix 104 104 | #: 105 105 | 106 106 | #: E201:1:6 @@ -154,7 +147,6 @@ E20.py:116:5: E201 [*] Whitespace after '[' | = help: Remove whitespace before '[' -ℹ Safe fix 113 113 | 114 114 | # F-strings 115 115 | f"{ {'a': 1} }" @@ -174,7 +166,6 @@ E20.py:145:5: E201 [*] Whitespace after '[' | = help: Remove whitespace before '[' -ℹ Safe fix 142 142 | ham[lower + offset : upper + offset] 143 143 | 144 144 | #: E201:1:5 diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E202_E20.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E202_E20.py.snap index d4044ba4a51e2..aee5ecbbeb364 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E202_E20.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E202_E20.py.snap @@ -11,7 +11,6 @@ E20.py:19:23: E202 [*] Whitespace before ')' | = help: Remove whitespace before ')' -ℹ Safe fix 16 16 | 17 17 | 18 18 | #: E202:1:23 @@ -32,7 +31,6 @@ E20.py:21:22: E202 [*] Whitespace before '}' | = help: Remove whitespace before '}' -ℹ Safe fix 18 18 | #: E202:1:23 19 19 | spam(ham[1], {eggs: 2} ) 20 20 | #: E202:1:22 @@ -53,7 +51,6 @@ E20.py:23:11: E202 [*] Whitespace before ']' | = help: Remove whitespace before ']' -ℹ Safe fix 20 20 | #: E202:1:22 21 21 | spam(ham[1], {eggs: 2 }) 22 22 | #: E202:1:11 @@ -74,7 +71,6 @@ E20.py:25:23: E202 [*] Whitespace before ')' | = help: Remove whitespace before ')' -ℹ Safe fix 22 22 | #: E202:1:11 23 23 | spam(ham[1 ], {eggs: 2}) 24 24 | #: E202:1:23 @@ -95,7 +91,6 @@ E20.py:27:22: E202 [*] Whitespace before '}' | = help: Remove whitespace before '}' -ℹ Safe fix 24 24 | #: E202:1:23 25 25 | spam(ham[1], {eggs: 2} ) 26 26 | #: E202:1:22 @@ -116,7 +111,6 @@ E20.py:29:11: E202 [*] Whitespace before ']' | = help: Remove whitespace before ']' -ℹ Safe fix 26 26 | #: E202:1:22 27 27 | spam(ham[1], {eggs: 2 }) 28 28 | #: E202:1:11 @@ -136,7 +130,6 @@ E20.py:116:18: E202 [*] Whitespace before ']' | = help: Remove whitespace before ']' -ℹ Safe fix 113 113 | 114 114 | # F-strings 115 115 | f"{ {'a': 1} }" @@ -156,7 +149,6 @@ E20.py:172:12: E202 [*] Whitespace before ']' | = help: Remove whitespace before ']' -ℹ Safe fix 169 169 | ham[upper :] 170 170 | 171 171 | #: E202:1:12 diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E203_E20.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E203_E20.py.snap index 7422f4309a74f..80efcd4c1b457 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E203_E20.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E203_E20.py.snap @@ -11,7 +11,6 @@ E20.py:51:10: E203 [*] Whitespace before ':' | = help: Remove whitespace before ':' -ℹ Safe fix 48 48 | 49 49 | 50 50 | #: E203:1:10 @@ -32,7 +31,6 @@ E20.py:55:10: E203 [*] Whitespace before ':' | = help: Remove whitespace before ':' -ℹ Safe fix 52 52 | print(x, y) 53 53 | x, y = y, x 54 54 | #: E203:1:10 @@ -53,7 +51,6 @@ E20.py:60:16: E203 [*] Whitespace before ';' | = help: Remove whitespace before ';' -ℹ Safe fix 57 57 | x, y = y, x 58 58 | #: E203:2:15 E702:2:16 59 59 | if x == 4: @@ -74,7 +71,6 @@ E20.py:63:16: E203 [*] Whitespace before ';' | = help: Remove whitespace before ';' -ℹ Safe fix 60 60 | print(x, y) ; x, y = y, x 61 61 | #: E203:2:15 E702:2:16 62 62 | if x == 4: @@ -95,7 +91,6 @@ E20.py:67:13: E203 [*] Whitespace before ',' | = help: Remove whitespace before ',' -ℹ Safe fix 64 64 | #: E203:3:13 65 65 | if x == 4: 66 66 | print(x, y) @@ -116,7 +111,6 @@ E20.py:71:13: E203 [*] Whitespace before ',' | = help: Remove whitespace before ',' -ℹ Safe fix 68 68 | #: E203:3:13 69 69 | if x == 4: 70 70 | print(x, y) @@ -136,7 +130,6 @@ E20.py:86:61: E203 [*] Whitespace before ':' | = help: Remove whitespace before ':' -ℹ Safe fix 83 83 | 84 84 | #: E203 multi whitespace before : 85 85 | predictions = predictions[ @@ -156,7 +149,6 @@ E20.py:91:61: E203 [*] Whitespace before ':' | = help: Remove whitespace before ':' -ℹ Safe fix 88 88 | 89 89 | #: E203 tab before : 90 90 | predictions = predictions[ @@ -176,7 +168,6 @@ E20.py:101:61: E203 [*] Whitespace before ':' | = help: Remove whitespace before ':' -ℹ Safe fix 98 98 | 99 99 | #: E203 multi whitespace before : with line a comment 100 100 | predictions = predictions[ @@ -196,7 +187,6 @@ E20.py:126:16: E203 [*] Whitespace before ':' | = help: Remove whitespace before ':' -ℹ Safe fix 123 123 | ham[(lower + offset) : upper + offset] 124 124 | 125 125 | #: E203:1:19 @@ -216,7 +206,6 @@ E20.py:129:19: E203 [*] Whitespace before ':' | = help: Remove whitespace before ':' -ℹ Safe fix 126 126 | {lower + offset : upper + offset} 127 127 | 128 128 | #: E203:1:19 @@ -236,7 +225,6 @@ E20.py:157:21: E203 [*] Whitespace before ':' | = help: Remove whitespace before ':' -ℹ Safe fix 154 154 | ham[lower + offset::upper + offset] 155 155 | 156 156 | #: E203:1:21 @@ -256,7 +244,6 @@ E20.py:160:20: E203 [*] Whitespace before ':' | = help: Remove whitespace before ':' -ℹ Safe fix 157 157 | ham[lower + offset : : upper + offset] 158 158 | 159 159 | #: E203:1:20 @@ -276,7 +263,6 @@ E20.py:163:20: E203 [*] Whitespace before ':' | = help: Remove whitespace before ':' -ℹ Safe fix 160 160 | ham[lower + offset: :upper + offset] 161 161 | 162 162 | #: E203:1:20 @@ -296,7 +282,6 @@ E20.py:175:10: E203 [*] Whitespace before ':' | = help: Remove whitespace before ':' -ℹ Safe fix 172 172 | ham[upper : ] 173 173 | 174 174 | #: E203:1:10 @@ -316,7 +301,6 @@ E20.py:181:14: E203 [*] Whitespace before ':' | = help: Remove whitespace before ':' -ℹ Safe fix 178 178 | ham[lower +1 :, "columnname"] 179 179 | 180 180 | #: E203:1:13 @@ -336,7 +320,6 @@ E20.py:187:17: E203 [*] Whitespace before ':' | = help: Remove whitespace before ':' -ℹ Safe fix 184 184 | f"{ham[lower +1 :, "columnname"]}" 185 185 | 186 186 | #: E203:1:13 diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E204_E204.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E204_E204.py.snap index 050562950c21b..47831346a488b 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E204_E204.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E204_E204.py.snap @@ -11,7 +11,6 @@ E204.py:14:2: E204 [*] Whitespace after decorator | = help: Remove whitespace -ℹ Safe fix 11 11 | print('bar') 12 12 | 13 13 | # E204 @@ -31,7 +30,6 @@ E204.py:25:6: E204 [*] Whitespace after decorator | = help: Remove whitespace -ℹ Safe fix 22 22 | print('bar') 23 23 | 24 24 | # E204 @@ -53,7 +51,6 @@ E204.py:31:2: E204 [*] Whitespace after decorator | = help: Remove whitespace -ℹ Safe fix 28 28 | 29 29 | 30 30 | # E204 diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E211_E21.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E211_E21.py.snap index 6c115b53c2636..5789f176b07e4 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E211_E21.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E211_E21.py.snap @@ -11,7 +11,6 @@ E21.py:2:5: E211 [*] Whitespace before '(' | = help: Removed whitespace before '(' -ℹ Safe fix 1 1 | #: E211 2 |-spam (1) 2 |+spam(1) @@ -30,7 +29,6 @@ E21.py:4:5: E211 [*] Whitespace before '[' | = help: Removed whitespace before '[' -ℹ Safe fix 1 1 | #: E211 2 2 | spam (1) 3 3 | #: E211 E211 @@ -51,7 +49,6 @@ E21.py:4:20: E211 [*] Whitespace before '[' | = help: Removed whitespace before '[' -ℹ Safe fix 1 1 | #: E211 2 2 | spam (1) 3 3 | #: E211 E211 @@ -72,7 +69,6 @@ E21.py:6:12: E211 [*] Whitespace before '[' | = help: Removed whitespace before '[' -ℹ Safe fix 3 3 | #: E211 E211 4 4 | dict ['key'] = list [index] 5 5 | #: E211 @@ -90,7 +86,6 @@ E21.py:17:15: E211 [*] Whitespace before '(' | = help: Removed whitespace before '(' -ℹ Safe fix 14 14 | pass 15 15 | 16 16 | @@ -111,7 +106,6 @@ E21.py:27:19: E211 [*] Whitespace before '(' | = help: Removed whitespace before '(' -ℹ Safe fix 24 24 | Logger.info(test) 25 25 | # test commented code 26 26 | # Logger.info("test code") @@ -132,7 +126,6 @@ E21.py:27:27: E211 [*] Whitespace before '(' | = help: Removed whitespace before '(' -ℹ Safe fix 24 24 | Logger.info(test) 25 25 | # test commented code 26 26 | # Logger.info("test code") @@ -141,5 +134,3 @@ E21.py:27:27: E211 [*] Whitespace before '(' 28 28 | if sys.argv[i] == "--name" : 29 29 | return sys.argv[i + 1] 30 30 | return None - - diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E221_E22.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E221_E22.py.snap index ec75229e10a6b..99c33816f80f5 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E221_E22.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E221_E22.py.snap @@ -12,7 +12,6 @@ E22.py:3:6: E221 [*] Multiple spaces before operator | = help: Replace with single space -ℹ Safe fix 1 1 | #: E221 2 2 | a = 12 + 3 3 |-b = 4 + 5 @@ -32,7 +31,6 @@ E22.py:5:2: E221 [*] Multiple spaces before operator | = help: Replace with single space -ℹ Safe fix 2 2 | a = 12 + 3 3 3 | b = 4 + 5 4 4 | #: E221 E221 @@ -53,7 +51,6 @@ E22.py:6:2: E221 [*] Multiple spaces before operator | = help: Replace with single space -ℹ Safe fix 3 3 | b = 4 + 5 4 4 | #: E221 E221 5 5 | x = 1 @@ -74,7 +71,6 @@ E22.py:9:5: E221 [*] Multiple spaces before operator | = help: Replace with single space -ℹ Safe fix 6 6 | y = 2 7 7 | long_variable = 3 8 8 | #: E221 E221 @@ -95,7 +91,6 @@ E22.py:10:5: E221 [*] Multiple spaces before operator | = help: Replace with single space -ℹ Safe fix 7 7 | long_variable = 3 8 8 | #: E221 E221 9 9 | x[0] = 1 @@ -116,7 +111,6 @@ E22.py:13:9: E221 [*] Multiple spaces before operator | = help: Replace with single space -ℹ Safe fix 10 10 | x[1] = 2 11 11 | long_variable = 3 12 12 | #: E221 E221 @@ -137,7 +131,6 @@ E22.py:15:9: E221 [*] Multiple spaces before operator | = help: Replace with single space -ℹ Safe fix 12 12 | #: E221 E221 13 13 | x = f(x) + 1 14 14 | y = long_variable + 2 @@ -158,7 +151,6 @@ E22.py:19:14: E221 [*] Multiple spaces before operator | = help: Replace with single space -ℹ Safe fix 16 16 | #: E221:3:14 17 17 | text = """ 18 18 | bar @@ -167,5 +159,3 @@ E22.py:19:14: E221 [*] Multiple spaces before operator 20 20 | #: Okay 21 21 | x = 1 22 22 | y = 2 - - diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E222_E22.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E222_E22.py.snap index 52ec6b7ed6831..9fffe206f1a60 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E222_E22.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E222_E22.py.snap @@ -11,7 +11,6 @@ E22.py:28:8: E222 [*] Multiple spaces after operator | = help: Replace with single space -ℹ Safe fix 25 25 | 26 26 | 27 27 | #: E222 @@ -32,7 +31,6 @@ E22.py:31:4: E222 [*] Multiple spaces after operator | = help: Replace with single space -ℹ Safe fix 28 28 | a = a + 1 29 29 | b = b + 10 30 30 | #: E222 E222 @@ -53,7 +51,6 @@ E22.py:32:4: E222 [*] Multiple spaces after operator | = help: Replace with single space -ℹ Safe fix 29 29 | b = b + 10 30 30 | #: E222 E222 31 31 | x = -1 @@ -74,7 +71,6 @@ E22.py:35:7: E222 [*] Multiple spaces after operator | = help: Replace with single space -ℹ Safe fix 32 32 | y = -2 33 33 | long_variable = 3 34 34 | #: E222 E222 @@ -95,7 +91,6 @@ E22.py:36:7: E222 [*] Multiple spaces after operator | = help: Replace with single space -ℹ Safe fix 33 33 | long_variable = 3 34 34 | #: E222 E222 35 35 | x[0] = 1 @@ -103,6 +98,4 @@ E22.py:36:7: E222 [*] Multiple spaces after operator 36 |+x[1] = 2 37 37 | long_variable = 3 38 38 | #: -39 39 | - - +39 39 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E223_E22.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E223_E22.py.snap index 363c9b3855b6e..48f3b0d2d2788 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E223_E22.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E223_E22.py.snap @@ -11,7 +11,6 @@ E22.py:43:2: E223 [*] Tab before operator | = help: Replace with single space -ℹ Safe fix 40 40 | 41 41 | #: E223 42 42 | foobart = 4 @@ -19,6 +18,4 @@ E22.py:43:2: E223 [*] Tab before operator 43 |+a = 3 # aligned with tab 44 44 | #: 45 45 | -46 46 | - - +46 46 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E224_E22.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E224_E22.py.snap index 4f268d558377e..c2f6ed0625441 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E224_E22.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E224_E22.py.snap @@ -11,7 +11,6 @@ E22.py:48:5: E224 [*] Tab after operator | = help: Replace with single space -ℹ Safe fix 45 45 | 46 46 | 47 47 | #: E224 @@ -19,6 +18,4 @@ E22.py:48:5: E224 [*] Tab after operator 48 |+a += 1 49 49 | b += 1000 50 50 | #: -51 51 | - - +51 51 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E225_E22.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E225_E22.py.snap index 26ef6f3c70256..490b00a7ea63b 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E225_E22.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E225_E22.py.snap @@ -11,7 +11,6 @@ E22.py:54:11: E225 [*] Missing whitespace around operator | = help: Add missing whitespace -ℹ Safe fix 51 51 | 52 52 | 53 53 | #: E225 @@ -32,7 +31,6 @@ E22.py:56:10: E225 [*] Missing whitespace around operator | = help: Add missing whitespace -ℹ Safe fix 53 53 | #: E225 54 54 | submitted +=1 55 55 | #: E225 @@ -53,7 +51,6 @@ E22.py:58:3: E225 [*] Missing whitespace around operator | = help: Add missing whitespace -ℹ Safe fix 55 55 | #: E225 56 56 | submitted+= 1 57 57 | #: E225 @@ -74,7 +71,6 @@ E22.py:76:2: E225 [*] Missing whitespace around operator | = help: Add missing whitespace -ℹ Safe fix 73 73 | #: E225 74 74 | _1kB = _1MB>> 10 75 75 | #: E225 E225 @@ -95,7 +91,6 @@ E22.py:78:2: E225 [*] Missing whitespace around operator | = help: Add missing whitespace -ℹ Safe fix 75 75 | #: E225 E225 76 76 | i=i+ 1 77 77 | #: E225 E225 @@ -116,7 +111,6 @@ E22.py:80:6: E225 [*] Missing whitespace around operator | = help: Add missing whitespace -ℹ Safe fix 77 77 | #: E225 E225 78 78 | i=i +1 79 79 | #: E225 @@ -137,7 +131,6 @@ E22.py:82:6: E225 [*] Missing whitespace around operator | = help: Add missing whitespace -ℹ Safe fix 79 79 | #: E225 80 80 | i = 1and 1 81 81 | #: E225 @@ -158,7 +151,6 @@ E22.py:84:2: E225 [*] Missing whitespace around operator | = help: Add missing whitespace -ℹ Safe fix 81 81 | #: E225 82 82 | i = 1or 0 83 83 | #: E225 @@ -179,7 +171,6 @@ E22.py:86:2: E225 [*] Missing whitespace around operator | = help: Add missing whitespace -ℹ Safe fix 83 83 | #: E225 84 84 | 1is 1 85 85 | #: E225 @@ -200,7 +191,6 @@ E22.py:92:2: E225 [*] Missing whitespace around operator | = help: Add missing whitespace -ℹ Safe fix 89 89 | #: E225 90 90 | i = 1@ 2 91 91 | #: E225 E226 @@ -221,7 +211,6 @@ E22.py:94:3: E225 [*] Missing whitespace around operator | = help: Add missing whitespace -ℹ Safe fix 91 91 | #: E225 E226 92 92 | i=i+1 93 93 | #: E225 E226 @@ -242,7 +231,6 @@ E22.py:96:2: E225 [*] Missing whitespace around operator | = help: Add missing whitespace -ℹ Safe fix 93 93 | #: E225 E226 94 94 | i =i+1 95 95 | #: E225 E226 @@ -251,5 +239,3 @@ E22.py:96:2: E225 [*] Missing whitespace around operator 97 97 | #: E225 E226 98 98 | c = (a +b)*(a - b) 99 99 | #: E225 E226 - - diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E226_E22.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E226_E22.py.snap index 881986bcc5329..af71285dd9500 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E226_E22.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E226_E22.py.snap @@ -12,7 +12,6 @@ E22.py:60:7: E226 [*] Missing whitespace around arithmetic operator | = help: Add missing whitespace -ℹ Safe fix 57 57 | #: E225 58 58 | c =-1 59 59 | #: E225 @@ -33,7 +32,6 @@ E22.py:62:11: E226 [*] Missing whitespace around arithmetic operator | = help: Add missing whitespace -ℹ Safe fix 59 59 | #: E225 60 60 | x = x /2 - 1 61 61 | #: E225 @@ -54,7 +52,6 @@ E22.py:64:10: E226 [*] Missing whitespace around arithmetic operator | = help: Add missing whitespace -ℹ Safe fix 61 61 | #: E225 62 62 | c = alpha -4 63 63 | #: E225 @@ -75,7 +72,6 @@ E22.py:66:7: E226 [*] Missing whitespace around arithmetic operator | = help: Add missing whitespace -ℹ Safe fix 63 63 | #: E225 64 64 | c = alpha- 4 65 65 | #: E225 @@ -96,7 +92,6 @@ E22.py:68:13: E226 [*] Missing whitespace around arithmetic operator | = help: Add missing whitespace -ℹ Safe fix 65 65 | #: E225 66 66 | z = x **y 67 67 | #: E225 @@ -117,7 +112,6 @@ E22.py:70:12: E226 [*] Missing whitespace around arithmetic operator | = help: Add missing whitespace -ℹ Safe fix 67 67 | #: E225 68 68 | z = (x + 1) **y 69 69 | #: E225 @@ -138,7 +132,6 @@ E22.py:76:4: E226 [*] Missing whitespace around arithmetic operator | = help: Add missing whitespace -ℹ Safe fix 73 73 | #: E225 74 74 | _1kB = _1MB>> 10 75 75 | #: E225 E225 @@ -159,7 +152,6 @@ E22.py:78:5: E226 [*] Missing whitespace around arithmetic operator | = help: Add missing whitespace -ℹ Safe fix 75 75 | #: E225 E225 76 76 | i=i+ 1 77 77 | #: E225 E225 @@ -180,7 +172,6 @@ E22.py:88:7: E226 [*] Missing whitespace around arithmetic operator | = help: Add missing whitespace -ℹ Safe fix 85 85 | #: E225 86 86 | 1in [] 87 87 | #: E225 @@ -201,7 +192,6 @@ E22.py:90:6: E226 [*] Missing whitespace around arithmetic operator | = help: Add missing whitespace -ℹ Safe fix 87 87 | #: E225 88 88 | i = 1 @2 89 89 | #: E225 @@ -222,7 +212,6 @@ E22.py:92:4: E226 [*] Missing whitespace around arithmetic operator | = help: Add missing whitespace -ℹ Safe fix 89 89 | #: E225 90 90 | i = 1@ 2 91 91 | #: E225 E226 @@ -243,7 +232,6 @@ E22.py:94:5: E226 [*] Missing whitespace around arithmetic operator | = help: Add missing whitespace -ℹ Safe fix 91 91 | #: E225 E226 92 92 | i=i+1 93 93 | #: E225 E226 @@ -264,7 +252,6 @@ E22.py:96:5: E226 [*] Missing whitespace around arithmetic operator | = help: Add missing whitespace -ℹ Safe fix 93 93 | #: E225 E226 94 94 | i =i+1 95 95 | #: E225 E226 @@ -285,7 +272,6 @@ E22.py:98:8: E226 [*] Missing whitespace around arithmetic operator | = help: Add missing whitespace -ℹ Safe fix 95 95 | #: E225 E226 96 96 | i= i+1 97 97 | #: E225 E226 @@ -306,7 +292,6 @@ E22.py:98:11: E226 [*] Missing whitespace around arithmetic operator | = help: Add missing whitespace -ℹ Safe fix 95 95 | #: E225 E226 96 96 | i= i+1 97 97 | #: E225 E226 @@ -326,7 +311,6 @@ E22.py:100:7: E226 [*] Missing whitespace around arithmetic operator | = help: Add missing whitespace -ℹ Safe fix 97 97 | #: E225 E226 98 98 | c = (a +b)*(a - b) 99 99 | #: E225 E226 @@ -346,7 +330,6 @@ E22.py:100:11: E226 [*] Missing whitespace around arithmetic operator | = help: Add missing whitespace -ℹ Safe fix 97 97 | #: E225 E226 98 98 | c = (a +b)*(a - b) 99 99 | #: E225 E226 @@ -366,7 +349,6 @@ E22.py:104:6: E226 [*] Missing whitespace around arithmetic operator | = help: Add missing whitespace -ℹ Safe fix 101 101 | #: 102 102 | 103 103 | #: E226 @@ -387,7 +369,6 @@ E22.py:106:7: E226 [*] Missing whitespace around arithmetic operator | = help: Add missing whitespace -ℹ Safe fix 103 103 | #: E226 104 104 | z = 2//30 105 105 | #: E226 E226 @@ -408,7 +389,6 @@ E22.py:106:15: E226 [*] Missing whitespace around arithmetic operator | = help: Add missing whitespace -ℹ Safe fix 103 103 | #: E226 104 104 | z = 2//30 105 105 | #: E226 E226 @@ -429,7 +409,6 @@ E22.py:110:6: E226 [*] Missing whitespace around arithmetic operator | = help: Add missing whitespace -ℹ Safe fix 107 107 | #: E226 108 108 | norman = True+False 109 109 | #: E226 @@ -450,7 +429,6 @@ E22.py:112:6: E226 [*] Missing whitespace around arithmetic operator | = help: Add missing whitespace -ℹ Safe fix 109 109 | #: E226 110 110 | x = x*2 - 1 111 111 | #: E226 @@ -471,7 +449,6 @@ E22.py:114:11: E226 [*] Missing whitespace around arithmetic operator | = help: Add missing whitespace -ℹ Safe fix 111 111 | #: E226 112 112 | x = x/2 - 1 113 113 | #: E226 E226 @@ -492,7 +469,6 @@ E22.py:114:17: E226 [*] Missing whitespace around arithmetic operator | = help: Add missing whitespace -ℹ Safe fix 111 111 | #: E226 112 112 | x = x/2 - 1 113 113 | #: E226 E226 @@ -513,7 +489,6 @@ E22.py:116:12: E226 [*] Missing whitespace around arithmetic operator | = help: Add missing whitespace -ℹ Safe fix 113 113 | #: E226 E226 114 114 | hypot2 = x*x + y*y 115 115 | #: E226 @@ -534,7 +509,6 @@ E22.py:119:14: E226 [*] Missing whitespace around arithmetic operator | = help: Add missing whitespace -ℹ Safe fix 116 116 | c = (a + b)*(a - b) 117 117 | #: E226 118 118 | def halves(n): @@ -543,5 +517,3 @@ E22.py:119:14: E226 [*] Missing whitespace around arithmetic operator 120 120 | #: E227 121 121 | _1kB = _1MB>>10 122 122 | #: E227 - - diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E227_E22.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E227_E22.py.snap index 8edf3984b36c8..c5864fa361f25 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E227_E22.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E227_E22.py.snap @@ -12,7 +12,6 @@ E22.py:72:13: E227 [*] Missing whitespace around bitwise or shift operator | = help: Add missing whitespace -ℹ Safe fix 69 69 | #: E225 70 70 | z = (x + 1)** y 71 71 | #: E225 @@ -33,7 +32,6 @@ E22.py:74:12: E227 [*] Missing whitespace around bitwise or shift operator | = help: Add missing whitespace -ℹ Safe fix 71 71 | #: E225 72 72 | _1kB = _1MB >>10 73 73 | #: E225 @@ -54,7 +52,6 @@ E22.py:121:12: E227 [*] Missing whitespace around bitwise or shift operator | = help: Add missing whitespace -ℹ Safe fix 118 118 | def halves(n): 119 119 | return (i//2 for i in range(n)) 120 120 | #: E227 @@ -75,7 +72,6 @@ E22.py:123:12: E227 [*] Missing whitespace around bitwise or shift operator | = help: Add missing whitespace -ℹ Safe fix 120 120 | #: E227 121 121 | _1kB = _1MB>>10 122 122 | #: E227 @@ -96,7 +92,6 @@ E22.py:125:6: E227 [*] Missing whitespace around bitwise or shift operator | = help: Add missing whitespace -ℹ Safe fix 122 122 | #: E227 123 123 | _1MB = _1kB<<10 124 124 | #: E227 @@ -117,7 +112,6 @@ E22.py:127:6: E227 [*] Missing whitespace around bitwise or shift operator | = help: Add missing whitespace -ℹ Safe fix 124 124 | #: E227 125 125 | a = b|c 126 126 | #: E227 @@ -138,7 +132,6 @@ E22.py:129:6: E227 [*] Missing whitespace around bitwise or shift operator | = help: Add missing whitespace -ℹ Safe fix 126 126 | #: E227 127 127 | b = c&a 128 128 | #: E227 @@ -159,7 +152,6 @@ E22.py:154:11: E227 [*] Missing whitespace around bitwise or shift operator | = help: Add missing whitespace -ℹ Safe fix 151 151 | func1(lambda *args, **kw: (args, kw)) 152 152 | func2(lambda a, b=h[:], c=0: (a, b, c)) 153 153 | if not -5 < x < +5: @@ -168,5 +160,3 @@ E22.py:154:11: E227 [*] Missing whitespace around bitwise or shift operator 155 155 | print >> sys.stdout, "x is an integer." 156 156 | x = x / 2 - 1 157 157 | x = 1 @ 2 - - diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E228_E22.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E228_E22.py.snap index fd9f368f63bea..4df6a9b256e82 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E228_E22.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E228_E22.py.snap @@ -12,7 +12,6 @@ E22.py:131:6: E228 [*] Missing whitespace around modulo operator | = help: Add missing whitespace -ℹ Safe fix 128 128 | #: E227 129 129 | c = b^a 130 130 | #: E228 @@ -33,7 +32,6 @@ E22.py:133:10: E228 [*] Missing whitespace around modulo operator | = help: Add missing whitespace -ℹ Safe fix 130 130 | #: E228 131 131 | a = b%c 132 132 | #: E228 @@ -53,7 +51,6 @@ E22.py:135:26: E228 [*] Missing whitespace around modulo operator | = help: Add missing whitespace -ℹ Safe fix 132 132 | #: E228 133 133 | msg = fmt%(errno, errmsg) 134 134 | #: E228 @@ -62,5 +59,3 @@ E22.py:135:26: E228 [*] Missing whitespace around modulo operator 136 136 | #: 137 137 | 138 138 | #: Okay - - diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E231_E23.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E231_E23.py.snap index 62abb9df58ccb..b1013908ff9f3 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E231_E23.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E231_E23.py.snap @@ -11,7 +11,6 @@ E23.py:2:7: E231 [*] Missing whitespace after ',' | = help: Add missing whitespace -ℹ Safe fix 1 1 | #: E231 2 |-a = (1,2) 2 |+a = (1, 2) @@ -30,7 +29,6 @@ E23.py:4:5: E231 [*] Missing whitespace after ',' | = help: Add missing whitespace -ℹ Safe fix 1 1 | #: E231 2 2 | a = (1,2) 3 3 | #: E231 @@ -51,7 +49,6 @@ E23.py:6:10: E231 [*] Missing whitespace after ':' | = help: Add missing whitespace -ℹ Safe fix 3 3 | #: E231 4 4 | a[b1,:] 5 5 | #: E231 @@ -71,7 +68,6 @@ E23.py:19:10: E231 [*] Missing whitespace after ',' | = help: Add missing whitespace -ℹ Safe fix 16 16 | 17 17 | def foo() -> None: 18 18 | #: E231 @@ -91,7 +87,6 @@ E23.py:29:20: E231 [*] Missing whitespace after ':' | = help: Add missing whitespace -ℹ Safe fix 26 26 | #: E231:2:20 27 27 | mdtypes_template = { 28 28 | 'tag_full': [('mdtype', 'u4'), ('byte_count', 'u4')], @@ -111,7 +106,6 @@ E23.py:33:6: E231 [*] Missing whitespace after ',' | = help: Add missing whitespace -ℹ Safe fix 30 30 | } 31 31 | 32 32 | # E231 @@ -131,7 +125,6 @@ E23.py:47:37: E231 [*] Missing whitespace after ':' | = help: Add missing whitespace -ℹ Safe fix 44 44 | snapshot.file_uri[len(f's3://{self.s3_bucket_name}/'):] 45 45 | 46 46 | #: E231 @@ -152,7 +145,6 @@ E23.py:60:13: E231 [*] Missing whitespace after ':' | = help: Add missing whitespace -ℹ Safe fix 57 57 | """Primary function.""" 58 58 | results = { 59 59 | "k1": [1], @@ -173,7 +165,6 @@ E23.py:65:17: E231 [*] Missing whitespace after ':' | = help: Add missing whitespace -ℹ Safe fix 62 62 | results_in_tuple = ( 63 63 | { 64 64 | "k1": [1], @@ -194,7 +185,6 @@ E23.py:71:17: E231 [*] Missing whitespace after ':' | = help: Add missing whitespace -ℹ Safe fix 68 68 | results_in_list = [ 69 69 | { 70 70 | "k1": [1], @@ -215,7 +205,6 @@ E23.py:76:17: E231 [*] Missing whitespace after ':' | = help: Add missing whitespace -ℹ Safe fix 73 73 | ] 74 74 | results_in_list_first = [ 75 75 | { @@ -236,7 +225,6 @@ E23.py:82:13: E231 [*] Missing whitespace after ':' | = help: Add missing whitespace -ℹ Safe fix 79 79 | 80 80 | x = [ 81 81 | { @@ -257,7 +245,6 @@ E23.py:84:13: E231 [*] Missing whitespace after ':' | = help: Add missing whitespace -ℹ Safe fix 81 81 | { 82 82 | "k1":[2], # E231 83 83 | "k2": x[2:4], @@ -278,7 +265,6 @@ E23.py:87:26: E231 [*] Missing whitespace after ',' | = help: Add missing whitespace -ℹ Safe fix 84 84 | "k3":[2], # E231 85 85 | "k4": [2], 86 86 | "k5": [2], @@ -299,7 +285,6 @@ E23.py:87:28: E231 [*] Missing whitespace after ',' | = help: Add missing whitespace -ℹ Safe fix 84 84 | "k3":[2], # E231 85 85 | "k4": [2], 86 86 | "k5": [2], @@ -320,7 +305,6 @@ E23.py:87:30: E231 [*] Missing whitespace after ',' | = help: Add missing whitespace -ℹ Safe fix 84 84 | "k3":[2], # E231 85 85 | "k4": [2], 86 86 | "k5": [2], @@ -341,7 +325,6 @@ E23.py:92:21: E231 [*] Missing whitespace after ':' | = help: Add missing whitespace -ℹ Safe fix 89 89 | { 90 90 | "k1": [ 91 91 | { @@ -362,7 +345,6 @@ E23.py:92:24: E231 [*] Missing whitespace after ',' | = help: Add missing whitespace -ℹ Safe fix 89 89 | { 90 90 | "k1": [ 91 91 | { @@ -383,7 +365,6 @@ E23.py:95:25: E231 [*] Missing whitespace after ',' | = help: Add missing whitespace -ℹ Safe fix 92 92 | "ka":[2,3], # E231 93 93 | }, 94 94 | { @@ -404,7 +385,6 @@ E23.py:98:21: E231 [*] Missing whitespace after ':' | = help: Add missing whitespace -ℹ Safe fix 95 95 | "kb": [2,3], # E231 96 96 | }, 97 97 | { @@ -425,7 +405,6 @@ E23.py:101:25: E231 [*] Missing whitespace after ',' | = help: Add missing whitespace -ℹ Safe fix 98 98 | "ka":[2, 3], # E231 99 99 | "kb": [2, 3], # Ok 100 100 | "kc": [2, 3], # Ok @@ -446,7 +425,6 @@ E23.py:102:21: E231 [*] Missing whitespace after ':' | = help: Add missing whitespace -ℹ Safe fix 99 99 | "kb": [2, 3], # Ok 100 100 | "kc": [2, 3], # Ok 101 101 | "kd": [2,3], # E231 @@ -467,7 +445,6 @@ E23.py:102:24: E231 [*] Missing whitespace after ',' | = help: Add missing whitespace -ℹ Safe fix 99 99 | "kb": [2, 3], # Ok 100 100 | "kc": [2, 3], # Ok 101 101 | "kd": [2,3], # E231 diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E241_E24.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E241_E24.py.snap index dba2129ca812e..73e68a674e15a 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E241_E24.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E241_E24.py.snap @@ -11,7 +11,6 @@ E24.py:2:8: E241 [*] Multiple spaces after comma | = help: Replace with single space -ℹ Safe fix 1 1 | #: E241 2 |-a = (1, 2) 2 |+a = (1, 2) @@ -30,7 +29,6 @@ E24.py:11:18: E241 [*] Multiple spaces after comma | = help: Replace with single space -ℹ Safe fix 8 8 | b = (1, 20) # space before 20 9 9 | #: E241 E241 E241 10 10 | # issue 135 @@ -49,7 +47,6 @@ E24.py:12:19: E241 [*] Multiple spaces after comma | = help: Replace with single space -ℹ Safe fix 9 9 | #: E241 E241 E241 10 10 | # issue 135 11 11 | more_spaces = [a, b, @@ -66,11 +63,8 @@ E24.py:13:18: E241 [*] Multiple spaces after comma | = help: Replace with single space -ℹ Safe fix 10 10 | # issue 135 11 11 | more_spaces = [a, b, 12 12 | ef, +h, 13 |- c, -d] 13 |+ c, -d] - - diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E242_E24.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E242_E24.py.snap index bf93c26308780..34883face207b 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E242_E24.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E242_E24.py.snap @@ -12,7 +12,6 @@ E24.py:6:8: E242 [*] Tab after comma | = help: Replace with single space -ℹ Safe fix 3 3 | #: Okay 4 4 | b = (1, 20) 5 5 | #: E242 @@ -21,5 +20,3 @@ E24.py:6:8: E242 [*] Tab after comma 7 7 | #: Okay 8 8 | b = (1, 20) # space before 20 9 9 | #: E241 E241 E241 - - diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E251_E25.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E251_E25.py.snap index a87bcdff5586b..940ac364477bd 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E251_E25.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E251_E25.py.snap @@ -11,7 +11,6 @@ E25.py:2:12: E251 [*] Unexpected spaces around keyword / parameter equals | = help: Remove whitespace -ℹ Safe fix 1 1 | #: E251 E251 2 |-def foo(bar = False): 2 |+def foo(bar= False): @@ -29,7 +28,6 @@ E25.py:2:14: E251 [*] Unexpected spaces around keyword / parameter equals | = help: Remove whitespace -ℹ Safe fix 1 1 | #: E251 E251 2 |-def foo(bar = False): 2 |+def foo(bar =False): @@ -48,7 +46,6 @@ E25.py:6:9: E251 [*] Unexpected spaces around keyword / parameter equals | = help: Remove whitespace -ℹ Safe fix 3 3 | '''Test function with an error in declaration''' 4 4 | pass 5 5 | #: E251 @@ -69,7 +66,6 @@ E25.py:8:8: E251 [*] Unexpected spaces around keyword / parameter equals | = help: Remove whitespace -ℹ Safe fix 5 5 | #: E251 6 6 | foo(bar= True) 7 7 | #: E251 @@ -90,7 +86,6 @@ E25.py:10:8: E251 [*] Unexpected spaces around keyword / parameter equals | = help: Remove whitespace -ℹ Safe fix 7 7 | #: E251 8 8 | foo(bar =True) 9 9 | #: E251 E251 @@ -111,7 +106,6 @@ E25.py:10:10: E251 [*] Unexpected spaces around keyword / parameter equals | = help: Remove whitespace -ℹ Safe fix 7 7 | #: E251 8 8 | foo(bar =True) 9 9 | #: E251 E251 @@ -132,7 +126,6 @@ E25.py:12:14: E251 [*] Unexpected spaces around keyword / parameter equals | = help: Remove whitespace -ℹ Safe fix 9 9 | #: E251 E251 10 10 | foo(bar = True) 11 11 | #: E251 @@ -155,7 +148,6 @@ E25.py:15:29: E251 [*] Unexpected spaces around keyword / parameter equals | = help: Remove whitespace -ℹ Safe fix 12 12 | y = bar(root= "sdasd") 13 13 | #: E251:2:29 14 14 | parser.add_argument('--long-option', @@ -179,7 +171,6 @@ E25.py:18:45: E251 [*] Unexpected spaces around keyword / parameter equals | = help: Remove whitespace -ℹ Safe fix 15 15 | default= 16 16 | "/rather/long/filesystem/path/here/blah/blah/blah") 17 17 | #: E251:1:45 @@ -201,7 +192,6 @@ E25.py:23:8: E251 [*] Unexpected spaces around keyword / parameter equals | = help: Remove whitespace -ℹ Safe fix 20 20 | #: E251:3:8 E251:3:10 21 21 | foo(True, 22 22 | baz=(1, 2), @@ -222,7 +212,6 @@ E25.py:23:10: E251 [*] Unexpected spaces around keyword / parameter equals | = help: Remove whitespace -ℹ Safe fix 20 20 | #: E251:3:8 E251:3:10 21 21 | foo(True, 22 22 | baz=(1, 2), @@ -231,5 +220,3 @@ E25.py:23:10: E251 [*] Unexpected spaces around keyword / parameter equals 24 24 | ) 25 25 | #: Okay 26 26 | foo(bar=(1 == 1)) - - diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E252_E25.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E252_E25.py.snap index 54c129811470f..fd1d1bda54201 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E252_E25.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E252_E25.py.snap @@ -12,7 +12,6 @@ E25.py:46:15: E252 [*] Missing whitespace around parameter equals | = help: Add missing whitespace -ℹ Safe fix 43 43 | async def add(a: int = 0, b: int = 0) -> int: 44 44 | return a + b 45 45 | #: E252:1:15 E252:1:16 E252:1:27 E252:1:36 @@ -33,7 +32,6 @@ E25.py:46:15: E252 [*] Missing whitespace around parameter equals | = help: Add missing whitespace -ℹ Safe fix 43 43 | async def add(a: int = 0, b: int = 0) -> int: 44 44 | return a + b 45 45 | #: E252:1:15 E252:1:16 E252:1:27 E252:1:36 @@ -54,7 +52,6 @@ E25.py:46:26: E252 [*] Missing whitespace around parameter equals | = help: Add missing whitespace -ℹ Safe fix 43 43 | async def add(a: int = 0, b: int = 0) -> int: 44 44 | return a + b 45 45 | #: E252:1:15 E252:1:16 E252:1:27 E252:1:36 @@ -75,7 +72,6 @@ E25.py:46:36: E252 [*] Missing whitespace around parameter equals | = help: Add missing whitespace -ℹ Safe fix 43 43 | async def add(a: int = 0, b: int = 0) -> int: 44 44 | return a + b 45 45 | #: E252:1:15 E252:1:16 E252:1:27 E252:1:36 @@ -84,5 +80,3 @@ E25.py:46:36: E252 [*] Missing whitespace around parameter equals 47 47 | return a + b + c 48 48 | #: Okay 49 49 | def add(a: int = _default(name='f')): - - diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E261_E26.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E261_E26.py.snap index d9b8a7679c0f4..ef2d83c729689 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E261_E26.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E261_E26.py.snap @@ -11,12 +11,9 @@ E26.py:2:5: E261 [*] Insert at least two spaces before an inline comment | = help: Insert spaces -ℹ Safe fix 1 1 | #: E261:1:5 2 |-pass # an inline comment 2 |+pass # an inline comment 3 3 | #: E262:1:12 4 4 | x = x + 1 #Increment x 5 5 | #: E262:1:12 - - diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E262_E26.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E262_E26.py.snap index 658391acdc36b..1024ea7d46e47 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E262_E26.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E262_E26.py.snap @@ -12,7 +12,6 @@ E26.py:4:12: E262 [*] Inline comment should start with `# ` | = help: Format space -ℹ Safe fix 1 1 | #: E261:1:5 2 2 | pass # an inline comment 3 3 | #: E262:1:12 @@ -33,7 +32,6 @@ E26.py:6:12: E262 [*] Inline comment should start with `# ` | = help: Format space -ℹ Safe fix 3 3 | #: E262:1:12 4 4 | x = x + 1 #Increment x 5 5 | #: E262:1:12 @@ -54,7 +52,6 @@ E26.py:8:12: E262 [*] Inline comment should start with `# ` | = help: Format space -ℹ Safe fix 5 5 | #: E262:1:12 6 6 | x = x + 1 # Increment x 7 7 | #: E262:1:12 @@ -75,7 +72,6 @@ E26.py:63:9: E262 [*] Inline comment should start with `# ` | = help: Format space -ℹ Safe fix 60 60 | #: E262:3:9 61 61 | # -*- coding: utf8 -*- 62 62 | #  (One space one NBSP) Ok for block comment @@ -96,7 +92,6 @@ E26.py:66:9: E262 [*] Inline comment should start with `# ` | = help: Format space -ℹ Safe fix 63 63 | a = 42 #  (One space one NBSP) 64 64 | #: E262:2:9 65 65 | # (Two spaces) Ok for block comment @@ -117,7 +112,6 @@ E26.py:84:8: E262 [*] Inline comment should start with `# ` | = help: Format space -ℹ Safe fix 81 81 | #: E266:1:3 82 82 | ## Foo 83 83 | @@ -135,11 +129,8 @@ E26.py:86:8: E262 [*] Inline comment should start with `# ` | = help: Format space -ℹ Safe fix 83 83 | 84 84 | a = 1 ## Foo 85 85 | 86 |-a = 1 #:Foo 86 |+a = 1 #: Foo - - diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E265_E26.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E265_E26.py.snap index 92b25ccb212b6..cf47edcb9037e 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E265_E26.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E265_E26.py.snap @@ -12,7 +12,6 @@ E26.py:10:1: E265 [*] Block comment should start with `# ` | = help: Format space -ℹ Safe fix 7 7 | #: E262:1:12 8 8 | x = y + 1 #: Increment x 9 9 | #: E265:1:1 @@ -33,7 +32,6 @@ E26.py:14:1: E265 [*] Block comment should start with `# ` | = help: Format space -ℹ Safe fix 11 11 | a = 1 12 12 | #: E265:2:1 13 13 | m = 42 @@ -54,7 +52,6 @@ E26.py:25:1: E265 [*] Block comment should start with `# ` | = help: Format space -ℹ Safe fix 22 22 | ### Of course it is unused 23 23 | return 24 24 | #: E265:1:1 E266:2:1 @@ -74,7 +71,6 @@ E26.py:32:1: E265 [*] Block comment should start with `# ` | = help: Format space -ℹ Safe fix 29 29 | #: 30 30 | 31 31 | #: Okay @@ -94,7 +90,6 @@ E26.py:73:1: E265 [*] Block comment should start with `# ` | = help: Format space -ℹ Safe fix 70 70 | # E Means test is giving error (E) 71 71 | # F Means test is failing (F) 72 72 | # EF Means test is giving error and Failing @@ -115,7 +110,6 @@ E26.py:78:1: E265 [*] Block comment should start with `# ` | = help: Format space -ℹ Safe fix 75 75 | 76 76 | #: Colon prefix is okay 77 77 | @@ -124,5 +118,3 @@ E26.py:78:1: E265 [*] Block comment should start with `# ` 79 79 | 80 80 | # We should strip the space, but preserve the hashes. 81 81 | #: E266:1:3 - - diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E266_E26.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E266_E26.py.snap index 4469e1b225d64..bc6bf79de595e 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E266_E26.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E266_E26.py.snap @@ -11,7 +11,6 @@ E26.py:19:5: E266 [*] Too many leading `#` before block comment | = help: Remove leading `#` -ℹ Safe fix 16 16 | #: E266:3:5 E266:6:5 17 17 | def how_it_feel(r): 18 18 | @@ -32,7 +31,6 @@ E26.py:22:5: E266 [*] Too many leading `#` before block comment | = help: Remove leading `#` -ℹ Safe fix 19 19 | ### This is a variable ### 20 20 | a = 42 21 21 | @@ -53,7 +51,6 @@ E26.py:26:1: E266 [*] Too many leading `#` before block comment | = help: Remove leading `#` -ℹ Safe fix 23 23 | return 24 24 | #: E265:1:1 E266:2:1 25 25 | ##if DEBUG: @@ -73,7 +70,6 @@ E26.py:69:1: E266 [*] Too many leading `#` before block comment | = help: Remove leading `#` -ℹ Safe fix 66 66 | a = 42 # (Two spaces) 67 67 | 68 68 | #: E265:5:1 @@ -94,7 +90,6 @@ E26.py:82:1: E266 [*] Too many leading `#` before block comment | = help: Remove leading `#` -ℹ Safe fix 79 79 | 80 80 | # We should strip the space, but preserve the hashes. 81 81 | #: E266:1:3 @@ -102,6 +97,4 @@ E26.py:82:1: E266 [*] Too many leading `#` before block comment 82 |+# Foo 83 83 | 84 84 | a = 1 ## Foo -85 85 | - - +85 85 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E271_E27.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E271_E27.py.snap index ffd296ba6a802..f0c424782e4bd 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E271_E27.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E271_E27.py.snap @@ -12,7 +12,6 @@ E27.py:4:9: E271 [*] Multiple spaces after keyword | = help: Replace with single space -ℹ Safe fix 1 1 | #: Okay 2 2 | True and False 3 3 | #: E271 @@ -33,7 +32,6 @@ E27.py:6:5: E271 [*] Multiple spaces after keyword | = help: Replace with single space -ℹ Safe fix 3 3 | #: E271 4 4 | True and False 5 5 | #: E272 @@ -54,7 +52,6 @@ E27.py:8:3: E271 [*] Multiple spaces after keyword | = help: Replace with single space -ℹ Safe fix 5 5 | #: E272 6 6 | True and False 7 7 | #: E271 @@ -75,7 +72,6 @@ E27.py:15:6: E271 [*] Multiple spaces after keyword | = help: Replace with single space -ℹ Safe fix 12 12 | #: E273 E274 13 13 | True and False 14 14 | #: E271 @@ -96,7 +92,6 @@ E27.py:17:6: E271 [*] Multiple spaces after keyword | = help: Replace with single space -ℹ Safe fix 14 14 | #: E271 15 15 | a and b 16 16 | #: E271 @@ -117,7 +112,6 @@ E27.py:19:6: E271 [*] Multiple spaces after keyword | = help: Replace with single space -ℹ Safe fix 16 16 | #: E271 17 17 | 1 and b 18 18 | #: E271 @@ -138,7 +132,6 @@ E27.py:21:7: E271 [*] Multiple spaces after keyword | = help: Replace with single space -ℹ Safe fix 18 18 | #: E271 19 19 | a and 2 20 20 | #: E271 E272 @@ -159,7 +152,6 @@ E27.py:23:7: E271 [*] Multiple spaces after keyword | = help: Replace with single space -ℹ Safe fix 20 20 | #: E271 E272 21 21 | 1 and b 22 22 | #: E271 E272 @@ -180,7 +172,6 @@ E27.py:36:14: E271 [*] Multiple spaces after keyword | = help: Replace with single space -ℹ Safe fix 33 33 | from u import (a, b) 34 34 | from v import c, d 35 35 | #: E271 @@ -200,7 +191,6 @@ E27.py:71:5: E271 [*] Multiple spaces after keyword | = help: Replace with single space -ℹ Safe fix 68 68 | # Soft keywords 69 69 | 70 70 | #: E271 diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E272_E27.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E272_E27.py.snap index c9f27f6f2a97c..8c2472aa2329f 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E272_E27.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E272_E27.py.snap @@ -12,7 +12,6 @@ E27.py:21:2: E272 [*] Multiple spaces before keyword | = help: Replace with single space -ℹ Safe fix 18 18 | #: E271 19 19 | a and 2 20 20 | #: E271 E272 @@ -33,7 +32,6 @@ E27.py:23:2: E272 [*] Multiple spaces before keyword | = help: Replace with single space -ℹ Safe fix 20 20 | #: E271 E272 21 21 | 1 and b 22 22 | #: E271 E272 @@ -54,7 +52,6 @@ E27.py:25:5: E272 [*] Multiple spaces before keyword | = help: Replace with single space -ℹ Safe fix 22 22 | #: E271 E272 23 23 | a and 2 24 24 | #: E272 diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E273_E27.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E273_E27.py.snap index ecdb9d3a290e7..73ec80938589c 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E273_E27.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E273_E27.py.snap @@ -12,7 +12,6 @@ E27.py:11:9: E273 [*] Tab after keyword | = help: Replace with single space -ℹ Safe fix 8 8 | if 1: 9 9 | pass 10 10 | #: E273 @@ -33,7 +32,6 @@ E27.py:13:5: E273 [*] Tab after keyword | = help: Replace with single space -ℹ Safe fix 10 10 | #: E273 11 11 | True and False 12 12 | #: E273 E274 @@ -54,7 +52,6 @@ E27.py:13:10: E273 [*] Tab after keyword | = help: Replace with single space -ℹ Safe fix 10 10 | #: E273 11 11 | True and False 12 12 | #: E273 E274 @@ -75,7 +72,6 @@ E27.py:27:6: E273 [*] Tab after keyword | = help: Replace with single space -ℹ Safe fix 24 24 | #: E272 25 25 | this and False 26 26 | #: E273 @@ -96,7 +92,6 @@ E27.py:31:10: E273 [*] Tab after keyword | = help: Replace with single space -ℹ Safe fix 28 28 | #: E274 29 29 | a and b 30 30 | #: E273 E274 @@ -116,7 +111,6 @@ E27.py:74:5: E273 [*] Tab after keyword | = help: Replace with single space -ℹ Safe fix 71 71 | type Number = int 72 72 | 73 73 | #: E273 diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E274_E27.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E274_E27.py.snap index 062a61bebf50d..2428a90865800 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E274_E27.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E274_E27.py.snap @@ -12,7 +12,6 @@ E27.py:29:2: E274 [*] Tab before keyword | = help: Replace with single space -ℹ Safe fix 26 26 | #: E273 27 27 | a and b 28 28 | #: E274 @@ -33,7 +32,6 @@ E27.py:31:5: E274 [*] Tab before keyword | = help: Replace with single space -ℹ Safe fix 28 28 | #: E274 29 29 | a and b 30 30 | #: E273 E274 diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E275_E27.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E275_E27.py.snap index 0d0cc6d0dfe56..5fd119dc1b4cf 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E275_E27.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E275_E27.py.snap @@ -12,7 +12,6 @@ E27.py:38:8: E275 [*] Missing whitespace after keyword | = help: Added missing whitespace after keyword -ℹ Safe fix 35 35 | #: E271 36 36 | from w import (e, f) 37 37 | #: E275 @@ -33,7 +32,6 @@ E27.py:40:24: E275 [*] Missing whitespace after keyword | = help: Added missing whitespace after keyword -ℹ Safe fix 37 37 | #: E275 38 38 | from w import(e, f) 39 39 | #: E275 @@ -54,7 +52,6 @@ E27.py:43:28: E275 [*] Missing whitespace after keyword | = help: Added missing whitespace after keyword -ℹ Safe fix 40 40 | from importable.module import(e, f) 41 41 | #: E275 42 42 | try: @@ -75,7 +72,6 @@ E27.py:47:1: E275 [*] Missing whitespace after keyword | = help: Added missing whitespace after keyword -ℹ Safe fix 44 44 | except ImportError: 45 45 | pass 46 46 | #: E275 @@ -96,7 +92,6 @@ E27.py:55:5: E275 [*] Missing whitespace after keyword | = help: Added missing whitespace after keyword -ℹ Safe fix 52 52 | matched = {"true": True, "false": False} 53 53 | #: E275:2:11 54 54 | if True: @@ -116,7 +111,6 @@ E27.py:77:1: E275 [*] Missing whitespace after keyword | = help: Added missing whitespace after keyword -ℹ Safe fix 74 74 | type Number = int 75 75 | 76 76 | #: E275 @@ -136,7 +130,6 @@ E27.py:78:5: E275 [*] Missing whitespace after keyword | = help: Added missing whitespace after keyword -ℹ Safe fix 75 75 | 76 76 | #: E275 77 77 | match(foo): diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E301_E30.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E301_E30.py.snap index c224ebbeb7806..0e0133b9b7c2a 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E301_E30.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E301_E30.py.snap @@ -12,7 +12,6 @@ E30.py:478:5: E301 [*] Expected 1 blank line, found 0 | = help: Add missing blank line -ℹ Safe fix 475 475 | 476 476 | def func1(): 477 477 | pass @@ -32,7 +31,6 @@ E30.py:489:5: E301 [*] Expected 1 blank line, found 0 | = help: Add missing blank line -ℹ Safe fix 485 485 | 486 486 | def fn1(): 487 487 | pass @@ -51,7 +49,6 @@ E30.py:499:5: E301 [*] Expected 1 blank line, found 0 | = help: Add missing blank line -ℹ Safe fix 496 496 | """Class for minimal repo.""" 497 497 | 498 498 | columns = [] @@ -71,7 +68,6 @@ E30.py:511:5: E301 [*] Expected 1 blank line, found 0 | = help: Add missing blank line -ℹ Safe fix 508 508 | 509 509 | def method(cls) -> None: 510 510 | pass @@ -91,7 +87,6 @@ E30.py:526:5: E301 [*] Expected 1 blank line, found 0 | = help: Add missing blank line -ℹ Safe fix 523 523 | @overload 524 524 | def bar(self, x: str) -> str: 525 525 | ... diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E30.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E30.py.snap index 3ae60bb0da739..f47ad3fd7009f 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E30.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E30.py.snap @@ -12,7 +12,6 @@ E30.py:533:1: E302 [*] Expected 2 blank lines, found 0 | = help: Add missing blank line(s) -ℹ Safe fix 530 530 | 531 531 | # E302 532 532 | """Main module.""" @@ -33,7 +32,6 @@ E30.py:540:1: E302 [*] Expected 2 blank lines, found 0 | = help: Add missing blank line(s) -ℹ Safe fix 537 537 | 538 538 | # E302 539 539 | import sys @@ -54,7 +52,6 @@ E30.py:549:1: E302 [*] Expected 2 blank lines, found 1 | = help: Add missing blank line(s) -ℹ Safe fix 546 546 | def a(): 547 547 | pass 548 548 | @@ -74,7 +71,6 @@ E30.py:560:1: E302 [*] Expected 2 blank lines, found 1 | = help: Add missing blank line(s) -ℹ Safe fix 557 557 | 558 558 | # comment 559 559 | @@ -94,7 +90,6 @@ E30.py:569:1: E302 [*] Expected 2 blank lines, found 1 | = help: Add missing blank line(s) -ℹ Safe fix 566 566 | def a(): 567 567 | pass 568 568 | @@ -114,7 +109,6 @@ E30.py:578:1: E302 [*] Expected 2 blank lines, found 1 | = help: Add missing blank line(s) -ℹ Safe fix 575 575 | async def x(): 576 576 | pass 577 577 | @@ -133,7 +127,6 @@ E30.py:586:1: E302 [*] Expected 2 blank lines, found 0 | = help: Add missing blank line(s) -ℹ Safe fix 583 583 | # E302 584 584 | def bar(): 585 585 | pass @@ -154,7 +147,6 @@ E30.py:592:1: E302 [*] Expected 2 blank lines, found 0 | = help: Add missing blank line(s) -ℹ Safe fix 589 589 | 590 590 | # E302 591 591 | def bar(): pass @@ -174,7 +166,6 @@ E30.py:602:1: E302 [*] Expected 2 blank lines, found 1 | = help: Add missing blank line(s) -ℹ Safe fix 598 598 | def f(): 599 599 | pass 600 600 | @@ -194,7 +185,6 @@ E30.py:624:1: E302 [*] Expected 2 blank lines, found 0 | = help: Add missing blank line(s) -ℹ Safe fix 621 621 | 622 622 | # E302 623 623 | class A:... @@ -215,7 +205,6 @@ E30.py:634:1: E302 [*] Expected 2 blank lines, found 1 | = help: Add missing blank line(s) -ℹ Safe fix 631 631 | @overload 632 632 | def fn(a: str) -> str: ... 633 633 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_docstring.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_docstring.py.snap index 4fa4accc0cf4c..be235e624d8a3 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_docstring.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_docstring.py.snap @@ -11,7 +11,6 @@ E302_first_line_docstring.py:3:1: E302 [*] Expected 2 blank lines, found 1 | = help: Add missing blank line(s) -ℹ Safe fix 1 1 | """Test where the error is after the module's docstring.""" 2 2 | 3 |+ diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_expression.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_expression.py.snap index 9cd8779d1b6f7..0751a8c695ba2 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_expression.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_expression.py.snap @@ -11,7 +11,6 @@ E302_first_line_expression.py:3:1: E302 [*] Expected 2 blank lines, found 1 | = help: Add missing blank line(s) -ℹ Safe fix 1 1 | "Test where the first line is a comment, " + "and the rule violation follows it." 2 2 | 3 |+ diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_function.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_function.py.snap index a847c86079c7a..cc614c225e05b 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_function.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_function.py.snap @@ -11,7 +11,6 @@ E302_first_line_function.py:4:1: E302 [*] Expected 2 blank lines, found 1 | = help: Add missing blank line(s) -ℹ Safe fix 1 1 | def fn1(): 2 2 | pass 3 3 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_statement.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_statement.py.snap index a4736c7dd4e63..6657de5fa1e59 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_statement.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_statement.py.snap @@ -11,7 +11,6 @@ E302_first_line_statement.py:3:1: E302 [*] Expected 2 blank lines, found 1 | = help: Add missing blank line(s) -ℹ Safe fix 1 1 | print("Test where the first line is a statement, and the rule violation follows it.") 2 2 | 3 |+ diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E30.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E30.py.snap index a5f47acd9e976..068bf6cae18b5 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E30.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E30.py.snap @@ -10,7 +10,6 @@ E30.py:617:2: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 613 613 | def method1(): 614 614 | return 1 615 615 | @@ -28,7 +27,6 @@ E30.py:644:5: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 640 640 | def fn(): 641 641 | _ = None 642 642 | @@ -46,7 +44,6 @@ E30.py:656:5: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 652 652 | def fn(): 653 653 | _ = None 654 654 | @@ -63,7 +60,6 @@ E30.py:667:1: E303 [*] Too many blank lines (3) | = help: Remove extraneous blank line(s) -ℹ Safe fix 663 663 | print() 664 664 | 665 665 | @@ -81,7 +77,6 @@ E30.py:676:1: E303 [*] Too many blank lines (3) | = help: Remove extraneous blank line(s) -ℹ Safe fix 672 672 | print() 673 673 | 674 674 | @@ -97,7 +92,6 @@ E30.py:687:5: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 683 683 | def a(): 684 684 | print() 685 685 | @@ -115,7 +109,6 @@ E30.py:690:5: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 686 686 | 687 687 | # comment 688 688 | @@ -134,7 +127,6 @@ E30.py:701:1: E303 [*] Too many blank lines (3) | = help: Remove extraneous blank line(s) -ℹ Safe fix 697 697 | #!python 698 698 | 699 699 | @@ -152,7 +144,6 @@ E30.py:713:5: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 709 709 | def a(self): 710 710 | pass 711 711 | @@ -169,7 +160,6 @@ E30.py:723:5: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 719 719 | if True: 720 720 | a = 1 721 721 | @@ -185,7 +175,6 @@ E30.py:731:5: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 727 727 | # E303 728 728 | class Test: 729 729 | @@ -203,7 +192,6 @@ E30.py:734:5: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 730 730 | 731 731 | # comment 732 732 | @@ -221,7 +209,6 @@ E30.py:748:5: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 744 744 | 745 745 | # wrongly indented comment 746 746 | @@ -238,7 +225,6 @@ E30.py:758:5: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 754 754 | def fn(): 755 755 | pass 756 756 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E303_first_line_comment.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E303_first_line_comment.py.snap index 0494356fb0a58..55ddc90b46cb6 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E303_first_line_comment.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E303_first_line_comment.py.snap @@ -9,7 +9,6 @@ E303_first_line_comment.py:5:1: E303 [*] Too many blank lines (3) | = help: Remove extraneous blank line(s) -ℹ Safe fix 1 1 | # Test where the first line is a comment, and the rule violation follows it. 2 2 | 3 3 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E303_first_line_docstring.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E303_first_line_docstring.py.snap index d709f904ddbd6..9df97dc235265 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E303_first_line_docstring.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E303_first_line_docstring.py.snap @@ -9,7 +9,6 @@ E303_first_line_docstring.py:5:1: E303 [*] Too many blank lines (3) | = help: Remove extraneous blank line(s) -ℹ Safe fix 1 1 | """Test where the error is after the module's docstring.""" 2 2 | 3 3 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E303_first_line_expression.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E303_first_line_expression.py.snap index d81f9098c5312..c7333a7f09e2b 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E303_first_line_expression.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E303_first_line_expression.py.snap @@ -9,7 +9,6 @@ E303_first_line_expression.py:5:1: E303 [*] Too many blank lines (3) | = help: Remove extraneous blank line(s) -ℹ Safe fix 1 1 | "Test where the first line is a comment, " + "and the rule violation follows it." 2 2 | 3 3 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E303_first_line_statement.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E303_first_line_statement.py.snap index 7197d3e13338d..f0d77c292705a 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E303_first_line_statement.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E303_first_line_statement.py.snap @@ -9,7 +9,6 @@ E303_first_line_statement.py:5:1: E303 [*] Too many blank lines (3) | = help: Remove extraneous blank line(s) -ℹ Safe fix 1 1 | print("Test where the first line is a statement, and the rule violation follows it.") 2 2 | 3 3 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E304_E30.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E304_E30.py.snap index 2c53c6bbf7092..7bcdc8b48f60e 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E304_E30.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E304_E30.py.snap @@ -12,7 +12,6 @@ E30.py:765:1: E304 [*] Blank lines found after function decorator (1) | = help: Remove extraneous blank line(s) -ℹ Safe fix 761 761 | 762 762 | # E304 763 763 | @decorator @@ -31,7 +30,6 @@ E30.py:774:1: E304 [*] Blank lines found after function decorator (1) | = help: Remove extraneous blank line(s) -ℹ Safe fix 769 769 | 770 770 | # E304 771 771 | @decorator @@ -50,7 +48,6 @@ E30.py:786:1: E304 [*] Blank lines found after function decorator (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 778 778 | 779 779 | # E304 780 780 | @decorator diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E305_E30.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E305_E30.py.snap index 6ebd457fc2509..f10e591882032 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E305_E30.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E305_E30.py.snap @@ -10,7 +10,6 @@ E30.py:798:1: E305 [*] Expected 2 blank lines after class or function definition | = help: Add missing blank line(s) -ℹ Safe fix 795 795 | # comment 796 796 | 797 797 | # another comment @@ -29,7 +28,6 @@ E30.py:809:1: E305 [*] Expected 2 blank lines after class or function definition | = help: Add missing blank line(s) -ℹ Safe fix 806 806 | # comment 807 807 | 808 808 | # another comment @@ -50,7 +48,6 @@ E30.py:821:1: E305 [*] Expected 2 blank lines after class or function definition | = help: Add missing blank line(s) -ℹ Safe fix 818 818 | 819 819 | # another comment 820 820 | @@ -69,7 +66,6 @@ E30.py:833:1: E305 [*] Expected 2 blank lines after class or function definition | = help: Add missing blank line(s) -ℹ Safe fix 830 830 | print() 831 831 | 832 832 | # Two spaces before comments, too. @@ -90,7 +86,6 @@ E30.py:846:1: E305 [*] Expected 2 blank lines after class or function definition | = help: Add missing blank line(s) -ℹ Safe fix 843 843 | def main(): 844 844 | blah, blah 845 845 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E306_E30.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E306_E30.py.snap index 8f83acc86f9d3..aadff5667e8c3 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E306_E30.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E306_E30.py.snap @@ -12,7 +12,6 @@ E30.py:854:5: E306 [*] Expected 1 blank line before a nested definition, found 0 | = help: Add missing blank line -ℹ Safe fix 851 851 | # E306:3:5 852 852 | def a(): 853 853 | x = 1 @@ -32,7 +31,6 @@ E30.py:862:5: E306 [*] Expected 1 blank line before a nested definition, found 0 | = help: Add missing blank line -ℹ Safe fix 859 859 | #: E306:3:5 860 860 | async def a(): 861 861 | x = 1 @@ -52,7 +50,6 @@ E30.py:870:5: E306 [*] Expected 1 blank line before a nested definition, found 0 | = help: Add missing blank line -ℹ Safe fix 867 867 | #: E306:3:5 E306:5:9 868 868 | def a(): 869 869 | x = 2 @@ -72,7 +69,6 @@ E30.py:872:9: E306 [*] Expected 1 blank line before a nested definition, found 0 | = help: Add missing blank line -ℹ Safe fix 869 869 | x = 2 870 870 | def b(): 871 871 | x = 1 @@ -92,7 +88,6 @@ E30.py:880:5: E306 [*] Expected 1 blank line before a nested definition, found 0 | = help: Add missing blank line -ℹ Safe fix 877 877 | # E306:3:5 E306:6:5 878 878 | def a(): 879 879 | x = 1 @@ -112,7 +107,6 @@ E30.py:883:5: E306 [*] Expected 1 blank line before a nested definition, found 0 | = help: Add missing blank line -ℹ Safe fix 880 880 | class C: 881 881 | pass 882 882 | x = 2 @@ -131,7 +125,6 @@ E30.py:892:5: E306 [*] Expected 1 blank line before a nested definition, found 0 | = help: Add missing blank line -ℹ Safe fix 889 889 | def foo(): 890 890 | def bar(): 891 891 | pass @@ -151,7 +144,6 @@ E30.py:899:5: E306 [*] Expected 1 blank line before a nested definition, found 0 | = help: Add missing blank line -ℹ Safe fix 896 896 | # E306:3:5 897 897 | def foo(): 898 898 | def bar(): pass @@ -171,7 +163,6 @@ E30.py:907:5: E306 [*] Expected 1 blank line before a nested definition, found 0 | = help: Add missing blank line -ℹ Safe fix 904 904 | # E306 905 905 | def a(): 906 906 | x = 2 @@ -191,7 +182,6 @@ E30.py:916:5: E306 [*] Expected 1 blank line before a nested definition, found 0 | = help: Add missing blank line -ℹ Safe fix 913 913 | # E306 914 914 | def a(): 915 915 | x = 2 @@ -211,7 +201,6 @@ E30.py:925:5: E306 [*] Expected 1 blank line before a nested definition, found 0 | = help: Add missing blank line -ℹ Safe fix 922 922 | # E306 923 923 | def a(): 924 924 | x = 2 diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E401_E40.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E401_E40.py.snap index 165907675e5bc..41091735a399d 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E401_E40.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E401_E40.py.snap @@ -11,7 +11,6 @@ E40.py:2:1: E401 [*] Multiple imports on one line | = help: Split imports -ℹ Safe fix 1 1 | #: E401 2 |-import os, sys 2 |+import os @@ -29,7 +28,6 @@ E40.py:65:1: E401 [*] Multiple imports on one line | = help: Split imports -ℹ Safe fix 62 62 | import bar 63 63 | 64 64 | #: E401 @@ -51,7 +49,6 @@ E40.py:66:1: E401 [*] Multiple imports on one line | = help: Split imports -ℹ Safe fix 63 63 | 64 64 | #: E401 65 65 | import re as regex, string # also with a comment! @@ -70,7 +67,6 @@ E40.py:68:8: E401 [*] Multiple imports on one line | = help: Split imports -ℹ Safe fix 65 65 | import re as regex, string # also with a comment! 66 66 | import re as regex, string; x = 1 67 67 | @@ -90,7 +86,6 @@ E40.py:72:5: E401 [*] Multiple imports on one line | = help: Split imports -ℹ Safe fix 69 69 | 70 70 | 71 71 | def blah(): @@ -111,7 +106,6 @@ E40.py:75:9: E401 [*] Multiple imports on one line | = help: Split imports -ℹ Safe fix 72 72 | import datetime as dt, copy 73 73 | 74 74 | def nested_and_tested(): @@ -132,7 +126,6 @@ E40.py:77:16: E401 [*] Multiple imports on one line | = help: Split imports -ℹ Safe fix 74 74 | def nested_and_tested(): 75 75 | import builtins, textwrap as tw 76 76 | @@ -152,7 +145,6 @@ E40.py:78:9: E401 [*] Multiple imports on one line | = help: Split imports -ℹ Safe fix 75 75 | import builtins, textwrap as tw 76 76 | 77 77 | x = 1; import re as regex, string @@ -170,11 +162,8 @@ E40.py:80:14: E401 [*] Multiple imports on one line | = help: Split imports -ℹ Safe fix 77 77 | x = 1; import re as regex, string 78 78 | import re as regex, string; x = 1 79 79 | 80 |- if True: import re as regex, string 80 |+ if True: import re as regex; import string - - diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E703_E70.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E703_E70.py.snap index 712fd8e14bddd..8453b5e546219 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E703_E70.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E703_E70.py.snap @@ -12,7 +12,6 @@ E70.py:10:13: E703 [*] Statement ends with an unnecessary semicolon | = help: Remove unnecessary semicolon -ℹ Safe fix 7 7 | #: E702:1:17 8 8 | import bdist_egg; bdist_egg.write_safety_flag(cmd.egg_info, safe) 9 9 | #: E703:1:13 @@ -33,7 +32,6 @@ E70.py:12:23: E703 [*] Statement ends with an unnecessary semicolon | = help: Remove unnecessary semicolon -ℹ Safe fix 9 9 | #: E703:1:13 10 10 | import shlex; 11 11 | #: E702:1:9 E703:1:23 @@ -54,7 +52,6 @@ E70.py:25:14: E703 [*] Statement ends with an unnecessary semicolon | = help: Remove unnecessary semicolon -ℹ Safe fix 22 22 | while all is round: 23 23 | def f(x): return 2*x 24 24 | #: E704:1:8 E702:1:11 E703:1:14 @@ -75,7 +72,6 @@ E70.py:68:1: E703 [*] Statement ends with an unnecessary semicolon | = help: Remove unnecessary semicolon -ℹ Safe fix 64 64 | while 1: 65 65 | 1;... 66 66 | #: E703:2:1 @@ -97,7 +93,6 @@ E70.py:71:4: E703 [*] Statement ends with an unnecessary semicolon | = help: Remove unnecessary semicolon -ℹ Safe fix 68 68 | ; 69 69 | #: E701:2:3 70 70 | a = \ @@ -105,5 +100,3 @@ E70.py:71:4: E703 [*] Statement ends with an unnecessary semicolon 71 |+ 5 72 72 | #: 73 73 | with x(y) as z: ... - - diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E703_E703.ipynb.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E703_E703.ipynb.snap index 068f245637b5c..da8ac71b83709 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E703_E703.ipynb.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E703_E703.ipynb.snap @@ -12,7 +12,6 @@ E703.ipynb:5:2: E703 [*] Statement ends with an unnecessary semicolon | = help: Remove unnecessary semicolon -ℹ Safe fix 2 2 | # Simple case 3 3 | x; 4 4 | # Only skip the last expression @@ -33,7 +32,6 @@ E703.ipynb:9:6: E703 [*] Statement ends with an unnecessary semicolon | = help: Remove unnecessary semicolon -ℹ Safe fix 6 6 | x; 7 7 | # Nested expressions isn't relevant 8 8 | if True: @@ -42,5 +40,3 @@ E703.ipynb:9:6: E703 [*] Statement ends with an unnecessary semicolon 10 10 | # Semicolons with multiple expressions 11 11 | x; x; 12 12 | # Comments, newlines and whitespace - - diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E711_E711.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E711_E711.py.snap index ebb91bb228c00..941ede566ebd9 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E711_E711.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E711_E711.py.snap @@ -11,13 +11,6 @@ E711.py:2:11: E711 [*] Comparison to `None` should be `cond is None` | = help: Replace with `cond is None` -ℹ Unsafe fix -1 1 | #: E711 -2 |-if res == None: - 2 |+if res is None: -3 3 | pass -4 4 | #: E711 -5 5 | if res != None: E711.py:5:11: E711 [*] Comparison to `None` should be `cond is not None` | @@ -30,15 +23,6 @@ E711.py:5:11: E711 [*] Comparison to `None` should be `cond is not None` | = help: Replace with `cond is not None` -ℹ Unsafe fix -2 2 | if res == None: -3 3 | pass -4 4 | #: E711 -5 |-if res != None: - 5 |+if res is not None: -6 6 | pass -7 7 | #: E711 -8 8 | if None == res: E711.py:8:4: E711 [*] Comparison to `None` should be `cond is None` | @@ -51,15 +35,6 @@ E711.py:8:4: E711 [*] Comparison to `None` should be `cond is None` | = help: Replace with `cond is None` -ℹ Unsafe fix -5 5 | if res != None: -6 6 | pass -7 7 | #: E711 -8 |-if None == res: - 8 |+if None is res: -9 9 | pass -10 10 | #: E711 -11 11 | if None != res: E711.py:11:4: E711 [*] Comparison to `None` should be `cond is not None` | @@ -72,15 +47,6 @@ E711.py:11:4: E711 [*] Comparison to `None` should be `cond is not None` | = help: Replace with `cond is not None` -ℹ Unsafe fix -8 8 | if None == res: -9 9 | pass -10 10 | #: E711 -11 |-if None != res: - 11 |+if None is not res: -12 12 | pass -13 13 | #: E711 -14 14 | if res[1] == None: E711.py:14:14: E711 [*] Comparison to `None` should be `cond is None` | @@ -93,15 +59,6 @@ E711.py:14:14: E711 [*] Comparison to `None` should be `cond is None` | = help: Replace with `cond is None` -ℹ Unsafe fix -11 11 | if None != res: -12 12 | pass -13 13 | #: E711 -14 |-if res[1] == None: - 14 |+if res[1] is None: -15 15 | pass -16 16 | #: E711 -17 17 | if res[1] != None: E711.py:17:14: E711 [*] Comparison to `None` should be `cond is not None` | @@ -114,15 +71,6 @@ E711.py:17:14: E711 [*] Comparison to `None` should be `cond is not None` | = help: Replace with `cond is not None` -ℹ Unsafe fix -14 14 | if res[1] == None: -15 15 | pass -16 16 | #: E711 -17 |-if res[1] != None: - 17 |+if res[1] is not None: -18 18 | pass -19 19 | #: E711 -20 20 | if None != res[1]: E711.py:20:4: E711 [*] Comparison to `None` should be `cond is not None` | @@ -135,15 +83,6 @@ E711.py:20:4: E711 [*] Comparison to `None` should be `cond is not None` | = help: Replace with `cond is not None` -ℹ Unsafe fix -17 17 | if res[1] != None: -18 18 | pass -19 19 | #: E711 -20 |-if None != res[1]: - 20 |+if None is not res[1]: -21 21 | pass -22 22 | #: E711 -23 23 | if None == res[1]: E711.py:23:4: E711 [*] Comparison to `None` should be `cond is None` | @@ -155,15 +94,6 @@ E711.py:23:4: E711 [*] Comparison to `None` should be `cond is None` | = help: Replace with `cond is None` -ℹ Unsafe fix -20 20 | if None != res[1]: -21 21 | pass -22 22 | #: E711 -23 |-if None == res[1]: - 23 |+if None is res[1]: -24 24 | pass -25 25 | -26 26 | if x == None != None: E711.py:26:9: E711 [*] Comparison to `None` should be `cond is None` | @@ -175,15 +105,6 @@ E711.py:26:9: E711 [*] Comparison to `None` should be `cond is None` | = help: Replace with `cond is None` -ℹ Unsafe fix -23 23 | if None == res[1]: -24 24 | pass -25 25 | -26 |-if x == None != None: - 26 |+if x is None is not None: -27 27 | pass -28 28 | -29 29 | #: Okay E711.py:26:17: E711 [*] Comparison to `None` should be `cond is not None` | @@ -194,15 +115,3 @@ E711.py:26:17: E711 [*] Comparison to `None` should be `cond is not None` 27 | pass | = help: Replace with `cond is not None` - -ℹ Unsafe fix -23 23 | if None == res[1]: -24 24 | pass -25 25 | -26 |-if x == None != None: - 26 |+if x is None is not None: -27 27 | pass -28 28 | -29 29 | #: Okay - - diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E712_E712.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E712_E712.py.snap index 0c98438051b37..714b838b069f9 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E712_E712.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E712_E712.py.snap @@ -11,13 +11,6 @@ E712.py:2:4: E712 [*] Avoid equality comparisons to `True`; use `if res:` for tr | = help: Replace with `res` -ℹ Unsafe fix -1 1 | #: E712 -2 |-if res == True: - 2 |+if res is True: -3 3 | pass -4 4 | #: E712 -5 5 | if res != False: E712.py:5:4: E712 [*] Avoid inequality comparisons to `False`; use `if res:` for truth checks | @@ -30,15 +23,6 @@ E712.py:5:4: E712 [*] Avoid inequality comparisons to `False`; use `if res:` for | = help: Replace with `res` -ℹ Unsafe fix -2 2 | if res == True: -3 3 | pass -4 4 | #: E712 -5 |-if res != False: - 5 |+if res is not False: -6 6 | pass -7 7 | #: E712 -8 8 | if True != res: E712.py:8:4: E712 [*] Avoid inequality comparisons to `True`; use `if not res:` for false checks | @@ -51,15 +35,6 @@ E712.py:8:4: E712 [*] Avoid inequality comparisons to `True`; use `if not res:` | = help: Replace with `not res` -ℹ Unsafe fix -5 5 | if res != False: -6 6 | pass -7 7 | #: E712 -8 |-if True != res: - 8 |+if True is not res: -9 9 | pass -10 10 | #: E712 -11 11 | if False == res: E712.py:11:4: E712 [*] Avoid equality comparisons to `False`; use `if not res:` for false checks | @@ -72,15 +47,6 @@ E712.py:11:4: E712 [*] Avoid equality comparisons to `False`; use `if not res:` | = help: Replace with `not res` -ℹ Unsafe fix -8 8 | if True != res: -9 9 | pass -10 10 | #: E712 -11 |-if False == res: - 11 |+if False is res: -12 12 | pass -13 13 | #: E712 -14 14 | if res[1] == True: E712.py:14:4: E712 [*] Avoid equality comparisons to `True`; use `if res[1]:` for truth checks | @@ -93,15 +59,6 @@ E712.py:14:4: E712 [*] Avoid equality comparisons to `True`; use `if res[1]:` fo | = help: Replace with `res[1]` -ℹ Unsafe fix -11 11 | if False == res: -12 12 | pass -13 13 | #: E712 -14 |-if res[1] == True: - 14 |+if res[1] is True: -15 15 | pass -16 16 | #: E712 -17 17 | if res[1] != False: E712.py:17:4: E712 [*] Avoid inequality comparisons to `False`; use `if res[1]:` for truth checks | @@ -114,15 +71,6 @@ E712.py:17:4: E712 [*] Avoid inequality comparisons to `False`; use `if res[1]:` | = help: Replace with `res[1]` -ℹ Unsafe fix -14 14 | if res[1] == True: -15 15 | pass -16 16 | #: E712 -17 |-if res[1] != False: - 17 |+if res[1] is not False: -18 18 | pass -19 19 | #: E712 -20 20 | var = 1 if cond == True else -1 if cond == False else cond E712.py:20:12: E712 [*] Avoid equality comparisons to `True`; use `if cond:` for truth checks | @@ -135,15 +83,6 @@ E712.py:20:12: E712 [*] Avoid equality comparisons to `True`; use `if cond:` for | = help: Replace with `cond` -ℹ Unsafe fix -17 17 | if res[1] != False: -18 18 | pass -19 19 | #: E712 -20 |-var = 1 if cond == True else -1 if cond == False else cond - 20 |+var = 1 if cond is True else -1 if cond == False else cond -21 21 | #: E712 -22 22 | if (True) == TrueElement or x == TrueElement: -23 23 | pass E712.py:20:36: E712 [*] Avoid equality comparisons to `False`; use `if not cond:` for false checks | @@ -156,15 +95,6 @@ E712.py:20:36: E712 [*] Avoid equality comparisons to `False`; use `if not cond: | = help: Replace with `not cond` -ℹ Unsafe fix -17 17 | if res[1] != False: -18 18 | pass -19 19 | #: E712 -20 |-var = 1 if cond == True else -1 if cond == False else cond - 20 |+var = 1 if cond == True else -1 if cond is False else cond -21 21 | #: E712 -22 22 | if (True) == TrueElement or x == TrueElement: -23 23 | pass E712.py:22:4: E712 [*] Avoid equality comparisons to `True`; use `if TrueElement:` for truth checks | @@ -176,15 +106,6 @@ E712.py:22:4: E712 [*] Avoid equality comparisons to `True`; use `if TrueElement | = help: Replace with `TrueElement` -ℹ Unsafe fix -19 19 | #: E712 -20 20 | var = 1 if cond == True else -1 if cond == False else cond -21 21 | #: E712 -22 |-if (True) == TrueElement or x == TrueElement: - 22 |+if (True) is TrueElement or x == TrueElement: -23 23 | pass -24 24 | -25 25 | if res == True != False: E712.py:25:4: E712 [*] Avoid equality comparisons to `True` or `False` | @@ -196,15 +117,6 @@ E712.py:25:4: E712 [*] Avoid equality comparisons to `True` or `False` | = help: Replace comparison -ℹ Unsafe fix -22 22 | if (True) == TrueElement or x == TrueElement: -23 23 | pass -24 24 | -25 |-if res == True != False: - 25 |+if res is True is not False: -26 26 | pass -27 27 | -28 28 | if(True) == TrueElement or x == TrueElement: E712.py:25:4: E712 [*] Avoid equality comparisons to `True` or `False` | @@ -216,15 +128,6 @@ E712.py:25:4: E712 [*] Avoid equality comparisons to `True` or `False` | = help: Replace comparison -ℹ Unsafe fix -22 22 | if (True) == TrueElement or x == TrueElement: -23 23 | pass -24 24 | -25 |-if res == True != False: - 25 |+if res is True is not False: -26 26 | pass -27 27 | -28 28 | if(True) == TrueElement or x == TrueElement: E712.py:28:3: E712 [*] Avoid equality comparisons to `True`; use `if TrueElement:` for truth checks | @@ -236,15 +139,6 @@ E712.py:28:3: E712 [*] Avoid equality comparisons to `True`; use `if TrueElement | = help: Replace with `TrueElement` -ℹ Unsafe fix -25 25 | if res == True != False: -26 26 | pass -27 27 | -28 |-if(True) == TrueElement or x == TrueElement: - 28 |+if(True) is TrueElement or x == TrueElement: -29 29 | pass -30 30 | -31 31 | if (yield i) == True: E712.py:31:4: E712 [*] Avoid equality comparisons to `True`; use `if yield i:` for truth checks | @@ -255,13 +149,3 @@ E712.py:31:4: E712 [*] Avoid equality comparisons to `True`; use `if yield i:` f 32 | print("even") | = help: Replace with `yield i` - -ℹ Unsafe fix -28 28 | if(True) == TrueElement or x == TrueElement: -29 29 | pass -30 30 | -31 |-if (yield i) == True: - 31 |+if (yield i) is True: -32 32 | print("even") -33 33 | -34 34 | #: Okay diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E713_E713.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E713_E713.py.snap index 44f8669d0f35b..623bf51b5b50d 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E713_E713.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E713_E713.py.snap @@ -11,7 +11,6 @@ E713.py:2:8: E713 [*] Test for membership should be `not in` | = help: Convert to `not in` -ℹ Safe fix 1 1 | #: E713 2 |-if not X in Y: 2 |+if X not in Y: @@ -30,7 +29,6 @@ E713.py:5:8: E713 [*] Test for membership should be `not in` | = help: Convert to `not in` -ℹ Safe fix 2 2 | if not X in Y: 3 3 | pass 4 4 | #: E713 @@ -51,7 +49,6 @@ E713.py:8:8: E713 [*] Test for membership should be `not in` | = help: Convert to `not in` -ℹ Safe fix 5 5 | if not X.B in Y: 6 6 | pass 7 7 | #: E713 @@ -72,7 +69,6 @@ E713.py:11:23: E713 [*] Test for membership should be `not in` | = help: Convert to `not in` -ℹ Safe fix 8 8 | if not X in Y and Z == "zero": 9 9 | pass 10 10 | #: E713 @@ -92,7 +88,6 @@ E713.py:14:9: E713 [*] Test for membership should be `not in` | = help: Convert to `not in` -ℹ Safe fix 11 11 | if X == "zero" or not Y in Z: 12 12 | pass 13 13 | #: E713 @@ -111,11 +106,8 @@ E713.py:40:12: E713 [*] Test for membership should be `not in` | = help: Convert to `not in` -ℹ Safe fix 37 37 | assert {"x": not foo} in bar 38 38 | assert [42, not foo] in bar 39 39 | assert not (re.search(r"^.:\\Users\\[^\\]*\\Downloads\\.*") is None) 40 |-assert not('name' in request)or not request['name'] 40 |+assert 'name' not in request or not request['name'] - - diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E714_E714.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E714_E714.py.snap index fb009a75859a2..a8afb1cf7c7a2 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E714_E714.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E714_E714.py.snap @@ -11,7 +11,6 @@ E714.py:2:8: E714 [*] Test for object identity should be `is not` | = help: Convert to `is not` -ℹ Safe fix 1 1 | #: E714 2 |-if not X is Y: 2 |+if X is not Y: @@ -29,7 +28,6 @@ E714.py:5:8: E714 [*] Test for object identity should be `is not` | = help: Convert to `is not` -ℹ Safe fix 2 2 | if not X is Y: 3 3 | pass 4 4 | #: E714 @@ -48,11 +46,8 @@ E714.py:39:13: E714 [*] Test for object identity should be `is not` | = help: Convert to `is not` -ℹ Safe fix 36 36 | assert (not foo) in bar 37 37 | assert {"x": not foo} in bar 38 38 | assert [42, not foo] in bar 39 |-assert not (re.search(r"^.:\\Users\\[^\\]*\\Downloads\\.*") is None) 39 |+assert re.search(r"^.:\\Users\\[^\\]*\\Downloads\\.*") is not None - - diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E731_E731.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E731_E731.py.snap index 32d034f1e76d7..b2cbb66f2c9a7 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E731_E731.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E731_E731.py.snap @@ -10,15 +10,6 @@ E731.py:3:5: E731 [*] Do not assign a `lambda` expression, use a `def` | = help: Rewrite `f` as a `def` -ℹ Unsafe fix -1 1 | def scope(): -2 2 | # E731 -3 |- f = lambda x: 2 * x - 3 |+ def f(x): - 4 |+ return 2 * x -4 5 | -5 6 | -6 7 | def scope(): E731.py:8:5: E731 [*] Do not assign a `lambda` expression, use a `def` | @@ -29,16 +20,6 @@ E731.py:8:5: E731 [*] Do not assign a `lambda` expression, use a `def` | = help: Rewrite `f` as a `def` -ℹ Unsafe fix -5 5 | -6 6 | def scope(): -7 7 | # E731 -8 |- f = lambda x: 2 * x - 8 |+ def f(x): - 9 |+ return 2 * x -9 10 | -10 11 | -11 12 | def scope(): E731.py:14:9: E731 [*] Do not assign a `lambda` expression, use a `def` | @@ -49,16 +30,6 @@ E731.py:14:9: E731 [*] Do not assign a `lambda` expression, use a `def` | = help: Rewrite `this` as a `def` -ℹ Unsafe fix -11 11 | def scope(): -12 12 | # E731 -13 13 | while False: -14 |- this = lambda y, z: 2 * x - 14 |+ def this(y, z): - 15 |+ return 2 * x -15 16 | -16 17 | -17 18 | def scope(): E731.py:19:5: E731 [*] Do not assign a `lambda` expression, use a `def` | @@ -69,16 +40,6 @@ E731.py:19:5: E731 [*] Do not assign a `lambda` expression, use a `def` | = help: Rewrite `f` as a `def` -ℹ Unsafe fix -16 16 | -17 17 | def scope(): -18 18 | # E731 -19 |- f = lambda: (yield 1) - 19 |+ def f(): - 20 |+ return (yield 1) -20 21 | -21 22 | -22 23 | def scope(): E731.py:24:5: E731 [*] Do not assign a `lambda` expression, use a `def` | @@ -89,16 +50,6 @@ E731.py:24:5: E731 [*] Do not assign a `lambda` expression, use a `def` | = help: Rewrite `f` as a `def` -ℹ Unsafe fix -21 21 | -22 22 | def scope(): -23 23 | # E731 -24 |- f = lambda: (yield from g()) - 24 |+ def f(): - 25 |+ return (yield from g()) -25 26 | -26 27 | -27 28 | def scope(): E731.py:57:5: E731 Do not assign a `lambda` expression, use a `def` | @@ -109,16 +60,6 @@ E731.py:57:5: E731 Do not assign a `lambda` expression, use a `def` | = help: Rewrite `f` as a `def` -ℹ Display-only fix -54 54 | -55 55 | class Scope: -56 56 | # E731 -57 |- f = lambda x: 2 * x - 57 |+ def f(x): - 58 |+ return 2 * x -58 59 | -59 60 | -60 61 | class Scope: E731.py:73:9: E731 Do not assign a `lambda` expression, use a `def` | @@ -131,16 +72,6 @@ E731.py:73:9: E731 Do not assign a `lambda` expression, use a `def` | = help: Rewrite `x` as a `def` -ℹ Display-only fix -70 70 | -71 71 | x: Callable[[int], int] -72 72 | if True: -73 |- x = lambda: 1 - 73 |+ def x(): - 74 |+ return 1 -74 75 | else: -75 76 | x = lambda: 2 -76 77 | return x E731.py:75:9: E731 Do not assign a `lambda` expression, use a `def` | @@ -152,16 +83,6 @@ E731.py:75:9: E731 Do not assign a `lambda` expression, use a `def` | = help: Rewrite `x` as a `def` -ℹ Display-only fix -72 72 | if True: -73 73 | x = lambda: 1 -74 74 | else: -75 |- x = lambda: 2 - 75 |+ def x(): - 76 |+ return 2 -76 77 | return x -77 78 | -78 79 | E731.py:86:5: E731 [*] Do not assign a `lambda` expression, use a `def` | @@ -172,16 +93,6 @@ E731.py:86:5: E731 [*] Do not assign a `lambda` expression, use a `def` | = help: Rewrite `f` as a `def` -ℹ Unsafe fix -83 83 | -84 84 | # ParamSpec cannot be used in this context, so do not preserve the annotation. -85 85 | P = ParamSpec("P") -86 |- f: Callable[P, int] = lambda *args: len(args) - 86 |+ def f(*args): - 87 |+ return len(args) -87 88 | -88 89 | -89 90 | def scope(): E731.py:94:5: E731 [*] Do not assign a `lambda` expression, use a `def` | @@ -192,16 +103,6 @@ E731.py:94:5: E731 [*] Do not assign a `lambda` expression, use a `def` | = help: Rewrite `f` as a `def` -ℹ Unsafe fix -91 91 | -92 92 | from typing import Callable -93 93 | -94 |- f: Callable[[], None] = lambda: None - 94 |+ def f() -> None: - 95 |+ return None -95 96 | -96 97 | -97 98 | def scope(): E731.py:102:5: E731 [*] Do not assign a `lambda` expression, use a `def` | @@ -212,16 +113,6 @@ E731.py:102:5: E731 [*] Do not assign a `lambda` expression, use a `def` | = help: Rewrite `f` as a `def` -ℹ Unsafe fix -99 99 | -100 100 | from typing import Callable -101 101 | -102 |- f: Callable[..., None] = lambda a, b: None - 102 |+ def f(a, b) -> None: - 103 |+ return None -103 104 | -104 105 | -105 106 | def scope(): E731.py:110:5: E731 [*] Do not assign a `lambda` expression, use a `def` | @@ -232,16 +123,6 @@ E731.py:110:5: E731 [*] Do not assign a `lambda` expression, use a `def` | = help: Rewrite `f` as a `def` -ℹ Unsafe fix -107 107 | -108 108 | from typing import Callable -109 109 | -110 |- f: Callable[[int], int] = lambda x: 2 * x - 110 |+ def f(x: int) -> int: - 111 |+ return 2 * x -111 112 | -112 113 | -113 114 | # Let's use the `Callable` type from `collections.abc` instead. E731.py:119:5: E731 [*] Do not assign a `lambda` expression, use a `def` | @@ -252,16 +133,6 @@ E731.py:119:5: E731 [*] Do not assign a `lambda` expression, use a `def` | = help: Rewrite `f` as a `def` -ℹ Unsafe fix -116 116 | -117 117 | from collections.abc import Callable -118 118 | -119 |- f: Callable[[str, int], str] = lambda a, b: a * b - 119 |+ def f(a: str, b: int) -> str: - 120 |+ return a * b -120 121 | -121 122 | -122 123 | def scope(): E731.py:127:5: E731 [*] Do not assign a `lambda` expression, use a `def` | @@ -272,16 +143,6 @@ E731.py:127:5: E731 [*] Do not assign a `lambda` expression, use a `def` | = help: Rewrite `f` as a `def` -ℹ Unsafe fix -124 124 | -125 125 | from collections.abc import Callable -126 126 | -127 |- f: Callable[[str, int], tuple[str, int]] = lambda a, b: (a, b) - 127 |+ def f(a: str, b: int) -> tuple[str, int]: - 128 |+ return a, b -128 129 | -129 130 | -130 131 | def scope(): E731.py:135:5: E731 [*] Do not assign a `lambda` expression, use a `def` | @@ -292,16 +153,6 @@ E731.py:135:5: E731 [*] Do not assign a `lambda` expression, use a `def` | = help: Rewrite `f` as a `def` -ℹ Unsafe fix -132 132 | -133 133 | from collections.abc import Callable -134 134 | -135 |- f: Callable[[str, int, list[str]], list[str]] = lambda a, b, /, c: [*c, a * b] - 135 |+ def f(a: str, b: int, /, c: list[str]) -> list[str]: - 136 |+ return [*c, a * b] -136 137 | -137 138 | -138 139 | class TemperatureScales(Enum): E731.py:139:5: E731 Do not assign a `lambda` expression, use a `def` | @@ -312,16 +163,6 @@ E731.py:139:5: E731 Do not assign a `lambda` expression, use a `def` | = help: Rewrite `CELSIUS` as a `def` -ℹ Display-only fix -136 136 | -137 137 | -138 138 | class TemperatureScales(Enum): -139 |- CELSIUS = (lambda deg_c: deg_c) - 139 |+ def CELSIUS(deg_c): - 140 |+ return deg_c -140 141 | FAHRENHEIT = (lambda deg_c: deg_c * 9 / 5 + 32) -141 142 | -142 143 | E731.py:140:5: E731 Do not assign a `lambda` expression, use a `def` | @@ -332,16 +173,6 @@ E731.py:140:5: E731 Do not assign a `lambda` expression, use a `def` | = help: Rewrite `FAHRENHEIT` as a `def` -ℹ Display-only fix -137 137 | -138 138 | class TemperatureScales(Enum): -139 139 | CELSIUS = (lambda deg_c: deg_c) -140 |- FAHRENHEIT = (lambda deg_c: deg_c * 9 / 5 + 32) - 140 |+ def FAHRENHEIT(deg_c): - 141 |+ return deg_c * 9 / 5 + 32 -141 142 | -142 143 | -143 144 | # Regression test for: https://github.com/astral-sh/ruff/issues/7141 E731.py:147:5: E731 [*] Do not assign a `lambda` expression, use a `def` | @@ -354,16 +185,3 @@ E731.py:147:5: E731 [*] Do not assign a `lambda` expression, use a `def` | |_____^ E731 | = help: Rewrite `f` as a `def` - -ℹ Unsafe fix -144 144 | def scope(): -145 145 | # E731 -146 146 | -147 |- f = lambda: ( -148 |- i := 1, -149 |- ) - 147 |+ def f(): - 148 |+ return (i := 1), -150 149 | -151 150 | -152 151 | from dataclasses import dataclass diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W291_W29.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W291_W29.py.snap index f2e3a64a92a9d..8d7e8caca1ffe 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W291_W29.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W291_W29.py.snap @@ -12,7 +12,6 @@ W29.py:4:6: W291 [*] Trailing whitespace | = help: Remove trailing whitespace -ℹ Safe fix 1 1 | #: Okay 2 2 | # 情 3 3 | #: W291:1:6 @@ -33,7 +32,6 @@ W29.py:11:35: W291 [*] Trailing whitespace | = help: Remove trailing whitespace -ℹ Safe fix 8 8 | bang = 12 9 9 | #: W291:2:35 10 10 | '''multiline @@ -54,7 +52,6 @@ W29.py:13:6: W291 [*] Trailing whitespace | = help: Remove trailing whitespace -ℹ Safe fix 10 10 | '''multiline 11 11 | string with trailing whitespace''' 12 12 | #: W291 W292 noeol @@ -63,5 +60,3 @@ W29.py:13:6: W291 [*] Trailing whitespace 14 14 | #: W191 W292 noeol 15 15 | if False: 16 16 | pass # indented with tabs - - diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W291_W291.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W291_W291.py.snap index 44f7a2f7aec58..8b4a07133cd1e 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W291_W291.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W291_W291.py.snap @@ -9,12 +9,6 @@ W291.py:1:23: W291 [*] Trailing whitespace | = help: Remove trailing whitespace -ℹ Unsafe fix -1 |-'''trailing whitespace - 1 |+'''trailing whitespace -2 2 | inside a multiline string''' -3 3 | -4 4 | f'''trailing whitespace W291.py:4:24: W291 [*] Trailing whitespace | @@ -26,15 +20,6 @@ W291.py:4:24: W291 [*] Trailing whitespace | = help: Remove trailing whitespace -ℹ Unsafe fix -1 1 | '''trailing whitespace -2 2 | inside a multiline string''' -3 3 | -4 |-f'''trailing whitespace - 4 |+f'''trailing whitespace -5 5 | inside a multiline f-string''' -6 6 | -7 7 | # Trailing whitespace after `{` W291.py:8:8: W291 [*] Trailing whitespace | @@ -46,7 +31,6 @@ W291.py:8:8: W291 [*] Trailing whitespace | = help: Remove trailing whitespace -ℹ Safe fix 5 5 | inside a multiline f-string''' 6 6 | 7 7 | # Trailing whitespace after `{` @@ -66,12 +50,9 @@ W291.py:14:10: W291 [*] Trailing whitespace | = help: Remove trailing whitespace -ℹ Safe fix 11 11 | 12 12 | # Trailing whitespace after `2` 13 13 | f'abc { 14 |- 1 + 2 14 |+ 1 + 2 15 15 | }' - - diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W292_W292_0.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W292_W292_0.py.snap index efd7799b3a5c5..ebb8412ff18c4 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W292_W292_0.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W292_W292_0.py.snap @@ -9,9 +9,6 @@ W292_0.py:2:9: W292 [*] No newline at end of file | = help: Add trailing newline -ℹ Safe fix 1 1 | def fn() -> None: 2 |- pass 2 |+ pass - - diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W293_W29.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W293_W29.py.snap index 7ff31152150c0..2c3720573c6e6 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W293_W29.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W293_W29.py.snap @@ -12,7 +12,6 @@ W29.py:7:1: W293 [*] Blank line contains whitespace | = help: Remove whitespace from blank line -ℹ Safe fix 4 4 | print 5 5 | #: W293:2:1 6 6 | class Foo(object): @@ -21,5 +20,3 @@ W29.py:7:1: W293 [*] Blank line contains whitespace 8 8 | bang = 12 9 9 | #: W291:2:35 10 10 | '''multiline - - diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W293_W293.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W293_W293.py.snap index a8f5782d43578..9ea4e80e8b37b 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W293_W293.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W293_W293.py.snap @@ -11,15 +11,6 @@ W293.py:4:1: W293 [*] Blank line contains whitespace | = help: Remove whitespace from blank line -ℹ Unsafe fix -1 1 | # See: https://github.com/astral-sh/ruff/issues/9323 -2 2 | class Chassis(RobotModuleTemplate): -3 3 | """底盘信息推送控制 -4 |- - 4 |+ -5 5 | """\ -6 6 | -7 7 | W293.py:10:1: W293 [*] Blank line contains whitespace | @@ -30,7 +21,6 @@ W293.py:10:1: W293 [*] Blank line contains whitespace | = help: Remove whitespace from blank line -ℹ Safe fix 5 5 | """\ 6 6 | 7 7 | @@ -52,7 +42,6 @@ W293.py:16:1: W293 [*] Blank line contains whitespace | = help: Remove whitespace from blank line -ℹ Safe fix 11 11 | 12 12 | 13 13 | "abc\ @@ -72,13 +61,3 @@ W293.py:18:1: W293 [*] Blank line contains whitespace 19 | inside a multiline string''' | = help: Remove whitespace from blank line - -ℹ Unsafe fix -15 15 | \ -16 16 | -17 17 | '''blank line with whitespace -18 |- - 18 |+ -19 19 | inside a multiline string''' - - diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W605_W605_0.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W605_W605_0.py.snap index 9ce7ff2bca06e..e4278d78b70ff 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W605_W605_0.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W605_W605_0.py.snap @@ -11,7 +11,6 @@ W605_0.py:2:10: W605 [*] Invalid escape sequence: `\.` | = help: Use a raw string literal -ℹ Safe fix 1 1 | #: W605:1:10 2 |-regex = '\.png$' 2 |+regex = r'\.png$' @@ -29,7 +28,6 @@ W605_0.py:6:1: W605 [*] Invalid escape sequence: `\.` | = help: Use a raw string literal -ℹ Safe fix 2 2 | regex = '\.png$' 3 3 | 4 4 | #: W605:2:1 @@ -49,7 +47,6 @@ W605_0.py:11:6: W605 [*] Invalid escape sequence: `\_` | = help: Use a raw string literal -ℹ Safe fix 8 8 | 9 9 | #: W605:2:6 10 10 | f( @@ -70,7 +67,6 @@ W605_0.py:18:6: W605 [*] Invalid escape sequence: `\_` | = help: Use a raw string literal -ℹ Safe fix 12 12 | ) 13 13 | 14 14 | #: W605:4:6 @@ -88,7 +84,6 @@ W605_0.py:23:39: W605 [*] Invalid escape sequence: `\_` | = help: Add backslash to escape sequence -ℹ Safe fix 20 20 | """ 21 21 | 22 22 | #: W605:1:38 @@ -109,7 +104,6 @@ W605_0.py:28:12: W605 [*] Invalid escape sequence: `\.` | = help: Use a raw string literal -ℹ Safe fix 25 25 | 26 26 | def f(): 27 27 | #: W605:1:11 @@ -130,7 +124,6 @@ W605_0.py:45:12: W605 [*] Invalid escape sequence: `\_` | = help: Add backslash to escape sequence -ℹ Safe fix 42 42 | \w 43 43 | ''' # noqa 44 44 | @@ -150,7 +143,6 @@ W605_0.py:48:6: W605 [*] Invalid escape sequence: `\ ` | = help: Use a raw string literal -ℹ Safe fix 45 45 | regex = '\\\_' 46 46 | 47 47 | #: W605:1:7 @@ -170,7 +162,6 @@ W605_0.py:53:9: W605 [*] Invalid escape sequence: `\.` | = help: Add backslash to escape sequence -ℹ Safe fix 50 50 | #: W605:1:13 51 51 | ( 52 52 | "foo \ @@ -190,7 +181,6 @@ W605_0.py:57:6: W605 [*] Invalid escape sequence: `\.` | = help: Add backslash to escape sequence -ℹ Safe fix 54 54 | ) 55 55 | 56 56 | #: W605:1:6 @@ -208,7 +198,6 @@ W605_0.py:60:13: W605 [*] Invalid escape sequence: `\.` | = help: Add backslash to escape sequence -ℹ Safe fix 57 57 | "foo \. bar \t" 58 58 | 59 59 | #: W605:1:13 diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W605_W605_1.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W605_W605_1.py.snap index ea0ced5b4fbb0..d46290fdab078 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W605_W605_1.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W605_W605_1.py.snap @@ -11,7 +11,6 @@ W605_1.py:4:11: W605 [*] Invalid escape sequence: `\.` | = help: Use a raw string literal -ℹ Safe fix 1 1 | # Same as `W605_0.py` but using f-strings instead. 2 2 | 3 3 | #: W605:1:10 @@ -31,7 +30,6 @@ W605_1.py:8:1: W605 [*] Invalid escape sequence: `\.` | = help: Use a raw string literal -ℹ Safe fix 4 4 | regex = f'\.png$' 5 5 | 6 6 | #: W605:2:1 @@ -51,7 +49,6 @@ W605_1.py:13:7: W605 [*] Invalid escape sequence: `\_` | = help: Use a raw string literal -ℹ Safe fix 10 10 | 11 11 | #: W605:2:6 12 12 | f( @@ -72,7 +69,6 @@ W605_1.py:20:6: W605 [*] Invalid escape sequence: `\_` | = help: Use a raw string literal -ℹ Safe fix 14 14 | ) 15 15 | 16 16 | #: W605:4:6 @@ -90,7 +86,6 @@ W605_1.py:25:40: W605 [*] Invalid escape sequence: `\_` | = help: Add backslash to escape sequence -ℹ Safe fix 22 22 | """ 23 23 | 24 24 | #: W605:1:38 @@ -111,7 +106,6 @@ W605_1.py:43:13: W605 [*] Invalid escape sequence: `\_` | = help: Add backslash to escape sequence -ℹ Safe fix 40 40 | \w 41 41 | ''' # noqa 42 42 | @@ -131,7 +125,6 @@ W605_1.py:44:11: W605 [*] Invalid escape sequence: `\{` | = help: Use a raw string literal -ℹ Safe fix 41 41 | ''' # noqa 42 42 | 43 43 | regex = f'\\\_' @@ -152,7 +145,6 @@ W605_1.py:45:11: W605 [*] Invalid escape sequence: `\{` | = help: Use a raw string literal -ℹ Safe fix 42 42 | 43 43 | regex = f'\\\_' 44 44 | value = f'\{{1}}' @@ -173,7 +165,6 @@ W605_1.py:46:14: W605 [*] Invalid escape sequence: `\}` | = help: Use a raw string literal -ℹ Safe fix 43 43 | regex = f'\\\_' 44 44 | value = f'\{{1}}' 45 45 | value = f'\{1}' @@ -193,7 +184,6 @@ W605_1.py:47:14: W605 [*] Invalid escape sequence: `\{` | = help: Use a raw string literal -ℹ Safe fix 44 44 | value = f'\{{1}}' 45 45 | value = f'\{1}' 46 46 | value = f'{1:\}' @@ -214,7 +204,6 @@ W605_1.py:48:15: W605 [*] Invalid escape sequence: `\{` | = help: Use a raw string literal -ℹ Safe fix 45 45 | value = f'\{1}' 46 46 | value = f'{1:\}' 47 47 | value = f"{f"\{1}"}" @@ -234,7 +223,6 @@ W605_1.py:57:9: W605 [*] Invalid escape sequence: `\d` | = help: Use a raw string literal -ℹ Safe fix 54 54 | value = f"{rf"\{1}"}" 55 55 | 56 56 | # Regression tests for https://github.com/astral-sh/ruff/issues/10434 @@ -253,7 +241,6 @@ W605_1.py:58:11: W605 [*] Invalid escape sequence: `\d` | = help: Add backslash to escape sequence -ℹ Safe fix 55 55 | 56 56 | # Regression tests for https://github.com/astral-sh/ruff/issues/10434 57 57 | f"{{}}+-\d" @@ -270,7 +257,6 @@ W605_1.py:59:12: W605 [*] Invalid escape sequence: `\d` | = help: Add backslash to escape sequence -ℹ Safe fix 56 56 | # Regression tests for https://github.com/astral-sh/ruff/issues/10434 57 57 | f"{{}}+-\d" 58 58 | f"\n{{}}+-\d+" diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E301_notebook.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E301_notebook.snap index b128dda953eff..fb10cd76046bb 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E301_notebook.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E301_notebook.snap @@ -12,7 +12,6 @@ E30.ipynb:13:5: E301 [*] Expected 1 blank line, found 0 | = help: Add missing blank line -ℹ Safe fix 10 10 | 11 11 | def method(cls) -> None: 12 12 | pass diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E302_notebook.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E302_notebook.snap index eada536b020d9..8f89a9dbf632e 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E302_notebook.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E302_notebook.snap @@ -12,7 +12,6 @@ E30.ipynb:21:1: E302 [*] Expected 2 blank lines, found 1 | = help: Add missing blank line(s) -ℹ Safe fix 18 18 | def a(): 19 19 | pass 20 20 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E303_notebook.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E303_notebook.snap index ce20914578b92..32e286d3b40f5 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E303_notebook.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E303_notebook.snap @@ -10,7 +10,6 @@ E30.ipynb:29:5: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 25 25 | def fn(): 26 26 | _ = None 27 27 | @@ -28,7 +27,6 @@ E30.ipynb:39:1: E303 [*] Too many blank lines (4) | = help: Remove extraneous blank line(s) -ℹ Safe fix 34 34 | # E303 35 35 | 36 36 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E303_typing_stub.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E303_typing_stub.snap index 520a83ea86ff2..2b50d7cf940b3 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E303_typing_stub.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E303_typing_stub.snap @@ -10,7 +10,6 @@ E30.pyi:17:1: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 13 13 | @overload 14 14 | def a(arg: int, name: str): ... 15 15 | @@ -28,7 +27,6 @@ E30.pyi:22:1: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 18 18 | def grouped2(): ... 19 19 | def grouped3( ): ... 20 20 | @@ -45,7 +43,6 @@ E30.pyi:35:5: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 31 31 | 32 32 | def with_blank_line(): ... 33 33 | @@ -63,7 +60,6 @@ E30.pyi:43:1: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 39 39 | pass 40 40 | b = "test" 41 41 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E304_notebook.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E304_notebook.snap index 7e09f8d244ca7..ec439a3263389 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E304_notebook.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E304_notebook.snap @@ -12,7 +12,6 @@ E30.ipynb:45:1: E304 [*] Blank lines found after function decorator (1) | = help: Remove extraneous blank line(s) -ℹ Safe fix 41 41 | # end 42 42 | # E304 43 43 | @decorator diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E304_typing_stub.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E304_typing_stub.snap index 565eeed36e6a6..733465fca1b9c 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E304_typing_stub.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E304_typing_stub.snap @@ -10,7 +10,6 @@ E30.pyi:32:5: E304 [*] Blank lines found after function decorator (1) | = help: Remove extraneous blank line(s) -ℹ Safe fix 28 28 | def grouped2(): ... 29 29 | def grouped3( ): ... 30 30 | @decorated diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E305_notebook.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E305_notebook.snap index 9672329251a92..00528a2e121cc 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E305_notebook.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E305_notebook.snap @@ -11,7 +11,6 @@ E30.ipynb:55:1: E305 [*] Expected 2 blank lines after class or function definiti | = help: Add missing blank line(s) -ℹ Safe fix 52 52 | # comment 53 53 | 54 54 | # another comment diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E306_notebook.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E306_notebook.snap index 7f1131c23f394..f94fc15923655 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E306_notebook.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E306_notebook.snap @@ -12,7 +12,6 @@ E30.ipynb:60:5: E306 [*] Expected 1 blank line before a nested definition, found | = help: Add missing blank line -ℹ Safe fix 57 57 | # E306:3:5 58 58 | def a(): 59 59 | x = 1 diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(-1)-between(0).snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(-1)-between(0).snap index 7b01f96447d7e..c2b25bfc811aa 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(-1)-between(0).snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(-1)-between(0).snap @@ -15,7 +15,6 @@ E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 1 | import json 2 |- 3 |- @@ -35,7 +34,6 @@ E30_isort.py:23:1: E302 [*] Expected 2 blank lines, found 1 | = help: Add missing blank line(s) -ℹ Safe fix 20 20 | 21 21 | abcd.foo() 22 22 | @@ -59,7 +57,6 @@ E30_isort.py:26:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 25 25 | if TYPE_CHECKING: 26 26 | import os 27 27 | @@ -79,7 +76,6 @@ E30_isort.py:35:1: E302 [*] Expected 2 blank lines, found 1 | = help: Add missing blank line(s) -ℹ Safe fix 32 32 | 33 33 | abcd.foo() 34 34 | @@ -98,7 +94,6 @@ E30_isort.py:41:1: E302 [*] Expected 2 blank lines, found 1 | = help: Add missing blank line(s) -ℹ Safe fix 38 38 | if TYPE_CHECKING: 39 39 | from typing_extensions import TypeAlias 40 40 | @@ -116,7 +111,6 @@ E30_isort.py:60:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 59 59 | 60 60 | from typing import Any, Sequence 61 61 | @@ -132,7 +126,6 @@ E30_isort.py:62:1: E302 [*] Expected 2 blank lines, found 1 | = help: Add missing blank line(s) -ℹ Safe fix 59 59 | 60 60 | from typing import Any, Sequence 61 61 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(0)-between(0).snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(0)-between(0).snap index 92e7ce4e2e43f..99b01df5d38fc 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(0)-between(0).snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(0)-between(0).snap @@ -15,7 +15,6 @@ E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 1 | import json 2 |- 3 |- @@ -38,7 +37,6 @@ E30_isort.py:23:1: E302 [*] Expected 2 blank lines, found 1 | = help: Add missing blank line(s) -ℹ Safe fix 20 20 | 21 21 | abcd.foo() 22 22 | @@ -62,7 +60,6 @@ E30_isort.py:26:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 25 25 | if TYPE_CHECKING: 26 26 | import os 27 27 | @@ -82,7 +79,6 @@ E30_isort.py:35:1: E302 [*] Expected 2 blank lines, found 1 | = help: Add missing blank line(s) -ℹ Safe fix 32 32 | 33 33 | abcd.foo() 34 34 | @@ -101,7 +97,6 @@ E30_isort.py:41:1: E302 [*] Expected 2 blank lines, found 1 | = help: Add missing blank line(s) -ℹ Safe fix 38 38 | if TYPE_CHECKING: 39 39 | from typing_extensions import TypeAlias 40 40 | @@ -119,7 +114,6 @@ E30_isort.py:60:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 58 58 | 59 59 | 60 60 | from typing import Any, Sequence diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(1)-between(1).snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(1)-between(1).snap index 2e8fed4bd6c27..cbd87faf91487 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(1)-between(1).snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(1)-between(1).snap @@ -15,7 +15,6 @@ E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 1 | import json 2 2 | 3 |- @@ -37,7 +36,6 @@ E30_isort.py:23:1: E302 [*] Expected 2 blank lines, found 1 | = help: Add missing blank line(s) -ℹ Safe fix 20 20 | 21 21 | abcd.foo() 22 22 | @@ -61,7 +59,6 @@ E30_isort.py:26:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 25 25 | if TYPE_CHECKING: 26 26 | import os 27 27 | @@ -81,7 +78,6 @@ E30_isort.py:35:1: E302 [*] Expected 2 blank lines, found 1 | = help: Add missing blank line(s) -ℹ Safe fix 32 32 | 33 33 | abcd.foo() 34 34 | @@ -100,7 +96,6 @@ E30_isort.py:41:1: E302 [*] Expected 2 blank lines, found 1 | = help: Add missing blank line(s) -ℹ Safe fix 38 38 | if TYPE_CHECKING: 39 39 | from typing_extensions import TypeAlias 40 40 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(4)-between(4).snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(4)-between(4).snap index c24ef9e346b1d..b8236a3f366ed 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(4)-between(4).snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(4)-between(4).snap @@ -15,7 +15,6 @@ E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 2 2 | 3 3 | 4 4 | @@ -36,7 +35,6 @@ E30_isort.py:8:1: E302 [*] Expected 4 blank lines, found 2 | = help: Add missing blank line(s) -ℹ Safe fix 5 5 | from typing import Any, Sequence 6 6 | 7 7 | @@ -57,7 +55,6 @@ E30_isort.py:23:1: E302 [*] Expected 2 blank lines, found 1 | = help: Add missing blank line(s) -ℹ Safe fix 20 20 | 21 21 | abcd.foo() 22 22 | @@ -81,7 +78,6 @@ E30_isort.py:26:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 25 25 | if TYPE_CHECKING: 26 26 | import os 27 27 | @@ -101,7 +97,6 @@ E30_isort.py:35:1: E302 [*] Expected 2 blank lines, found 1 | = help: Add missing blank line(s) -ℹ Safe fix 32 32 | 33 33 | abcd.foo() 34 34 | @@ -120,7 +115,6 @@ E30_isort.py:41:1: E302 [*] Expected 2 blank lines, found 1 | = help: Add missing blank line(s) -ℹ Safe fix 38 38 | if TYPE_CHECKING: 39 39 | from typing_extensions import TypeAlias 40 40 | @@ -138,7 +132,6 @@ E30_isort.py:60:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 59 59 | 60 60 | from typing import Any, Sequence 61 61 | @@ -156,7 +149,6 @@ E30_isort.py:62:1: E302 [*] Expected 4 blank lines, found 1 | = help: Add missing blank line(s) -ℹ Safe fix 59 59 | 60 60 | from typing import Any, Sequence 61 61 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_typing_stub_isort.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_typing_stub_isort.snap index ea026fcf0733a..41188f1e2a35d 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_typing_stub_isort.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_typing_stub_isort.snap @@ -15,7 +15,6 @@ E30_isort.pyi:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 1 | import json 2 |- 3 |- @@ -33,7 +32,6 @@ E30_isort.pyi:5:1: E303 [*] Too many blank lines (3) | = help: Remove extraneous blank line(s) -ℹ Safe fix 1 1 | import json 2 2 | 3 |- @@ -49,7 +47,6 @@ E30_isort.pyi:8:1: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 4 4 | 5 5 | from typing import Any, Sequence 6 6 | @@ -67,7 +64,6 @@ E30_isort.pyi:11:1: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 7 7 | 8 8 | class MissingCommand(TypeError): ... # noqa: N818 9 9 | @@ -84,7 +80,6 @@ E30_isort.pyi:17:1: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 13 13 | backend_object: str | None 14 14 | backend: Any 15 15 | @@ -102,7 +97,6 @@ E30_isort.pyi:21:5: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 17 17 | if __name__ == "__main__": 18 18 | import abcd 19 19 | @@ -126,7 +120,6 @@ E30_isort.pyi:26:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 25 25 | if TYPE_CHECKING: 26 26 | import os 27 27 | @@ -143,7 +136,6 @@ E30_isort.pyi:30:5: E303 [*] Too many blank lines (3) | = help: Remove extraneous blank line(s) -ℹ Safe fix 25 25 | if TYPE_CHECKING: 26 26 | import os 27 27 | @@ -162,7 +154,6 @@ E30_isort.pyi:33:5: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 29 29 | 30 30 | from typing_extensions import TypeAlias 31 31 | @@ -178,7 +169,6 @@ E30_isort.pyi:45:1: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 41 41 | def __call__2(self, name: str, *args: Any, **kwargs: Any) -> Any: 42 42 | ... 43 43 | @@ -194,7 +184,6 @@ E30_isort.pyi:48:1: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 44 44 | 45 45 | def _exit(self) -> None: ... 46 46 | @@ -210,7 +199,6 @@ E30_isort.pyi:51:1: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 47 47 | 48 48 | def _optional_commands(self) -> dict[str, bool]: ... 49 49 | @@ -226,7 +214,6 @@ E30_isort.pyi:54:1: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 50 50 | 51 51 | def run(argv: Sequence[str]) -> int: ... 52 52 | @@ -242,7 +229,6 @@ E30_isort.pyi:57:1: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 53 53 | 54 54 | def read_line(fd: int = 0) -> bytearray: ... 55 55 | @@ -260,7 +246,6 @@ E30_isort.pyi:60:1: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 56 56 | 57 57 | def flush() -> None: ... 58 58 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__constant_literals.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__constant_literals.snap index 83478872dfd16..72ef6a331a134 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__constant_literals.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__constant_literals.snap @@ -12,7 +12,6 @@ constant_literals.py:4:4: F632 [*] Use `==` to compare constant literals | = help: Replace `is` with `==` -ℹ Safe fix 1 1 | ### 2 2 | # Errors 3 3 | ### @@ -33,7 +32,6 @@ constant_literals.py:6:4: F632 [*] Use `==` to compare constant literals | = help: Replace `is` with `==` -ℹ Safe fix 3 3 | ### 4 4 | if "abc" is "def": # F632 (fix) 5 5 | pass @@ -54,7 +52,6 @@ constant_literals.py:8:4: F632 [*] Use `==` to compare constant literals | = help: Replace `is` with `==` -ℹ Safe fix 5 5 | pass 6 6 | if "abc" is None: # F632 (fix, but leaves behind unfixable E711) 7 7 | pass @@ -75,7 +72,6 @@ constant_literals.py:10:4: F632 [*] Use `==` to compare constant literals | = help: Replace `is` with `==` -ℹ Safe fix 7 7 | pass 8 8 | if None is "abc": # F632 (fix, but leaves behind unfixable E711) 9 9 | pass @@ -96,7 +92,6 @@ constant_literals.py:12:4: F632 [*] Use `==` to compare constant literals | = help: Replace `is` with `==` -ℹ Safe fix 9 9 | pass 10 10 | if "abc" is False: # F632 (fix, but leaves behind unfixable E712) 11 11 | pass @@ -117,15 +112,6 @@ constant_literals.py:14:4: E712 [*] Avoid equality comparisons to `False`; use ` | = help: Replace with `not None` -ℹ Unsafe fix -11 11 | pass -12 12 | if False is "abc": # F632 (fix, but leaves behind unfixable E712) -13 13 | pass -14 |-if False == None: # E711, E712 (fix) - 14 |+if False is None: # E711, E712 (fix) -15 15 | pass -16 16 | if None == False: # E711, E712 (fix) -17 17 | pass constant_literals.py:14:13: E711 [*] Comparison to `None` should be `cond is None` | @@ -138,15 +124,6 @@ constant_literals.py:14:13: E711 [*] Comparison to `None` should be `cond is Non | = help: Replace with `cond is None` -ℹ Unsafe fix -11 11 | pass -12 12 | if False is "abc": # F632 (fix, but leaves behind unfixable E712) -13 13 | pass -14 |-if False == None: # E711, E712 (fix) - 14 |+if False is None: # E711, E712 (fix) -15 15 | pass -16 16 | if None == False: # E711, E712 (fix) -17 17 | pass constant_literals.py:16:4: E711 [*] Comparison to `None` should be `cond is None` | @@ -158,15 +135,6 @@ constant_literals.py:16:4: E711 [*] Comparison to `None` should be `cond is None | = help: Replace with `cond is None` -ℹ Unsafe fix -13 13 | pass -14 14 | if False == None: # E711, E712 (fix) -15 15 | pass -16 |-if None == False: # E711, E712 (fix) - 16 |+if None is False: # E711, E712 (fix) -17 17 | pass -18 18 | -19 19 | named_var = [] constant_literals.py:16:4: E712 [*] Avoid equality comparisons to `False`; use `if not None:` for false checks | @@ -178,15 +146,6 @@ constant_literals.py:16:4: E712 [*] Avoid equality comparisons to `False`; use ` | = help: Replace with `not None` -ℹ Unsafe fix -13 13 | pass -14 14 | if False == None: # E711, E712 (fix) -15 15 | pass -16 |-if None == False: # E711, E712 (fix) - 16 |+if None is False: # E711, E712 (fix) -17 17 | pass -18 18 | -19 19 | named_var = [] constant_literals.py:20:4: F632 [*] Use `==` to compare constant literals | @@ -198,7 +157,6 @@ constant_literals.py:20:4: F632 [*] Use `==` to compare constant literals | = help: Replace `is` with `==` -ℹ Safe fix 17 17 | pass 18 18 | 19 19 | named_var = [] @@ -219,7 +177,6 @@ constant_literals.py:22:4: F632 [*] Use `==` to compare constant literals | = help: Replace `is` with `==` -ℹ Safe fix 19 19 | named_var = [] 20 20 | if [] is []: # F632 (fix) 21 21 | pass @@ -240,7 +197,6 @@ constant_literals.py:24:4: F632 [*] Use `==` to compare constant literals | = help: Replace `is` with `==` -ℹ Safe fix 21 21 | pass 22 22 | if named_var is []: # F632 (fix) 23 23 | pass @@ -261,7 +217,6 @@ constant_literals.py:26:4: F632 [*] Use `==` to compare constant literals | = help: Replace `is` with `==` -ℹ Safe fix 23 23 | pass 24 24 | if [] is named_var: # F632 (fix) 25 25 | pass @@ -282,7 +237,6 @@ constant_literals.py:28:4: F632 [*] Use `==` to compare constant literals | = help: Replace `is` with `==` -ℹ Safe fix 25 25 | pass 26 26 | if named_var is [1]: # F632 (fix) 27 27 | pass @@ -302,7 +256,6 @@ constant_literals.py:30:4: F632 [*] Use `==` to compare constant literals | = help: Replace `is` with `==` -ℹ Safe fix 27 27 | pass 28 28 | if [1] is named_var: # F632 (fix) 29 29 | pass @@ -322,7 +275,6 @@ constant_literals.py:34:4: F632 [*] Use `==` to compare constant literals | = help: Replace `is` with `==` -ℹ Safe fix 31 31 | pass 32 32 | 33 33 | named_var = {} @@ -343,7 +295,6 @@ constant_literals.py:36:4: F632 [*] Use `==` to compare constant literals | = help: Replace `is` with `==` -ℹ Safe fix 33 33 | named_var = {} 34 34 | if {} is {}: # F632 (fix) 35 35 | pass @@ -364,7 +315,6 @@ constant_literals.py:38:4: F632 [*] Use `==` to compare constant literals | = help: Replace `is` with `==` -ℹ Safe fix 35 35 | pass 36 36 | if named_var is {}: # F632 (fix) 37 37 | pass @@ -385,7 +335,6 @@ constant_literals.py:40:4: F632 [*] Use `==` to compare constant literals | = help: Replace `is` with `==` -ℹ Safe fix 37 37 | pass 38 38 | if {} is named_var: # F632 (fix) 39 39 | pass @@ -406,7 +355,6 @@ constant_literals.py:42:4: F632 [*] Use `==` to compare constant literals | = help: Replace `is` with `==` -ℹ Safe fix 39 39 | pass 40 40 | if named_var is {1}: # F632 (fix) 41 41 | pass @@ -426,7 +374,6 @@ constant_literals.py:44:4: F632 [*] Use `==` to compare constant literals | = help: Replace `is` with `==` -ℹ Safe fix 41 41 | pass 42 42 | if {1} is named_var: # F632 (fix) 43 43 | pass @@ -446,7 +393,6 @@ constant_literals.py:48:4: F632 [*] Use `==` to compare constant literals | = help: Replace `is` with `==` -ℹ Safe fix 45 45 | pass 46 46 | 47 47 | named_var = {1: 1} @@ -467,7 +413,6 @@ constant_literals.py:50:4: F632 [*] Use `==` to compare constant literals | = help: Replace `is` with `==` -ℹ Safe fix 47 47 | named_var = {1: 1} 48 48 | if {1: 1} is {1: 1}: # F632 (fix) 49 49 | pass @@ -488,7 +433,6 @@ constant_literals.py:52:4: F632 [*] Use `==` to compare constant literals | = help: Replace `is` with `==` -ℹ Safe fix 49 49 | pass 50 50 | if named_var is {1: 1}: # F632 (fix) 51 51 | pass @@ -509,7 +453,6 @@ constant_literals.py:54:4: F632 [*] Use `==` to compare constant literals | = help: Replace `is` with `==` -ℹ Safe fix 51 51 | pass 52 52 | if {1: 1} is named_var: # F632 (fix) 53 53 | pass @@ -530,7 +473,6 @@ constant_literals.py:56:4: F632 [*] Use `==` to compare constant literals | = help: Replace `is` with `==` -ℹ Safe fix 53 53 | pass 54 54 | if named_var is {1: 1}: # F632 (fix) 55 55 | pass @@ -550,7 +492,6 @@ constant_literals.py:58:4: F632 [*] Use `==` to compare constant literals | = help: Replace `is` with `==` -ℹ Safe fix 55 55 | pass 56 56 | if {1: 1} is named_var: # F632 (fix) 57 57 | pass diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__E502_E502.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__E502_E502.py.snap index 6862f6161fdb1..ea42b070e9558 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__E502_E502.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__E502_E502.py.snap @@ -12,7 +12,6 @@ E502.py:9:9: E502 [*] Redundant backslash | = help: Remove redundant backslash -ℹ Safe fix 6 6 | 3 \ 7 7 | + 4 8 8 | @@ -31,7 +30,6 @@ E502.py:10:11: E502 [*] Redundant backslash | = help: Remove redundant backslash -ℹ Safe fix 7 7 | + 4 8 8 | 9 9 | a = (3 -\ @@ -51,7 +49,6 @@ E502.py:14:9: E502 [*] Redundant backslash | = help: Remove redundant backslash -ℹ Safe fix 11 11 | 7) 12 12 | 13 13 | z = 5 + \ @@ -72,7 +69,6 @@ E502.py:15:11: E502 [*] Redundant backslash | = help: Remove redundant backslash -ℹ Safe fix 12 12 | 13 13 | z = 5 + \ 14 14 | (3 -\ @@ -92,7 +88,6 @@ E502.py:23:17: E502 [*] Redundant backslash | = help: Remove redundant backslash -ℹ Safe fix 20 20 | 2] 21 21 | 22 22 | b = [ @@ -113,7 +108,6 @@ E502.py:24:8: E502 [*] Redundant backslash | = help: Remove redundant backslash -ℹ Safe fix 21 21 | 22 22 | b = [ 23 23 | 2 + 4 + 5 + \ @@ -133,7 +127,6 @@ E502.py:29:11: E502 [*] Redundant backslash | = help: Remove redundant backslash -ℹ Safe fix 26 26 | ] 27 27 | 28 28 | c = (True and @@ -154,7 +147,6 @@ E502.py:30:14: E502 [*] Redundant backslash | = help: Remove redundant backslash -ℹ Safe fix 27 27 | 28 28 | c = (True and 29 29 | False \ @@ -174,7 +166,6 @@ E502.py:31:14: E502 [*] Redundant backslash | = help: Remove redundant backslash -ℹ Safe fix 28 28 | c = (True and 29 29 | False \ 30 30 | or False \ @@ -194,7 +185,6 @@ E502.py:44:14: E502 [*] Redundant backslash | = help: Remove redundant backslash -ℹ Safe fix 41 41 | 42 42 | 43 43 | s = { @@ -212,7 +202,6 @@ E502.py:55:12: E502 [*] Redundant backslash | = help: Remove redundant backslash -ℹ Safe fix 52 52 | } 53 53 | 54 54 | @@ -233,7 +222,6 @@ E502.py:61:9: E502 [*] Redundant backslash | = help: Remove redundant backslash -ℹ Safe fix 58 58 | y = ( 59 59 | 2 + 2 # \ 60 60 | + 3 # \ @@ -253,7 +241,6 @@ E502.py:82:12: E502 [*] Redundant backslash | = help: Remove redundant backslash -ℹ Safe fix 79 79 | x = "abc" \ 80 80 | "xyz" 81 81 | @@ -272,7 +259,6 @@ E502.py:87:14: E502 [*] Redundant backslash | = help: Remove redundant backslash -ℹ Safe fix 84 84 | 85 85 | 86 86 | def foo(): diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391_0.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391_0.py.snap index 643743f66be96..4465233d6bb39 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391_0.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391_0.py.snap @@ -10,7 +10,6 @@ W391_0.py:14:1: W391 [*] Extra newline at end of file | = help: Remove trailing newline -ℹ Safe fix 11 11 | if __name__ == '__main__': 12 12 | foo() 13 13 | bar() diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391_2.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391_2.py.snap index 8ca9ecd0c1458..4d285d4fbef9e 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391_2.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391_2.py.snap @@ -12,7 +12,6 @@ W391_2.py:14:1: W391 [*] Too many newlines at end of file | = help: Remove trailing newlines -ℹ Safe fix 11 11 | if __name__ == '__main__': 12 12 | foo() 13 13 | bar() diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__shebang.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__shebang.snap index fa3897bebc056..1bcda0a025dc3 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__shebang.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__shebang.snap @@ -11,11 +11,8 @@ shebang.py:3:1: E265 [*] Block comment should start with `# ` | = help: Format space -ℹ Safe fix 1 1 | #!/usr/bin/python 2 2 | # 3 |-#! 3 |+# ! 4 4 | #: - - diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(-1)-between(0).snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(-1)-between(0).snap index 8e0ac4d6f2f6e..43986e2885eb2 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(-1)-between(0).snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(-1)-between(0).snap @@ -15,7 +15,6 @@ E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 1 | import json 2 |- 3 |- @@ -31,7 +30,6 @@ E30_isort.py:5:1: E303 [*] Too many blank lines (3) | = help: Remove extraneous blank line(s) -ℹ Safe fix 1 1 | import json 2 2 | 3 3 | @@ -49,7 +47,6 @@ E30_isort.py:21:5: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 17 17 | if __name__ == "__main__": 18 18 | import abcd 19 19 | @@ -73,7 +70,6 @@ E30_isort.py:26:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 25 25 | if TYPE_CHECKING: 26 26 | import os 27 27 | @@ -90,7 +86,6 @@ E30_isort.py:30:5: E303 [*] Too many blank lines (3) | = help: Remove extraneous blank line(s) -ℹ Safe fix 25 25 | if TYPE_CHECKING: 26 26 | import os 27 27 | @@ -109,7 +104,6 @@ E30_isort.py:33:5: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 29 29 | 30 30 | from typing_extensions import TypeAlias 31 31 | @@ -127,7 +121,6 @@ E30_isort.py:60:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 59 59 | 60 60 | from typing import Any, Sequence 61 61 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(0)-between(0).snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(0)-between(0).snap index 092f7ecbde343..e55a70c3d7d13 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(0)-between(0).snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(0)-between(0).snap @@ -15,7 +15,6 @@ E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 1 | import json 2 |- 3 |- @@ -34,7 +33,6 @@ E30_isort.py:5:1: E303 [*] Too many blank lines (3) | = help: Remove extraneous blank line(s) -ℹ Safe fix 1 1 | import json 2 2 | 3 3 | @@ -50,7 +48,6 @@ E30_isort.py:8:1: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 3 3 | 4 4 | 5 5 | from typing import Any, Sequence @@ -69,7 +66,6 @@ E30_isort.py:21:5: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 17 17 | if __name__ == "__main__": 18 18 | import abcd 19 19 | @@ -93,7 +89,6 @@ E30_isort.py:26:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 25 25 | if TYPE_CHECKING: 26 26 | import os 27 27 | @@ -110,7 +105,6 @@ E30_isort.py:30:5: E303 [*] Too many blank lines (3) | = help: Remove extraneous blank line(s) -ℹ Safe fix 25 25 | if TYPE_CHECKING: 26 26 | import os 27 27 | @@ -129,7 +123,6 @@ E30_isort.py:33:5: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 29 29 | 30 30 | from typing_extensions import TypeAlias 31 31 | @@ -147,7 +140,6 @@ E30_isort.py:60:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 58 58 | 59 59 | 60 60 | from typing import Any, Sequence @@ -163,7 +155,6 @@ E30_isort.py:62:1: E303 [*] Too many blank lines (1) | = help: Remove extraneous blank line(s) -ℹ Safe fix 58 58 | 59 59 | 60 60 | from typing import Any, Sequence diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(1)-between(1).snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(1)-between(1).snap index 3ba9a6f5e8c21..e822b3058aaa9 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(1)-between(1).snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(1)-between(1).snap @@ -15,7 +15,6 @@ E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 1 | import json 2 2 | 3 |- @@ -33,7 +32,6 @@ E30_isort.py:5:1: E303 [*] Too many blank lines (3) | = help: Remove extraneous blank line(s) -ℹ Safe fix 1 1 | import json 2 2 | 3 3 | @@ -49,7 +47,6 @@ E30_isort.py:8:1: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 4 4 | 5 5 | from typing import Any, Sequence 6 6 | @@ -67,7 +64,6 @@ E30_isort.py:21:5: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 17 17 | if __name__ == "__main__": 18 18 | import abcd 19 19 | @@ -91,7 +87,6 @@ E30_isort.py:26:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 25 25 | if TYPE_CHECKING: 26 26 | import os 27 27 | @@ -108,7 +103,6 @@ E30_isort.py:30:5: E303 [*] Too many blank lines (3) | = help: Remove extraneous blank line(s) -ℹ Safe fix 25 25 | if TYPE_CHECKING: 26 26 | import os 27 27 | @@ -127,7 +121,6 @@ E30_isort.py:33:5: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 29 29 | 30 30 | from typing_extensions import TypeAlias 31 31 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(4)-between(4).snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(4)-between(4).snap index b4ebcc11a63ce..84f454bbee57c 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(4)-between(4).snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(4)-between(4).snap @@ -15,7 +15,6 @@ E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 2 2 | 3 3 | 4 4 | @@ -38,7 +37,6 @@ E30_isort.py:21:5: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 17 17 | if __name__ == "__main__": 18 18 | import abcd 19 19 | @@ -62,7 +60,6 @@ E30_isort.py:26:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 25 25 | if TYPE_CHECKING: 26 26 | import os 27 27 | @@ -81,7 +78,6 @@ E30_isort.py:33:5: E303 [*] Too many blank lines (2) | = help: Remove extraneous blank line(s) -ℹ Safe fix 29 29 | 30 30 | from typing_extensions import TypeAlias 31 31 | @@ -99,7 +95,6 @@ E30_isort.py:60:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 59 59 | 60 60 | from typing import Any, Sequence 61 61 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__w292_4.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__w292_4.snap index 8761934c7442c..3809d820259c2 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__w292_4.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__w292_4.snap @@ -8,8 +8,5 @@ W292_4.py:1:2: W292 [*] No newline at end of file | = help: Add trailing newline -ℹ Safe fix 1 |- - 1 |+ - - + 1 |+ diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D200_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D200_D.py.snap index 85ada6d00fdb2..9fa448f6cb742 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D200_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D200_D.py.snap @@ -13,17 +13,6 @@ D.py:129:5: D200 [*] One-line docstring should fit on one line | = help: Reformat to one line -ℹ Unsafe fix -126 126 | '(found 3)') -127 127 | @expect('D212: Multi-line docstring summary should start at the first line') -128 128 | def asdlkfasd(): -129 |- """ -130 |- Wrong. -131 |- """ - 129 |+ """Wrong.""" -132 130 | -133 131 | -134 132 | @expect('D201: No blank lines allowed before function docstring (found 1)') D.py:597:5: D200 [*] One-line docstring should fit on one line | @@ -37,17 +26,6 @@ D.py:597:5: D200 [*] One-line docstring should fit on one line | = help: Reformat to one line -ℹ Unsafe fix -594 594 | '(found 3)') -595 595 | @expect('D212: Multi-line docstring summary should start at the first line') -596 596 | def one_liner(): -597 |- """ -598 |- -599 |- Wrong.""" - 597 |+ """Wrong.""" -600 598 | -601 599 | -602 600 | @expect('D200: One-line docstring should fit on one line with quotes ' D.py:606:5: D200 [*] One-line docstring should fit on one line | @@ -61,17 +39,6 @@ D.py:606:5: D200 [*] One-line docstring should fit on one line | = help: Reformat to one line -ℹ Unsafe fix -603 603 | '(found 3)') -604 604 | @expect('D212: Multi-line docstring summary should start at the first line') -605 605 | def one_liner(): -606 |- r"""Wrong. -607 |- -608 |- """ - 606 |+ r"""Wrong.""" -609 607 | -610 608 | -611 609 | @expect('D200: One-line docstring should fit on one line with quotes ' D.py:615:5: D200 One-line docstring should fit on one line | @@ -108,5 +75,3 @@ D.py:645:5: D200 One-line docstring should fit on one line 648 | class StatementOnSameLineAsDocstring: | = help: Reformat to one line - - diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D200_D200.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D200_D200.py.snap index 9cae5fd5f9deb..0f60583652ce3 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D200_D200.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D200_D200.py.snap @@ -21,16 +21,6 @@ D200.py:7:5: D200 [*] One-line docstring should fit on one line | = help: Reformat to one line -ℹ Unsafe fix -4 4 | -5 5 | -6 6 | def func(): -7 |- """\\ -8 |- """ - 7 |+ """\\""" -9 8 | -10 9 | -11 10 | def func(): D200.py:12:5: D200 One-line docstring should fit on one line | @@ -41,5 +31,3 @@ D200.py:12:5: D200 One-line docstring should fit on one line | |_______^ D200 | = help: Reformat to one line - - diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D201_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D201_D.py.snap index 977ac47b9d93c..1a9fcdd925e65 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D201_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D201_D.py.snap @@ -10,7 +10,6 @@ D.py:137:5: D201 [*] No blank lines allowed before function docstring (found 1) | = help: Remove blank line(s) before function docstring -ℹ Safe fix 133 133 | 134 134 | @expect('D201: No blank lines allowed before function docstring (found 1)') 135 135 | def leading_space(): @@ -30,7 +29,6 @@ D.py:151:5: D201 [*] No blank lines allowed before function docstring (found 1) | = help: Remove blank line(s) before function docstring -ℹ Safe fix 147 147 | @expect('D201: No blank lines allowed before function docstring (found 1)') 148 148 | @expect('D202: No blank lines allowed after function docstring (found 1)') 149 149 | def trailing_and_leading_space(): @@ -52,7 +50,6 @@ D.py:546:5: D201 [*] No blank lines allowed before function docstring (found 1) | = help: Remove blank line(s) before function docstring -ℹ Safe fix 542 542 | @expect('D201: No blank lines allowed before function docstring (found 1)') 543 543 | @expect('D213: Multi-line docstring summary should start at the second line') 544 544 | def multiline_leading_space(): @@ -76,7 +73,6 @@ D.py:568:5: D201 [*] No blank lines allowed before function docstring (found 1) | = help: Remove blank line(s) before function docstring -ℹ Safe fix 564 564 | @expect('D202: No blank lines allowed after function docstring (found 1)') 565 565 | @expect('D213: Multi-line docstring summary should start at the second line') 566 566 | def multiline_trailing_and_leading_space(): @@ -84,5 +80,3 @@ D.py:568:5: D201 [*] No blank lines allowed before function docstring (found 1) 568 567 | """Trailing and leading space. 569 568 | 570 569 | More content. - - diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D202_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D202_D.py.snap index 8a67b2b1762d9..2a296015f19bb 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D202_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D202_D.py.snap @@ -12,7 +12,6 @@ D.py:142:5: D202 [*] No blank lines allowed after function docstring (found 1) | = help: Remove blank line(s) after function docstring -ℹ Safe fix 140 140 | @expect('D202: No blank lines allowed after function docstring (found 1)') 141 141 | def trailing_space(): 142 142 | """Leading space.""" @@ -32,7 +31,6 @@ D.py:151:5: D202 [*] No blank lines allowed after function docstring (found 1) | = help: Remove blank line(s) after function docstring -ℹ Safe fix 149 149 | def trailing_and_leading_space(): 150 150 | 151 151 | """Trailing and leading space.""" @@ -56,7 +54,6 @@ D.py:555:5: D202 [*] No blank lines allowed after function docstring (found 1) | = help: Remove blank line(s) after function docstring -ℹ Safe fix 556 556 | 557 557 | More content. 558 558 | """ @@ -80,13 +77,10 @@ D.py:568:5: D202 [*] No blank lines allowed after function docstring (found 1) | = help: Remove blank line(s) after function docstring -ℹ Safe fix 569 569 | 570 570 | More content. 571 571 | """ 572 |- 573 572 | pass 574 573 | -575 574 | - - +575 574 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D202_D202.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D202_D202.py.snap index 90e915d1022aa..038d164da48a0 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D202_D202.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D202_D202.py.snap @@ -10,7 +10,6 @@ D202.py:57:5: D202 [*] No blank lines allowed after function docstring (found 2) | = help: Remove blank line(s) after function docstring -ℹ Safe fix 55 55 | # D202 56 56 | def outer(): 57 57 | """This is a docstring.""" @@ -29,7 +28,6 @@ D202.py:68:5: D202 [*] No blank lines allowed after function docstring (found 2) | = help: Remove blank line(s) after function docstring -ℹ Safe fix 66 66 | # D202 67 67 | def outer(): 68 68 | """This is a docstring.""" @@ -50,7 +48,6 @@ D202.py:80:5: D202 [*] No blank lines allowed after function docstring (found 1) | = help: Remove blank line(s) after function docstring -ℹ Safe fix 78 78 | # D202 79 79 | def outer(): 80 80 | """This is a docstring.""" @@ -58,5 +55,3 @@ D202.py:80:5: D202 [*] No blank lines allowed after function docstring (found 1) 82 81 | # This is a comment. 83 82 | 84 83 | def inner(): - - diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D203_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D203_D.py.snap index 3ef6f3205fec5..cafb720d97d38 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D203_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D203_D.py.snap @@ -9,7 +9,6 @@ D.py:161:5: D203 [*] 1 blank line required before class docstring | = help: Insert 1 blank line before class docstring -ℹ Safe fix 158 158 | 159 159 | 160 160 | class LeadingSpaceMissing: @@ -27,7 +26,6 @@ D.py:192:5: D203 [*] 1 blank line required before class docstring | = help: Insert 1 blank line before class docstring -ℹ Safe fix 189 189 | 190 190 | 191 191 | class LeadingAndTrailingSpaceMissing: @@ -54,7 +52,6 @@ D.py:526:5: D203 [*] 1 blank line required before class docstring | = help: Insert 1 blank line before class docstring -ℹ Safe fix 523 523 | # This is reproducing a bug where AttributeError is raised when parsing class 524 524 | # parameters as functions for Google / Numpy conventions. 525 525 | class Blah: # noqa: D203,D213 @@ -73,7 +70,6 @@ D.py:649:5: D203 [*] 1 blank line required before class docstring | = help: Insert 1 blank line before class docstring -ℹ Safe fix 646 646 | " 647 647 | 648 648 | class StatementOnSameLineAsDocstring: @@ -90,7 +86,6 @@ D.py:654:5: D203 [*] 1 blank line required before class docstring | = help: Insert 1 blank line before class docstring -ℹ Safe fix 651 651 | pass 652 652 | 653 653 | class StatementOnSameLineAsDocstring: @@ -109,7 +104,6 @@ D.py:658:5: D203 [*] 1 blank line required before class docstring | = help: Insert 1 blank line before class docstring -ℹ Safe fix 655 655 | 656 656 | 657 657 | class CommentAfterDocstring: @@ -117,5 +111,3 @@ D.py:658:5: D203 [*] 1 blank line required before class docstring 658 659 | "After this docstring there's a comment." # priorities=1 659 660 | def sort_services(self): 660 661 | pass - - diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D204_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D204_D.py.snap index 425f22147bb85..3df242aa3ac91 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D204_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D204_D.py.snap @@ -11,7 +11,6 @@ D.py:181:5: D204 [*] 1 blank line required after class docstring | = help: Insert 1 blank line after class docstring -ℹ Safe fix 179 179 | class TrailingSpace: 180 180 | 181 181 | """TrailingSpace.""" @@ -29,7 +28,6 @@ D.py:192:5: D204 [*] 1 blank line required after class docstring | = help: Insert 1 blank line after class docstring -ℹ Safe fix 190 190 | 191 191 | class LeadingAndTrailingSpaceMissing: 192 192 | """Leading and trailing space missing.""" @@ -48,7 +46,6 @@ D.py:649:5: D204 [*] 1 blank line required after class docstring | = help: Insert 1 blank line after class docstring -ℹ Safe fix 646 646 | " 647 647 | 648 648 | class StatementOnSameLineAsDocstring: @@ -68,7 +65,6 @@ D.py:654:5: D204 [*] 1 blank line required after class docstring | = help: Insert 1 blank line after class docstring -ℹ Safe fix 651 651 | pass 652 652 | 653 653 | class StatementOnSameLineAsDocstring: @@ -90,13 +86,10 @@ D.py:658:5: D204 [*] 1 blank line required after class docstring | = help: Insert 1 blank line after class docstring -ℹ Safe fix 656 656 | 657 657 | class CommentAfterDocstring: 658 658 | "After this docstring there's a comment." # priorities=1 659 |+ 659 660 | def sort_services(self): 660 661 | pass -661 662 | - - +661 662 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D205_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D205_D.py.snap index 290cd8a05fccd..50812cea14731 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D205_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D205_D.py.snap @@ -29,7 +29,6 @@ D.py:210:5: D205 [*] 1 blank line required between summary line and description | = help: Insert single blank line -ℹ Safe fix 209 209 | def multi_line_two_separating_blanks(): 210 210 | """Summary. 211 211 | @@ -37,5 +36,3 @@ D.py:210:5: D205 [*] 1 blank line required between summary line and description 213 212 | Description. 214 213 | 215 214 | """ - - diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D207_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D207_D.py.snap index d70f30883a4a4..257b6f5e8e414 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D207_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D207_D.py.snap @@ -12,7 +12,6 @@ D.py:232:1: D207 [*] Docstring is under-indented | = help: Increase indentation -ℹ Safe fix 229 229 | def asdfsdf(): 230 230 | """Summary. 231 231 | @@ -31,7 +30,6 @@ D.py:244:1: D207 [*] Docstring is under-indented | = help: Increase indentation -ℹ Safe fix 241 241 | 242 242 | Description. 243 243 | @@ -51,7 +49,6 @@ D.py:440:1: D207 [*] Docstring is under-indented | = help: Increase indentation -ℹ Safe fix 437 437 | @expect('D213: Multi-line docstring summary should start at the second line') 438 438 | def docstring_start_in_same_line(): """First Line. 439 439 | @@ -69,7 +66,6 @@ D.py:441:1: D207 [*] Docstring is under-indented | = help: Increase indentation -ℹ Safe fix 438 438 | def docstring_start_in_same_line(): """First Line. 439 439 | 440 440 | Second Line @@ -78,5 +74,3 @@ D.py:441:1: D207 [*] Docstring is under-indented 442 442 | 443 443 | 444 444 | def function_with_lambda_arg(x=lambda y: y): - - diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D208_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D208_D.py.snap index 5048d030c7dcd..3a8e6f80a13a3 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D208_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D208_D.py.snap @@ -12,7 +12,6 @@ D.py:252:1: D208 [*] Docstring is over-indented | = help: Remove over-indentation -ℹ Safe fix 249 249 | def asdfsdsdf24(): 250 250 | """Summary. 251 251 | @@ -31,7 +30,6 @@ D.py:264:1: D208 [*] Docstring is over-indented | = help: Remove over-indentation -ℹ Safe fix 261 261 | 262 262 | Description. 263 263 | @@ -52,7 +50,6 @@ D.py:272:1: D208 [*] Docstring is over-indented | = help: Remove over-indentation -ℹ Safe fix 269 269 | def asdfsdfsdsdsdfsdf24(): 270 270 | """Summary. 271 271 | @@ -73,7 +70,6 @@ D.py:673:1: D208 [*] Docstring is over-indented | = help: Remove over-indentation -ℹ Safe fix 670 670 | def retain_extra_whitespace(): 671 671 | """Summary. 672 672 | @@ -93,7 +89,6 @@ D.py:674:1: D208 [*] Docstring is over-indented | = help: Remove over-indentation -ℹ Safe fix 671 671 | """Summary. 672 672 | 673 673 | This is overindented @@ -113,7 +108,6 @@ D.py:675:1: D208 [*] Docstring is over-indented | = help: Remove over-indentation -ℹ Safe fix 672 672 | 673 673 | This is overindented 674 674 | And so is this, but it we should preserve the extra space on this line relative @@ -134,7 +128,6 @@ D.py:682:1: D208 [*] Docstring is over-indented | = help: Remove over-indentation -ℹ Safe fix 679 679 | def retain_extra_whitespace_multiple(): 680 680 | """Summary. 681 681 | @@ -154,7 +147,6 @@ D.py:683:1: D208 [*] Docstring is over-indented | = help: Remove over-indentation -ℹ Safe fix 680 680 | """Summary. 681 681 | 682 682 | This is overindented @@ -175,7 +167,6 @@ D.py:684:1: D208 [*] Docstring is over-indented | = help: Remove over-indentation -ℹ Safe fix 681 681 | 682 682 | This is overindented 683 683 | And so is this, but it we should preserve the extra space on this line relative @@ -196,7 +187,6 @@ D.py:685:1: D208 [*] Docstring is over-indented | = help: Remove over-indentation -ℹ Safe fix 682 682 | This is overindented 683 683 | And so is this, but it we should preserve the extra space on this line relative 684 684 | to the one before @@ -217,7 +207,6 @@ D.py:686:1: D208 [*] Docstring is over-indented | = help: Remove over-indentation -ℹ Safe fix 683 683 | And so is this, but it we should preserve the extra space on this line relative 684 684 | to the one before 685 685 | This is also overindented @@ -237,7 +226,6 @@ D.py:687:1: D208 [*] Docstring is over-indented | = help: Remove over-indentation -ℹ Safe fix 684 684 | to the one before 685 685 | This is also overindented 686 686 | And so is this, but it we should preserve the extra space on this line relative @@ -258,7 +246,6 @@ D.py:695:1: D208 [*] Docstring is over-indented | = help: Remove over-indentation -ℹ Safe fix 692 692 | def retain_extra_whitespace_deeper(): 693 693 | """Summary. 694 694 | @@ -278,7 +265,6 @@ D.py:696:1: D208 [*] Docstring is over-indented | = help: Remove over-indentation -ℹ Safe fix 693 693 | """Summary. 694 694 | 695 695 | This is overindented @@ -299,7 +285,6 @@ D.py:697:1: D208 [*] Docstring is over-indented | = help: Remove over-indentation -ℹ Safe fix 694 694 | 695 695 | This is overindented 696 696 | And so is this, but it we should preserve the extra space on this line relative @@ -319,7 +304,6 @@ D.py:698:1: D208 [*] Docstring is over-indented | = help: Remove over-indentation -ℹ Safe fix 695 695 | This is overindented 696 696 | And so is this, but it we should preserve the extra space on this line relative 697 697 | to the one before @@ -340,7 +324,6 @@ D.py:704:1: D208 [*] Docstring is over-indented | = help: Remove over-indentation -ℹ Safe fix 701 701 | def retain_extra_whitespace_followed_by_same_offset(): 702 702 | """Summary. 703 703 | @@ -360,7 +343,6 @@ D.py:705:1: D208 [*] Docstring is over-indented | = help: Remove over-indentation -ℹ Safe fix 702 702 | """Summary. 703 703 | 704 704 | This is overindented @@ -381,7 +363,6 @@ D.py:706:1: D208 [*] Docstring is over-indented | = help: Remove over-indentation -ℹ Safe fix 703 703 | 704 704 | This is overindented 705 705 | And so is this, but it we should preserve the extra space on this line relative @@ -401,7 +382,6 @@ D.py:707:1: D208 [*] Docstring is over-indented | = help: Remove over-indentation -ℹ Safe fix 704 704 | This is overindented 705 705 | And so is this, but it we should preserve the extra space on this line relative 706 706 | This is overindented @@ -421,12 +401,9 @@ D.py:723:1: D208 [*] Docstring is over-indented | = help: Remove over-indentation -ℹ Safe fix 720 720 | def inconsistent_indent_byte_size(): 721 721 | """There's a non-breaking space (2-bytes) after 3 spaces (https://github.com/astral-sh/ruff/issues/9080). 722 722 | 723 |-     Returns: 723 |+ Returns: 724 724 | """ - - diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D208_D208.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D208_D208.py.snap index 517dc3802e1ec..9d5b54e494633 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D208_D208.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D208_D208.py.snap @@ -10,7 +10,6 @@ D208.py:2:1: D208 [*] Docstring is over-indented | = help: Remove over-indentation -ℹ Safe fix 1 1 | """ 2 |- Author 2 |+Author @@ -29,7 +28,6 @@ D208.py:8:1: D208 [*] Docstring is over-indented | = help: Remove over-indentation -ℹ Safe fix 5 5 | 6 6 | class Platform: 7 7 | """ Remove sampler @@ -49,7 +47,6 @@ D208.py:9:1: D208 [*] Docstring is over-indented | = help: Remove over-indentation -ℹ Safe fix 6 6 | class Platform: 7 7 | """ Remove sampler 8 8 | Args: @@ -68,7 +65,6 @@ D208.py:10:1: D208 [*] Docstring is over-indented | = help: Remove over-indentation -ℹ Safe fix 7 7 | """ Remove sampler 8 8 | Args: 9 9 |     Returns: @@ -77,5 +73,3 @@ D208.py:10:1: D208 [*] Docstring is over-indented 11 11 | 12 12 | 13 13 | def memory_test(): - - diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D209_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D209_D.py.snap index 97495aa3191e7..6844c240355d5 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D209_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D209_D.py.snap @@ -13,7 +13,6 @@ D.py:281:5: D209 [*] Multi-line docstring closing quotes should be on a separate | = help: Move closing quotes to new line -ℹ Safe fix 280 280 | def asdfljdf24(): 281 281 | """Summary. 282 282 | @@ -36,7 +35,6 @@ D.py:588:5: D209 [*] Multi-line docstring closing quotes should be on a separate | = help: Move closing quotes to new line -ℹ Safe fix 587 587 | def asdfljdjgf24(): 588 588 | """Summary. 589 589 | @@ -46,5 +44,3 @@ D.py:588:5: D209 [*] Multi-line docstring closing quotes should be on a separate 591 592 | 592 593 | 593 594 | @expect('D200: One-line docstring should fit on one line with quotes ' - - diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D210_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D210_D.py.snap index 29b6fe31604c9..f40fe57712265 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D210_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D210_D.py.snap @@ -10,7 +10,6 @@ D.py:288:5: D210 [*] No whitespaces allowed surrounding docstring text | = help: Trim surrounding whitespace -ℹ Safe fix 285 285 | 286 286 | @expect('D210: No whitespaces allowed surrounding docstring text') 287 287 | def endswith(): @@ -29,7 +28,6 @@ D.py:293:5: D210 [*] No whitespaces allowed surrounding docstring text | = help: Trim surrounding whitespace -ℹ Safe fix 290 290 | 291 291 | @expect('D210: No whitespaces allowed surrounding docstring text') 292 292 | def around(): @@ -52,7 +50,6 @@ D.py:299:5: D210 [*] No whitespaces allowed surrounding docstring text | = help: Trim surrounding whitespace -ℹ Safe fix 296 296 | @expect('D210: No whitespaces allowed surrounding docstring text') 297 297 | @expect('D213: Multi-line docstring summary should start at the second line') 298 298 | def multiline(): @@ -70,5 +67,3 @@ D.py:581:5: D210 No whitespaces allowed surrounding docstring text | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D210 | = help: Trim surrounding whitespace - - diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D211_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D211_D.py.snap index f89dc69584eeb..6d41be9ed1c0c 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D211_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D211_D.py.snap @@ -10,7 +10,6 @@ D.py:170:5: D211 [*] No blank lines allowed before class docstring | = help: Remove blank line(s) before class docstring -ℹ Safe fix 166 166 | 167 167 | 168 168 | class WithLeadingSpace: @@ -29,13 +28,10 @@ D.py:181:5: D211 [*] No blank lines allowed before class docstring | = help: Remove blank line(s) before class docstring -ℹ Safe fix 177 177 | 178 178 | 179 179 | class TrailingSpace: 180 |- 181 180 | """TrailingSpace.""" 182 181 | pass -183 182 | - - +183 182 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D212_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D212_D.py.snap index c37abb9572d59..eb074882ac38f 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D212_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D212_D.py.snap @@ -13,7 +13,6 @@ D.py:129:5: D212 [*] Multi-line docstring summary should start at the first line | = help: Remove whitespace after opening quotes -ℹ Safe fix 126 126 | '(found 3)') 127 127 | @expect('D212: Multi-line docstring summary should start at the first line') 128 128 | def asdlkfasd(): @@ -36,7 +35,6 @@ D.py:597:5: D212 [*] Multi-line docstring summary should start at the first line | = help: Remove whitespace after opening quotes -ℹ Safe fix 594 594 | '(found 3)') 595 595 | @expect('D212: Multi-line docstring summary should start at the first line') 596 596 | def one_liner(): @@ -60,7 +58,6 @@ D.py:624:5: D212 [*] Multi-line docstring summary should start at the first line | = help: Remove whitespace after opening quotes -ℹ Safe fix 621 621 | '(found 3)') 622 622 | @expect('D212: Multi-line docstring summary should start at the first line') 623 623 | def one_liner(): @@ -71,5 +68,3 @@ D.py:624:5: D212 [*] Multi-line docstring summary should start at the first line 627 625 | 628 626 | 629 627 | @expect('D404: First word of the docstring should not be "This"') - - diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D213_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D213_D.py.snap index 0253bc44cd427..60f2bce05ce54 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D213_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D213_D.py.snap @@ -14,7 +14,6 @@ D.py:200:5: D213 [*] Multi-line docstring summary should start at the second lin | = help: Insert line break and indentation after opening quotes -ℹ Safe fix 197 197 | '(found 0)') 198 198 | @expect('D213: Multi-line docstring summary should start at the second line') 199 199 | def multi_line_zero_separating_blanks(): @@ -40,7 +39,6 @@ D.py:210:5: D213 [*] Multi-line docstring summary should start at the second lin | = help: Insert line break and indentation after opening quotes -ℹ Safe fix 207 207 | '(found 2)') 208 208 | @expect('D213: Multi-line docstring summary should start at the second line') 209 209 | def multi_line_two_separating_blanks(): @@ -65,7 +63,6 @@ D.py:220:5: D213 [*] Multi-line docstring summary should start at the second lin | = help: Insert line break and indentation after opening quotes -ℹ Safe fix 217 217 | 218 218 | @expect('D213: Multi-line docstring summary should start at the second line') 219 219 | def multi_line_one_separating_blanks(): @@ -90,7 +87,6 @@ D.py:230:5: D213 [*] Multi-line docstring summary should start at the second lin | = help: Insert line break and indentation after opening quotes -ℹ Safe fix 227 227 | @expect('D207: Docstring is under-indented') 228 228 | @expect('D213: Multi-line docstring summary should start at the second line') 229 229 | def asdfsdf(): @@ -115,7 +111,6 @@ D.py:240:5: D213 [*] Multi-line docstring summary should start at the second lin | = help: Insert line break and indentation after opening quotes -ℹ Safe fix 237 237 | @expect('D207: Docstring is under-indented') 238 238 | @expect('D213: Multi-line docstring summary should start at the second line') 239 239 | def asdsdfsdffsdf(): @@ -140,7 +135,6 @@ D.py:250:5: D213 [*] Multi-line docstring summary should start at the second lin | = help: Insert line break and indentation after opening quotes -ℹ Safe fix 247 247 | @expect('D208: Docstring is over-indented') 248 248 | @expect('D213: Multi-line docstring summary should start at the second line') 249 249 | def asdfsdsdf24(): @@ -165,7 +159,6 @@ D.py:260:5: D213 [*] Multi-line docstring summary should start at the second lin | = help: Insert line break and indentation after opening quotes -ℹ Safe fix 257 257 | @expect('D208: Docstring is over-indented') 258 258 | @expect('D213: Multi-line docstring summary should start at the second line') 259 259 | def asdfsdsdfsdf24(): @@ -190,7 +183,6 @@ D.py:270:5: D213 [*] Multi-line docstring summary should start at the second lin | = help: Insert line break and indentation after opening quotes -ℹ Safe fix 267 267 | @expect('D208: Docstring is over-indented') 268 268 | @expect('D213: Multi-line docstring summary should start at the second line') 269 269 | def asdfsdfsdsdsdfsdf24(): @@ -213,7 +205,6 @@ D.py:281:5: D213 [*] Multi-line docstring summary should start at the second lin | = help: Insert line break and indentation after opening quotes -ℹ Safe fix 278 278 | 'line') 279 279 | @expect('D213: Multi-line docstring summary should start at the second line') 280 280 | def asdfljdf24(): @@ -237,7 +228,6 @@ D.py:299:5: D213 [*] Multi-line docstring summary should start at the second lin | = help: Insert line break and indentation after opening quotes -ℹ Safe fix 296 296 | @expect('D210: No whitespaces allowed surrounding docstring text') 297 297 | @expect('D213: Multi-line docstring summary should start at the second line') 298 298 | def multiline(): @@ -263,7 +253,6 @@ D.py:343:5: D213 [*] Multi-line docstring summary should start at the second lin | = help: Insert line break and indentation after opening quotes -ℹ Safe fix 340 340 | 341 341 | @expect('D213: Multi-line docstring summary should start at the second line') 342 342 | def exceptions_of_D301(): @@ -288,7 +277,6 @@ D.py:383:5: D213 [*] Multi-line docstring summary should start at the second lin | = help: Insert line break and indentation after opening quotes -ℹ Safe fix 380 380 | 381 381 | @expect('D213: Multi-line docstring summary should start at the second line') 382 382 | def new_209(): @@ -313,7 +301,6 @@ D.py:392:5: D213 [*] Multi-line docstring summary should start at the second lin | = help: Insert line break and indentation after opening quotes -ℹ Safe fix 389 389 | 390 390 | @expect('D213: Multi-line docstring summary should start at the second line') 391 391 | def old_209(): @@ -337,7 +324,6 @@ D.py:438:37: D213 [*] Multi-line docstring summary should start at the second li | = help: Insert line break and indentation after opening quotes -ℹ Safe fix 435 435 | 436 436 | @expect("D207: Docstring is under-indented") 437 437 | @expect('D213: Multi-line docstring summary should start at the second line') @@ -362,7 +348,6 @@ D.py:450:5: D213 [*] Multi-line docstring summary should start at the second lin | = help: Insert line break and indentation after opening quotes -ℹ Safe fix 447 447 | 448 448 | @expect('D213: Multi-line docstring summary should start at the second line') 449 449 | def a_following_valid_function(x=None): @@ -391,7 +376,6 @@ D.py:526:5: D213 [*] Multi-line docstring summary should start at the second lin | = help: Insert line break and indentation after opening quotes -ℹ Safe fix 523 523 | # This is reproducing a bug where AttributeError is raised when parsing class 524 524 | # parameters as functions for Google / Numpy conventions. 525 525 | class Blah: # noqa: D203,D213 @@ -415,7 +399,6 @@ D.py:546:5: D213 [*] Multi-line docstring summary should start at the second lin | = help: Insert line break and indentation after opening quotes -ℹ Safe fix 543 543 | @expect('D213: Multi-line docstring summary should start at the second line') 544 544 | def multiline_leading_space(): 545 545 | @@ -441,7 +424,6 @@ D.py:555:5: D213 [*] Multi-line docstring summary should start at the second lin | = help: Insert line break and indentation after opening quotes -ℹ Safe fix 552 552 | @expect('D202: No blank lines allowed after function docstring (found 1)') 553 553 | @expect('D213: Multi-line docstring summary should start at the second line') 554 554 | def multiline_trailing_space(): @@ -467,7 +449,6 @@ D.py:568:5: D213 [*] Multi-line docstring summary should start at the second lin | = help: Insert line break and indentation after opening quotes -ℹ Safe fix 565 565 | @expect('D213: Multi-line docstring summary should start at the second line') 566 566 | def multiline_trailing_and_leading_space(): 567 567 | @@ -490,7 +471,6 @@ D.py:588:5: D213 [*] Multi-line docstring summary should start at the second lin | = help: Insert line break and indentation after opening quotes -ℹ Safe fix 585 585 | 'line') 586 586 | @expect('D213: Multi-line docstring summary should start at the second line') 587 587 | def asdfljdjgf24(): @@ -513,7 +493,6 @@ D.py:606:5: D213 [*] Multi-line docstring summary should start at the second lin | = help: Insert line break and indentation after opening quotes -ℹ Safe fix 603 603 | '(found 3)') 604 604 | @expect('D212: Multi-line docstring summary should start at the first line') 605 605 | def one_liner(): @@ -536,7 +515,6 @@ D.py:615:5: D213 [*] Multi-line docstring summary should start at the second lin | = help: Insert line break and indentation after opening quotes -ℹ Safe fix 612 612 | '(found 3)') 613 613 | @expect('D212: Multi-line docstring summary should start at the first line') 614 614 | def one_liner(): @@ -561,7 +539,6 @@ D.py:671:5: D213 [*] Multi-line docstring summary should start at the second lin | = help: Insert line break and indentation after opening quotes -ℹ Safe fix 668 668 | 669 669 | 670 670 | def retain_extra_whitespace(): @@ -589,7 +566,6 @@ D.py:680:5: D213 [*] Multi-line docstring summary should start at the second lin | = help: Insert line break and indentation after opening quotes -ℹ Safe fix 677 677 | 678 678 | 679 679 | def retain_extra_whitespace_multiple(): @@ -617,7 +593,6 @@ D.py:693:5: D213 [*] Multi-line docstring summary should start at the second lin | = help: Insert line break and indentation after opening quotes -ℹ Safe fix 690 690 | 691 691 | 692 692 | def retain_extra_whitespace_deeper(): @@ -643,7 +618,6 @@ D.py:702:5: D213 [*] Multi-line docstring summary should start at the second lin | = help: Insert line break and indentation after opening quotes -ℹ Safe fix 699 699 | """ 700 700 | 701 701 | def retain_extra_whitespace_followed_by_same_offset(): @@ -668,7 +642,6 @@ D.py:712:5: D213 [*] Multi-line docstring summary should start at the second lin | = help: Insert line break and indentation after opening quotes -ℹ Safe fix 709 709 | 710 710 | 711 711 | def retain_extra_whitespace_not_overindented(): @@ -691,7 +664,6 @@ D.py:721:5: D213 [*] Multi-line docstring summary should start at the second lin | = help: Insert line break and indentation after opening quotes -ℹ Safe fix 718 718 | 719 719 | 720 720 | def inconsistent_indent_byte_size(): @@ -701,5 +673,3 @@ D.py:721:5: D213 [*] Multi-line docstring summary should start at the second lin 722 723 | 723 724 |     Returns: 724 725 | """ - - diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D214_D214_module.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D214_D214_module.py.snap index c95abffdad67b..0440ee2e60ab3 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D214_D214_module.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D214_D214_module.py.snap @@ -12,7 +12,6 @@ D214_module.py:3:5: D214 [*] Section is over-indented ("Returns") | = help: Remove over-indentation from "Returns" -ℹ Safe fix 1 1 | """A module docstring with D214 violations 2 2 | 3 |- Returns @@ -32,7 +31,6 @@ D214_module.py:7:5: D214 [*] Section is over-indented ("Args") | = help: Remove over-indentation from "Args" -ℹ Safe fix 4 4 | ----- 5 5 | valid returns 6 6 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D214_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D214_sections.py.snap index 89f47fa2c67b6..c2ef668241aac 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D214_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D214_sections.py.snap @@ -12,7 +12,6 @@ sections.py:146:9: D214 [*] Section is over-indented ("Returns") | = help: Remove over-indentation from "Returns" -ℹ Safe fix 143 143 | def section_overindented(): # noqa: D416 144 144 | """Toggle the gizmo. 145 145 | @@ -32,7 +31,6 @@ sections.py:563:9: D214 [*] Section is over-indented ("Returns") | = help: Remove over-indentation from "Returns" -ℹ Safe fix 560 560 | Args: 561 561 | Here's a note. 562 562 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D215_D215.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D215_D215.py.snap index b93074fda8c98..b2591d36634ff 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D215_D215.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D215_D215.py.snap @@ -11,7 +11,6 @@ D215.py:3:5: D215 [*] Section underline is over-indented ("TODO") | = help: Remove over-indentation from "TODO" underline -ℹ Safe fix 1 1 | """ 2 2 | TODO: 3 |- - diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D215_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D215_sections.py.snap index afbd747fbd769..ddb4089de66cc 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D215_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D215_sections.py.snap @@ -10,7 +10,6 @@ sections.py:159:9: D215 [*] Section underline is over-indented ("Returns") | = help: Remove over-indentation from "Returns" underline -ℹ Safe fix 156 156 | """Toggle the gizmo. 157 157 | 158 158 | Returns @@ -29,7 +28,6 @@ sections.py:173:9: D215 [*] Section underline is over-indented ("Returns") | = help: Remove over-indentation from "Returns" underline -ℹ Safe fix 170 170 | """Toggle the gizmo. 171 171 | 172 172 | Returns diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D300_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D300_D.py.snap index 7f14c7fe4c8ca..d7f52d717b857 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D300_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D300_D.py.snap @@ -10,7 +10,6 @@ D.py:307:5: D300 [*] Use triple double quotes `"""` | = help: Convert to triple double quotes -ℹ Safe fix 304 304 | 305 305 | @expect('D300: Use """triple double quotes""" (found \'\'\'-quotes)') 306 306 | def triple_single_quotes_raw(): @@ -29,7 +28,6 @@ D.py:312:5: D300 [*] Use triple double quotes `"""` | = help: Convert to triple double quotes -ℹ Safe fix 309 309 | 310 310 | @expect('D300: Use """triple double quotes""" (found \'\'\'-quotes)') 311 311 | def triple_single_quotes_raw_uppercase(): @@ -48,7 +46,6 @@ D.py:317:5: D300 [*] Use triple double quotes `"""` | = help: Convert to triple double quotes -ℹ Safe fix 314 314 | 315 315 | @expect('D300: Use """triple double quotes""" (found \'-quotes)') 316 316 | def single_quotes_raw(): @@ -67,7 +64,6 @@ D.py:322:5: D300 [*] Use triple double quotes `"""` | = help: Convert to triple double quotes -ℹ Safe fix 319 319 | 320 320 | @expect('D300: Use """triple double quotes""" (found \'-quotes)') 321 321 | def single_quotes_raw_uppercase(): @@ -86,7 +82,6 @@ D.py:328:5: D300 [*] Use triple double quotes `"""` | = help: Convert to triple double quotes -ℹ Safe fix 325 325 | @expect('D300: Use """triple double quotes""" (found \'-quotes)') 326 326 | @expect('D301: Use r""" if any backslashes in a docstring') 327 327 | def single_quotes_raw_uppercase_backslash(): @@ -108,7 +103,6 @@ D.py:645:5: D300 [*] Use triple double quotes `"""` | = help: Convert to triple double quotes -ℹ Safe fix 642 642 | 643 643 | 644 644 | def single_line_docstring_with_an_escaped_backslash(): @@ -130,7 +124,6 @@ D.py:649:5: D300 [*] Use triple double quotes `"""` | = help: Convert to triple double quotes -ℹ Safe fix 646 646 | " 647 647 | 648 648 | class StatementOnSameLineAsDocstring: @@ -148,7 +141,6 @@ D.py:654:5: D300 [*] Use triple double quotes `"""` | = help: Convert to triple double quotes -ℹ Safe fix 651 651 | pass 652 652 | 653 653 | class StatementOnSameLineAsDocstring: @@ -168,7 +160,6 @@ D.py:658:5: D300 [*] Use triple double quotes `"""` | = help: Convert to triple double quotes -ℹ Safe fix 655 655 | 656 656 | 657 657 | class CommentAfterDocstring: @@ -188,7 +179,6 @@ D.py:664:5: D300 [*] Use triple double quotes `"""` | = help: Convert to triple double quotes -ℹ Safe fix 661 661 | 662 662 | 663 663 | def newline_after_closing_quote(self): @@ -198,6 +188,4 @@ D.py:664:5: D300 [*] Use triple double quotes `"""` 665 |+ but continuations shouldn't be considered multi-line""" 666 666 | 667 667 | -668 668 | - - +668 668 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D300_D300.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D300_D300.py.snap index 2e3fedcf3d496..0a7e6f79b0a27 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D300_D300.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D300_D300.py.snap @@ -17,7 +17,6 @@ D300.py:10:5: D300 [*] Use triple double quotes `"""` | = help: Convert to triple double quotes -ℹ Safe fix 7 7 | 8 8 | 9 9 | def contains_quote(): @@ -26,5 +25,3 @@ D300.py:10:5: D300 [*] Use triple double quotes `"""` 11 11 | 12 12 | 13 13 | # OK - - diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D301_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D301_D.py.snap index 8c21aeac86c68..dd141a8348d46 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D301_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D301_D.py.snap @@ -9,15 +9,3 @@ D.py:333:5: D301 [*] Use `r"""` if any backslashes in a docstring | ^^^^^^^^^^^^^^^^ D301 | = help: Add `r` prefix - -ℹ Unsafe fix -330 330 | -331 331 | @expect('D301: Use r""" if any backslashes in a docstring') -332 332 | def double_quotes_backslash(): -333 |- """Sum\\mary.""" - 333 |+ r"""Sum\\mary.""" -334 334 | -335 335 | -336 336 | @expect('D301: Use r""" if any backslashes in a docstring') - - diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D301_D301.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D301_D301.py.snap index 2d729186933d7..06274a28f3c2a 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D301_D301.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D301_D301.py.snap @@ -9,13 +9,6 @@ D301.py:2:5: D301 [*] Use `r"""` if any backslashes in a docstring | = help: Add `r` prefix -ℹ Unsafe fix -1 1 | def double_quotes_backslash(): -2 |- """Sum\\mary.""" - 2 |+ r"""Sum\\mary.""" -3 3 | -4 4 | -5 5 | def double_quotes_backslash_raw(): D301.py:37:5: D301 Use `r"""` if any backslashes in a docstring | @@ -36,15 +29,6 @@ D301.py:93:5: D301 [*] Use `r"""` if any backslashes in a docstring | = help: Add `r` prefix -ℹ Unsafe fix -90 90 | -91 91 | -92 92 | def should_add_raw_for_single_double_quote_escape(): -93 |- """ - 93 |+ r""" -94 94 | This is single quote escape \". -95 95 | """ -96 96 | D301.py:99:5: D301 [*] Use `r"""` if any backslashes in a docstring | @@ -56,12 +40,3 @@ D301.py:99:5: D301 [*] Use `r"""` if any backslashes in a docstring | |_______^ D301 | = help: Add `r` prefix - -ℹ Unsafe fix -96 96 | -97 97 | -98 98 | def should_add_raw_for_single_single_quote_escape(): -99 |- ''' - 99 |+ r''' -100 100 | This is single quote escape \'. -101 101 | ''' diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D400_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D400_D.py.snap index aacdb3584bcfe..1c370c1405ca1 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D400_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D400_D.py.snap @@ -10,15 +10,6 @@ D.py:355:5: D400 [*] First line should end with a period | = help: Add period -ℹ Unsafe fix -352 352 | @expect("D415: First line should end with a period, question mark, " -353 353 | "or exclamation point (not 'y')") -354 354 | def lwnlkjl(): -355 |- """Summary""" - 355 |+ """Summary.""" -356 356 | -357 357 | -358 358 | @expect("D401: First line should be in imperative mood " D.py:406:25: D400 [*] First line should end with a period | @@ -29,15 +20,6 @@ D.py:406:25: D400 [*] First line should end with a period | = help: Add period -ℹ Unsafe fix -403 403 | @expect("D400: First line should end with a period (not 'r')") -404 404 | @expect("D415: First line should end with a period, question mark," -405 405 | " or exclamation point (not 'r')") -406 |-def oneliner_withdoc(): """One liner""" - 406 |+def oneliner_withdoc(): """One liner.""" -407 407 | -408 408 | -409 409 | def ignored_decorator(func): # noqa: D400,D401,D415 D.py:410:5: D400 [*] First line should end with a period | @@ -49,15 +31,6 @@ D.py:410:5: D400 [*] First line should end with a period | = help: Add period -ℹ Unsafe fix -407 407 | -408 408 | -409 409 | def ignored_decorator(func): # noqa: D400,D401,D415 -410 |- """Runs something""" - 410 |+ """Runs something.""" -411 411 | func() -412 412 | pass -413 413 | D.py:416:5: D400 [*] First line should end with a period | @@ -69,15 +42,6 @@ D.py:416:5: D400 [*] First line should end with a period | = help: Add period -ℹ Unsafe fix -413 413 | -414 414 | -415 415 | def decorator_for_test(func): # noqa: D400,D401,D415 -416 |- """Runs something""" - 416 |+ """Runs something.""" -417 417 | func() -418 418 | pass -419 419 | D.py:422:35: D400 [*] First line should end with a period | @@ -87,15 +51,6 @@ D.py:422:35: D400 [*] First line should end with a period | = help: Add period -ℹ Unsafe fix -419 419 | -420 420 | -421 421 | @ignored_decorator -422 |-def oneliner_ignored_decorator(): """One liner""" - 422 |+def oneliner_ignored_decorator(): """One liner.""" -423 423 | -424 424 | -425 425 | @decorator_for_test D.py:429:49: D400 [*] First line should end with a period | @@ -106,15 +61,6 @@ D.py:429:49: D400 [*] First line should end with a period | = help: Add period -ℹ Unsafe fix -426 426 | @expect("D400: First line should end with a period (not 'r')") -427 427 | @expect("D415: First line should end with a period, question mark," -428 428 | " or exclamation point (not 'r')") -429 |-def oneliner_with_decorator_expecting_errors(): """One liner""" - 429 |+def oneliner_with_decorator_expecting_errors(): """One liner.""" -430 430 | -431 431 | -432 432 | @decorator_for_test D.py:470:5: D400 [*] First line should end with a period | @@ -126,15 +72,6 @@ D.py:470:5: D400 [*] First line should end with a period | = help: Add period -ℹ Unsafe fix -467 467 | @expect("D415: First line should end with a period, question mark, " -468 468 | "or exclamation point (not 'g')") -469 469 | def docstring_bad(): -470 |- """Runs something""" - 470 |+ """Runs something.""" -471 471 | pass -472 472 | -473 473 | D.py:475:5: D400 [*] First line should end with a period | @@ -145,15 +82,6 @@ D.py:475:5: D400 [*] First line should end with a period | = help: Add period -ℹ Unsafe fix -472 472 | -473 473 | -474 474 | def docstring_bad_ignore_all(): # noqa -475 |- """Runs something""" - 475 |+ """Runs something.""" -476 476 | pass -477 477 | -478 478 | D.py:480:5: D400 [*] First line should end with a period | @@ -164,15 +92,6 @@ D.py:480:5: D400 [*] First line should end with a period | = help: Add period -ℹ Unsafe fix -477 477 | -478 478 | -479 479 | def docstring_bad_ignore_one(): # noqa: D400,D401,D415 -480 |- """Runs something""" - 480 |+ """Runs something.""" -481 481 | pass -482 482 | -483 483 | D.py:487:5: D400 [*] First line should end with a period | @@ -184,15 +103,6 @@ D.py:487:5: D400 [*] First line should end with a period | = help: Add period -ℹ Unsafe fix -484 484 | @expect("D401: First line should be in imperative mood " -485 485 | "(perhaps 'Run', not 'Runs')") -486 486 | def docstring_ignore_some_violations_but_catch_D401(): # noqa: E501,D400,D415 -487 |- """Runs something""" - 487 |+ """Runs something.""" -488 488 | pass -489 489 | -490 490 | D.py:514:5: D400 [*] First line should end with a period | @@ -202,15 +112,6 @@ D.py:514:5: D400 [*] First line should end with a period | = help: Add period -ℹ Unsafe fix -511 511 | -512 512 | -513 513 | def valid_google_string(): # noqa: D400 -514 |- """Test a valid something!""" - 514 |+ """Test a valid something!.""" -515 515 | -516 516 | -517 517 | @expect("D415: First line should end with a period, question mark, " D.py:520:5: D400 [*] First line should end with a period | @@ -221,15 +122,6 @@ D.py:520:5: D400 [*] First line should end with a period | = help: Add period -ℹ Unsafe fix -517 517 | @expect("D415: First line should end with a period, question mark, " -518 518 | "or exclamation point (not 'g')") -519 519 | def bad_google_string(): # noqa: D400 -520 |- """Test a valid something""" - 520 |+ """Test a valid something.""" -521 521 | -522 522 | -523 523 | # This is reproducing a bug where AttributeError is raised when parsing class D.py:581:5: D400 [*] First line should end with a period | @@ -240,15 +132,6 @@ D.py:581:5: D400 [*] First line should end with a period | = help: Add period -ℹ Unsafe fix -578 578 | @expect("D415: First line should end with a period, question mark, " -579 579 | "or exclamation point (not '\"')") -580 580 | def endswith_quote(): -581 |- """Whitespace at the end, but also a quote" """ - 581 |+ """Whitespace at the end, but also a quote". """ -582 582 | -583 583 | -584 584 | @expect('D209: Multi-line docstring closing quotes should be on a separate ' D.py:615:5: D400 [*] First line should end with a period | @@ -262,15 +145,6 @@ D.py:615:5: D400 [*] First line should end with a period | = help: Add period -ℹ Unsafe fix -612 612 | '(found 3)') -613 613 | @expect('D212: Multi-line docstring summary should start at the first line') -614 614 | def one_liner(): -615 |- """Wrong." - 615 |+ """Wrong.". -616 616 | -617 617 | """ -618 618 | D.py:639:17: D400 [*] First line should end with a period | @@ -281,15 +155,6 @@ D.py:639:17: D400 [*] First line should end with a period | = help: Add period -ℹ Unsafe fix -636 636 | """ This is a docstring that starts with a space.""" # noqa: D210 -637 637 | -638 638 | -639 |-class SameLine: """This is a docstring on the same line""" - 639 |+class SameLine: """This is a docstring on the same line.""" -640 640 | -641 641 | def same_line(): """This is a docstring on the same line""" -642 642 | D.py:641:18: D400 [*] First line should end with a period | @@ -300,15 +165,6 @@ D.py:641:18: D400 [*] First line should end with a period | = help: Add period -ℹ Unsafe fix -638 638 | -639 639 | class SameLine: """This is a docstring on the same line""" -640 640 | -641 |-def same_line(): """This is a docstring on the same line""" - 641 |+def same_line(): """This is a docstring on the same line.""" -642 642 | -643 643 | -644 644 | def single_line_docstring_with_an_escaped_backslash(): D.py:664:5: D400 [*] First line should end with a period | @@ -319,15 +175,3 @@ D.py:664:5: D400 [*] First line should end with a period | |_________________________________________________________^ D400 | = help: Add period - -ℹ Unsafe fix -662 662 | -663 663 | def newline_after_closing_quote(self): -664 664 | "We enforce a newline after the closing quote for a multi-line docstring \ -665 |- but continuations shouldn't be considered multi-line" - 665 |+ but continuations shouldn't be considered multi-line." -666 666 | -667 667 | -668 668 | - - diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D400_D400.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D400_D400.py.snap index f7a9059cce9bd..944d2215eedfd 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D400_D400.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D400_D400.py.snap @@ -10,13 +10,6 @@ D400.py:2:5: D400 [*] First line should end with a period | = help: Add period -ℹ Unsafe fix -1 1 | def f(): -2 |- "Here's a line without a period" - 2 |+ "Here's a line without a period." -3 3 | ... -4 4 | -5 5 | D400.py:7:5: D400 [*] First line should end with a period | @@ -27,15 +20,6 @@ D400.py:7:5: D400 [*] First line should end with a period | = help: Add period -ℹ Unsafe fix -4 4 | -5 5 | -6 6 | def f(): -7 |- """Here's a line without a period""" - 7 |+ """Here's a line without a period.""" -8 8 | ... -9 9 | -10 10 | D400.py:12:5: D400 [*] First line should end with a period | @@ -50,15 +34,6 @@ D400.py:12:5: D400 [*] First line should end with a period | = help: Add period -ℹ Unsafe fix -11 11 | def f(): -12 12 | """ -13 13 | Here's a line without a period, -14 |- but here's the next line - 14 |+ but here's the next line. -15 15 | """ -16 16 | ... -17 17 | D400.py:20:5: D400 [*] First line should end with a period | @@ -69,15 +44,6 @@ D400.py:20:5: D400 [*] First line should end with a period | = help: Add period -ℹ Unsafe fix -17 17 | -18 18 | -19 19 | def f(): -20 |- """Here's a line without a period""" - 20 |+ """Here's a line without a period.""" -21 21 | ... -22 22 | -23 23 | D400.py:25:5: D400 [*] First line should end with a period | @@ -91,15 +57,6 @@ D400.py:25:5: D400 [*] First line should end with a period | = help: Add period -ℹ Unsafe fix -24 24 | def f(): -25 25 | """ -26 26 | Here's a line without a period, -27 |- but here's the next line""" - 27 |+ but here's the next line.""" -28 28 | ... -29 29 | -30 30 | D400.py:32:5: D400 [*] First line should end with a period | @@ -113,15 +70,6 @@ D400.py:32:5: D400 [*] First line should end with a period | = help: Add period -ℹ Unsafe fix -31 31 | def f(): -32 32 | """ -33 33 | Here's a line without a period, -34 |- but here's the next line with trailing space """ - 34 |+ but here's the next line with trailing space. """ -35 35 | ... -36 36 | -37 37 | D400.py:39:5: D400 [*] First line should end with a period | @@ -132,15 +80,6 @@ D400.py:39:5: D400 [*] First line should end with a period | = help: Add period -ℹ Unsafe fix -36 36 | -37 37 | -38 38 | def f(): -39 |- r"Here's a line without a period" - 39 |+ r"Here's a line without a period." -40 40 | ... -41 41 | -42 42 | D400.py:44:5: D400 [*] First line should end with a period | @@ -151,15 +90,6 @@ D400.py:44:5: D400 [*] First line should end with a period | = help: Add period -ℹ Unsafe fix -41 41 | -42 42 | -43 43 | def f(): -44 |- r"""Here's a line without a period""" - 44 |+ r"""Here's a line without a period.""" -45 45 | ... -46 46 | -47 47 | D400.py:49:5: D400 [*] First line should end with a period | @@ -174,15 +104,6 @@ D400.py:49:5: D400 [*] First line should end with a period | = help: Add period -ℹ Unsafe fix -48 48 | def f(): -49 49 | r""" -50 50 | Here's a line without a period, -51 |- but here's the next line - 51 |+ but here's the next line. -52 52 | """ -53 53 | ... -54 54 | D400.py:57:5: D400 [*] First line should end with a period | @@ -193,15 +114,6 @@ D400.py:57:5: D400 [*] First line should end with a period | = help: Add period -ℹ Unsafe fix -54 54 | -55 55 | -56 56 | def f(): -57 |- r"""Here's a line without a period""" - 57 |+ r"""Here's a line without a period.""" -58 58 | ... -59 59 | -60 60 | D400.py:62:5: D400 [*] First line should end with a period | @@ -215,15 +127,6 @@ D400.py:62:5: D400 [*] First line should end with a period | = help: Add period -ℹ Unsafe fix -61 61 | def f(): -62 62 | r""" -63 63 | Here's a line without a period, -64 |- but here's the next line""" - 64 |+ but here's the next line.""" -65 65 | ... -66 66 | -67 67 | D400.py:69:5: D400 [*] First line should end with a period | @@ -237,15 +140,6 @@ D400.py:69:5: D400 [*] First line should end with a period | = help: Add period -ℹ Unsafe fix -68 68 | def f(): -69 69 | r""" -70 70 | Here's a line without a period, -71 |- but here's the next line with trailing space """ - 71 |+ but here's the next line with trailing space. """ -72 72 | ... -73 73 | -74 74 | D400.py:97:5: D400 [*] First line should end with a period | @@ -260,15 +154,3 @@ D400.py:97:5: D400 [*] First line should end with a period | |_______^ D400 | = help: Add period - -ℹ Unsafe fix -95 95 | -96 96 | def f(): -97 97 | """ -98 |- My example - 98 |+ My example. -99 99 | ========== -100 100 | -101 101 | My example explanation - - diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D403_D403.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D403_D403.py.snap index 07a0589fb11fc..9795a6ca79db8 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D403_D403.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D403_D403.py.snap @@ -11,7 +11,6 @@ D403.py:2:5: D403 [*] First word of the first line should be capitalized: `this` | = help: Capitalize `this` to `This` -ℹ Safe fix 1 1 | def bad_function(): 2 |- """this docstring is not capitalized""" 2 |+ """This docstring is not capitalized""" @@ -29,7 +28,6 @@ D403.py:30:5: D403 [*] First word of the first line should be capitalized: `sing | = help: Capitalize `singleword` to `Singleword` -ℹ Safe fix 27 27 | """th•s is not capitalized.""" 28 28 | 29 29 | def single_word(): @@ -47,7 +45,6 @@ D403.py:33:5: D403 [*] First word of the first line should be capitalized: `sing | = help: Capitalize `singleword` to `Singleword` -ℹ Safe fix 30 30 | """singleword.""" 31 31 | 32 32 | def single_word_no_dot(): diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D405_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D405_sections.py.snap index 2aff3caaa0427..bb24e8a6c6500 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D405_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D405_sections.py.snap @@ -12,7 +12,6 @@ sections.py:19:5: D405 [*] Section name should be properly capitalized ("returns | = help: Capitalize "returns" -ℹ Safe fix 16 16 | def not_capitalized(): # noqa: D416 17 17 | """Toggle the gizmo. 18 18 | @@ -32,7 +31,6 @@ sections.py:218:5: D405 [*] Section name should be properly capitalized ("Short | = help: Capitalize "Short summary" -ℹ Safe fix 215 215 | def multiple_sections(): # noqa: D416 216 216 | """Toggle the gizmo. 217 217 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D406_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D406_sections.py.snap index b64a36dc51e68..ccf274439a19f 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D406_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D406_sections.py.snap @@ -12,7 +12,6 @@ sections.py:32:5: D406 [*] Section name should end with a newline ("Returns") | = help: Add newline after "Returns" -ℹ Safe fix 29 29 | def superfluous_suffix(): # noqa: D416 30 30 | """Toggle the gizmo. 31 31 | @@ -32,7 +31,6 @@ sections.py:227:5: D406 [*] Section name should end with a newline ("Raises") | = help: Add newline after "Raises" -ℹ Safe fix 224 224 | Returns 225 225 | ------ 226 226 | Many many wonderful things. @@ -53,7 +51,6 @@ sections.py:590:5: D406 [*] Section name should end with a newline ("Parameters" | = help: Add newline after "Parameters" -ℹ Safe fix 587 587 | def test_lowercase_sub_section_header_should_be_valid(parameters: list[str], value: int): # noqa: D213 588 588 | """Test that lower case subsection header is valid even if it has the same name as section kind. 589 589 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D407_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D407_sections.py.snap index 61fe5b4c6da24..90c7b5340a672 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D407_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D407_sections.py.snap @@ -11,7 +11,6 @@ sections.py:44:5: D407 [*] Missing dashed underline after section ("Returns") | = help: Add dashed line under "Returns" -ℹ Safe fix 42 42 | """Toggle the gizmo. 43 43 | 44 44 | Returns @@ -31,7 +30,6 @@ sections.py:56:5: D407 [*] Missing dashed underline after section ("Returns") | = help: Add dashed line under "Returns" -ℹ Safe fix 54 54 | """Toggle the gizmo. 55 55 | 56 56 | Returns @@ -49,7 +47,6 @@ sections.py:67:5: D407 [*] Missing dashed underline after section ("Returns") | = help: Add dashed line under "Returns" -ℹ Safe fix 64 64 | def no_underline_and_no_newline(): # noqa: D416 65 65 | """Toggle the gizmo. 66 66 | @@ -70,7 +67,6 @@ sections.py:227:5: D407 [*] Missing dashed underline after section ("Raises") | = help: Add dashed line under "Raises" -ℹ Safe fix 225 225 | ------ 226 226 | Many many wonderful things. 227 227 | Raises: @@ -89,7 +85,6 @@ sections.py:263:5: D407 [*] Missing dashed underline after section ("Args") | = help: Add dashed line under "Args" -ℹ Safe fix 261 261 | """Toggle the gizmo. 262 262 | 263 263 | Args: @@ -109,7 +104,6 @@ sections.py:266:5: D407 [*] Missing dashed underline after section ("Returns") | = help: Add dashed line under "Returns" -ℹ Safe fix 264 264 | note: A random string. 265 265 | 266 266 | Returns: @@ -128,7 +122,6 @@ sections.py:268:5: D407 [*] Missing dashed underline after section ("Raises") | = help: Add dashed line under "Raises" -ℹ Safe fix 266 266 | Returns: 267 267 | 268 268 | Raises: @@ -147,7 +140,6 @@ sections.py:280:5: D407 [*] Missing dashed underline after section ("Args") | = help: Add dashed line under "Args" -ℹ Safe fix 278 278 | """Toggle the gizmo. 279 279 | 280 280 | Args @@ -167,7 +159,6 @@ sections.py:297:9: D407 [*] Missing dashed underline after section ("Args") | = help: Add dashed line under "Args" -ℹ Safe fix 295 295 | Will this work when referencing x? 296 296 | 297 297 | Args: @@ -186,7 +177,6 @@ sections.py:312:5: D407 [*] Missing dashed underline after section ("Args") | = help: Add dashed line under "Args" -ℹ Safe fix 310 310 | """Toggle the gizmo. 311 311 | 312 312 | Args: @@ -206,7 +196,6 @@ sections.py:324:9: D407 [*] Missing dashed underline after section ("Args") | = help: Add dashed line under "Args" -ℹ Safe fix 322 322 | """Test a valid args section. 323 323 | 324 324 | Args: @@ -225,7 +214,6 @@ sections.py:336:9: D407 [*] Missing dashed underline after section ("Args") | = help: Add dashed line under "Args" -ℹ Safe fix 334 334 | """Test a valid args section. 335 335 | 336 336 | Args: @@ -245,7 +233,6 @@ sections.py:348:9: D407 [*] Missing dashed underline after section ("Args") | = help: Add dashed line under "Args" -ℹ Safe fix 346 346 | """Test a valid args section. 347 347 | 348 348 | Args: @@ -264,7 +251,6 @@ sections.py:361:9: D407 [*] Missing dashed underline after section ("Args") | = help: Add dashed line under "Args" -ℹ Safe fix 359 359 | """Test a valid args section. 360 360 | 361 361 | Args: @@ -283,7 +269,6 @@ sections.py:373:9: D407 [*] Missing dashed underline after section ("Args") | = help: Add dashed line under "Args" -ℹ Safe fix 371 371 | """Test a valid args section. 372 372 | 373 373 | Args: @@ -303,7 +288,6 @@ sections.py:382:9: D407 [*] Missing dashed underline after section ("Args") | = help: Add dashed line under "Args" -ℹ Safe fix 380 380 | """Do stuff. 381 381 | 382 382 | Args: @@ -322,7 +306,6 @@ sections.py:503:9: D407 [*] Missing dashed underline after section ("Args") | = help: Add dashed line under "Args" -ℹ Safe fix 501 501 | Testing this incorrectly indented docstring. 502 502 | 503 503 | Args: @@ -340,7 +323,6 @@ sections.py:522:5: D407 [*] Missing dashed underline after section ("Parameters" | = help: Add dashed line under "Parameters" -ℹ Safe fix 519 519 | """Equal length equals should be replaced with dashes. 520 520 | 521 521 | Parameters @@ -359,7 +341,6 @@ sections.py:530:5: D407 [*] Missing dashed underline after section ("Parameters" | = help: Add dashed line under "Parameters" -ℹ Safe fix 527 527 | """Here, the length of equals is not the same. 528 528 | 529 529 | Parameters @@ -379,7 +360,6 @@ sections.py:550:5: D407 [*] Missing dashed underline after section ("Args") | = help: Add dashed line under "Args" -ℹ Safe fix 548 548 | """Below, `returns:` should _not_ be considered a section header. 549 549 | 550 550 | Args: @@ -398,7 +378,6 @@ sections.py:560:5: D407 [*] Missing dashed underline after section ("Args") | = help: Add dashed line under "Args" -ℹ Safe fix 558 558 | """Below, `Returns:` should be considered a section header. 559 559 | 560 560 | Args: @@ -417,7 +396,6 @@ sections.py:563:9: D407 [*] Missing dashed underline after section ("Returns") | = help: Add dashed line under "Returns" -ℹ Safe fix 561 561 | Here's a note. 562 562 | 563 563 | Returns: @@ -437,7 +415,6 @@ sections.py:602:4: D407 [*] Missing dashed underline after section ("Parameters" | = help: Add dashed line under "Parameters" -ℹ Safe fix 600 600 | """Test that lower case subsection header is valid even if it is of a different kind. 601 601 | 602 602 | Parameters diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D408_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D408_sections.py.snap index 38bec4612b427..81f23371f57ac 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D408_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D408_sections.py.snap @@ -11,7 +11,6 @@ sections.py:98:5: D408 [*] Section underline should be in the line following the | = help: Add underline to "Returns" -ℹ Safe fix 94 94 | """Toggle the gizmo. 95 95 | 96 96 | Returns diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D409_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D409_sections.py.snap index 1b59fad56deee..03f0165c075d6 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D409_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D409_sections.py.snap @@ -10,7 +10,6 @@ sections.py:111:5: D409 [*] Section underline should match the length of its nam | = help: Adjust underline length to match "Returns" -ℹ Safe fix 108 108 | """Toggle the gizmo. 109 109 | 110 110 | Returns @@ -30,7 +29,6 @@ sections.py:225:5: D409 [*] Section underline should match the length of its nam | = help: Adjust underline length to match "Returns" -ℹ Safe fix 222 222 | returns. 223 223 | 224 224 | Returns @@ -50,7 +48,6 @@ sections.py:578:5: D409 [*] Section underline should match the length of its nam | = help: Adjust underline length to match "Other Parameters" -ℹ Safe fix 575 575 | A dictionary of string attributes 576 576 | 577 577 | Other Parameters diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D410_D410.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D410_D410.py.snap index 2f7b0e4f92977..f85089aaae5f2 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D410_D410.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D410_D410.py.snap @@ -12,7 +12,6 @@ D410.py:4:5: D410 [*] Missing blank line after section ("Parameters") | = help: Add blank line after "Parameters" -ℹ Safe fix 7 7 | _description_ 8 8 | b : int 9 9 | _description_ @@ -32,7 +31,6 @@ D410.py:21:5: D410 [*] Missing blank line after section ("Parameters") | = help: Add blank line after "Parameters" -ℹ Safe fix 20 20 | 21 21 | Parameters 22 22 | ---------- diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D410_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D410_sections.py.snap index e8c466e1387ca..babfdb73e0aa3 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D410_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D410_sections.py.snap @@ -12,7 +12,6 @@ sections.py:78:5: D410 [*] Missing blank line after section ("Returns") | = help: Add blank line after "Returns" -ℹ Safe fix 77 77 | 78 78 | Returns 79 79 | ------- @@ -32,7 +31,6 @@ sections.py:224:5: D410 [*] Missing blank line after section ("Returns") | = help: Add blank line after "Returns" -ℹ Safe fix 224 224 | Returns 225 225 | ------ 226 226 | Many many wonderful things. diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D411_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D411_sections.py.snap index b516028f32fe3..78cc96e5b14dd 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D411_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D411_sections.py.snap @@ -11,7 +11,6 @@ sections.py:80:5: D411 [*] Missing blank line before section ("Yields") | = help: Add blank line before "Yields" -ℹ Safe fix 77 77 | 78 78 | Returns 79 79 | ------- @@ -30,7 +29,6 @@ sections.py:134:5: D411 [*] Missing blank line before section ("Returns") | = help: Add blank line before "Returns" -ℹ Safe fix 131 131 | """Toggle the gizmo. 132 132 | 133 133 | The function's description. @@ -49,7 +47,6 @@ sections.py:227:5: D411 [*] Missing blank line before section ("Raises") | = help: Add blank line before "Raises" -ℹ Safe fix 224 224 | Returns 225 225 | ------ 226 226 | Many many wonderful things. diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D412_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D412_sections.py.snap index a6461d2987661..241241feaef1f 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D412_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D412_sections.py.snap @@ -11,7 +11,6 @@ sections.py:218:5: D412 [*] No blank lines allowed between a section header and | = help: Remove blank line(s) -ℹ Safe fix 217 217 | 218 218 | Short summary 219 219 | ------------- diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D412_sphinx.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D412_sphinx.py.snap index 8c9f7c45dccad..cea2584a9593e 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D412_sphinx.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D412_sphinx.py.snap @@ -10,7 +10,6 @@ sphinx.py:13:5: D412 [*] No blank lines allowed between a section header and its | = help: Remove blank line(s) -ℹ Safe fix 12 12 | """ 13 13 | Example: 14 14 | @@ -28,7 +27,6 @@ sphinx.py:24:5: D412 [*] No blank lines allowed between a section header and its | = help: Remove blank line(s) -ℹ Safe fix 23 23 | """ 24 24 | Example: 25 25 | @@ -48,7 +46,6 @@ sphinx.py:47:5: D412 [*] No blank lines allowed between a section header and its | = help: Remove blank line(s) -ℹ Safe fix 47 47 | Example 48 48 | ------- 49 49 | @@ -67,7 +64,6 @@ sphinx.py:59:5: D412 [*] No blank lines allowed between a section header and its | = help: Remove blank line(s) -ℹ Safe fix 59 59 | Example 60 60 | ------- 61 61 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D413_D413.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D413_D413.py.snap index a2a831d93e752..e87a3713b407e 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D413_D413.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D413_D413.py.snap @@ -12,7 +12,6 @@ D413.py:7:1: D413 [*] Missing blank line after last section ("Returns") | = help: Add blank line after "Returns" -ℹ Safe fix 6 6 | 7 7 | Returns: 8 8 | the value @@ -32,7 +31,6 @@ D413.py:19:5: D413 [*] Missing blank line after last section ("Returns") | = help: Add blank line after "Returns" -ℹ Safe fix 18 18 | 19 19 | Returns: 20 20 | the value @@ -51,7 +49,6 @@ D413.py:58:5: D413 [*] Missing blank line after last section ("Returns") | = help: Add blank line after "Returns" -ℹ Safe fix 56 56 | with a hanging indent 57 57 | 58 58 | Returns: @@ -74,7 +71,6 @@ D413.py:69:5: D413 [*] Missing blank line after last section ("Returns") | = help: Add blank line after "Returns" -ℹ Safe fix 68 68 | 69 69 | Returns: 70 70 | the value diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D413_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D413_sections.py.snap index 223c7c38218af..cfb1a9e652a01 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D413_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D413_sections.py.snap @@ -10,7 +10,6 @@ sections.py:67:5: D413 [*] Missing blank line after last section ("Returns") | = help: Add blank line after "Returns" -ℹ Safe fix 64 64 | def no_underline_and_no_newline(): # noqa: D416 65 65 | """Toggle the gizmo. 66 66 | @@ -33,7 +32,6 @@ sections.py:122:5: D413 [*] Missing blank line after last section ("Returns") | = help: Add blank line after "Returns" -ℹ Safe fix 122 122 | Returns 123 123 | ------- 124 124 | A value of some sort. @@ -53,7 +51,6 @@ sections.py:172:5: D413 [*] Missing blank line after last section ("Returns") | = help: Add blank line after "Returns" -ℹ Safe fix 171 171 | 172 172 | Returns 173 173 | ------- @@ -73,7 +70,6 @@ sections.py:521:5: D413 [*] Missing blank line after last section ("Parameters") | = help: Add blank line after "Parameters" -ℹ Safe fix 520 520 | 521 521 | Parameters 522 522 | ========== @@ -93,7 +89,6 @@ sections.py:529:5: D413 [*] Missing blank line after last section ("Parameters") | = help: Add blank line after "Parameters" -ℹ Safe fix 528 528 | 529 529 | Parameters 530 530 | =========== @@ -112,7 +107,6 @@ sections.py:550:5: D413 [*] Missing blank line after last section ("Args") | = help: Add blank line after "Args" -ℹ Safe fix 551 551 | Here's a note. 552 552 | 553 553 | returns: @@ -131,7 +125,6 @@ sections.py:563:9: D413 [*] Missing blank line after last section ("Returns") | = help: Add blank line after "Returns" -ℹ Safe fix 561 561 | Here's a note. 562 562 | 563 563 | Returns: @@ -151,7 +144,6 @@ sections.py:590:5: D413 [*] Missing blank line after last section ("Parameters") | = help: Add blank line after "Parameters" -ℹ Safe fix 593 593 | A list of string parameters 594 594 | value: 595 595 | Some value diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D415_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D415_D.py.snap index c563e9541455a..e374d5165c868 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D415_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D415_D.py.snap @@ -10,15 +10,6 @@ D.py:355:5: D415 [*] First line should end with a period, question mark, or excl | = help: Add closing punctuation -ℹ Unsafe fix -352 352 | @expect("D415: First line should end with a period, question mark, " -353 353 | "or exclamation point (not 'y')") -354 354 | def lwnlkjl(): -355 |- """Summary""" - 355 |+ """Summary.""" -356 356 | -357 357 | -358 358 | @expect("D401: First line should be in imperative mood " D.py:406:25: D415 [*] First line should end with a period, question mark, or exclamation point | @@ -29,15 +20,6 @@ D.py:406:25: D415 [*] First line should end with a period, question mark, or exc | = help: Add closing punctuation -ℹ Unsafe fix -403 403 | @expect("D400: First line should end with a period (not 'r')") -404 404 | @expect("D415: First line should end with a period, question mark," -405 405 | " or exclamation point (not 'r')") -406 |-def oneliner_withdoc(): """One liner""" - 406 |+def oneliner_withdoc(): """One liner.""" -407 407 | -408 408 | -409 409 | def ignored_decorator(func): # noqa: D400,D401,D415 D.py:410:5: D415 [*] First line should end with a period, question mark, or exclamation point | @@ -49,15 +31,6 @@ D.py:410:5: D415 [*] First line should end with a period, question mark, or excl | = help: Add closing punctuation -ℹ Unsafe fix -407 407 | -408 408 | -409 409 | def ignored_decorator(func): # noqa: D400,D401,D415 -410 |- """Runs something""" - 410 |+ """Runs something.""" -411 411 | func() -412 412 | pass -413 413 | D.py:416:5: D415 [*] First line should end with a period, question mark, or exclamation point | @@ -69,15 +42,6 @@ D.py:416:5: D415 [*] First line should end with a period, question mark, or excl | = help: Add closing punctuation -ℹ Unsafe fix -413 413 | -414 414 | -415 415 | def decorator_for_test(func): # noqa: D400,D401,D415 -416 |- """Runs something""" - 416 |+ """Runs something.""" -417 417 | func() -418 418 | pass -419 419 | D.py:422:35: D415 [*] First line should end with a period, question mark, or exclamation point | @@ -87,15 +51,6 @@ D.py:422:35: D415 [*] First line should end with a period, question mark, or exc | = help: Add closing punctuation -ℹ Unsafe fix -419 419 | -420 420 | -421 421 | @ignored_decorator -422 |-def oneliner_ignored_decorator(): """One liner""" - 422 |+def oneliner_ignored_decorator(): """One liner.""" -423 423 | -424 424 | -425 425 | @decorator_for_test D.py:429:49: D415 [*] First line should end with a period, question mark, or exclamation point | @@ -106,15 +61,6 @@ D.py:429:49: D415 [*] First line should end with a period, question mark, or exc | = help: Add closing punctuation -ℹ Unsafe fix -426 426 | @expect("D400: First line should end with a period (not 'r')") -427 427 | @expect("D415: First line should end with a period, question mark," -428 428 | " or exclamation point (not 'r')") -429 |-def oneliner_with_decorator_expecting_errors(): """One liner""" - 429 |+def oneliner_with_decorator_expecting_errors(): """One liner.""" -430 430 | -431 431 | -432 432 | @decorator_for_test D.py:470:5: D415 [*] First line should end with a period, question mark, or exclamation point | @@ -126,15 +72,6 @@ D.py:470:5: D415 [*] First line should end with a period, question mark, or excl | = help: Add closing punctuation -ℹ Unsafe fix -467 467 | @expect("D415: First line should end with a period, question mark, " -468 468 | "or exclamation point (not 'g')") -469 469 | def docstring_bad(): -470 |- """Runs something""" - 470 |+ """Runs something.""" -471 471 | pass -472 472 | -473 473 | D.py:475:5: D415 [*] First line should end with a period, question mark, or exclamation point | @@ -145,15 +82,6 @@ D.py:475:5: D415 [*] First line should end with a period, question mark, or excl | = help: Add closing punctuation -ℹ Unsafe fix -472 472 | -473 473 | -474 474 | def docstring_bad_ignore_all(): # noqa -475 |- """Runs something""" - 475 |+ """Runs something.""" -476 476 | pass -477 477 | -478 478 | D.py:480:5: D415 [*] First line should end with a period, question mark, or exclamation point | @@ -164,15 +92,6 @@ D.py:480:5: D415 [*] First line should end with a period, question mark, or excl | = help: Add closing punctuation -ℹ Unsafe fix -477 477 | -478 478 | -479 479 | def docstring_bad_ignore_one(): # noqa: D400,D401,D415 -480 |- """Runs something""" - 480 |+ """Runs something.""" -481 481 | pass -482 482 | -483 483 | D.py:487:5: D415 [*] First line should end with a period, question mark, or exclamation point | @@ -184,15 +103,6 @@ D.py:487:5: D415 [*] First line should end with a period, question mark, or excl | = help: Add closing punctuation -ℹ Unsafe fix -484 484 | @expect("D401: First line should be in imperative mood " -485 485 | "(perhaps 'Run', not 'Runs')") -486 486 | def docstring_ignore_some_violations_but_catch_D401(): # noqa: E501,D400,D415 -487 |- """Runs something""" - 487 |+ """Runs something.""" -488 488 | pass -489 489 | -490 490 | D.py:520:5: D415 [*] First line should end with a period, question mark, or exclamation point | @@ -203,15 +113,6 @@ D.py:520:5: D415 [*] First line should end with a period, question mark, or excl | = help: Add closing punctuation -ℹ Unsafe fix -517 517 | @expect("D415: First line should end with a period, question mark, " -518 518 | "or exclamation point (not 'g')") -519 519 | def bad_google_string(): # noqa: D400 -520 |- """Test a valid something""" - 520 |+ """Test a valid something.""" -521 521 | -522 522 | -523 523 | # This is reproducing a bug where AttributeError is raised when parsing class D.py:581:5: D415 [*] First line should end with a period, question mark, or exclamation point | @@ -222,15 +123,6 @@ D.py:581:5: D415 [*] First line should end with a period, question mark, or excl | = help: Add closing punctuation -ℹ Unsafe fix -578 578 | @expect("D415: First line should end with a period, question mark, " -579 579 | "or exclamation point (not '\"')") -580 580 | def endswith_quote(): -581 |- """Whitespace at the end, but also a quote" """ - 581 |+ """Whitespace at the end, but also a quote". """ -582 582 | -583 583 | -584 584 | @expect('D209: Multi-line docstring closing quotes should be on a separate ' D.py:615:5: D415 [*] First line should end with a period, question mark, or exclamation point | @@ -244,15 +136,6 @@ D.py:615:5: D415 [*] First line should end with a period, question mark, or excl | = help: Add closing punctuation -ℹ Unsafe fix -612 612 | '(found 3)') -613 613 | @expect('D212: Multi-line docstring summary should start at the first line') -614 614 | def one_liner(): -615 |- """Wrong." - 615 |+ """Wrong.". -616 616 | -617 617 | """ -618 618 | D.py:639:17: D415 [*] First line should end with a period, question mark, or exclamation point | @@ -263,15 +146,6 @@ D.py:639:17: D415 [*] First line should end with a period, question mark, or exc | = help: Add closing punctuation -ℹ Unsafe fix -636 636 | """ This is a docstring that starts with a space.""" # noqa: D210 -637 637 | -638 638 | -639 |-class SameLine: """This is a docstring on the same line""" - 639 |+class SameLine: """This is a docstring on the same line.""" -640 640 | -641 641 | def same_line(): """This is a docstring on the same line""" -642 642 | D.py:641:18: D415 [*] First line should end with a period, question mark, or exclamation point | @@ -282,15 +156,6 @@ D.py:641:18: D415 [*] First line should end with a period, question mark, or exc | = help: Add closing punctuation -ℹ Unsafe fix -638 638 | -639 639 | class SameLine: """This is a docstring on the same line""" -640 640 | -641 |-def same_line(): """This is a docstring on the same line""" - 641 |+def same_line(): """This is a docstring on the same line.""" -642 642 | -643 643 | -644 644 | def single_line_docstring_with_an_escaped_backslash(): D.py:664:5: D415 [*] First line should end with a period, question mark, or exclamation point | @@ -301,15 +166,3 @@ D.py:664:5: D415 [*] First line should end with a period, question mark, or excl | |_________________________________________________________^ D415 | = help: Add closing punctuation - -ℹ Unsafe fix -662 662 | -663 663 | def newline_after_closing_quote(self): -664 664 | "We enforce a newline after the closing quote for a multi-line docstring \ -665 |- but continuations shouldn't be considered multi-line" - 665 |+ but continuations shouldn't be considered multi-line." -666 666 | -667 667 | -668 668 | - - diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__bom.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__bom.snap index bf80e65243b0c..26d96178427eb 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__bom.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__bom.snap @@ -8,8 +8,5 @@ bom.py:1:1: D300 [*] Use triple double quotes `"""` | = help: Convert to triple double quotes -ℹ Safe fix 1 |-''' SAM macro definitions ''' 1 |+""" SAM macro definitions """ - - diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d209_d400.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d209_d400.snap index 02a19f057d2c5..4ca8bddc73dc8 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d209_d400.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d209_d400.snap @@ -11,7 +11,6 @@ D209_D400.py:2:5: D209 [*] Multi-line docstring closing quotes should be on a se | = help: Move closing quotes to new line -ℹ Safe fix 1 1 | def lorem(): 2 2 | """lorem ipsum dolor sit amet consectetur adipiscing elit 3 |- sed do eiusmod tempor incididunt ut labore et dolore magna aliqua""" @@ -27,11 +26,3 @@ D209_D400.py:2:5: D400 [*] First line should end with a period | |________________________________________________________________________^ D400 | = help: Add period - -ℹ Unsafe fix -1 1 | def lorem(): -2 2 | """lorem ipsum dolor sit amet consectetur adipiscing elit -3 |- sed do eiusmod tempor incididunt ut labore et dolore magna aliqua""" - 3 |+ sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.""" - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_0.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_0.py.snap index 433865de23481..c26ebfa70f37e 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_0.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_0.py.snap @@ -11,7 +11,6 @@ F401_0.py:2:8: F401 [*] `functools` imported but unused | = help: Remove unused import: `functools` -ℹ Safe fix 1 1 | from __future__ import all_feature_names 2 |-import functools, os 2 |+import os @@ -30,7 +29,6 @@ F401_0.py:6:5: F401 [*] `collections.OrderedDict` imported but unused | = help: Remove unused import: `collections.OrderedDict` -ℹ Safe fix 3 3 | from datetime import datetime 4 4 | from collections import ( 5 5 | Counter, @@ -50,7 +48,6 @@ F401_0.py:12:8: F401 [*] `logging.handlers` imported but unused | = help: Remove unused import: `logging.handlers` -ℹ Safe fix 9 9 | import multiprocessing.pool 10 10 | import multiprocessing.process 11 11 | import logging.config @@ -68,7 +65,6 @@ F401_0.py:32:12: F401 [*] `shelve` imported but unused | = help: Remove unused import: `shelve` -ℹ Safe fix 29 29 | from models import Fruit, Nut, Vegetable 30 30 | 31 31 | if TYPE_CHECKING: @@ -88,7 +84,6 @@ F401_0.py:33:12: F401 [*] `importlib` imported but unused | = help: Remove unused import: `importlib` -ℹ Safe fix 30 30 | 31 31 | if TYPE_CHECKING: 32 32 | import shelve @@ -108,7 +103,6 @@ F401_0.py:37:12: F401 [*] `pathlib` imported but unused | = help: Remove unused import: `pathlib` -ℹ Safe fix 34 34 | 35 35 | if TYPE_CHECKING: 36 36 | """Hello, world!""" @@ -125,7 +119,6 @@ F401_0.py:52:16: F401 [*] `pickle` imported but unused | = help: Remove unused import: `pickle` -ℹ Safe fix 49 49 | z = multiprocessing.pool.ThreadPool() 50 50 | 51 51 | def b(self) -> None: @@ -145,7 +138,6 @@ F401_0.py:93:16: F401 [*] `x` imported but unused | = help: Remove unused import: `x` -ℹ Safe fix 90 90 | # Test: match statements. 91 91 | match *0, 1, *2: 92 92 | case 0,: @@ -163,7 +155,6 @@ F401_0.py:94:16: F401 [*] `y` imported but unused | = help: Remove unused import: `y` -ℹ Safe fix 91 91 | match *0, 1, *2: 92 92 | case 0,: 93 93 | import x @@ -183,7 +174,6 @@ F401_0.py:99:8: F401 [*] `foo.bar.baz` imported but unused | = help: Remove unused import: `foo.bar.baz` -ℹ Safe fix 96 96 | 97 97 | # Test: access a sub-importation via an alias. 98 98 | import foo.bar as bop @@ -203,7 +193,6 @@ F401_0.py:105:12: F401 [*] `a1` imported but unused | = help: Remove unused import: `a1` -ℹ Safe fix 102 102 | 103 103 | # Test: isolated deletions. 104 104 | if TYPE_CHECKING: @@ -221,7 +210,6 @@ F401_0.py:107:12: F401 [*] `a2` imported but unused | = help: Remove unused import: `a2` -ℹ Safe fix 104 104 | if TYPE_CHECKING: 105 105 | import a1 106 106 | @@ -241,7 +229,6 @@ F401_0.py:112:16: F401 [*] `b1` imported but unused | = help: Remove unused import: `b1` -ℹ Safe fix 109 109 | 110 110 | match *0, 1, *2: 111 111 | case 0,: @@ -259,7 +246,6 @@ F401_0.py:114:16: F401 [*] `b2` imported but unused | = help: Remove unused import: `b2` -ℹ Safe fix 111 111 | case 0,: 112 112 | import b1 113 113 | @@ -276,11 +262,8 @@ F401_0.py:122:1: F401 [*] `datameta_client_lib.model_helpers.noqa` imported but | = help: Remove unused import: `datameta_client_lib.model_helpers.noqa` -ℹ Safe fix 118 118 | from datameta_client_lib.model_utils import ( # noqa: F401 119 119 | noqa ) 120 120 | 121 |-from datameta_client_lib.model_helpers import ( 122 |-noqa ) - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_11.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_11.py.snap index 39c9b95a011e2..140e7be7f064e 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_11.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_11.py.snap @@ -9,7 +9,6 @@ F401_11.py:4:27: F401 [*] `pathlib.PurePath` imported but unused | = help: Remove unused import: `pathlib.PurePath` -ℹ Safe fix 1 1 | """Test: parsing of nested string annotations.""" 2 2 | 3 3 | from typing import List @@ -18,5 +17,3 @@ F401_11.py:4:27: F401 [*] `pathlib.PurePath` imported but unused 5 5 | 6 6 | 7 7 | x: """List['Path']""" = [] - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_15.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_15.py.snap index cd5526e8f4fde..38c565af3274f 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_15.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_15.py.snap @@ -9,7 +9,6 @@ F401_15.py:5:25: F401 [*] `pathlib.Path` imported but unused | = help: Remove unused import: `pathlib.Path` -ℹ Safe fix 2 2 | from django.db.models import ForeignKey 3 3 | 4 4 | if TYPE_CHECKING: @@ -18,5 +17,3 @@ F401_15.py:5:25: F401 [*] `pathlib.Path` imported but unused 6 6 | 7 7 | 8 8 | class Foo: - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_17.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_17.py.snap index caf5d2c6767c3..ae550e0828ad3 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_17.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_17.py.snap @@ -11,7 +11,6 @@ F401_17.py:12:27: F401 [*] `threading.Thread` imported but unused | = help: Remove unused import: `threading.Thread` -ℹ Safe fix 9 9 | 10 10 | 11 11 | def fn(thread: Thread): @@ -30,7 +29,6 @@ F401_17.py:20:27: F401 [*] `threading.Thread` imported but unused | = help: Remove unused import: `threading.Thread` -ℹ Safe fix 17 17 | 18 18 | 19 19 | def fn(thread: Thread): @@ -38,5 +36,3 @@ F401_17.py:20:27: F401 [*] `threading.Thread` imported but unused 21 20 | 22 21 | # The `Thread` on the left-hand side should resolve to the `Thread` imported at the 23 22 | # top level. - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_18.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_18.py.snap index 33647bd2bf029..c7928f2d7c138 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_18.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_18.py.snap @@ -9,7 +9,6 @@ F401_18.py:5:12: F401 [*] `__future__` imported but unused | = help: Remove unused import: `__future__` -ℹ Safe fix 2 2 | 3 3 | 4 4 | def f(): @@ -18,5 +17,3 @@ F401_18.py:5:12: F401 [*] `__future__` imported but unused 6 6 | 7 7 | 8 8 | def f(): - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_23.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_23.py.snap index afde9e550a87d..055b7c47b91f4 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_23.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_23.py.snap @@ -10,7 +10,6 @@ F401_23.py:4:16: F401 [*] `re.RegexFlag` imported but unused | = help: Remove unused import: `re.RegexFlag` -ℹ Safe fix 1 1 | """Test: ensure that we treat strings in `typing.Annotation` as type definitions.""" 2 2 | 3 3 | from pathlib import Path diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_5.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_5.py.snap index e4317c5d195e7..1da5724503adc 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_5.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_5.py.snap @@ -11,7 +11,6 @@ F401_5.py:2:17: F401 [*] `a.b.c` imported but unused | = help: Remove unused import: `a.b.c` -ℹ Safe fix 1 1 | """Test: removal of multi-segment and aliases imports.""" 2 |-from a.b import c 3 2 | from d.e import f as g @@ -29,7 +28,6 @@ F401_5.py:3:22: F401 [*] `d.e.f` imported but unused | = help: Remove unused import: `d.e.f` -ℹ Safe fix 1 1 | """Test: removal of multi-segment and aliases imports.""" 2 2 | from a.b import c 3 |-from d.e import f as g @@ -46,7 +44,6 @@ F401_5.py:4:8: F401 [*] `h.i` imported but unused | = help: Remove unused import: `h.i` -ℹ Safe fix 1 1 | """Test: removal of multi-segment and aliases imports.""" 2 2 | from a.b import c 3 3 | from d.e import f as g @@ -62,10 +59,7 @@ F401_5.py:5:15: F401 [*] `j.k` imported but unused | = help: Remove unused import: `j.k` -ℹ Safe fix 2 2 | from a.b import c 3 3 | from d.e import f as g 4 4 | import h.i 5 |-import j.k as l - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_6.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_6.py.snap index d0db5ee40d5df..c5e546e5ccefa 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_6.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_6.py.snap @@ -11,7 +11,6 @@ F401_6.py:7:25: F401 [*] `.background.BackgroundTasks` imported but unused | = help: Remove unused import: `.background.BackgroundTasks` -ℹ Safe fix 4 4 | from .applications import FastAPI as FastAPI 5 5 | 6 6 | # F401 `background.BackgroundTasks` imported but unused @@ -30,7 +29,6 @@ F401_6.py:10:43: F401 [*] `.datastructures.UploadFile` imported but unused | = help: Remove unused import: `.datastructures.UploadFile` -ℹ Safe fix 7 7 | from .background import BackgroundTasks 8 8 | 9 9 | # F401 `datastructures.UploadFile` imported but unused @@ -49,7 +47,6 @@ F401_6.py:16:8: F401 [*] `background` imported but unused | = help: Remove unused import: `background` -ℹ Safe fix 13 13 | import applications as applications 14 14 | 15 15 | # F401 `background` imported but unused @@ -66,10 +63,7 @@ F401_6.py:19:26: F401 [*] `datastructures` imported but unused | = help: Remove unused import: `datastructures` -ℹ Safe fix 16 16 | import background 17 17 | 18 18 | # F401 `datastructures` imported but unused 19 |-import datastructures as structures - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_7.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_7.py.snap index cb4ec75028592..26a5fc8e9248d 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_7.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_7.py.snap @@ -11,7 +11,6 @@ F401_7.py:30:5: F401 [*] `typing.Union` imported but unused | = help: Remove unused import: `typing.Union` -ℹ Safe fix 27 27 | # This should ignore the first error. 28 28 | from typing import ( 29 29 | Mapping, # noqa: F401 @@ -30,7 +29,6 @@ F401_7.py:66:20: F401 [*] `typing.Awaitable` imported but unused | = help: Remove unused import -ℹ Safe fix 63 63 | from typing import AsyncIterable, AsyncGenerator # noqa 64 64 | 65 65 | # This should mark F501 as unused. @@ -44,10 +42,7 @@ F401_7.py:66:31: F401 [*] `typing.AwaitableGenerator` imported but unused | = help: Remove unused import -ℹ Safe fix 63 63 | from typing import AsyncIterable, AsyncGenerator # noqa 64 64 | 65 65 | # This should mark F501 as unused. 66 |-from typing import Awaitable, AwaitableGenerator # noqa: F501 - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_9.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_9.py.snap index c7071cc24fbfa..77573d2424796 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_9.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_9.py.snap @@ -9,11 +9,8 @@ F401_9.py:4:22: F401 [*] `foo.baz` imported but unused | = help: Remove unused import: `foo.baz` -ℹ Safe fix 1 1 | """Test: late-binding of `__all__`.""" 2 2 | 3 3 | __all__ = ("bar",) 4 |-from foo import bar, baz 4 |+from foo import bar - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_24____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_24____init__.py.snap index 019ddc0195896..9b1c11269efb8 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_24____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_24____init__.py.snap @@ -8,14 +8,6 @@ __init__.py:19:8: F401 [*] `sys` imported but unused | = help: Remove unused import: `sys` -ℹ Unsafe fix -16 16 | import argparse as argparse # Ok: is redundant alias -17 17 | -18 18 | -19 |-import sys # F401: remove unused -20 19 | -21 20 | -22 21 | # first-party __init__.py:33:15: F401 [*] `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias | @@ -24,14 +16,6 @@ __init__.py:33:15: F401 [*] `.unused` imported but unused; consider removing, ad | = help: Remove unused import: `.unused` -ℹ Unsafe fix -30 30 | from . import aliased as aliased # Ok: is redundant alias -31 31 | -32 32 | -33 |-from . import unused # F401: change to redundant alias -34 33 | -35 34 | -36 35 | from . import renamed as bees # F401: no fix __init__.py:36:26: F401 [*] `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias | @@ -39,9 +23,3 @@ __init__.py:36:26: F401 [*] `.renamed` imported but unused; consider removing, a | ^^^^ F401 | = help: Remove unused import: `.renamed` - -ℹ Unsafe fix -33 33 | from . import unused # F401: change to redundant alias -34 34 | -35 35 | -36 |-from . import renamed as bees # F401: no fix diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_25__all_nonempty____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_25__all_nonempty____init__.py.snap index 2d1d54e3488e5..2d5889e44bbfd 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_25__all_nonempty____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_25__all_nonempty____init__.py.snap @@ -8,14 +8,6 @@ __init__.py:19:8: F401 [*] `sys` imported but unused | = help: Remove unused import: `sys` -ℹ Unsafe fix -16 16 | import argparse # Ok: is exported in __all__ -17 17 | -18 18 | -19 |-import sys # F401: remove unused -20 19 | -21 20 | -22 21 | # first-party __init__.py:36:15: F401 [*] `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias | @@ -24,14 +16,6 @@ __init__.py:36:15: F401 [*] `.unused` imported but unused; consider removing, ad | = help: Remove unused import: `.unused` -ℹ Unsafe fix -33 33 | from . import exported # Ok: is exported in __all__ -34 34 | -35 35 | -36 |-from . import unused # F401: add to __all__ -37 36 | -38 37 | -39 38 | from . import renamed as bees # F401: add to __all__ __init__.py:39:26: F401 [*] `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias | @@ -39,12 +23,3 @@ __init__.py:39:26: F401 [*] `.renamed` imported but unused; consider removing, a | ^^^^ F401 | = help: Remove unused import: `.renamed` - -ℹ Unsafe fix -36 36 | from . import unused # F401: add to __all__ -37 37 | -38 38 | -39 |-from . import renamed as bees # F401: add to __all__ -40 39 | -41 40 | -42 41 | __all__ = ["argparse", "exported"] diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_26__all_empty____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_26__all_empty____init__.py.snap index 0fa48cf5f179e..7bb1897fd5475 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_26__all_empty____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_26__all_empty____init__.py.snap @@ -8,14 +8,6 @@ __init__.py:5:15: F401 [*] `.unused` imported but unused; consider removing, add | = help: Remove unused import: `.unused` -ℹ Unsafe fix -2 2 | """ -3 3 | -4 4 | -5 |-from . import unused # F401: add to __all__ -6 5 | -7 6 | -8 7 | from . import renamed as bees # F401: add to __all__ __init__.py:8:26: F401 [*] `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias | @@ -23,12 +15,3 @@ __init__.py:8:26: F401 [*] `.renamed` imported but unused; consider removing, ad | ^^^^ F401 | = help: Remove unused import: `.renamed` - -ℹ Unsafe fix -5 5 | from . import unused # F401: add to __all__ -6 6 | -7 7 | -8 |-from . import renamed as bees # F401: add to __all__ -9 8 | -10 9 | -11 10 | __all__ = [] diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_27__all_mistyped____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_27__all_mistyped____init__.py.snap index a4f1d557bdef4..56e2e913ac180 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_27__all_mistyped____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_27__all_mistyped____init__.py.snap @@ -8,14 +8,6 @@ __init__.py:5:15: F401 [*] `.unused` imported but unused; consider removing, add | = help: Remove unused import: `.unused` -ℹ Unsafe fix -2 2 | """ -3 3 | -4 4 | -5 |-from . import unused # F401: recommend add to all w/o fix -6 5 | -7 6 | -8 7 | from . import renamed as bees # F401: recommend add to all w/o fix __init__.py:8:26: F401 [*] `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias | @@ -23,12 +15,3 @@ __init__.py:8:26: F401 [*] `.renamed` imported but unused; consider removing, ad | ^^^^ F401 | = help: Remove unused import: `.renamed` - -ℹ Unsafe fix -5 5 | from . import unused # F401: recommend add to all w/o fix -6 6 | -7 7 | -8 |-from . import renamed as bees # F401: recommend add to all w/o fix -9 8 | -10 9 | -11 10 | __all__ = None diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_28__all_multiple____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_28__all_multiple____init__.py.snap index daeee1984e4aa..7aa09cf69f0d2 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_28__all_multiple____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_28__all_multiple____init__.py.snap @@ -8,14 +8,6 @@ __init__.py:5:15: F401 [*] `.unused` imported but unused; consider removing, add | = help: Remove unused import -ℹ Unsafe fix -2 2 | """ -3 3 | -4 4 | -5 |-from . import unused, renamed as bees # F401: add to __all__ -6 5 | -7 6 | -8 7 | __all__ = []; __init__.py:5:34: F401 [*] `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias | @@ -23,12 +15,3 @@ __init__.py:5:34: F401 [*] `.renamed` imported but unused; consider removing, ad | ^^^^ F401 | = help: Remove unused import - -ℹ Unsafe fix -2 2 | """ -3 3 | -4 4 | -5 |-from . import unused, renamed as bees # F401: add to __all__ -6 5 | -7 6 | -8 7 | __all__ = []; diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_29__all_conditional____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_29__all_conditional____init__.py.snap index 392a58cf7aa16..63c15f7c5b52a 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_29__all_conditional____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_29__all_conditional____init__.py.snap @@ -12,15 +12,6 @@ __init__.py:8:15: F401 [*] `.unused` imported but unused; consider removing, add | = help: Remove unused import -ℹ Unsafe fix -5 5 | -6 6 | import sys -7 7 | -8 |-from . import unused, exported, renamed as bees - 8 |+from . import exported -9 9 | -10 10 | if sys.version_info > (3, 9): -11 11 | from . import also_exported __init__.py:8:44: F401 [*] `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias | @@ -32,13 +23,3 @@ __init__.py:8:44: F401 [*] `.renamed` imported but unused; consider removing, ad 10 | if sys.version_info > (3, 9): | = help: Remove unused import - -ℹ Unsafe fix -5 5 | -6 6 | import sys -7 7 | -8 |-from . import unused, exported, renamed as bees - 8 |+from . import exported -9 9 | -10 10 | if sys.version_info > (3, 9): -11 11 | from . import also_exported diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_30.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_30.py.snap index 7b42b5f341833..fca763fa5880b 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_30.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_30.py.snap @@ -10,7 +10,6 @@ F401_30.py:6:19: F401 [*] `.main.MaμToMan` imported but unused | = help: Remove unused import: `.main.MaμToMan` -ℹ Safe fix 3 3 | even if they have characters in them that undergo NFKC normalization 4 4 | """ 5 5 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F504_F504.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F504_F504.py.snap index a04af93d12ad3..5765f9ac0c3ea 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F504_F504.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F504_F504.py.snap @@ -12,7 +12,6 @@ F504.py:3:1: F504 [*] `%`-format string has unused named argument(s): b | = help: Remove extra named arguments: b -ℹ Safe fix 1 1 | # Ruff has no way of knowing if the following are F505s 2 2 | a = "wrong" 3 |-"%(a)s %(c)s" % {a: "?", "b": "!"} # F504 ("b" not used) @@ -31,7 +30,6 @@ F504.py:8:1: F504 [*] `%`-format string has unused named argument(s): b | = help: Remove extra named arguments: b -ℹ Safe fix 5 5 | hidden = {"a": "!"} 6 6 | "%(a)s %(c)s" % {"x": 1, **hidden} # Ok (cannot see through splat) 7 7 | @@ -51,7 +49,6 @@ F504.py:9:1: F504 [*] `%`-format string has unused named argument(s): b | = help: Remove extra named arguments: b -ℹ Safe fix 6 6 | "%(a)s %(c)s" % {"x": 1, **hidden} # Ok (cannot see through splat) 7 7 | 8 8 | "%(a)s" % {"a": 1, r"b": "!"} # F504 ("b" not used) @@ -72,7 +69,6 @@ F504.py:11:1: F504 [*] `%`-format string has unused named argument(s): ab | = help: Remove extra named arguments: ab -ℹ Safe fix 8 8 | "%(a)s" % {"a": 1, r"b": "!"} # F504 ("b" not used) 9 9 | "%(a)s" % {'a': 1, u"b": "!"} # F504 ("b" not used) 10 10 | @@ -92,12 +88,9 @@ F504.py:14:1: F504 [*] `%`-format string has unused named argument(s): test1, te | = help: Remove extra named arguments: test1, test2 -ℹ Safe fix 12 12 | 13 13 | # https://github.com/astral-sh/ruff/issues/4899 14 14 | "" % { 15 |- 'test1': '', 16 |- 'test2': '', 15 |+ 17 16 | } - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F504_F50x.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F504_F50x.py.snap index 8bcd33a080e3e..f2ba29788eb7a 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F504_F50x.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F504_F50x.py.snap @@ -12,7 +12,6 @@ F50x.py:8:1: F504 [*] `%`-format string has unused named argument(s): baz | = help: Remove extra named arguments: baz -ℹ Safe fix 5 5 | '%s %s' % (1,) # F507 6 6 | '%s %s' % (1, 2, 3) # F507 7 7 | '%(bar)s' % {} # F505 @@ -21,5 +20,3 @@ F50x.py:8:1: F504 [*] `%`-format string has unused named argument(s): baz 9 9 | '%(bar)s' % (1, 2, 3) # F502 10 10 | '%s %s' % {'k': 'v'} # F503 11 11 | '%(bar)*s' % {'bar': 'baz'} # F506, F508 - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F522_F522.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F522_F522.py.snap index 5e33645d06379..6632dc890d772 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F522_F522.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F522_F522.py.snap @@ -10,7 +10,6 @@ F522.py:1:1: F522 [*] `.format` call has unused named argument(s): bar | = help: Remove extra named arguments: bar -ℹ Safe fix 1 |-"{}".format(1, bar=2) # F522 1 |+"{}".format(1, ) # F522 2 2 | "{bar}{}".format(1, bar=2, spam=3) # F522 @@ -27,7 +26,6 @@ F522.py:2:1: F522 [*] `.format` call has unused named argument(s): spam | = help: Remove extra named arguments: spam -ℹ Safe fix 1 1 | "{}".format(1, bar=2) # F522 2 |-"{bar}{}".format(1, bar=2, spam=3) # F522 2 |+"{bar}{}".format(1, bar=2, ) # F522 @@ -46,7 +44,6 @@ F522.py:4:1: F522 [*] `.format` call has unused named argument(s): eggs, ham | = help: Remove extra named arguments: eggs, ham -ℹ Safe fix 1 1 | "{}".format(1, bar=2) # F522 2 2 | "{bar}{}".format(1, bar=2, spam=3) # F522 3 3 | "{bar:{spam}}".format(bar=2, spam=3) # No issues @@ -66,11 +63,8 @@ F522.py:5:2: F522 [*] `.format` call has unused named argument(s): x | = help: Remove extra named arguments: x -ℹ Safe fix 3 3 | "{bar:{spam}}".format(bar=2, spam=3) # No issues 4 4 | "{bar:{spam}}".format(bar=2, spam=3, eggs=4, ham=5) # F522 5 5 | ('' 6 |- .format(x=2)) # F522 6 |+ .format()) # F522 - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F523_F523.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F523_F523.py.snap index 48ecf84655537..e7484a948334e 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F523_F523.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F523_F523.py.snap @@ -11,7 +11,6 @@ F523.py:2:1: F523 [*] `.format` call has unused arguments at position(s): 1 | = help: Remove extra positional arguments at position(s): 1 -ℹ Safe fix 1 1 | # With indexes 2 |-"{0}".format(1, 2) # F523 2 |+"{0}".format(1, ) # F523 @@ -41,7 +40,6 @@ F523.py:5:1: F523 [*] `.format` call has unused arguments at position(s): 2 | = help: Remove extra positional arguments at position(s): 2 -ℹ Safe fix 2 2 | "{0}".format(1, 2) # F523 3 3 | "{1}".format(1, 2, 3) # F523 4 4 | "{1:{0}}".format(1, 2) # No issues @@ -61,7 +59,6 @@ F523.py:6:1: F523 [*] `.format` call has unused arguments at position(s): 1 | = help: Remove extra positional arguments at position(s): 1 -ℹ Safe fix 3 3 | "{1}".format(1, 2, 3) # F523 4 4 | "{1:{0}}".format(1, 2) # No issues 5 5 | "{1:{0}}".format(1, 2, 3) # F523 @@ -92,7 +89,6 @@ F523.py:10:1: F523 [*] `.format` call has unused arguments at position(s): 1 | = help: Remove extra positional arguments at position(s): 1 -ℹ Safe fix 7 7 | "{1.arg[1]!r:0{2['arg']}{1}}".format(1, 2, 3, 4) # F523 8 8 | 9 9 | # With no indexes @@ -113,7 +109,6 @@ F523.py:11:1: F523 [*] `.format` call has unused arguments at position(s): 1, 2 | = help: Remove extra positional arguments at position(s): 1, 2 -ℹ Safe fix 8 8 | 9 9 | # With no indexes 10 10 | "{}".format(1, 2) # F523 @@ -134,7 +129,6 @@ F523.py:13:1: F523 [*] `.format` call has unused arguments at position(s): 2 | = help: Remove extra positional arguments at position(s): 2 -ℹ Safe fix 10 10 | "{}".format(1, 2) # F523 11 11 | "{}".format(1, 2, 3) # F523 12 12 | "{:{}}".format(1, 2) # No issues @@ -165,7 +159,6 @@ F523.py:22:1: F523 [*] `.format` call has unused arguments at position(s): 1, 2 | = help: Remove extra positional arguments at position(s): 1, 2 -ℹ Safe fix 19 19 | "{0}{1}".format(1, 2, 3, *args) # F523 20 20 | 21 21 | # With nested quotes @@ -185,7 +178,6 @@ F523.py:23:1: F523 [*] `.format` call has unused arguments at position(s): 2 | = help: Remove extra positional arguments at position(s): 2 -ℹ Safe fix 20 20 | 21 21 | # With nested quotes 22 22 | "''1{0}".format(1, 2, 3) # F523 @@ -206,7 +198,6 @@ F523.py:24:1: F523 [*] `.format` call has unused arguments at position(s): 2 | = help: Remove extra positional arguments at position(s): 2 -ℹ Safe fix 21 21 | # With nested quotes 22 22 | "''1{0}".format(1, 2, 3) # F523 23 23 | "\"\"{1}{0}".format(1, 2, 3) # F523 @@ -257,11 +248,8 @@ F523.py:32:2: F523 [*] `.format` call has unused arguments at position(s): 0 | = help: Remove extra positional arguments at position(s): 0 -ℹ Safe fix 30 30 | 31 31 | # Multiline 32 32 | ('' 33 |-.format(2)) 33 |+.format()) - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F541_F541.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F541_F541.py.snap index ab3ce59d46ec8..a3f0cf5fd5fe2 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F541_F541.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F541_F541.py.snap @@ -11,7 +11,6 @@ F541.py:6:5: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Safe fix 3 3 | b = f"ghi{'jkl'}" 4 4 | 5 5 | # Errors @@ -32,7 +31,6 @@ F541.py:7:5: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Safe fix 4 4 | 5 5 | # Errors 6 6 | c = f"def" @@ -53,7 +51,6 @@ F541.py:9:5: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Safe fix 6 6 | c = f"def" 7 7 | d = f"def" + "ghi" 8 8 | e = ( @@ -74,7 +71,6 @@ F541.py:13:5: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Safe fix 10 10 | "ghi" 11 11 | ) 12 12 | f = ( @@ -95,7 +91,6 @@ F541.py:14:5: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Safe fix 11 11 | ) 12 12 | f = ( 13 13 | f"a" @@ -116,7 +111,6 @@ F541.py:16:5: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Safe fix 13 13 | f"a" 14 14 | F"b" 15 15 | "c" @@ -137,7 +131,6 @@ F541.py:17:5: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Safe fix 14 14 | F"b" 15 15 | "c" 16 16 | rf"d" @@ -158,7 +151,6 @@ F541.py:19:5: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Safe fix 16 16 | rf"d" 17 17 | fr"e" 18 18 | ) @@ -178,7 +170,6 @@ F541.py:25:13: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Safe fix 22 22 | g = f"ghi{123:{45}}" 23 23 | 24 24 | # Error @@ -198,7 +189,6 @@ F541.py:34:7: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Safe fix 31 31 | f"{f'{v:0.2f}'}" 32 32 | 33 33 | # Errors @@ -219,7 +209,6 @@ F541.py:35:4: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Safe fix 32 32 | 33 33 | # Errors 34 34 | f"{v:{f'0.2f'}}" @@ -240,7 +229,6 @@ F541.py:36:1: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Safe fix 33 33 | # Errors 34 34 | f"{v:{f'0.2f'}}" 35 35 | f"{f''}" @@ -261,7 +249,6 @@ F541.py:37:1: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Safe fix 34 34 | f"{v:{f'0.2f'}}" 35 35 | f"{f''}" 36 36 | f"{{test}}" @@ -282,7 +269,6 @@ F541.py:38:1: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Safe fix 35 35 | f"{f''}" 36 36 | f"{{test}}" 37 37 | f'{{ 40 }}' @@ -303,7 +289,6 @@ F541.py:39:1: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Safe fix 36 36 | f"{{test}}" 37 37 | f'{{ 40 }}' 38 38 | f"{{a {{x}}" @@ -324,7 +309,6 @@ F541.py:40:3: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Safe fix 37 37 | f'{{ 40 }}' 38 38 | f"{{a {{x}}" 39 39 | f"{{{{x}}}}" @@ -345,7 +329,6 @@ F541.py:41:3: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Safe fix 38 38 | f"{{a {{x}}" 39 39 | f"{{{{x}}}}" 40 40 | ""f"" @@ -366,7 +349,6 @@ F541.py:42:4: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Safe fix 39 39 | f"{{{{x}}}}" 40 40 | ""f"" 41 41 | ''f"" @@ -385,7 +367,6 @@ F541.py:43:7: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Safe fix 40 40 | ""f"" 41 41 | ''f"" 42 42 | (""f""r"") @@ -402,11 +383,8 @@ F541.py:44:1: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Safe fix 41 41 | ''f"" 42 42 | (""f""r"") 43 43 | f"{v:{f"0.2f"}}" 44 |-f"\{{x}}" 44 |+"\{x}" - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F601_F601.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F601_F601.py.snap index ace4761b43cbd..8753443a6c432 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F601_F601.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F601_F601.py.snap @@ -76,14 +76,6 @@ F601.py:18:5: F601 [*] Dictionary key literal `"a"` repeated | = help: Remove repeated key literal `"a"` -ℹ Unsafe fix -15 15 | "a": 1, -16 16 | "a": 2, -17 17 | "a": 3, -18 |- "a": 3, -19 18 | } -20 19 | -21 20 | x = { F601.py:23:5: F601 Dictionary key literal `"a"` repeated | @@ -118,14 +110,6 @@ F601.py:25:5: F601 [*] Dictionary key literal `"a"` repeated | = help: Remove repeated key literal `"a"` -ℹ Unsafe fix -22 22 | "a": 1, -23 23 | "a": 2, -24 24 | "a": 3, -25 |- "a": 3, -26 25 | "a": 4, -27 26 | } -28 27 | F601.py:26:5: F601 Dictionary key literal `"a"` repeated | @@ -148,14 +132,6 @@ F601.py:31:5: F601 [*] Dictionary key literal `"a"` repeated | = help: Remove repeated key literal `"a"` -ℹ Unsafe fix -28 28 | -29 29 | x = { -30 30 | "a": 1, -31 |- "a": 1, -32 31 | "a": 2, -33 32 | "a": 3, -34 33 | "a": 4, F601.py:32:5: F601 Dictionary key literal `"a"` repeated | @@ -222,14 +198,6 @@ F601.py:45:5: F601 [*] Dictionary key literal `"a"` repeated | = help: Remove repeated key literal `"a"` -ℹ Unsafe fix -42 42 | a: 2, -43 43 | "a": 3, -44 44 | a: 3, -45 |- "a": 3, -46 45 | a: 4, -47 46 | } -48 47 | F601.py:49:14: F601 [*] Dictionary key literal `"a"` repeated | @@ -241,15 +209,6 @@ F601.py:49:14: F601 [*] Dictionary key literal `"a"` repeated | = help: Remove repeated key literal `"a"` -ℹ Unsafe fix -46 46 | a: 4, -47 47 | } -48 48 | -49 |-x = {"a": 1, "a": 1} - 49 |+x = {"a": 1} -50 50 | x = {"a": 1, "b": 2, "a": 1} -51 51 | -52 52 | x = { F601.py:50:22: F601 [*] Dictionary key literal `"a"` repeated | @@ -261,15 +220,6 @@ F601.py:50:22: F601 [*] Dictionary key literal `"a"` repeated | = help: Remove repeated key literal `"a"` -ℹ Unsafe fix -47 47 | } -48 48 | -49 49 | x = {"a": 1, "a": 1} -50 |-x = {"a": 1, "b": 2, "a": 1} - 50 |+x = {"a": 1, "b": 2} -51 51 | -52 52 | x = { -53 53 | ('a', 'b'): 'asdf', F601.py:54:5: F601 Dictionary key literal `('a', 'b')` repeated | @@ -291,14 +241,6 @@ F601.py:58:19: F601 [*] Dictionary key literal `"x"` repeated | = help: Remove repeated key literal `"x"` -ℹ Unsafe fix -55 55 | } -56 56 | -57 57 | # Regression test for: https://github.com/astral-sh/ruff/issues/4897 -58 |-t={"x":"test123", "x":("test123")} - 58 |+t={"x":"test123"} -59 59 | -60 60 | t={"x":("test123"), "x":"test123"} F601.py:60:21: F601 [*] Dictionary key literal `"x"` repeated | @@ -308,12 +250,3 @@ F601.py:60:21: F601 [*] Dictionary key literal `"x"` repeated | ^^^ F601 | = help: Remove repeated key literal `"x"` - -ℹ Unsafe fix -57 57 | # Regression test for: https://github.com/astral-sh/ruff/issues/4897 -58 58 | t={"x":"test123", "x":("test123")} -59 59 | -60 |-t={"x":("test123"), "x":"test123"} - 60 |+t={"x":("test123")} - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F602_F602.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F602_F602.py.snap index c092beeb97607..11b9b09e5ee01 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F602_F602.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F602_F602.py.snap @@ -44,14 +44,6 @@ F602.py:13:5: F602 [*] Dictionary key `a` repeated | = help: Remove repeated key `a` -ℹ Unsafe fix -10 10 | a: 1, -11 11 | a: 2, -12 12 | a: 3, -13 |- a: 3, -14 13 | } -15 14 | -16 15 | x = { F602.py:18:5: F602 Dictionary key `a` repeated | @@ -86,14 +78,6 @@ F602.py:20:5: F602 [*] Dictionary key `a` repeated | = help: Remove repeated key `a` -ℹ Unsafe fix -17 17 | a: 1, -18 18 | a: 2, -19 19 | a: 3, -20 |- a: 3, -21 20 | a: 4, -22 21 | } -23 22 | F602.py:21:5: F602 Dictionary key `a` repeated | @@ -116,14 +100,6 @@ F602.py:26:5: F602 [*] Dictionary key `a` repeated | = help: Remove repeated key `a` -ℹ Unsafe fix -23 23 | -24 24 | x = { -25 25 | a: 1, -26 |- a: 1, -27 26 | a: 2, -28 27 | a: 3, -29 28 | a: 4, F602.py:27:5: F602 Dictionary key `a` repeated | @@ -168,14 +144,6 @@ F602.py:35:5: F602 [*] Dictionary key `a` repeated | = help: Remove repeated key `a` -ℹ Unsafe fix -32 32 | x = { -33 33 | a: 1, -34 34 | "a": 1, -35 |- a: 1, -36 35 | "a": 2, -37 36 | a: 2, -38 37 | "a": 3, F602.py:37:5: F602 Dictionary key `a` repeated | @@ -219,13 +187,6 @@ F602.py:44:12: F602 [*] Dictionary key `a` repeated | = help: Remove repeated key `a` -ℹ Unsafe fix -41 41 | a: 4, -42 42 | } -43 43 | -44 |-x = {a: 1, a: 1} - 44 |+x = {a: 1} -45 45 | x = {a: 1, b: 2, a: 1} F602.py:45:18: F602 [*] Dictionary key `a` repeated | @@ -234,12 +195,3 @@ F602.py:45:18: F602 [*] Dictionary key `a` repeated | ^ F602 | = help: Remove repeated key `a` - -ℹ Unsafe fix -42 42 | } -43 43 | -44 44 | x = {a: 1, a: 1} -45 |-x = {a: 1, b: 2, a: 1} - 45 |+x = {a: 1, b: 2} - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F632_F632.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F632_F632.py.snap index a20f5d5c45f5f..9c1df7356596d 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F632_F632.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F632_F632.py.snap @@ -9,7 +9,6 @@ F632.py:1:4: F632 [*] Use `==` to compare constant literals | = help: Replace `is` with `==` -ℹ Safe fix 1 |-if x is "abc": 1 |+if x == "abc": 2 2 | pass @@ -26,7 +25,6 @@ F632.py:4:4: F632 [*] Use `!=` to compare constant literals | = help: Replace `is not` with `!=` -ℹ Safe fix 1 1 | if x is "abc": 2 2 | pass 3 3 | @@ -48,7 +46,6 @@ F632.py:7:4: F632 [*] Use `!=` to compare constant literals | = help: Replace `is not` with `!=` -ℹ Safe fix 4 4 | if 123 is not y: 5 5 | pass 6 6 | @@ -69,7 +66,6 @@ F632.py:11:4: F632 [*] Use `==` to compare constant literals | = help: Replace `is` with `==` -ℹ Safe fix 8 8 | not y: 9 9 | pass 10 10 | @@ -89,7 +85,6 @@ F632.py:14:4: F632 [*] Use `==` to compare constant literals | = help: Replace `is` with `==` -ℹ Safe fix 11 11 | if "123" is x < 3: 12 12 | pass 13 13 | @@ -109,7 +104,6 @@ F632.py:17:4: F632 [*] Use `==` to compare constant literals | = help: Replace `is` with `==` -ℹ Safe fix 14 14 | if "123" != x is 3: 15 15 | pass 16 16 | @@ -129,7 +123,6 @@ F632.py:20:14: F632 [*] Use `==` to compare constant literals | = help: Replace `is` with `==` -ℹ Safe fix 17 17 | if ("123" != x) is 3: 18 18 | pass 19 19 | @@ -152,7 +145,6 @@ F632.py:23:2: F632 [*] Use `!=` to compare constant literals | = help: Replace `is not` with `!=` -ℹ Safe fix 20 20 | if "123" != (x is 3): 21 21 | pass 22 22 | @@ -176,7 +168,6 @@ F632.py:26:2: F632 [*] Use `!=` to compare constant literals | = help: Replace `is not` with `!=` -ℹ Safe fix 23 23 | {2 is 24 24 | not ''} 25 25 | @@ -196,7 +187,6 @@ F632.py:30:4: F632 [*] Use `!=` to compare constant literals | = help: Replace `is not` with `!=` -ℹ Safe fix 27 27 | not ''} 28 28 | 29 29 | # Regression test for @@ -215,7 +205,6 @@ F632.py:30:11: F632 [*] Use `!=` to compare constant literals | = help: Replace `is not` with `!=` -ℹ Safe fix 27 27 | not ''} 28 28 | 29 29 | # Regression test for @@ -233,7 +222,6 @@ F632.py:34:12: F632 [*] Use `!=` to compare constant literals | = help: Replace `is not` with `!=` -ℹ Safe fix 31 31 | pass 32 32 | 33 33 | # Regression test for https://github.com/astral-sh/ruff/issues/11736 diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_17.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_17.py.snap index b2e62e8597fb6..8562d8f829fd7 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_17.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_17.py.snap @@ -11,7 +11,6 @@ F811_17.py:6:12: F811 [*] Redefinition of unused `fu` from line 2 | = help: Remove definition: `fu` -ℹ Safe fix 3 3 | 4 4 | 5 5 | def bar(): @@ -28,5 +27,3 @@ F811_17.py:9:13: F811 Redefinition of unused `fu` from line 6 10 | pass | = help: Remove definition: `fu` - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_21.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_21.py.snap index 6d0405c66f566..732e718629ef1 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_21.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_21.py.snap @@ -11,7 +11,6 @@ F811_21.py:32:5: F811 [*] Redefinition of unused `Sequence` from line 26 | = help: Remove definition: `Sequence` -ℹ Safe fix 29 29 | # This should ignore the first error. 30 30 | from typing import ( 31 31 | List, # noqa: F811 @@ -21,5 +20,3 @@ F811_21.py:32:5: F811 [*] Redefinition of unused `Sequence` from line 26 34 33 | 35 34 | # This should ignore both errors. 36 35 | from typing import ( # noqa - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_6.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_6.py.snap index 92fc67263100e..ce97ded5ecdfa 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_6.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_6.py.snap @@ -11,11 +11,8 @@ F811_6.py:6:12: F811 [*] Redefinition of unused `os` from line 5 | = help: Remove definition: `os` -ℹ Safe fix 3 3 | i = 2 4 4 | if i == 1: 5 5 | import os 6 |- import os 7 6 | os.path - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_8.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_8.py.snap index 07e8aeb1e6324..149e19e3df9ba 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_8.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_8.py.snap @@ -12,7 +12,6 @@ F811_8.py:5:12: F811 [*] Redefinition of unused `os` from line 4 | = help: Remove definition: `os` -ℹ Safe fix 2 2 | 3 3 | try: 4 4 | import os @@ -20,5 +19,3 @@ F811_8.py:5:12: F811 [*] Redefinition of unused `os` from line 4 6 5 | except: 7 6 | pass 8 7 | os.path - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_0.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_0.py.snap index 7e1b2458bfa3f..7b01ea8d234d3 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_0.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_0.py.snap @@ -11,7 +11,6 @@ F841_0.py:3:22: F841 [*] Local variable `e` is assigned to but never used | = help: Remove assignment to unused variable `e` -ℹ Safe fix 1 1 | try: 2 2 | 1 / 0 3 |-except ValueError as e: @@ -29,15 +28,6 @@ F841_0.py:16:5: F841 [*] Local variable `z` is assigned to but never used | = help: Remove assignment to unused variable `z` -ℹ Unsafe fix -13 13 | def f(): -14 14 | x = 1 -15 15 | y = 2 -16 |- z = x + y - 16 |+ x + y -17 17 | -18 18 | -19 19 | def f(): F841_0.py:20:5: F841 [*] Local variable `foo` is assigned to but never used | @@ -48,14 +38,6 @@ F841_0.py:20:5: F841 [*] Local variable `foo` is assigned to but never used | = help: Remove assignment to unused variable `foo` -ℹ Unsafe fix -17 17 | -18 18 | -19 19 | def f(): -20 |- foo = (1, 2) -21 20 | (a, b) = (1, 2) -22 21 | -23 22 | bar = (1, 2) F841_0.py:21:6: F841 [*] Local variable `a` is assigned to but never used | @@ -68,15 +50,6 @@ F841_0.py:21:6: F841 [*] Local variable `a` is assigned to but never used | = help: Remove assignment to unused variable `a` -ℹ Unsafe fix -18 18 | -19 19 | def f(): -20 20 | foo = (1, 2) -21 |- (a, b) = (1, 2) - 21 |+ (_a, b) = (1, 2) -22 22 | -23 23 | bar = (1, 2) -24 24 | (c, d) = bar F841_0.py:21:9: F841 [*] Local variable `b` is assigned to but never used | @@ -89,15 +62,6 @@ F841_0.py:21:9: F841 [*] Local variable `b` is assigned to but never used | = help: Remove assignment to unused variable `b` -ℹ Unsafe fix -18 18 | -19 19 | def f(): -20 20 | foo = (1, 2) -21 |- (a, b) = (1, 2) - 21 |+ (a, _b) = (1, 2) -22 22 | -23 23 | bar = (1, 2) -24 24 | (c, d) = bar F841_0.py:26:14: F841 [*] Local variable `baz` is assigned to but never used | @@ -108,15 +72,6 @@ F841_0.py:26:14: F841 [*] Local variable `baz` is assigned to but never used | = help: Remove assignment to unused variable `baz` -ℹ Unsafe fix -23 23 | bar = (1, 2) -24 24 | (c, d) = bar -25 25 | -26 |- (x, y) = baz = bar - 26 |+ (x, y) = bar -27 27 | -28 28 | -29 29 | def f(): F841_0.py:51:9: F841 [*] Local variable `b` is assigned to but never used | @@ -129,15 +84,6 @@ F841_0.py:51:9: F841 [*] Local variable `b` is assigned to but never used | = help: Remove assignment to unused variable `b` -ℹ Unsafe fix -48 48 | -49 49 | def c(): -50 50 | # F841 -51 |- b = 1 - 51 |+ pass -52 52 | -53 53 | def d(): -54 54 | nonlocal b F841_0.py:79:26: F841 [*] Local variable `my_file` is assigned to but never used | @@ -148,15 +94,6 @@ F841_0.py:79:26: F841 [*] Local variable `my_file` is assigned to but never used | = help: Remove assignment to unused variable `my_file` -ℹ Unsafe fix -76 76 | -77 77 | -78 78 | def f(): -79 |- with open("file") as my_file, open("") as ((this, that)): - 79 |+ with open("file"), open("") as ((this, that)): -80 80 | print("hello") -81 81 | -82 82 | F841_0.py:85:25: F841 [*] Local variable `my_file` is assigned to but never used | @@ -169,15 +106,6 @@ F841_0.py:85:25: F841 [*] Local variable `my_file` is assigned to but never used | = help: Remove assignment to unused variable `my_file` -ℹ Unsafe fix -82 82 | -83 83 | def f(): -84 84 | with ( -85 |- open("file") as my_file, - 85 |+ open("file"), -86 86 | open("") as ((this, that)), -87 87 | ): -88 88 | print("hello") F841_0.py:102:5: F841 [*] Local variable `msg3` is assigned to but never used | @@ -190,14 +118,6 @@ F841_0.py:102:5: F841 [*] Local variable `msg3` is assigned to but never used | = help: Remove assignment to unused variable `msg3` -ℹ Unsafe fix -99 99 | def f(x: int): -100 100 | msg1 = "Hello, world!" -101 101 | msg2 = "Hello, world!" -102 |- msg3 = "Hello, world!" -103 102 | match x: -104 103 | case 1: -105 104 | print(msg1) F841_0.py:115:5: F841 [*] Local variable `Baz` is assigned to but never used | @@ -210,15 +130,6 @@ F841_0.py:115:5: F841 [*] Local variable `Baz` is assigned to but never used | = help: Remove assignment to unused variable `Baz` -ℹ Unsafe fix -112 112 | -113 113 | Foo = enum.Enum("Foo", "A B") -114 114 | Bar = enum.Enum("Bar", "A B") -115 |- Baz = enum.Enum("Baz", "A B") - 115 |+ enum.Enum("Baz", "A B") -116 116 | -117 117 | match x: -118 118 | case (Foo.A): F841_0.py:122:14: F841 Local variable `y` is assigned to but never used | @@ -238,5 +149,3 @@ F841_0.py:127:21: F841 Local variable `value` is assigned to but never used 128 | print(key) | = help: Remove assignment to unused variable `value` - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_1.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_1.py.snap index 9cb0b013fd00e..794cb9362322b 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_1.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_1.py.snap @@ -9,15 +9,6 @@ F841_1.py:6:5: F841 [*] Local variable `x` is assigned to but never used | = help: Remove assignment to unused variable `x` -ℹ Unsafe fix -3 3 | -4 4 | -5 5 | def f(): -6 |- x, y = 1, 2 # this triggers F841 as it's just a simple assignment where unpacking isn't needed - 6 |+ _x, y = 1, 2 # this triggers F841 as it's just a simple assignment where unpacking isn't needed -7 7 | -8 8 | -9 9 | def f(): F841_1.py:6:8: F841 [*] Local variable `y` is assigned to but never used | @@ -27,15 +18,6 @@ F841_1.py:6:8: F841 [*] Local variable `y` is assigned to but never used | = help: Remove assignment to unused variable `y` -ℹ Unsafe fix -3 3 | -4 4 | -5 5 | def f(): -6 |- x, y = 1, 2 # this triggers F841 as it's just a simple assignment where unpacking isn't needed - 6 |+ x, _y = 1, 2 # this triggers F841 as it's just a simple assignment where unpacking isn't needed -7 7 | -8 8 | -9 9 | def f(): F841_1.py:16:14: F841 [*] Local variable `coords` is assigned to but never used | @@ -45,15 +27,6 @@ F841_1.py:16:14: F841 [*] Local variable `coords` is assigned to but never used | = help: Remove assignment to unused variable `coords` -ℹ Unsafe fix -13 13 | -14 14 | -15 15 | def f(): -16 |- (x, y) = coords = 1, 2 - 16 |+ (x, y) = 1, 2 -17 17 | -18 18 | -19 19 | def f(): F841_1.py:20:5: F841 [*] Local variable `coords` is assigned to but never used | @@ -63,15 +36,6 @@ F841_1.py:20:5: F841 [*] Local variable `coords` is assigned to but never used | = help: Remove assignment to unused variable `coords` -ℹ Unsafe fix -17 17 | -18 18 | -19 19 | def f(): -20 |- coords = (x, y) = 1, 2 - 20 |+ (x, y) = 1, 2 -21 21 | -22 22 | -23 23 | def f(): F841_1.py:24:6: F841 [*] Local variable `a` is assigned to but never used | @@ -81,12 +45,6 @@ F841_1.py:24:6: F841 [*] Local variable `a` is assigned to but never used | = help: Remove assignment to unused variable `a` -ℹ Unsafe fix -21 21 | -22 22 | -23 23 | def f(): -24 |- (a, b) = (x, y) = 1, 2 # this triggers F841 on everything - 24 |+ (_a, b) = (x, y) = 1, 2 # this triggers F841 on everything F841_1.py:24:9: F841 [*] Local variable `b` is assigned to but never used | @@ -96,12 +54,6 @@ F841_1.py:24:9: F841 [*] Local variable `b` is assigned to but never used | = help: Remove assignment to unused variable `b` -ℹ Unsafe fix -21 21 | -22 22 | -23 23 | def f(): -24 |- (a, b) = (x, y) = 1, 2 # this triggers F841 on everything - 24 |+ (a, _b) = (x, y) = 1, 2 # this triggers F841 on everything F841_1.py:24:15: F841 [*] Local variable `x` is assigned to but never used | @@ -111,12 +63,6 @@ F841_1.py:24:15: F841 [*] Local variable `x` is assigned to but never used | = help: Remove assignment to unused variable `x` -ℹ Unsafe fix -21 21 | -22 22 | -23 23 | def f(): -24 |- (a, b) = (x, y) = 1, 2 # this triggers F841 on everything - 24 |+ (a, b) = (_x, y) = 1, 2 # this triggers F841 on everything F841_1.py:24:18: F841 [*] Local variable `y` is assigned to but never used | @@ -125,12 +71,3 @@ F841_1.py:24:18: F841 [*] Local variable `y` is assigned to but never used | ^ F841 | = help: Remove assignment to unused variable `y` - -ℹ Unsafe fix -21 21 | -22 22 | -23 23 | def f(): -24 |- (a, b) = (x, y) = 1, 2 # this triggers F841 on everything - 24 |+ (a, b) = (x, _y) = 1, 2 # this triggers F841 on everything - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_3.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_3.py.snap index 8b60f4da8a24c..9bbab36f7ce40 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_3.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_3.py.snap @@ -10,14 +10,6 @@ F841_3.py:5:5: F841 [*] Local variable `x` is assigned to but never used | = help: Remove assignment to unused variable `x` -ℹ Unsafe fix -2 2 | -3 3 | -4 4 | def f(): -5 |- x = 1 -6 5 | y = 2 -7 6 | -8 7 | z = 3 F841_3.py:6:5: F841 [*] Local variable `y` is assigned to but never used | @@ -30,14 +22,6 @@ F841_3.py:6:5: F841 [*] Local variable `y` is assigned to but never used | = help: Remove assignment to unused variable `y` -ℹ Unsafe fix -3 3 | -4 4 | def f(): -5 5 | x = 1 -6 |- y = 2 -7 6 | -8 7 | z = 3 -9 8 | print(z) F841_3.py:13:5: F841 [*] Local variable `x` is assigned to but never used | @@ -48,14 +32,6 @@ F841_3.py:13:5: F841 [*] Local variable `x` is assigned to but never used | = help: Remove assignment to unused variable `x` -ℹ Unsafe fix -10 10 | -11 11 | -12 12 | def f(): -13 |- x: int = 1 -14 13 | y: int = 2 -15 14 | -16 15 | z: int = 3 F841_3.py:14:5: F841 [*] Local variable `y` is assigned to but never used | @@ -68,14 +44,6 @@ F841_3.py:14:5: F841 [*] Local variable `y` is assigned to but never used | = help: Remove assignment to unused variable `y` -ℹ Unsafe fix -11 11 | -12 12 | def f(): -13 13 | x: int = 1 -14 |- y: int = 2 -15 14 | -16 15 | z: int = 3 -17 16 | print(z) F841_3.py:21:19: F841 [*] Local variable `x1` is assigned to but never used | @@ -86,15 +54,6 @@ F841_3.py:21:19: F841 [*] Local variable `x1` is assigned to but never used | = help: Remove assignment to unused variable `x1` -ℹ Unsafe fix -18 18 | -19 19 | -20 20 | def f(): -21 |- with foo() as x1: - 21 |+ with foo(): -22 22 | pass -23 23 | -24 24 | with foo() as (x2, y2): F841_3.py:27:20: F841 [*] Local variable `x3` is assigned to but never used | @@ -106,15 +65,6 @@ F841_3.py:27:20: F841 [*] Local variable `x3` is assigned to but never used | = help: Remove assignment to unused variable `x3` -ℹ Unsafe fix -24 24 | with foo() as (x2, y2): -25 25 | pass -26 26 | -27 |- with (foo() as x3, foo() as y3, foo() as z3): - 27 |+ with (foo(), foo() as y3, foo() as z3): -28 28 | pass -29 29 | -30 30 | F841_3.py:27:33: F841 [*] Local variable `y3` is assigned to but never used | @@ -126,15 +76,6 @@ F841_3.py:27:33: F841 [*] Local variable `y3` is assigned to but never used | = help: Remove assignment to unused variable `y3` -ℹ Unsafe fix -24 24 | with foo() as (x2, y2): -25 25 | pass -26 26 | -27 |- with (foo() as x3, foo() as y3, foo() as z3): - 27 |+ with (foo() as x3, foo(), foo() as z3): -28 28 | pass -29 29 | -30 30 | F841_3.py:27:46: F841 [*] Local variable `z3` is assigned to but never used | @@ -146,15 +87,6 @@ F841_3.py:27:46: F841 [*] Local variable `z3` is assigned to but never used | = help: Remove assignment to unused variable `z3` -ℹ Unsafe fix -24 24 | with foo() as (x2, y2): -25 25 | pass -26 26 | -27 |- with (foo() as x3, foo() as y3, foo() as z3): - 27 |+ with (foo() as x3, foo() as y3, foo()): -28 28 | pass -29 29 | -30 30 | F841_3.py:32:6: F841 [*] Local variable `x1` is assigned to but never used | @@ -166,15 +98,6 @@ F841_3.py:32:6: F841 [*] Local variable `x1` is assigned to but never used | = help: Remove assignment to unused variable `x1` -ℹ Unsafe fix -29 29 | -30 30 | -31 31 | def f(): -32 |- (x1, y1) = (1, 2) - 32 |+ (_x1, y1) = (1, 2) -33 33 | (x2, y2) = coords2 = (1, 2) -34 34 | coords3 = (x3, y3) = (1, 2) -35 35 | F841_3.py:32:10: F841 [*] Local variable `y1` is assigned to but never used | @@ -186,15 +109,6 @@ F841_3.py:32:10: F841 [*] Local variable `y1` is assigned to but never used | = help: Remove assignment to unused variable `y1` -ℹ Unsafe fix -29 29 | -30 30 | -31 31 | def f(): -32 |- (x1, y1) = (1, 2) - 32 |+ (x1, _y1) = (1, 2) -33 33 | (x2, y2) = coords2 = (1, 2) -34 34 | coords3 = (x3, y3) = (1, 2) -35 35 | F841_3.py:33:16: F841 [*] Local variable `coords2` is assigned to but never used | @@ -206,15 +120,6 @@ F841_3.py:33:16: F841 [*] Local variable `coords2` is assigned to but never used | = help: Remove assignment to unused variable `coords2` -ℹ Unsafe fix -30 30 | -31 31 | def f(): -32 32 | (x1, y1) = (1, 2) -33 |- (x2, y2) = coords2 = (1, 2) - 33 |+ (x2, y2) = (1, 2) -34 34 | coords3 = (x3, y3) = (1, 2) -35 35 | -36 36 | F841_3.py:34:5: F841 [*] Local variable `coords3` is assigned to but never used | @@ -225,15 +130,6 @@ F841_3.py:34:5: F841 [*] Local variable `coords3` is assigned to but never used | = help: Remove assignment to unused variable `coords3` -ℹ Unsafe fix -31 31 | def f(): -32 32 | (x1, y1) = (1, 2) -33 33 | (x2, y2) = coords2 = (1, 2) -34 |- coords3 = (x3, y3) = (1, 2) - 34 |+ (x3, y3) = (1, 2) -35 35 | -36 36 | -37 37 | def f(): F841_3.py:40:26: F841 [*] Local variable `x1` is assigned to but never used | @@ -245,7 +141,6 @@ F841_3.py:40:26: F841 [*] Local variable `x1` is assigned to but never used | = help: Remove assignment to unused variable `x1` -ℹ Safe fix 37 37 | def f(): 38 38 | try: 39 39 | 1 / 0 @@ -265,7 +160,6 @@ F841_3.py:45:47: F841 [*] Local variable `x2` is assigned to but never used | = help: Remove assignment to unused variable `x2` -ℹ Safe fix 42 42 | 43 43 | try: 44 44 | 1 / 0 @@ -285,15 +179,6 @@ F841_3.py:50:5: F841 [*] Local variable `x` is assigned to but never used | = help: Remove assignment to unused variable `x` -ℹ Unsafe fix -47 47 | -48 48 | -49 49 | def f(a, b): -50 |- x = ( - 50 |+ ( -51 51 | a() -52 52 | if a is not None -53 53 | else b F841_3.py:56:5: F841 [*] Local variable `y` is assigned to but never used | @@ -305,16 +190,6 @@ F841_3.py:56:5: F841 [*] Local variable `y` is assigned to but never used | = help: Remove assignment to unused variable `y` -ℹ Unsafe fix -53 53 | else b -54 54 | ) -55 55 | -56 |- y = \ -57 |- a() if a is not None else b - 56 |+ a() if a is not None else b -58 57 | -59 58 | -60 59 | def f(a, b): F841_3.py:61:5: F841 [*] Local variable `x` is assigned to but never used | @@ -326,18 +201,6 @@ F841_3.py:61:5: F841 [*] Local variable `x` is assigned to but never used | = help: Remove assignment to unused variable `x` -ℹ Unsafe fix -58 58 | -59 59 | -60 60 | def f(a, b): -61 |- x = ( -62 |- a -63 |- if a is not None -64 |- else b -65 |- ) -66 61 | -67 62 | y = \ -68 63 | a if a is not None else b F841_3.py:67:5: F841 [*] Local variable `y` is assigned to but never used | @@ -349,15 +212,6 @@ F841_3.py:67:5: F841 [*] Local variable `y` is assigned to but never used | = help: Remove assignment to unused variable `y` -ℹ Unsafe fix -64 64 | else b -65 65 | ) -66 66 | -67 |- y = \ -68 |- a if a is not None else b -69 67 | -70 68 | -71 69 | def f(): F841_3.py:72:24: F841 [*] Local variable `cm` is assigned to but never used | @@ -368,15 +222,6 @@ F841_3.py:72:24: F841 [*] Local variable `cm` is assigned to but never used | = help: Remove assignment to unused variable `cm` -ℹ Unsafe fix -69 69 | -70 70 | -71 71 | def f(): -72 |- with Nested(m) as (cm): - 72 |+ with Nested(m): -73 73 | pass -74 74 | -75 75 | F841_3.py:77:25: F841 [*] Local variable `cm` is assigned to but never used | @@ -387,15 +232,6 @@ F841_3.py:77:25: F841 [*] Local variable `cm` is assigned to but never used | = help: Remove assignment to unused variable `cm` -ℹ Unsafe fix -74 74 | -75 75 | -76 76 | def f(): -77 |- with (Nested(m) as (cm),): - 77 |+ with (Nested(m),): -78 78 | pass -79 79 | -80 80 | F841_3.py:87:26: F841 [*] Local variable `cm` is assigned to but never used | @@ -406,15 +242,6 @@ F841_3.py:87:26: F841 [*] Local variable `cm` is assigned to but never used | = help: Remove assignment to unused variable `cm` -ℹ Unsafe fix -84 84 | -85 85 | -86 86 | def f(): -87 |- with (Nested(m)) as (cm): - 87 |+ with (Nested(m)): -88 88 | pass -89 89 | -90 90 | F841_3.py:92:5: F841 [*] Local variable `toplevel` is assigned to but never used | @@ -426,15 +253,6 @@ F841_3.py:92:5: F841 [*] Local variable `toplevel` is assigned to but never used | = help: Remove assignment to unused variable `toplevel` -ℹ Unsafe fix -89 89 | -90 90 | -91 91 | def f(): -92 |- toplevel = tt = lexer.get_token() - 92 |+ tt = lexer.get_token() -93 93 | if not tt: -94 94 | break -95 95 | F841_3.py:98:5: F841 [*] Local variable `toplevel` is assigned to but never used | @@ -444,15 +262,6 @@ F841_3.py:98:5: F841 [*] Local variable `toplevel` is assigned to but never used | = help: Remove assignment to unused variable `toplevel` -ℹ Unsafe fix -95 95 | -96 96 | -97 97 | def f(): -98 |- toplevel = tt = lexer.get_token() - 98 |+ tt = lexer.get_token() -99 99 | -100 100 | -101 101 | def f(): F841_3.py:98:16: F841 [*] Local variable `tt` is assigned to but never used | @@ -462,15 +271,6 @@ F841_3.py:98:16: F841 [*] Local variable `tt` is assigned to but never used | = help: Remove assignment to unused variable `tt` -ℹ Unsafe fix -95 95 | -96 96 | -97 97 | def f(): -98 |- toplevel = tt = lexer.get_token() - 98 |+ toplevel = lexer.get_token() -99 99 | -100 100 | -101 101 | def f(): F841_3.py:102:5: F841 [*] Local variable `toplevel` is assigned to but never used | @@ -480,15 +280,6 @@ F841_3.py:102:5: F841 [*] Local variable `toplevel` is assigned to but never use | = help: Remove assignment to unused variable `toplevel` -ℹ Unsafe fix -99 99 | -100 100 | -101 101 | def f(): -102 |- toplevel = (a, b) = lexer.get_token() - 102 |+ (a, b) = lexer.get_token() -103 103 | -104 104 | -105 105 | def f(): F841_3.py:106:14: F841 [*] Local variable `toplevel` is assigned to but never used | @@ -498,15 +289,6 @@ F841_3.py:106:14: F841 [*] Local variable `toplevel` is assigned to but never us | = help: Remove assignment to unused variable `toplevel` -ℹ Unsafe fix -103 103 | -104 104 | -105 105 | def f(): -106 |- (a, b) = toplevel = lexer.get_token() - 106 |+ (a, b) = lexer.get_token() -107 107 | -108 108 | -109 109 | def f(): F841_3.py:110:5: F841 [*] Local variable `toplevel` is assigned to but never used | @@ -516,15 +298,6 @@ F841_3.py:110:5: F841 [*] Local variable `toplevel` is assigned to but never use | = help: Remove assignment to unused variable `toplevel` -ℹ Unsafe fix -107 107 | -108 108 | -109 109 | def f(): -110 |- toplevel = tt = 1 - 110 |+ tt = 1 -111 111 | -112 112 | -113 113 | def f(provided: int) -> int: F841_3.py:110:16: F841 [*] Local variable `tt` is assigned to but never used | @@ -534,15 +307,6 @@ F841_3.py:110:16: F841 [*] Local variable `tt` is assigned to but never used | = help: Remove assignment to unused variable `tt` -ℹ Unsafe fix -107 107 | -108 108 | -109 109 | def f(): -110 |- toplevel = tt = 1 - 110 |+ toplevel = 1 -111 111 | -112 112 | -113 113 | def f(provided: int) -> int: F841_3.py:115:19: F841 Local variable `x` is assigned to but never used | @@ -614,7 +378,6 @@ F841_3.py:155:17: F841 [*] Local variable `e` is assigned to but never used | = help: Remove assignment to unused variable `e` -ℹ Safe fix 152 152 | def f() -> None: 153 153 | try: 154 154 | print("hello") @@ -633,14 +396,6 @@ F841_3.py:160:5: F841 [*] Local variable `x` is assigned to but never used | = help: Remove assignment to unused variable `x` -ℹ Unsafe fix -157 157 | -158 158 | -159 159 | def f(): -160 |- x = 1 -161 160 | y = 2 -162 161 | -163 162 | F841_3.py:161:5: F841 [*] Local variable `y` is assigned to but never used | @@ -651,14 +406,6 @@ F841_3.py:161:5: F841 [*] Local variable `y` is assigned to but never used | = help: Remove assignment to unused variable `y` -ℹ Unsafe fix -158 158 | -159 159 | def f(): -160 160 | x = 1 -161 |- y = 2 -162 161 | -163 162 | -164 163 | def f(): F841_3.py:165:5: F841 [*] Local variable `x` is assigned to but never used | @@ -670,14 +417,6 @@ F841_3.py:165:5: F841 [*] Local variable `x` is assigned to but never used | = help: Remove assignment to unused variable `x` -ℹ Unsafe fix -162 162 | -163 163 | -164 164 | def f(): -165 |- x = 1 -166 165 | -167 166 | y = 2 -168 167 | F841_3.py:167:5: F841 [*] Local variable `y` is assigned to but never used | @@ -688,14 +427,6 @@ F841_3.py:167:5: F841 [*] Local variable `y` is assigned to but never used | = help: Remove assignment to unused variable `y` -ℹ Unsafe fix -164 164 | def f(): -165 165 | x = 1 -166 166 | -167 |- y = 2 -168 167 | -169 168 | -170 169 | def f(): F841_3.py:173:6: F841 [*] Local variable `x` is assigned to but never used | @@ -705,12 +436,3 @@ F841_3.py:173:6: F841 [*] Local variable `x` is assigned to but never used | ^ F841 | = help: Remove assignment to unused variable `x` - -ℹ Unsafe fix -170 170 | def f(): -171 171 | (x) = foo() -172 172 | ((x)) = foo() -173 |- (x) = (y.z) = foo() - 173 |+ (y.z) = foo() - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_4.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_4.py.snap index f5f7f03e018d6..e6a1740cc8f93 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_4.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_4.py.snap @@ -9,15 +9,3 @@ F841_4.py:12:5: F841 [*] Local variable `a` is assigned to but never used 13 | b, c = foo() | = help: Remove assignment to unused variable `a` - -ℹ Unsafe fix -9 9 | -10 10 | -11 11 | def bar(): -12 |- a = foo() - 12 |+ foo() -13 13 | b, c = foo() -14 14 | -15 15 | - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F901_F901.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F901_F901.py.snap index 33261837366b8..5d72b897d1961 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F901_F901.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F901_F901.py.snap @@ -9,7 +9,6 @@ F901.py:2:11: F901 [*] `raise NotImplemented` should be `raise NotImplementedErr | = help: Use `raise NotImplementedError` -ℹ Safe fix 1 1 | def f() -> None: 2 |- raise NotImplemented() 2 |+ raise NotImplementedError() @@ -25,7 +24,6 @@ F901.py:6:11: F901 [*] `raise NotImplemented` should be `raise NotImplementedErr | = help: Use `raise NotImplementedError` -ℹ Safe fix 3 3 | 4 4 | 5 5 | def g() -> None: @@ -44,7 +42,6 @@ F901.py:11:11: F901 [*] `raise NotImplemented` should be `raise NotImplementedEr | = help: Use `raise NotImplementedError` -ℹ Safe fix 1 |+import builtins 1 2 | def f() -> None: 2 3 | raise NotImplemented() diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_global_import_in_global_scope.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_global_import_in_global_scope.snap index 2ac6d0d48702d..d338d1b798ab5 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_global_import_in_global_scope.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_global_import_in_global_scope.snap @@ -11,7 +11,6 @@ source: crates/ruff_linter/src/rules/pyflakes/mod.rs | = help: Remove unused import: `os` -ℹ Safe fix 2 2 | import os 3 3 | 4 4 | def f(): @@ -20,5 +19,3 @@ source: crates/ruff_linter/src/rules/pyflakes/mod.rs 6 6 | 7 7 | # Despite this `del`, `import os` in `f` should still be flagged as shadowing an unused 8 8 | # import. (This is a false negative, but is consistent with Pyflakes.) - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_global_import_in_local_scope.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_global_import_in_local_scope.snap index a419b0ee52fdd..a16413dcdb9bd 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_global_import_in_local_scope.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_global_import_in_local_scope.snap @@ -10,7 +10,6 @@ source: crates/ruff_linter/src/rules/pyflakes/mod.rs | = help: Remove unused import: `os` -ℹ Safe fix 1 1 | 2 |-import os 3 2 | @@ -27,7 +26,6 @@ source: crates/ruff_linter/src/rules/pyflakes/mod.rs | = help: Remove definition: `os` -ℹ Safe fix 2 2 | import os 3 3 | 4 4 | def f(): @@ -35,5 +33,3 @@ source: crates/ruff_linter/src/rules/pyflakes/mod.rs 6 5 | 7 6 | # Despite this `del`, `import os` in `f` should still be flagged as shadowing an unused 8 7 | # import. - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_import_shadow_in_local_scope.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_import_shadow_in_local_scope.snap index 9dfb6527c7f9b..5404ed9635a2e 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_import_shadow_in_local_scope.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_import_shadow_in_local_scope.snap @@ -10,7 +10,6 @@ source: crates/ruff_linter/src/rules/pyflakes/mod.rs | = help: Remove unused import: `os` -ℹ Safe fix 1 1 | 2 |-import os 3 2 | @@ -25,5 +24,3 @@ source: crates/ruff_linter/src/rules/pyflakes/mod.rs 6 | print(os) | = help: Remove definition: `os` - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_local_import_in_local_scope.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_local_import_in_local_scope.snap index df130cc6e8937..da12aa134da63 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_local_import_in_local_scope.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_local_import_in_local_scope.snap @@ -12,7 +12,6 @@ source: crates/ruff_linter/src/rules/pyflakes/mod.rs | = help: Remove definition: `os` -ℹ Safe fix 1 1 | 2 2 | def f(): 3 3 | import os @@ -20,5 +19,3 @@ source: crates/ruff_linter/src/rules/pyflakes/mod.rs 5 4 | 6 5 | # Despite this `del`, `import os` should still be flagged as shadowing an unused 7 6 | # import. - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f401_preview_first_party_submodule_dunder_all.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f401_preview_first_party_submodule_dunder_all.snap index 0d7b4c45059e9..f713007f5a94b 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f401_preview_first_party_submodule_dunder_all.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f401_preview_first_party_submodule_dunder_all.snap @@ -10,7 +10,6 @@ __init__.py:2:8: F401 [*] `submodule.a` imported but unused; consider removing, | = help: Add `submodule` to __all__ -ℹ Safe fix 1 1 | 2 2 | import submodule.a 3 |-__all__ = ['FOO'] diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f841_dummy_variable_rgx.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f841_dummy_variable_rgx.snap index 360b3028862ec..66214b7457738 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f841_dummy_variable_rgx.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f841_dummy_variable_rgx.snap @@ -11,7 +11,6 @@ F841_0.py:3:22: F841 [*] Local variable `e` is assigned to but never used | = help: Remove assignment to unused variable `e` -ℹ Safe fix 1 1 | try: 2 2 | 1 / 0 3 |-except ValueError as e: @@ -29,14 +28,6 @@ F841_0.py:20:5: F841 [*] Local variable `foo` is assigned to but never used | = help: Remove assignment to unused variable `foo` -ℹ Unsafe fix -17 17 | -18 18 | -19 19 | def f(): -20 |- foo = (1, 2) -21 20 | (a, b) = (1, 2) -22 21 | -23 22 | bar = (1, 2) F841_0.py:21:6: F841 Local variable `a` is assigned to but never used | @@ -69,15 +60,6 @@ F841_0.py:26:14: F841 [*] Local variable `baz` is assigned to but never used | = help: Remove assignment to unused variable `baz` -ℹ Unsafe fix -23 23 | bar = (1, 2) -24 24 | (c, d) = bar -25 25 | -26 |- (x, y) = baz = bar - 26 |+ (x, y) = bar -27 27 | -28 28 | -29 29 | def f(): F841_0.py:35:5: F841 [*] Local variable `_` is assigned to but never used | @@ -89,14 +71,6 @@ F841_0.py:35:5: F841 [*] Local variable `_` is assigned to but never used | = help: Remove assignment to unused variable `_` -ℹ Unsafe fix -32 32 | -33 33 | -34 34 | def f(): -35 |- _ = 1 -36 35 | __ = 1 -37 36 | _discarded = 1 -38 37 | F841_0.py:36:5: F841 [*] Local variable `__` is assigned to but never used | @@ -108,14 +82,6 @@ F841_0.py:36:5: F841 [*] Local variable `__` is assigned to but never used | = help: Remove assignment to unused variable `__` -ℹ Unsafe fix -33 33 | -34 34 | def f(): -35 35 | _ = 1 -36 |- __ = 1 -37 36 | _discarded = 1 -38 37 | -39 38 | F841_0.py:37:5: F841 [*] Local variable `_discarded` is assigned to but never used | @@ -126,14 +92,6 @@ F841_0.py:37:5: F841 [*] Local variable `_discarded` is assigned to but never us | = help: Remove assignment to unused variable `_discarded` -ℹ Unsafe fix -34 34 | def f(): -35 35 | _ = 1 -36 36 | __ = 1 -37 |- _discarded = 1 -38 37 | -39 38 | -40 39 | a = 1 F841_0.py:51:9: F841 [*] Local variable `b` is assigned to but never used | @@ -146,15 +104,6 @@ F841_0.py:51:9: F841 [*] Local variable `b` is assigned to but never used | = help: Remove assignment to unused variable `b` -ℹ Unsafe fix -48 48 | -49 49 | def c(): -50 50 | # F841 -51 |- b = 1 - 51 |+ pass -52 52 | -53 53 | def d(): -54 54 | nonlocal b F841_0.py:79:26: F841 [*] Local variable `my_file` is assigned to but never used | @@ -165,15 +114,6 @@ F841_0.py:79:26: F841 [*] Local variable `my_file` is assigned to but never used | = help: Remove assignment to unused variable `my_file` -ℹ Unsafe fix -76 76 | -77 77 | -78 78 | def f(): -79 |- with open("file") as my_file, open("") as ((this, that)): - 79 |+ with open("file"), open("") as ((this, that)): -80 80 | print("hello") -81 81 | -82 82 | F841_0.py:85:25: F841 [*] Local variable `my_file` is assigned to but never used | @@ -186,15 +126,6 @@ F841_0.py:85:25: F841 [*] Local variable `my_file` is assigned to but never used | = help: Remove assignment to unused variable `my_file` -ℹ Unsafe fix -82 82 | -83 83 | def f(): -84 84 | with ( -85 |- open("file") as my_file, - 85 |+ open("file"), -86 86 | open("") as ((this, that)), -87 87 | ): -88 88 | print("hello") F841_0.py:102:5: F841 [*] Local variable `msg3` is assigned to but never used | @@ -207,14 +138,6 @@ F841_0.py:102:5: F841 [*] Local variable `msg3` is assigned to but never used | = help: Remove assignment to unused variable `msg3` -ℹ Unsafe fix -99 99 | def f(x: int): -100 100 | msg1 = "Hello, world!" -101 101 | msg2 = "Hello, world!" -102 |- msg3 = "Hello, world!" -103 102 | match x: -104 103 | case 1: -105 104 | print(msg1) F841_0.py:115:5: F841 [*] Local variable `Baz` is assigned to but never used | @@ -227,15 +150,6 @@ F841_0.py:115:5: F841 [*] Local variable `Baz` is assigned to but never used | = help: Remove assignment to unused variable `Baz` -ℹ Unsafe fix -112 112 | -113 113 | Foo = enum.Enum("Foo", "A B") -114 114 | Bar = enum.Enum("Bar", "A B") -115 |- Baz = enum.Enum("Baz", "A B") - 115 |+ enum.Enum("Baz", "A B") -116 116 | -117 117 | match x: -118 118 | case (Foo.A): F841_0.py:122:14: F841 Local variable `y` is assigned to but never used | @@ -266,12 +180,9 @@ F841_0.py:152:25: F841 [*] Local variable `_` is assigned to but never used | = help: Remove assignment to unused variable `_` -ℹ Safe fix 149 149 | def f(): 150 150 | try: 151 151 | pass 152 |- except Exception as _: 152 |+ except Exception: 153 153 | pass - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__future_annotations.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__future_annotations.snap index 5a15b089872bd..1713984cd5bf0 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__future_annotations.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__future_annotations.snap @@ -11,7 +11,6 @@ future_annotations.py:8:5: F401 [*] `models.Nut` imported but unused | = help: Remove unused import: `models.Nut` -ℹ Safe fix 5 5 | 6 6 | from models import ( 7 7 | Fruit, @@ -27,5 +26,3 @@ future_annotations.py:26:19: F821 Undefined name `Bar` | ^^^ F821 27 | return cls(x=0, y=0) | - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_multiple_unbinds_from_module_scope.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_multiple_unbinds_from_module_scope.snap index 8963cbc2ec14e..f9b257fd69b9c 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_multiple_unbinds_from_module_scope.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_multiple_unbinds_from_module_scope.snap @@ -11,7 +11,6 @@ source: crates/ruff_linter/src/rules/pyflakes/mod.rs | = help: Remove assignment to unused variable `x` -ℹ Safe fix 4 4 | def f(): 5 5 | try: 6 6 | pass @@ -31,7 +30,6 @@ source: crates/ruff_linter/src/rules/pyflakes/mod.rs | = help: Remove assignment to unused variable `x` -ℹ Safe fix 9 9 | 10 10 | try: 11 11 | pass @@ -40,5 +38,3 @@ source: crates/ruff_linter/src/rules/pyflakes/mod.rs 13 13 | pass 14 14 | 15 15 | # This should resolve to the `x` in `x = 1`. - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_class_scope.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_class_scope.snap index 30714ade296db..d8cbaf91d7e9a 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_class_scope.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_class_scope.snap @@ -11,7 +11,6 @@ source: crates/ruff_linter/src/rules/pyflakes/mod.rs | = help: Remove assignment to unused variable `x` -ℹ Safe fix 5 5 | def f(): 6 6 | try: 7 7 | pass @@ -28,5 +27,3 @@ source: crates/ruff_linter/src/rules/pyflakes/mod.rs 13 | print(x) | ^ F821 | - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_module_scope.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_module_scope.snap index 1a45bebe8c475..cb22fa76e4d10 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_module_scope.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_module_scope.snap @@ -11,7 +11,6 @@ source: crates/ruff_linter/src/rules/pyflakes/mod.rs | = help: Remove assignment to unused variable `x` -ℹ Safe fix 4 4 | def f(): 5 5 | try: 6 6 | pass @@ -20,5 +19,3 @@ source: crates/ruff_linter/src/rules/pyflakes/mod.rs 8 8 | pass 9 9 | 10 10 | # This should resolve to the `x` in `x = 1`. - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_nested_module_scope.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_nested_module_scope.snap index f2885ba2b58cd..14a7fcbfb38f5 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_nested_module_scope.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_nested_module_scope.snap @@ -11,7 +11,6 @@ source: crates/ruff_linter/src/rules/pyflakes/mod.rs | = help: Remove assignment to unused variable `x` -ℹ Safe fix 4 4 | def f(): 5 5 | try: 6 6 | pass @@ -31,7 +30,6 @@ source: crates/ruff_linter/src/rules/pyflakes/mod.rs | = help: Remove assignment to unused variable `x` -ℹ Safe fix 10 10 | def g(): 11 11 | try: 12 12 | pass @@ -40,5 +38,3 @@ source: crates/ruff_linter/src/rules/pyflakes/mod.rs 14 14 | pass 15 15 | 16 16 | # This should resolve to the `x` in `x = 1`. - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__multi_statement_lines.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__multi_statement_lines.snap index c2e289a7ef4d0..46f92118de742 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__multi_statement_lines.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__multi_statement_lines.snap @@ -10,7 +10,6 @@ multi_statement_lines.py:2:12: F401 [*] `foo1` imported but unused | = help: Remove unused import: `foo1` -ℹ Safe fix 1 1 | if True: 2 |- import foo1; x = 1 2 |+ x = 1 @@ -29,7 +28,6 @@ multi_statement_lines.py:3:12: F401 [*] `foo2` imported but unused | = help: Remove unused import: `foo2` -ℹ Safe fix 1 1 | if True: 2 2 | import foo1; x = 1 3 |- import foo2; x = 1 @@ -47,7 +45,6 @@ multi_statement_lines.py:6:12: F401 [*] `foo3` imported but unused | = help: Remove unused import: `foo3` -ℹ Safe fix 3 3 | import foo2; x = 1 4 4 | 5 5 | if True: @@ -67,7 +64,6 @@ multi_statement_lines.py:10:12: F401 [*] `foo4` imported but unused | = help: Remove unused import: `foo4` -ℹ Safe fix 7 7 | x = 1 8 8 | 9 9 | if True: @@ -86,7 +82,6 @@ multi_statement_lines.py:14:19: F401 [*] `foo5` imported but unused | = help: Remove unused import: `foo5` -ℹ Safe fix 11 11 | ; x = 1 12 12 | 13 13 | if True: @@ -107,7 +102,6 @@ multi_statement_lines.py:19:17: F401 [*] `foo6` imported but unused | = help: Remove unused import: `foo6` -ℹ Safe fix 15 15 | 16 16 | 17 17 | if True: @@ -129,7 +123,6 @@ multi_statement_lines.py:23:18: F401 [*] `foo7` imported but unused | = help: Remove unused import: `foo7` -ℹ Safe fix 20 20 | 21 21 | if True: 22 22 | x = 1 \ @@ -148,7 +141,6 @@ multi_statement_lines.py:26:19: F401 [*] `foo8` imported but unused | = help: Remove unused import: `foo8` -ℹ Safe fix 23 23 | ; import foo7 24 24 | 25 25 | if True: @@ -169,7 +161,6 @@ multi_statement_lines.py:27:23: F401 [*] `foo9` imported but unused | = help: Remove unused import: `foo9` -ℹ Safe fix 24 24 | 25 25 | if True: 26 26 | x = 1; import foo8; x = 1 @@ -189,7 +180,6 @@ multi_statement_lines.py:31:16: F401 [*] `foo10` imported but unused | = help: Remove unused import: `foo10` -ℹ Safe fix 28 28 | 29 29 | if True: 30 30 | x = 1; \ @@ -210,7 +200,6 @@ multi_statement_lines.py:36:17: F401 [*] `foo11` imported but unused | = help: Remove unused import: `foo11` -ℹ Safe fix 33 33 | 34 34 | if True: 35 35 | x = 1 \ @@ -230,7 +219,6 @@ multi_statement_lines.py:42:16: F401 [*] `foo12` imported but unused | = help: Remove unused import: `foo12` -ℹ Safe fix 37 37 | ;x = 1 38 38 | 39 39 | if True: @@ -251,7 +239,6 @@ multi_statement_lines.py:47:12: F401 [*] `foo13` imported but unused | = help: Remove unused import: `foo13` -ℹ Safe fix 42 42 | import foo12 43 43 | 44 44 | if True: @@ -274,7 +261,6 @@ multi_statement_lines.py:53:12: F401 [*] `foo14` imported but unused | = help: Remove unused import: `foo14` -ℹ Safe fix 50 50 | if True: 51 51 | x = 1; \ 52 52 | # \ @@ -294,7 +280,6 @@ multi_statement_lines.py:57:8: F401 [*] `foo15` imported but unused | = help: Remove unused import: `foo15` -ℹ Safe fix 53 53 | import foo14 54 54 | 55 55 | # Continuation, but not as the last content in the file. @@ -314,12 +299,9 @@ multi_statement_lines.py:62:8: F401 [*] `foo16` imported but unused | = help: Remove unused import: `foo16` -ℹ Safe fix 58 58 | 59 59 | # Continuation, followed by end-of-file. (Removing `import foo` would cause a syntax 60 60 | # error.) 61 |-x = 1; \ 62 |-import foo16 - 61 |+x = 1; - - + 61 |+x = 1; diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_24____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_24____init__.py.snap index 1c7ce2e8a7a8b..bdab1da6a3b20 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_24____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_24____init__.py.snap @@ -8,14 +8,6 @@ __init__.py:19:8: F401 [*] `sys` imported but unused | = help: Remove unused import: `sys` -ℹ Unsafe fix -16 16 | import argparse as argparse # Ok: is redundant alias -17 17 | -18 18 | -19 |-import sys # F401: remove unused -20 19 | -21 20 | -22 21 | # first-party __init__.py:33:15: F401 [*] `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias | @@ -24,7 +16,6 @@ __init__.py:33:15: F401 [*] `.unused` imported but unused; consider removing, ad | = help: Use an explicit re-export: `unused as unused` -ℹ Safe fix 30 30 | from . import aliased as aliased # Ok: is redundant alias 31 31 | 32 32 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_25__all_nonempty____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_25__all_nonempty____init__.py.snap index cb3e3848d5a93..aa51c8d07a60e 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_25__all_nonempty____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_25__all_nonempty____init__.py.snap @@ -8,14 +8,6 @@ __init__.py:19:8: F401 [*] `sys` imported but unused | = help: Remove unused import: `sys` -ℹ Unsafe fix -16 16 | import argparse # Ok: is exported in __all__ -17 17 | -18 18 | -19 |-import sys # F401: remove unused -20 19 | -21 20 | -22 21 | # first-party __init__.py:36:15: F401 [*] `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias | @@ -24,7 +16,6 @@ __init__.py:36:15: F401 [*] `.unused` imported but unused; consider removing, ad | = help: Add unused import `unused` to __all__ -ℹ Safe fix 39 39 | from . import renamed as bees # F401: add to __all__ 40 40 | 41 41 | @@ -38,7 +29,6 @@ __init__.py:39:26: F401 [*] `.renamed` imported but unused; consider removing, a | = help: Add unused import `bees` to __all__ -ℹ Safe fix 39 39 | from . import renamed as bees # F401: add to __all__ 40 40 | 41 41 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_26__all_empty____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_26__all_empty____init__.py.snap index 6c393f0fbfce9..1694fe30530e5 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_26__all_empty____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_26__all_empty____init__.py.snap @@ -8,7 +8,6 @@ __init__.py:5:15: F401 [*] `.unused` imported but unused; consider removing, add | = help: Add unused import `unused` to __all__ -ℹ Safe fix 8 8 | from . import renamed as bees # F401: add to __all__ 9 9 | 10 10 | @@ -22,7 +21,6 @@ __init__.py:8:26: F401 [*] `.renamed` imported but unused; consider removing, ad | = help: Add unused import `bees` to __all__ -ℹ Safe fix 8 8 | from . import renamed as bees # F401: add to __all__ 9 9 | 10 10 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_28__all_multiple____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_28__all_multiple____init__.py.snap index a77b95641d619..ad62ca23280f3 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_28__all_multiple____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_28__all_multiple____init__.py.snap @@ -8,7 +8,6 @@ __init__.py:5:15: F401 [*] `.unused` imported but unused; consider removing, add | = help: Add unused import `unused` to __all__ -ℹ Safe fix 5 5 | from . import unused, renamed as bees # F401: add to __all__ 6 6 | 7 7 | @@ -22,7 +21,6 @@ __init__.py:5:34: F401 [*] `.renamed` imported but unused; consider removing, ad | = help: Add unused import `bees` to __all__ -ℹ Safe fix 5 5 | from . import unused, renamed as bees # F401: add to __all__ 6 6 | 7 7 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401___init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401___init__.py.snap index 3f4855817c4b1..31a2481f70d0d 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401___init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401___init__.py.snap @@ -9,9 +9,3 @@ __init__.py:1:8: F401 [*] `os` imported but unused 3 | print(__path__) | = help: Remove unused import: `os` - -ℹ Unsafe fix -1 |-import os -2 1 | -3 2 | print(__path__) -4 3 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F841_F841_4.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F841_F841_4.py.snap index 661343dd141da..370937670942c 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F841_F841_4.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F841_F841_4.py.snap @@ -10,15 +10,6 @@ F841_4.py:12:5: F841 [*] Local variable `a` is assigned to but never used | = help: Remove assignment to unused variable `a` -ℹ Unsafe fix -9 9 | -10 10 | -11 11 | def bar(): -12 |- a = foo() - 12 |+ foo() -13 13 | b, c = foo() -14 14 | -15 15 | F841_4.py:13:5: F841 [*] Local variable `b` is assigned to but never used | @@ -29,15 +20,6 @@ F841_4.py:13:5: F841 [*] Local variable `b` is assigned to but never used | = help: Remove assignment to unused variable `b` -ℹ Unsafe fix -10 10 | -11 11 | def bar(): -12 12 | a = foo() -13 |- b, c = foo() - 13 |+ _b, c = foo() -14 14 | -15 15 | -16 16 | def baz(): F841_4.py:13:8: F841 [*] Local variable `c` is assigned to but never used | @@ -47,15 +29,3 @@ F841_4.py:13:8: F841 [*] Local variable `c` is assigned to but never used | ^ F841 | = help: Remove assignment to unused variable `c` - -ℹ Unsafe fix -10 10 | -11 11 | def bar(): -12 12 | a = foo() -13 |- b, c = foo() - 13 |+ b, _c = foo() -14 14 | -15 15 | -16 16 | def baz(): - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__print_in_body_after_double_shadowing_except.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__print_in_body_after_double_shadowing_except.snap index 45cdf09182aca..f7508ae7333e5 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__print_in_body_after_double_shadowing_except.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__print_in_body_after_double_shadowing_except.snap @@ -12,7 +12,6 @@ source: crates/ruff_linter/src/rules/pyflakes/mod.rs | = help: Remove assignment to unused variable `x` -ℹ Safe fix 4 4 | 5 5 | try: 6 6 | 1 / 0 @@ -32,7 +31,6 @@ source: crates/ruff_linter/src/rules/pyflakes/mod.rs | = help: Remove assignment to unused variable `x` -ℹ Safe fix 6 6 | 1 / 0 7 7 | except ValueError as x: 8 8 | pass @@ -41,5 +39,3 @@ source: crates/ruff_linter/src/rules/pyflakes/mod.rs 10 10 | pass 11 11 | 12 12 | # No error here, though it should arguably be an F821 error. `x` will - - diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__print_in_body_after_shadowing_except.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__print_in_body_after_shadowing_except.snap index 32d67c366975e..ef217d6fb638b 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__print_in_body_after_shadowing_except.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__print_in_body_after_shadowing_except.snap @@ -11,7 +11,6 @@ source: crates/ruff_linter/src/rules/pyflakes/mod.rs | = help: Remove assignment to unused variable `x` -ℹ Safe fix 4 4 | 5 5 | try: 6 6 | 1 / 0 @@ -20,5 +19,3 @@ source: crates/ruff_linter/src/rules/pyflakes/mod.rs 8 8 | pass 9 9 | 10 10 | # No error here, though it should arguably be an F821 error. `x` will - - diff --git a/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH004_PGH004_0.py.snap b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH004_PGH004_0.py.snap index 5c4e0772479d1..a823ff66b50e2 100644 --- a/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH004_PGH004_0.py.snap +++ b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH004_PGH004_0.py.snap @@ -39,15 +39,6 @@ PGH004_0.py:18:8: PGH004 [*] Use a colon when specifying `noqa` rule codes | = help: Add missing colon -ℹ Unsafe fix -15 15 | x = 2 # noqa:X100 -16 16 | -17 17 | # PGH004 -18 |-x = 2 # noqa X100 - 18 |+x = 2 # noqa: X100 -19 19 | -20 20 | # PGH004 -21 21 | x = 2 # noqa X100, X200 PGH004_0.py:21:8: PGH004 [*] Use a colon when specifying `noqa` rule codes | @@ -59,15 +50,6 @@ PGH004_0.py:21:8: PGH004 [*] Use a colon when specifying `noqa` rule codes | = help: Add missing colon -ℹ Unsafe fix -18 18 | x = 2 # noqa X100 -19 19 | -20 20 | # PGH004 -21 |-x = 2 # noqa X100, X200 - 21 |+x = 2 # noqa: X100, X200 -22 22 | -23 23 | # PGH004 -24 24 | x = 2 # noqa : X300 PGH004_0.py:24:8: PGH004 [*] Do not add spaces between `noqa` and its colon | @@ -79,15 +61,6 @@ PGH004_0.py:24:8: PGH004 [*] Do not add spaces between `noqa` and its colon | = help: Remove space(s) before colon -ℹ Unsafe fix -21 21 | x = 2 # noqa X100, X200 -22 22 | -23 23 | # PGH004 -24 |-x = 2 # noqa : X300 - 24 |+x = 2 # noqa: X300 -25 25 | -26 26 | # PGH004 -27 27 | x = 2 # noqa : X400 PGH004_0.py:27:8: PGH004 [*] Do not add spaces between `noqa` and its colon | @@ -99,15 +72,6 @@ PGH004_0.py:27:8: PGH004 [*] Do not add spaces between `noqa` and its colon | = help: Remove space(s) before colon -ℹ Unsafe fix -24 24 | x = 2 # noqa : X300 -25 25 | -26 26 | # PGH004 -27 |-x = 2 # noqa : X400 - 27 |+x = 2 # noqa: X400 -28 28 | -29 29 | # PGH004 -30 30 | x = 2 # noqa :X500 PGH004_0.py:30:8: PGH004 [*] Do not add spaces between `noqa` and its colon | @@ -116,10 +80,3 @@ PGH004_0.py:30:8: PGH004 [*] Do not add spaces between `noqa` and its colon | ^^^^^^^ PGH004 | = help: Remove space(s) before colon - -ℹ Unsafe fix -27 27 | x = 2 # noqa : X400 -28 28 | -29 29 | # PGH004 -30 |-x = 2 # noqa :X500 - 30 |+x = 2 # noqa:X500 diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0208_iteration_over_set.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0208_iteration_over_set.py.snap index 68b9aa856d41c..46ee34927ce80 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0208_iteration_over_set.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0208_iteration_over_set.py.snap @@ -11,7 +11,6 @@ iteration_over_set.py:3:13: PLC0208 [*] Use a sequence type instead of a `set` w | = help: Convert to `tuple` -ℹ Safe fix 1 1 | # Errors 2 2 | 3 |-for item in {1}: @@ -30,7 +29,6 @@ iteration_over_set.py:6:13: PLC0208 [*] Use a sequence type instead of a `set` w | = help: Convert to `tuple` -ℹ Safe fix 3 3 | for item in {1}: 4 4 | print(f"I can count to {item}!") 5 5 | @@ -50,7 +48,6 @@ iteration_over_set.py:9:13: PLC0208 [*] Use a sequence type instead of a `set` w | = help: Convert to `tuple` -ℹ Safe fix 6 6 | for item in {"apples", "lemons", "water"}: # flags in-line set literals 7 7 | print(f"I like {item}.") 8 8 | @@ -73,7 +70,6 @@ iteration_over_set.py:12:13: PLC0208 [*] Use a sequence type instead of a `set` | = help: Convert to `tuple` -ℹ Safe fix 9 9 | for item in {1,}: 10 10 | print(f"I can count to {item}!") 11 11 | @@ -97,7 +93,6 @@ iteration_over_set.py:17:28: PLC0208 [*] Use a sequence type instead of a `set` | = help: Convert to `tuple` -ℹ Safe fix 14 14 | }: # flags in-line set literals 15 15 | print(f"I like {item}.") 16 16 | @@ -118,7 +113,6 @@ iteration_over_set.py:19:27: PLC0208 [*] Use a sequence type instead of a `set` | = help: Convert to `tuple` -ℹ Safe fix 16 16 | 17 17 | numbers_list = [i for i in {1, 2, 3}] # flags sets in list comprehensions 18 18 | @@ -139,7 +133,6 @@ iteration_over_set.py:21:36: PLC0208 [*] Use a sequence type instead of a `set` | = help: Convert to `tuple` -ℹ Safe fix 18 18 | 19 19 | numbers_set = {i for i in {1, 2, 3}} # flags sets in set comprehensions 20 20 | @@ -160,7 +153,6 @@ iteration_over_set.py:23:27: PLC0208 [*] Use a sequence type instead of a `set` | = help: Convert to `tuple` -ℹ Safe fix 20 20 | 21 21 | numbers_dict = {str(i): i for i in {1, 2, 3}} # flags sets in dict comprehensions 22 22 | @@ -168,6 +160,4 @@ iteration_over_set.py:23:27: PLC0208 [*] Use a sequence type instead of a `set` 23 |+numbers_gen = (i for i in (1, 2, 3)) # flags sets in generator expressions 24 24 | 25 25 | # Non-errors -26 26 | - - +26 26 | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0414_import_aliasing.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0414_import_aliasing.py.snap index ac761dd336862..c010c9579a54a 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0414_import_aliasing.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0414_import_aliasing.py.snap @@ -12,15 +12,6 @@ import_aliasing.py:6:8: PLC0414 [*] Import alias does not rename original packag | = help: Remove import alias -ℹ Unsafe fix -3 3 | # 1. useless-import-alias -4 4 | # 2. consider-using-from-import -5 5 | -6 |-import collections as collections # [useless-import-alias] - 6 |+import collections # [useless-import-alias] -7 7 | from collections import OrderedDict as OrderedDict # [useless-import-alias] -8 8 | from collections import OrderedDict as o_dict -9 9 | import os.path as path # [consider-using-from-import] import_aliasing.py:7:25: PLC0414 [*] Import alias does not rename original package | @@ -32,15 +23,6 @@ import_aliasing.py:7:25: PLC0414 [*] Import alias does not rename original packa | = help: Remove import alias -ℹ Unsafe fix -4 4 | # 2. consider-using-from-import -5 5 | -6 6 | import collections as collections # [useless-import-alias] -7 |-from collections import OrderedDict as OrderedDict # [useless-import-alias] - 7 |+from collections import OrderedDict # [useless-import-alias] -8 8 | from collections import OrderedDict as o_dict -9 9 | import os.path as path # [consider-using-from-import] -10 10 | import os.path as p import_aliasing.py:16:15: PLC0414 [*] Import alias does not rename original package | @@ -53,15 +35,6 @@ import_aliasing.py:16:15: PLC0414 [*] Import alias does not rename original pack | = help: Remove import alias -ℹ Unsafe fix -13 13 | import os -14 14 | import os as OS -15 15 | from sys import version -16 |-from . import bar as bar # [useless-import-alias] - 16 |+from . import bar # [useless-import-alias] -17 17 | from . import bar as Bar -18 18 | from . import bar -19 19 | from ..foo import bar as bar # [useless-import-alias] import_aliasing.py:19:19: PLC0414 [*] Import alias does not rename original package | @@ -74,15 +47,6 @@ import_aliasing.py:19:19: PLC0414 [*] Import alias does not rename original pack | = help: Remove import alias -ℹ Unsafe fix -16 16 | from . import bar as bar # [useless-import-alias] -17 17 | from . import bar as Bar -18 18 | from . import bar -19 |-from ..foo import bar as bar # [useless-import-alias] - 19 |+from ..foo import bar # [useless-import-alias] -20 20 | from ..foo.bar import foobar as foobar # [useless-import-alias] -21 21 | from ..foo.bar import foobar as anotherfoobar -22 22 | from . import foo as foo, foo2 as bar2 # [useless-import-alias] import_aliasing.py:20:23: PLC0414 [*] Import alias does not rename original package | @@ -95,15 +59,6 @@ import_aliasing.py:20:23: PLC0414 [*] Import alias does not rename original pack | = help: Remove import alias -ℹ Unsafe fix -17 17 | from . import bar as Bar -18 18 | from . import bar -19 19 | from ..foo import bar as bar # [useless-import-alias] -20 |-from ..foo.bar import foobar as foobar # [useless-import-alias] - 20 |+from ..foo.bar import foobar # [useless-import-alias] -21 21 | from ..foo.bar import foobar as anotherfoobar -22 22 | from . import foo as foo, foo2 as bar2 # [useless-import-alias] -23 23 | from . import foo as bar, foo2 as foo2 # [useless-import-alias] import_aliasing.py:22:15: PLC0414 [*] Import alias does not rename original package | @@ -116,15 +71,6 @@ import_aliasing.py:22:15: PLC0414 [*] Import alias does not rename original pack | = help: Remove import alias -ℹ Unsafe fix -19 19 | from ..foo import bar as bar # [useless-import-alias] -20 20 | from ..foo.bar import foobar as foobar # [useless-import-alias] -21 21 | from ..foo.bar import foobar as anotherfoobar -22 |-from . import foo as foo, foo2 as bar2 # [useless-import-alias] - 22 |+from . import foo, foo2 as bar2 # [useless-import-alias] -23 23 | from . import foo as bar, foo2 as foo2 # [useless-import-alias] -24 24 | from . import foo as bar, foo2 as bar2 -25 25 | from foo.bar import foobar as foobar # [useless-import-alias] import_aliasing.py:23:27: PLC0414 [*] Import alias does not rename original package | @@ -137,15 +83,6 @@ import_aliasing.py:23:27: PLC0414 [*] Import alias does not rename original pack | = help: Remove import alias -ℹ Unsafe fix -20 20 | from ..foo.bar import foobar as foobar # [useless-import-alias] -21 21 | from ..foo.bar import foobar as anotherfoobar -22 22 | from . import foo as foo, foo2 as bar2 # [useless-import-alias] -23 |-from . import foo as bar, foo2 as foo2 # [useless-import-alias] - 23 |+from . import foo as bar, foo2 # [useless-import-alias] -24 24 | from . import foo as bar, foo2 as bar2 -25 25 | from foo.bar import foobar as foobar # [useless-import-alias] -26 26 | from foo.bar import foobar as foo import_aliasing.py:25:21: PLC0414 [*] Import alias does not rename original package | @@ -157,15 +94,3 @@ import_aliasing.py:25:21: PLC0414 [*] Import alias does not rename original pack 27 | from .foo.bar import f as foobar | = help: Remove import alias - -ℹ Unsafe fix -22 22 | from . import foo as foo, foo2 as bar2 # [useless-import-alias] -23 23 | from . import foo as bar, foo2 as foo2 # [useless-import-alias] -24 24 | from . import foo as bar, foo2 as bar2 -25 |-from foo.bar import foobar as foobar # [useless-import-alias] - 25 |+from foo.bar import foobar # [useless-import-alias] -26 26 | from foo.bar import foobar as foo -27 27 | from .foo.bar import f as foobar -28 28 | from ............a import b # [relative-beyond-top-level] - - diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2801_unnecessary_dunder_call.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2801_unnecessary_dunder_call.py.snap index 48923d03a102d..c435bc221e442 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2801_unnecessary_dunder_call.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2801_unnecessary_dunder_call.py.snap @@ -11,15 +11,6 @@ unnecessary_dunder_call.py:4:7: PLC2801 [*] Unnecessary dunder call to `__add__` | = help: Use `+` operator -ℹ Unsafe fix -1 1 | from typing import Any -2 2 | -3 3 | a = 2 -4 |-print((3.0).__add__(4.0)) # PLC2801 - 4 |+print(3.0 + 4.0) # PLC2801 -5 5 | print((3.0).__sub__(4.0)) # PLC2801 -6 6 | print((3.0).__mul__(4.0)) # PLC2801 -7 7 | print((3.0).__truediv__(4.0)) # PLC2801 unnecessary_dunder_call.py:5:7: PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. | @@ -32,15 +23,6 @@ unnecessary_dunder_call.py:5:7: PLC2801 [*] Unnecessary dunder call to `__sub__` | = help: Use `-` operator -ℹ Unsafe fix -2 2 | -3 3 | a = 2 -4 4 | print((3.0).__add__(4.0)) # PLC2801 -5 |-print((3.0).__sub__(4.0)) # PLC2801 - 5 |+print(3.0 - 4.0) # PLC2801 -6 6 | print((3.0).__mul__(4.0)) # PLC2801 -7 7 | print((3.0).__truediv__(4.0)) # PLC2801 -8 8 | print((3.0).__floordiv__(4.0)) # PLC2801 unnecessary_dunder_call.py:6:7: PLC2801 [*] Unnecessary dunder call to `__mul__`. Use `*` operator. | @@ -53,15 +35,6 @@ unnecessary_dunder_call.py:6:7: PLC2801 [*] Unnecessary dunder call to `__mul__` | = help: Use `*` operator -ℹ Unsafe fix -3 3 | a = 2 -4 4 | print((3.0).__add__(4.0)) # PLC2801 -5 5 | print((3.0).__sub__(4.0)) # PLC2801 -6 |-print((3.0).__mul__(4.0)) # PLC2801 - 6 |+print(3.0 * 4.0) # PLC2801 -7 7 | print((3.0).__truediv__(4.0)) # PLC2801 -8 8 | print((3.0).__floordiv__(4.0)) # PLC2801 -9 9 | print((3.0).__mod__(4.0)) # PLC2801 unnecessary_dunder_call.py:7:7: PLC2801 [*] Unnecessary dunder call to `__truediv__`. Use `/` operator. | @@ -74,15 +47,6 @@ unnecessary_dunder_call.py:7:7: PLC2801 [*] Unnecessary dunder call to `__truedi | = help: Use `/` operator -ℹ Unsafe fix -4 4 | print((3.0).__add__(4.0)) # PLC2801 -5 5 | print((3.0).__sub__(4.0)) # PLC2801 -6 6 | print((3.0).__mul__(4.0)) # PLC2801 -7 |-print((3.0).__truediv__(4.0)) # PLC2801 - 7 |+print(3.0 / 4.0) # PLC2801 -8 8 | print((3.0).__floordiv__(4.0)) # PLC2801 -9 9 | print((3.0).__mod__(4.0)) # PLC2801 -10 10 | print((3.0).__eq__(4.0)) # PLC2801 unnecessary_dunder_call.py:8:7: PLC2801 [*] Unnecessary dunder call to `__floordiv__`. Use `//` operator. | @@ -95,15 +59,6 @@ unnecessary_dunder_call.py:8:7: PLC2801 [*] Unnecessary dunder call to `__floord | = help: Use `//` operator -ℹ Unsafe fix -5 5 | print((3.0).__sub__(4.0)) # PLC2801 -6 6 | print((3.0).__mul__(4.0)) # PLC2801 -7 7 | print((3.0).__truediv__(4.0)) # PLC2801 -8 |-print((3.0).__floordiv__(4.0)) # PLC2801 - 8 |+print(3.0 // 4.0) # PLC2801 -9 9 | print((3.0).__mod__(4.0)) # PLC2801 -10 10 | print((3.0).__eq__(4.0)) # PLC2801 -11 11 | print((3.0).__ne__(4.0)) # PLC2801 unnecessary_dunder_call.py:9:7: PLC2801 [*] Unnecessary dunder call to `__mod__`. Use `%` operator. | @@ -116,15 +71,6 @@ unnecessary_dunder_call.py:9:7: PLC2801 [*] Unnecessary dunder call to `__mod__` | = help: Use `%` operator -ℹ Unsafe fix -6 6 | print((3.0).__mul__(4.0)) # PLC2801 -7 7 | print((3.0).__truediv__(4.0)) # PLC2801 -8 8 | print((3.0).__floordiv__(4.0)) # PLC2801 -9 |-print((3.0).__mod__(4.0)) # PLC2801 - 9 |+print(3.0 % 4.0) # PLC2801 -10 10 | print((3.0).__eq__(4.0)) # PLC2801 -11 11 | print((3.0).__ne__(4.0)) # PLC2801 -12 12 | print((3.0).__lt__(4.0)) # PLC2801 unnecessary_dunder_call.py:10:7: PLC2801 [*] Unnecessary dunder call to `__eq__`. Use `==` operator. | @@ -137,15 +83,6 @@ unnecessary_dunder_call.py:10:7: PLC2801 [*] Unnecessary dunder call to `__eq__` | = help: Use `==` operator -ℹ Unsafe fix -7 7 | print((3.0).__truediv__(4.0)) # PLC2801 -8 8 | print((3.0).__floordiv__(4.0)) # PLC2801 -9 9 | print((3.0).__mod__(4.0)) # PLC2801 -10 |-print((3.0).__eq__(4.0)) # PLC2801 - 10 |+print(3.0 == 4.0) # PLC2801 -11 11 | print((3.0).__ne__(4.0)) # PLC2801 -12 12 | print((3.0).__lt__(4.0)) # PLC2801 -13 13 | print((3.0).__le__(4.0)) # PLC2801 unnecessary_dunder_call.py:11:7: PLC2801 [*] Unnecessary dunder call to `__ne__`. Use `!=` operator. | @@ -158,15 +95,6 @@ unnecessary_dunder_call.py:11:7: PLC2801 [*] Unnecessary dunder call to `__ne__` | = help: Use `!=` operator -ℹ Unsafe fix -8 8 | print((3.0).__floordiv__(4.0)) # PLC2801 -9 9 | print((3.0).__mod__(4.0)) # PLC2801 -10 10 | print((3.0).__eq__(4.0)) # PLC2801 -11 |-print((3.0).__ne__(4.0)) # PLC2801 - 11 |+print(3.0 != 4.0) # PLC2801 -12 12 | print((3.0).__lt__(4.0)) # PLC2801 -13 13 | print((3.0).__le__(4.0)) # PLC2801 -14 14 | print((3.0).__gt__(4.0)) # PLC2801 unnecessary_dunder_call.py:12:7: PLC2801 [*] Unnecessary dunder call to `__lt__`. Use `<` operator. | @@ -179,15 +107,6 @@ unnecessary_dunder_call.py:12:7: PLC2801 [*] Unnecessary dunder call to `__lt__` | = help: Use `<` operator -ℹ Unsafe fix -9 9 | print((3.0).__mod__(4.0)) # PLC2801 -10 10 | print((3.0).__eq__(4.0)) # PLC2801 -11 11 | print((3.0).__ne__(4.0)) # PLC2801 -12 |-print((3.0).__lt__(4.0)) # PLC2801 - 12 |+print(3.0 < 4.0) # PLC2801 -13 13 | print((3.0).__le__(4.0)) # PLC2801 -14 14 | print((3.0).__gt__(4.0)) # PLC2801 -15 15 | print((3.0).__ge__(4.0)) # PLC2801 unnecessary_dunder_call.py:13:7: PLC2801 [*] Unnecessary dunder call to `__le__`. Use `<=` operator. | @@ -200,15 +119,6 @@ unnecessary_dunder_call.py:13:7: PLC2801 [*] Unnecessary dunder call to `__le__` | = help: Use `<=` operator -ℹ Unsafe fix -10 10 | print((3.0).__eq__(4.0)) # PLC2801 -11 11 | print((3.0).__ne__(4.0)) # PLC2801 -12 12 | print((3.0).__lt__(4.0)) # PLC2801 -13 |-print((3.0).__le__(4.0)) # PLC2801 - 13 |+print(3.0 <= 4.0) # PLC2801 -14 14 | print((3.0).__gt__(4.0)) # PLC2801 -15 15 | print((3.0).__ge__(4.0)) # PLC2801 -16 16 | print((3.0).__str__()) # PLC2801 unnecessary_dunder_call.py:14:7: PLC2801 [*] Unnecessary dunder call to `__gt__`. Use `>` operator. | @@ -221,15 +131,6 @@ unnecessary_dunder_call.py:14:7: PLC2801 [*] Unnecessary dunder call to `__gt__` | = help: Use `>` operator -ℹ Unsafe fix -11 11 | print((3.0).__ne__(4.0)) # PLC2801 -12 12 | print((3.0).__lt__(4.0)) # PLC2801 -13 13 | print((3.0).__le__(4.0)) # PLC2801 -14 |-print((3.0).__gt__(4.0)) # PLC2801 - 14 |+print(3.0 > 4.0) # PLC2801 -15 15 | print((3.0).__ge__(4.0)) # PLC2801 -16 16 | print((3.0).__str__()) # PLC2801 -17 17 | print((3.0).__repr__()) # PLC2801 unnecessary_dunder_call.py:15:7: PLC2801 [*] Unnecessary dunder call to `__ge__`. Use `>=` operator. | @@ -242,15 +143,6 @@ unnecessary_dunder_call.py:15:7: PLC2801 [*] Unnecessary dunder call to `__ge__` | = help: Use `>=` operator -ℹ Unsafe fix -12 12 | print((3.0).__lt__(4.0)) # PLC2801 -13 13 | print((3.0).__le__(4.0)) # PLC2801 -14 14 | print((3.0).__gt__(4.0)) # PLC2801 -15 |-print((3.0).__ge__(4.0)) # PLC2801 - 15 |+print(3.0 >= 4.0) # PLC2801 -16 16 | print((3.0).__str__()) # PLC2801 -17 17 | print((3.0).__repr__()) # PLC2801 -18 18 | print([1, 2, 3].__len__()) # PLC2801 unnecessary_dunder_call.py:16:7: PLC2801 [*] Unnecessary dunder call to `__str__`. Use `str()` builtin. | @@ -263,15 +155,6 @@ unnecessary_dunder_call.py:16:7: PLC2801 [*] Unnecessary dunder call to `__str__ | = help: Use `str()` builtin -ℹ Unsafe fix -13 13 | print((3.0).__le__(4.0)) # PLC2801 -14 14 | print((3.0).__gt__(4.0)) # PLC2801 -15 15 | print((3.0).__ge__(4.0)) # PLC2801 -16 |-print((3.0).__str__()) # PLC2801 - 16 |+print(str(3.0)) # PLC2801 -17 17 | print((3.0).__repr__()) # PLC2801 -18 18 | print([1, 2, 3].__len__()) # PLC2801 -19 19 | print((1).__neg__()) # PLC2801 unnecessary_dunder_call.py:17:7: PLC2801 [*] Unnecessary dunder call to `__repr__`. Use `repr()` builtin. | @@ -284,15 +167,6 @@ unnecessary_dunder_call.py:17:7: PLC2801 [*] Unnecessary dunder call to `__repr_ | = help: Use `repr()` builtin -ℹ Unsafe fix -14 14 | print((3.0).__gt__(4.0)) # PLC2801 -15 15 | print((3.0).__ge__(4.0)) # PLC2801 -16 16 | print((3.0).__str__()) # PLC2801 -17 |-print((3.0).__repr__()) # PLC2801 - 17 |+print(repr(3.0)) # PLC2801 -18 18 | print([1, 2, 3].__len__()) # PLC2801 -19 19 | print((1).__neg__()) # PLC2801 -20 20 | print(-a.__sub__(1)) # PLC2801 unnecessary_dunder_call.py:18:7: PLC2801 [*] Unnecessary dunder call to `__len__`. Use `len()` builtin. | @@ -305,15 +179,6 @@ unnecessary_dunder_call.py:18:7: PLC2801 [*] Unnecessary dunder call to `__len__ | = help: Use `len()` builtin -ℹ Unsafe fix -15 15 | print((3.0).__ge__(4.0)) # PLC2801 -16 16 | print((3.0).__str__()) # PLC2801 -17 17 | print((3.0).__repr__()) # PLC2801 -18 |-print([1, 2, 3].__len__()) # PLC2801 - 18 |+print(len([1, 2, 3])) # PLC2801 -19 19 | print((1).__neg__()) # PLC2801 -20 20 | print(-a.__sub__(1)) # PLC2801 -21 21 | print(-(a).__sub__(1)) # PLC2801 unnecessary_dunder_call.py:19:7: PLC2801 Unnecessary dunder call to `__neg__`. Multiply by -1 instead. | @@ -337,15 +202,6 @@ unnecessary_dunder_call.py:20:8: PLC2801 [*] Unnecessary dunder call to `__sub__ | = help: Use `-` operator -ℹ Unsafe fix -17 17 | print((3.0).__repr__()) # PLC2801 -18 18 | print([1, 2, 3].__len__()) # PLC2801 -19 19 | print((1).__neg__()) # PLC2801 -20 |-print(-a.__sub__(1)) # PLC2801 - 20 |+print(-(a - 1)) # PLC2801 -21 21 | print(-(a).__sub__(1)) # PLC2801 -22 22 | print(-(-a.__sub__(1))) # PLC2801 -23 23 | print((5 - a).__sub__(1)) # PLC2801 unnecessary_dunder_call.py:21:8: PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. | @@ -358,15 +214,6 @@ unnecessary_dunder_call.py:21:8: PLC2801 [*] Unnecessary dunder call to `__sub__ | = help: Use `-` operator -ℹ Unsafe fix -18 18 | print([1, 2, 3].__len__()) # PLC2801 -19 19 | print((1).__neg__()) # PLC2801 -20 20 | print(-a.__sub__(1)) # PLC2801 -21 |-print(-(a).__sub__(1)) # PLC2801 - 21 |+print(-(a - 1)) # PLC2801 -22 22 | print(-(-a.__sub__(1))) # PLC2801 -23 23 | print((5 - a).__sub__(1)) # PLC2801 -24 24 | print(-(5 - a).__sub__(1)) # PLC2801 unnecessary_dunder_call.py:22:10: PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. | @@ -379,15 +226,6 @@ unnecessary_dunder_call.py:22:10: PLC2801 [*] Unnecessary dunder call to `__sub_ | = help: Use `-` operator -ℹ Unsafe fix -19 19 | print((1).__neg__()) # PLC2801 -20 20 | print(-a.__sub__(1)) # PLC2801 -21 21 | print(-(a).__sub__(1)) # PLC2801 -22 |-print(-(-a.__sub__(1))) # PLC2801 - 22 |+print(-(-(a - 1))) # PLC2801 -23 23 | print((5 - a).__sub__(1)) # PLC2801 -24 24 | print(-(5 - a).__sub__(1)) # PLC2801 -25 25 | print(-(-5 - a).__sub__(1)) # PLC2801 unnecessary_dunder_call.py:23:7: PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. | @@ -400,15 +238,6 @@ unnecessary_dunder_call.py:23:7: PLC2801 [*] Unnecessary dunder call to `__sub__ | = help: Use `-` operator -ℹ Unsafe fix -20 20 | print(-a.__sub__(1)) # PLC2801 -21 21 | print(-(a).__sub__(1)) # PLC2801 -22 22 | print(-(-a.__sub__(1))) # PLC2801 -23 |-print((5 - a).__sub__(1)) # PLC2801 - 23 |+print(5 - a - 1) # PLC2801 -24 24 | print(-(5 - a).__sub__(1)) # PLC2801 -25 25 | print(-(-5 - a).__sub__(1)) # PLC2801 -26 26 | print(+-+-+-a.__sub__(1)) # PLC2801 unnecessary_dunder_call.py:24:8: PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. | @@ -421,15 +250,6 @@ unnecessary_dunder_call.py:24:8: PLC2801 [*] Unnecessary dunder call to `__sub__ | = help: Use `-` operator -ℹ Unsafe fix -21 21 | print(-(a).__sub__(1)) # PLC2801 -22 22 | print(-(-a.__sub__(1))) # PLC2801 -23 23 | print((5 - a).__sub__(1)) # PLC2801 -24 |-print(-(5 - a).__sub__(1)) # PLC2801 - 24 |+print(-(5 - a - 1)) # PLC2801 -25 25 | print(-(-5 - a).__sub__(1)) # PLC2801 -26 26 | print(+-+-+-a.__sub__(1)) # PLC2801 -27 27 | print(a.__rsub__(2 - 1)) # PLC2801 unnecessary_dunder_call.py:25:8: PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. | @@ -442,15 +262,6 @@ unnecessary_dunder_call.py:25:8: PLC2801 [*] Unnecessary dunder call to `__sub__ | = help: Use `-` operator -ℹ Unsafe fix -22 22 | print(-(-a.__sub__(1))) # PLC2801 -23 23 | print((5 - a).__sub__(1)) # PLC2801 -24 24 | print(-(5 - a).__sub__(1)) # PLC2801 -25 |-print(-(-5 - a).__sub__(1)) # PLC2801 - 25 |+print(-(-5 - a - 1)) # PLC2801 -26 26 | print(+-+-+-a.__sub__(1)) # PLC2801 -27 27 | print(a.__rsub__(2 - 1)) # PLC2801 -28 28 | print(a.__sub__(((((1)))))) # PLC2801 unnecessary_dunder_call.py:26:13: PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. | @@ -463,15 +274,6 @@ unnecessary_dunder_call.py:26:13: PLC2801 [*] Unnecessary dunder call to `__sub_ | = help: Use `-` operator -ℹ Unsafe fix -23 23 | print((5 - a).__sub__(1)) # PLC2801 -24 24 | print(-(5 - a).__sub__(1)) # PLC2801 -25 25 | print(-(-5 - a).__sub__(1)) # PLC2801 -26 |-print(+-+-+-a.__sub__(1)) # PLC2801 - 26 |+print(+-+-+-(a - 1)) # PLC2801 -27 27 | print(a.__rsub__(2 - 1)) # PLC2801 -28 28 | print(a.__sub__(((((1)))))) # PLC2801 -29 29 | print(a.__sub__(((((2 - 1)))))) # PLC2801 unnecessary_dunder_call.py:27:7: PLC2801 [*] Unnecessary dunder call to `__rsub__`. Use `-` operator. | @@ -484,15 +286,6 @@ unnecessary_dunder_call.py:27:7: PLC2801 [*] Unnecessary dunder call to `__rsub_ | = help: Use `-` operator -ℹ Unsafe fix -24 24 | print(-(5 - a).__sub__(1)) # PLC2801 -25 25 | print(-(-5 - a).__sub__(1)) # PLC2801 -26 26 | print(+-+-+-a.__sub__(1)) # PLC2801 -27 |-print(a.__rsub__(2 - 1)) # PLC2801 - 27 |+print((2 - 1) - a) # PLC2801 -28 28 | print(a.__sub__(((((1)))))) # PLC2801 -29 29 | print(a.__sub__(((((2 - 1)))))) # PLC2801 -30 30 | print(a.__sub__( unnecessary_dunder_call.py:28:7: PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. | @@ -505,15 +298,6 @@ unnecessary_dunder_call.py:28:7: PLC2801 [*] Unnecessary dunder call to `__sub__ | = help: Use `-` operator -ℹ Unsafe fix -25 25 | print(-(-5 - a).__sub__(1)) # PLC2801 -26 26 | print(+-+-+-a.__sub__(1)) # PLC2801 -27 27 | print(a.__rsub__(2 - 1)) # PLC2801 -28 |-print(a.__sub__(((((1)))))) # PLC2801 - 28 |+print(a - 1) # PLC2801 -29 29 | print(a.__sub__(((((2 - 1)))))) # PLC2801 -30 30 | print(a.__sub__( -31 31 | 3 unnecessary_dunder_call.py:29:7: PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. | @@ -526,15 +310,6 @@ unnecessary_dunder_call.py:29:7: PLC2801 [*] Unnecessary dunder call to `__sub__ | = help: Use `-` operator -ℹ Unsafe fix -26 26 | print(+-+-+-a.__sub__(1)) # PLC2801 -27 27 | print(a.__rsub__(2 - 1)) # PLC2801 -28 28 | print(a.__sub__(((((1)))))) # PLC2801 -29 |-print(a.__sub__(((((2 - 1)))))) # PLC2801 - 29 |+print(a - (2 - 1)) # PLC2801 -30 30 | print(a.__sub__( -31 31 | 3 -32 32 | + unnecessary_dunder_call.py:30:7: PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. | @@ -552,20 +327,6 @@ unnecessary_dunder_call.py:30:7: PLC2801 [*] Unnecessary dunder call to `__sub__ | = help: Use `-` operator -ℹ Unsafe fix -27 27 | print(a.__rsub__(2 - 1)) # PLC2801 -28 28 | print(a.__sub__(((((1)))))) # PLC2801 -29 29 | print(a.__sub__(((((2 - 1)))))) # PLC2801 -30 |-print(a.__sub__( -31 |- 3 - 30 |+print(a - (3 -32 31 | + -33 |- 4 -34 |-)) - 32 |+ 4)) -35 33 | print(a.__rsub__( -36 34 | 3 -37 35 | + unnecessary_dunder_call.py:35:7: PLC2801 [*] Unnecessary dunder call to `__rsub__`. Use `-` operator. | @@ -583,20 +344,6 @@ unnecessary_dunder_call.py:35:7: PLC2801 [*] Unnecessary dunder call to `__rsub_ | = help: Use `-` operator -ℹ Unsafe fix -32 32 | + -33 33 | 4 -34 34 | )) -35 |-print(a.__rsub__( -36 |- 3 - 35 |+print((3 -37 36 | + -38 |- 4 -39 |-)) - 37 |+ 4) - a) -40 38 | print(2 * a.__add__(3)) # PLC2801 -41 39 | x = 2 * a.__add__(3) # PLC2801 -42 40 | x = 2 * -a.__add__(3) # PLC2801 unnecessary_dunder_call.py:40:11: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. | @@ -609,15 +356,6 @@ unnecessary_dunder_call.py:40:11: PLC2801 [*] Unnecessary dunder call to `__add_ | = help: Use `+` operator -ℹ Unsafe fix -37 37 | + -38 38 | 4 -39 39 | )) -40 |-print(2 * a.__add__(3)) # PLC2801 - 40 |+print(2 * (a + 3)) # PLC2801 -41 41 | x = 2 * a.__add__(3) # PLC2801 -42 42 | x = 2 * -a.__add__(3) # PLC2801 -43 43 | x = a.__add__(3) # PLC2801 unnecessary_dunder_call.py:41:9: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. | @@ -630,15 +368,6 @@ unnecessary_dunder_call.py:41:9: PLC2801 [*] Unnecessary dunder call to `__add__ | = help: Use `+` operator -ℹ Unsafe fix -38 38 | 4 -39 39 | )) -40 40 | print(2 * a.__add__(3)) # PLC2801 -41 |-x = 2 * a.__add__(3) # PLC2801 - 41 |+x = 2 * (a + 3) # PLC2801 -42 42 | x = 2 * -a.__add__(3) # PLC2801 -43 43 | x = a.__add__(3) # PLC2801 -44 44 | x = -a.__add__(3) # PLC2801 unnecessary_dunder_call.py:42:10: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. | @@ -651,15 +380,6 @@ unnecessary_dunder_call.py:42:10: PLC2801 [*] Unnecessary dunder call to `__add_ | = help: Use `+` operator -ℹ Unsafe fix -39 39 | )) -40 40 | print(2 * a.__add__(3)) # PLC2801 -41 41 | x = 2 * a.__add__(3) # PLC2801 -42 |-x = 2 * -a.__add__(3) # PLC2801 - 42 |+x = 2 * -(a + 3) # PLC2801 -43 43 | x = a.__add__(3) # PLC2801 -44 44 | x = -a.__add__(3) # PLC2801 -45 45 | x = (-a).__add__(3) # PLC2801 unnecessary_dunder_call.py:43:5: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. | @@ -672,15 +392,6 @@ unnecessary_dunder_call.py:43:5: PLC2801 [*] Unnecessary dunder call to `__add__ | = help: Use `+` operator -ℹ Unsafe fix -40 40 | print(2 * a.__add__(3)) # PLC2801 -41 41 | x = 2 * a.__add__(3) # PLC2801 -42 42 | x = 2 * -a.__add__(3) # PLC2801 -43 |-x = a.__add__(3) # PLC2801 - 43 |+x = a + 3 # PLC2801 -44 44 | x = -a.__add__(3) # PLC2801 -45 45 | x = (-a).__add__(3) # PLC2801 -46 46 | x = -(-a).__add__(3) # PLC2801 unnecessary_dunder_call.py:44:6: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. | @@ -693,15 +404,6 @@ unnecessary_dunder_call.py:44:6: PLC2801 [*] Unnecessary dunder call to `__add__ | = help: Use `+` operator -ℹ Unsafe fix -41 41 | x = 2 * a.__add__(3) # PLC2801 -42 42 | x = 2 * -a.__add__(3) # PLC2801 -43 43 | x = a.__add__(3) # PLC2801 -44 |-x = -a.__add__(3) # PLC2801 - 44 |+x = -(a + 3) # PLC2801 -45 45 | x = (-a).__add__(3) # PLC2801 -46 46 | x = -(-a).__add__(3) # PLC2801 -47 47 | unnecessary_dunder_call.py:45:5: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. | @@ -713,15 +415,6 @@ unnecessary_dunder_call.py:45:5: PLC2801 [*] Unnecessary dunder call to `__add__ | = help: Use `+` operator -ℹ Unsafe fix -42 42 | x = 2 * -a.__add__(3) # PLC2801 -43 43 | x = a.__add__(3) # PLC2801 -44 44 | x = -a.__add__(3) # PLC2801 -45 |-x = (-a).__add__(3) # PLC2801 - 45 |+x = -a + 3 # PLC2801 -46 46 | x = -(-a).__add__(3) # PLC2801 -47 47 | -48 48 | # Calls unnecessary_dunder_call.py:46:6: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. | @@ -734,15 +427,6 @@ unnecessary_dunder_call.py:46:6: PLC2801 [*] Unnecessary dunder call to `__add__ | = help: Use `+` operator -ℹ Unsafe fix -43 43 | x = a.__add__(3) # PLC2801 -44 44 | x = -a.__add__(3) # PLC2801 -45 45 | x = (-a).__add__(3) # PLC2801 -46 |-x = -(-a).__add__(3) # PLC2801 - 46 |+x = -(-a + 3) # PLC2801 -47 47 | -48 48 | # Calls -49 49 | print(a.__call__()) # PLC2801 (no fix, intentional) unnecessary_dunder_call.py:49:7: PLC2801 Unnecessary dunder call to `__call__` | @@ -763,15 +447,6 @@ unnecessary_dunder_call.py:52:16: PLC2801 [*] Unnecessary dunder call to `__add_ | = help: Use `+` operator -ℹ Unsafe fix -49 49 | print(a.__call__()) # PLC2801 (no fix, intentional) -50 50 | -51 51 | # Lambda expressions -52 |-blah = lambda: a.__add__(1) # PLC2801 - 52 |+blah = lambda: a + 1 # PLC2801 -53 53 | -54 54 | # If expressions -55 55 | print(a.__add__(1) if a > 0 else a.__sub__(1)) # PLC2801 unnecessary_dunder_call.py:55:7: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. | @@ -783,15 +458,6 @@ unnecessary_dunder_call.py:55:7: PLC2801 [*] Unnecessary dunder call to `__add__ | = help: Use `+` operator -ℹ Unsafe fix -52 52 | blah = lambda: a.__add__(1) # PLC2801 -53 53 | -54 54 | # If expressions -55 |-print(a.__add__(1) if a > 0 else a.__sub__(1)) # PLC2801 - 55 |+print(a + 1 if a > 0 else a.__sub__(1)) # PLC2801 -56 56 | -57 57 | # Dict/Set/List/Tuple -58 58 | print({"a": a.__add__(1)}) # PLC2801 unnecessary_dunder_call.py:55:34: PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. | @@ -803,15 +469,6 @@ unnecessary_dunder_call.py:55:34: PLC2801 [*] Unnecessary dunder call to `__sub_ | = help: Use `-` operator -ℹ Unsafe fix -52 52 | blah = lambda: a.__add__(1) # PLC2801 -53 53 | -54 54 | # If expressions -55 |-print(a.__add__(1) if a > 0 else a.__sub__(1)) # PLC2801 - 55 |+print(a.__add__(1) if a > 0 else a - 1) # PLC2801 -56 56 | -57 57 | # Dict/Set/List/Tuple -58 58 | print({"a": a.__add__(1)}) # PLC2801 unnecessary_dunder_call.py:58:13: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. | @@ -823,15 +480,6 @@ unnecessary_dunder_call.py:58:13: PLC2801 [*] Unnecessary dunder call to `__add_ | = help: Use `+` operator -ℹ Unsafe fix -55 55 | print(a.__add__(1) if a > 0 else a.__sub__(1)) # PLC2801 -56 56 | -57 57 | # Dict/Set/List/Tuple -58 |-print({"a": a.__add__(1)}) # PLC2801 - 58 |+print({"a": a + 1}) # PLC2801 -59 59 | print({a.__add__(1)}) # PLC2801 -60 60 | print([a.__add__(1)]) # PLC2801 -61 61 | print((a.__add__(1),)) # PLC2801 unnecessary_dunder_call.py:59:8: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. | @@ -844,15 +492,6 @@ unnecessary_dunder_call.py:59:8: PLC2801 [*] Unnecessary dunder call to `__add__ | = help: Use `+` operator -ℹ Unsafe fix -56 56 | -57 57 | # Dict/Set/List/Tuple -58 58 | print({"a": a.__add__(1)}) # PLC2801 -59 |-print({a.__add__(1)}) # PLC2801 - 59 |+print({a + 1}) # PLC2801 -60 60 | print([a.__add__(1)]) # PLC2801 -61 61 | print((a.__add__(1),)) # PLC2801 -62 62 | unnecessary_dunder_call.py:60:8: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. | @@ -864,15 +503,6 @@ unnecessary_dunder_call.py:60:8: PLC2801 [*] Unnecessary dunder call to `__add__ | = help: Use `+` operator -ℹ Unsafe fix -57 57 | # Dict/Set/List/Tuple -58 58 | print({"a": a.__add__(1)}) # PLC2801 -59 59 | print({a.__add__(1)}) # PLC2801 -60 |-print([a.__add__(1)]) # PLC2801 - 60 |+print([a + 1]) # PLC2801 -61 61 | print((a.__add__(1),)) # PLC2801 -62 62 | -63 63 | # Comprehension variants unnecessary_dunder_call.py:61:8: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. | @@ -885,15 +515,6 @@ unnecessary_dunder_call.py:61:8: PLC2801 [*] Unnecessary dunder call to `__add__ | = help: Use `+` operator -ℹ Unsafe fix -58 58 | print({"a": a.__add__(1)}) # PLC2801 -59 59 | print({a.__add__(1)}) # PLC2801 -60 60 | print([a.__add__(1)]) # PLC2801 -61 |-print((a.__add__(1),)) # PLC2801 - 61 |+print((a + 1,)) # PLC2801 -62 62 | -63 63 | # Comprehension variants -64 64 | print({i: i.__add__(1) for i in range(5)}) # PLC2801 unnecessary_dunder_call.py:64:11: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. | @@ -905,15 +526,6 @@ unnecessary_dunder_call.py:64:11: PLC2801 [*] Unnecessary dunder call to `__add_ | = help: Use `+` operator -ℹ Unsafe fix -61 61 | print((a.__add__(1),)) # PLC2801 -62 62 | -63 63 | # Comprehension variants -64 |-print({i: i.__add__(1) for i in range(5)}) # PLC2801 - 64 |+print({i: i + 1 for i in range(5)}) # PLC2801 -65 65 | print({i.__add__(1) for i in range(5)}) # PLC2801 -66 66 | print([i.__add__(1) for i in range(5)]) # PLC2801 -67 67 | print((i.__add__(1) for i in range(5))) # PLC2801 unnecessary_dunder_call.py:65:8: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. | @@ -926,15 +538,6 @@ unnecessary_dunder_call.py:65:8: PLC2801 [*] Unnecessary dunder call to `__add__ | = help: Use `+` operator -ℹ Unsafe fix -62 62 | -63 63 | # Comprehension variants -64 64 | print({i: i.__add__(1) for i in range(5)}) # PLC2801 -65 |-print({i.__add__(1) for i in range(5)}) # PLC2801 - 65 |+print({i + 1 for i in range(5)}) # PLC2801 -66 66 | print([i.__add__(1) for i in range(5)]) # PLC2801 -67 67 | print((i.__add__(1) for i in range(5))) # PLC2801 -68 68 | unnecessary_dunder_call.py:66:8: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. | @@ -946,15 +549,6 @@ unnecessary_dunder_call.py:66:8: PLC2801 [*] Unnecessary dunder call to `__add__ | = help: Use `+` operator -ℹ Unsafe fix -63 63 | # Comprehension variants -64 64 | print({i: i.__add__(1) for i in range(5)}) # PLC2801 -65 65 | print({i.__add__(1) for i in range(5)}) # PLC2801 -66 |-print([i.__add__(1) for i in range(5)]) # PLC2801 - 66 |+print([i + 1 for i in range(5)]) # PLC2801 -67 67 | print((i.__add__(1) for i in range(5))) # PLC2801 -68 68 | -69 69 | # Generators unnecessary_dunder_call.py:67:8: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. | @@ -967,15 +561,6 @@ unnecessary_dunder_call.py:67:8: PLC2801 [*] Unnecessary dunder call to `__add__ | = help: Use `+` operator -ℹ Unsafe fix -64 64 | print({i: i.__add__(1) for i in range(5)}) # PLC2801 -65 65 | print({i.__add__(1) for i in range(5)}) # PLC2801 -66 66 | print([i.__add__(1) for i in range(5)]) # PLC2801 -67 |-print((i.__add__(1) for i in range(5))) # PLC2801 - 67 |+print((i + 1 for i in range(5))) # PLC2801 -68 68 | -69 69 | # Generators -70 70 | gen = (i.__add__(1) for i in range(5)) # PLC2801 unnecessary_dunder_call.py:70:8: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. | @@ -986,15 +571,6 @@ unnecessary_dunder_call.py:70:8: PLC2801 [*] Unnecessary dunder call to `__add__ | = help: Use `+` operator -ℹ Unsafe fix -67 67 | print((i.__add__(1) for i in range(5))) # PLC2801 -68 68 | -69 69 | # Generators -70 |-gen = (i.__add__(1) for i in range(5)) # PLC2801 - 70 |+gen = (i + 1 for i in range(5)) # PLC2801 -71 71 | print(next(gen)) -72 72 | -73 73 | # Subscripts unnecessary_dunder_call.py:74:13: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. | @@ -1006,15 +582,6 @@ unnecessary_dunder_call.py:74:13: PLC2801 [*] Unnecessary dunder call to `__add_ | = help: Use `+` operator -ℹ Unsafe fix -71 71 | print(next(gen)) -72 72 | -73 73 | # Subscripts -74 |-print({"a": a.__add__(1)}["a"]) # PLC2801 - 74 |+print({"a": a + 1}["a"]) # PLC2801 -75 75 | -76 76 | # Starred -77 77 | print(*[a.__add__(1)]) # PLC2801 unnecessary_dunder_call.py:77:9: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. | @@ -1026,15 +593,6 @@ unnecessary_dunder_call.py:77:9: PLC2801 [*] Unnecessary dunder call to `__add__ | = help: Use `+` operator -ℹ Unsafe fix -74 74 | print({"a": a.__add__(1)}["a"]) # PLC2801 -75 75 | -76 76 | # Starred -77 |-print(*[a.__add__(1)]) # PLC2801 - 77 |+print(*[a + 1]) # PLC2801 -78 78 | -79 79 | # Slices -80 80 | print([a.__add__(1), a.__sub__(1)][0:1]) # PLC2801 unnecessary_dunder_call.py:80:8: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. | @@ -1044,15 +602,6 @@ unnecessary_dunder_call.py:80:8: PLC2801 [*] Unnecessary dunder call to `__add__ | = help: Use `+` operator -ℹ Unsafe fix -77 77 | print(*[a.__add__(1)]) # PLC2801 -78 78 | -79 79 | # Slices -80 |-print([a.__add__(1), a.__sub__(1)][0:1]) # PLC2801 - 80 |+print([a + 1, a.__sub__(1)][0:1]) # PLC2801 -81 81 | -82 82 | -83 83 | class Thing: unnecessary_dunder_call.py:80:22: PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. | @@ -1062,15 +611,6 @@ unnecessary_dunder_call.py:80:22: PLC2801 [*] Unnecessary dunder call to `__sub_ | = help: Use `-` operator -ℹ Unsafe fix -77 77 | print(*[a.__add__(1)]) # PLC2801 -78 78 | -79 79 | # Slices -80 |-print([a.__add__(1), a.__sub__(1)][0:1]) # PLC2801 - 80 |+print([a.__add__(1), a - 1][0:1]) # PLC2801 -81 81 | -82 82 | -83 83 | class Thing: unnecessary_dunder_call.py:92:16: PLC2801 Unnecessary dunder call to `__getattribute__`. Access attribute directly or use getattr built-in function. | @@ -1081,5 +621,3 @@ unnecessary_dunder_call.py:92:16: PLC2801 Unnecessary dunder call to `__getattri 94 | def use_descriptor(self, item): | = help: Access attribute directly or use getattr built-in function - - diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0241_duplicate_bases.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0241_duplicate_bases.py.snap index f939250ceb6f3..378aa0f6675ff 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0241_duplicate_bases.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0241_duplicate_bases.py.snap @@ -10,7 +10,6 @@ duplicate_bases.py:13:13: PLE0241 [*] Duplicate base `A` for class `F1` | = help: Remove duplicate base -ℹ Safe fix 10 10 | 11 11 | 12 12 | # Duplicate base class is last. @@ -28,7 +27,6 @@ duplicate_bases.py:17:13: PLE0241 [*] Duplicate base `A` for class `F2` | = help: Remove duplicate base -ℹ Safe fix 14 14 | ... 15 15 | 16 16 | @@ -49,7 +47,6 @@ duplicate_bases.py:23:5: PLE0241 [*] Duplicate base `A` for class `F3` | = help: Remove duplicate base -ℹ Safe fix 19 19 | 20 20 | 21 21 | class F3( @@ -69,7 +66,6 @@ duplicate_bases.py:30:5: PLE0241 [*] Duplicate base `A` for class `F4` | = help: Remove duplicate base -ℹ Safe fix 27 27 | 28 28 | class F4( 29 29 | A, @@ -87,7 +83,6 @@ duplicate_bases.py:36:13: PLE0241 [*] Duplicate base `A` for class `G1` | = help: Remove duplicate base -ℹ Safe fix 33 33 | 34 34 | 35 35 | # Duplicate base class is not last. @@ -105,7 +100,6 @@ duplicate_bases.py:40:13: PLE0241 [*] Duplicate base `A` for class `G2` | = help: Remove duplicate base -ℹ Safe fix 37 37 | ... 38 38 | 39 39 | @@ -126,7 +120,6 @@ duplicate_bases.py:46:5: PLE0241 [*] Duplicate base `A` for class `G3` | = help: Remove duplicate base -ℹ Safe fix 43 43 | 44 44 | class G3( 45 45 | A, @@ -146,7 +139,6 @@ duplicate_bases.py:54:5: PLE0241 [*] Duplicate base `A` for class `G4` | = help: Remove duplicate base -ℹ Safe fix 51 51 | 52 52 | class G4( 53 53 | A, diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1141_dict_iter_missing_items.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1141_dict_iter_missing_items.py.snap index 34684ce92dac2..6263c576baa07 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1141_dict_iter_missing_items.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1141_dict_iter_missing_items.py.snap @@ -10,7 +10,6 @@ dict_iter_missing_items.py:13:13: PLE1141 [*] Unpacking a dictionary in iteratio | = help: Add a call to `.items()` -ℹ Safe fix 10 10 | s2 = {1, 2, 3} 11 11 | 12 12 | # Errors @@ -30,7 +29,6 @@ dict_iter_missing_items.py:16:13: PLE1141 [*] Unpacking a dictionary in iteratio | = help: Add a call to `.items()` -ℹ Safe fix 13 13 | for k, v in d: 14 14 | pass 15 15 | @@ -38,6 +36,4 @@ dict_iter_missing_items.py:16:13: PLE1141 [*] Unpacking a dictionary in iteratio 16 |+for k, v in d_tuple_incorrect_tuple.items(): 17 17 | pass 18 18 | -19 19 | - - +19 19 | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1519_singledispatch_method.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1519_singledispatch_method.py.snap index caa3e35b7c10e..5618eba730265 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1519_singledispatch_method.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1519_singledispatch_method.py.snap @@ -11,15 +11,6 @@ singledispatch_method.py:10:5: PLE1519 [*] `@singledispatch` decorator should no | = help: Replace with `@singledispatchmethod` -ℹ Unsafe fix -7 7 | -8 8 | -9 9 | class Board: -10 |- @singledispatch # [singledispatch-method] - 10 |+ @singledispatchmethod # [singledispatch-method] -11 11 | @classmethod -12 12 | def convert_position(cls, position): -13 13 | pass singledispatch_method.py:15:5: PLE1519 [*] `@singledispatch` decorator should not be used on methods | @@ -32,15 +23,6 @@ singledispatch_method.py:15:5: PLE1519 [*] `@singledispatch` decorator should no | = help: Replace with `@singledispatchmethod` -ℹ Unsafe fix -12 12 | def convert_position(cls, position): -13 13 | pass -14 14 | -15 |- @singledispatch # [singledispatch-method] - 15 |+ @singledispatchmethod # [singledispatch-method] -16 16 | def move(self, position): -17 17 | pass -18 18 | singledispatch_method.py:23:5: PLE1519 [*] `@singledispatch` decorator should not be used on methods | @@ -52,13 +34,3 @@ singledispatch_method.py:23:5: PLE1519 [*] `@singledispatch` decorator should no 25 | def do(position): | = help: Replace with `@singledispatchmethod` - -ℹ Unsafe fix -20 20 | def place(self, position): -21 21 | pass -22 22 | -23 |- @singledispatch # [singledispatch-method] - 23 |+ @singledispatchmethod # [singledispatch-method] -24 24 | @staticmethod -25 25 | def do(position): -26 26 | pass diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1520_singledispatchmethod_function.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1520_singledispatchmethod_function.py.snap index 1507083e5817f..abf02071c2fbc 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1520_singledispatchmethod_function.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1520_singledispatchmethod_function.py.snap @@ -9,14 +9,3 @@ singledispatchmethod_function.py:4:1: PLE1520 [*] `@singledispatchmethod` decora 6 | pass | = help: Replace with `@singledispatch` - -ℹ Unsafe fix -1 |-from functools import singledispatchmethod - 1 |+from functools import singledispatchmethod, singledispatch -2 2 | -3 3 | -4 |-@singledispatchmethod # [singledispatchmethod-function] - 4 |+@singledispatch # [singledispatchmethod-function] -5 5 | def convert_position(position): -6 6 | pass -7 7 | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2510_invalid_characters.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2510_invalid_characters.py.snap index 3f23d12764d77..97c6182930b3c 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2510_invalid_characters.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2510_invalid_characters.py.snap @@ -11,7 +11,6 @@ invalid_characters.py:15:6: PLE2510 [*] Invalid unescaped character backspace, u | = help: Replace with escape sequence -ℹ Safe fix 12 12 | # (Pylint, "C0414") => Rule::UselessImportAlias, 13 13 | # (Pylint, "C3002") => Rule::UnnecessaryDirectLambdaCall, 14 14 | #foo = 'hi' @@ -32,7 +31,6 @@ invalid_characters.py:16:7: PLE2510 [*] Invalid unescaped character backspace, u | = help: Replace with escape sequence -ℹ Safe fix 13 13 | # (Pylint, "C3002") => Rule::UnnecessaryDirectLambdaCall, 14 14 | #foo = 'hi' 15 15 | b = '␈' @@ -53,7 +51,6 @@ invalid_characters.py:55:21: PLE2510 [*] Invalid unescaped character backspace, | = help: Replace with escape sequence -ℹ Safe fix 52 52 | zwsp_after_multicharacter_grapheme_cluster = "ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" 53 53 | zwsp_after_multicharacter_grapheme_cluster = f"ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" 54 54 | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2512_invalid_characters.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2512_invalid_characters.py.snap index 3ef59bd9291bd..7ae9f99bc8572 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2512_invalid_characters.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2512_invalid_characters.py.snap @@ -11,7 +11,6 @@ invalid_characters.py:24:12: PLE2512 [*] Invalid unescaped character SUB, use "\ | = help: Replace with escape sequence -ℹ Safe fix 21 21 | cr_ok = '\\r' 22 22 | cr_ok = f'\\r' 23 23 | @@ -31,7 +30,6 @@ invalid_characters.py:25:13: PLE2512 [*] Invalid unescaped character SUB, use "\ | = help: Replace with escape sequence -ℹ Safe fix 22 22 | cr_ok = f'\\r' 23 23 | 24 24 | sub = 'sub ' @@ -52,7 +50,6 @@ invalid_characters.py:55:25: PLE2512 [*] Invalid unescaped character SUB, use "\ | = help: Replace with escape sequence -ℹ Safe fix 52 52 | zwsp_after_multicharacter_grapheme_cluster = "ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" 53 53 | zwsp_after_multicharacter_grapheme_cluster = f"ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" 54 54 | @@ -72,7 +69,6 @@ invalid_characters.py:58:12: PLE2512 [*] Invalid unescaped character SUB, use "\ | = help: Replace with escape sequence -ℹ Safe fix 55 55 | nested_fstrings = f'␈{f'{f'␛'}'}' 56 56 | 57 57 | # https://github.com/astral-sh/ruff/issues/7455#issuecomment-1741998106 diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2513_invalid_characters.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2513_invalid_characters.py.snap index 993c89041e59f..1df7fe32a53bb 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2513_invalid_characters.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2513_invalid_characters.py.snap @@ -11,7 +11,6 @@ invalid_characters.py:30:16: PLE2513 [*] Invalid unescaped character ESC, use "\ | = help: Replace with escape sequence -ℹ Safe fix 27 27 | sub_ok = '\x1a' 28 28 | sub_ok = f'\x1a' 29 29 | @@ -31,7 +30,6 @@ invalid_characters.py:31:17: PLE2513 [*] Invalid unescaped character ESC, use "\ | = help: Replace with escape sequence -ℹ Safe fix 28 28 | sub_ok = f'\x1a' 29 29 | 30 30 | esc = 'esc esc ␛' @@ -52,7 +50,6 @@ invalid_characters.py:55:29: PLE2513 [*] Invalid unescaped character ESC, use "\ | = help: Replace with escape sequence -ℹ Safe fix 52 52 | zwsp_after_multicharacter_grapheme_cluster = "ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" 53 53 | zwsp_after_multicharacter_grapheme_cluster = f"ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" 54 54 | @@ -71,7 +68,6 @@ invalid_characters.py:60:12: PLE2513 [*] Invalid unescaped character ESC, use "\ | = help: Replace with escape sequence -ℹ Safe fix 57 57 | # https://github.com/astral-sh/ruff/issues/7455#issuecomment-1741998106 58 58 | x = f"""}}ab""" 59 59 | # https://github.com/astral-sh/ruff/issues/7455#issuecomment-1741998256 diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2514_invalid_characters.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2514_invalid_characters.py.snap index 3ab1a52ec4958..a88b20ece2d23 100644 Binary files a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2514_invalid_characters.py.snap and b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2514_invalid_characters.py.snap differ diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2515_invalid_characters.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2515_invalid_characters.py.snap index bf097d02f2cec..eabb9af2bbb3c 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2515_invalid_characters.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2515_invalid_characters.py.snap @@ -11,7 +11,6 @@ invalid_characters.py:44:13: PLE2515 [*] Invalid unescaped character zero-width- | = help: Replace with escape sequence -ℹ Safe fix 41 41 | nul_ok = '\0' 42 42 | nul_ok = f'\0' 43 43 | @@ -31,7 +30,6 @@ invalid_characters.py:45:14: PLE2515 [*] Invalid unescaped character zero-width- | = help: Replace with escape sequence -ℹ Safe fix 42 42 | nul_ok = f'\0' 43 43 | 44 44 | zwsp = 'zero​width' @@ -52,7 +50,6 @@ invalid_characters.py:50:36: PLE2515 [*] Invalid unescaped character zero-width- | = help: Replace with escape sequence -ℹ Safe fix 47 47 | zwsp_ok = '\u200b' 48 48 | zwsp_ok = f'\u200b' 49 49 | @@ -72,7 +69,6 @@ invalid_characters.py:51:37: PLE2515 [*] Invalid unescaped character zero-width- | = help: Replace with escape sequence -ℹ Safe fix 48 48 | zwsp_ok = f'\u200b' 49 49 | 50 50 | zwsp_after_multibyte_character = "ಫ​" @@ -92,7 +88,6 @@ invalid_characters.py:52:60: PLE2515 [*] Invalid unescaped character zero-width- | = help: Replace with escape sequence -ℹ Safe fix 49 49 | 50 50 | zwsp_after_multibyte_character = "ಫ​" 51 51 | zwsp_after_multibyte_character = f"ಫ​" @@ -112,7 +107,6 @@ invalid_characters.py:52:61: PLE2515 [*] Invalid unescaped character zero-width- | = help: Replace with escape sequence -ℹ Safe fix 49 49 | 50 50 | zwsp_after_multibyte_character = "ಫ​" 51 51 | zwsp_after_multibyte_character = f"ಫ​" @@ -133,7 +127,6 @@ invalid_characters.py:53:61: PLE2515 [*] Invalid unescaped character zero-width- | = help: Replace with escape sequence -ℹ Safe fix 50 50 | zwsp_after_multibyte_character = "ಫ​" 51 51 | zwsp_after_multibyte_character = f"ಫ​" 52 52 | zwsp_after_multicharacter_grapheme_cluster = "ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" @@ -154,7 +147,6 @@ invalid_characters.py:53:62: PLE2515 [*] Invalid unescaped character zero-width- | = help: Replace with escape sequence -ℹ Safe fix 50 50 | zwsp_after_multibyte_character = "ಫ​" 51 51 | zwsp_after_multibyte_character = f"ಫ​" 52 52 | zwsp_after_multicharacter_grapheme_cluster = "ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE4703_modified_iterating_set.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE4703_modified_iterating_set.py.snap index 0af466fe72d09..3d62d6a8d0c51 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE4703_modified_iterating_set.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE4703_modified_iterating_set.py.snap @@ -12,15 +12,6 @@ modified_iterating_set.py:4:1: PLE4703 [*] Iterated set `nums` is modified withi | = help: Iterate over a copy of `nums` -ℹ Unsafe fix -1 1 | # Errors -2 2 | -3 3 | nums = {1, 2, 3} -4 |-for num in nums: - 4 |+for num in nums.copy(): -5 5 | nums.add(num + 1) -6 6 | -7 7 | animals = {"dog", "cat", "cow"} modified_iterating_set.py:8:1: PLE4703 [*] Iterated set `animals` is modified within the `for` loop | @@ -33,15 +24,6 @@ modified_iterating_set.py:8:1: PLE4703 [*] Iterated set `animals` is modified wi | = help: Iterate over a copy of `animals` -ℹ Unsafe fix -5 5 | nums.add(num + 1) -6 6 | -7 7 | animals = {"dog", "cat", "cow"} -8 |-for animal in animals: - 8 |+for animal in animals.copy(): -9 9 | animals.pop("cow") -10 10 | -11 11 | fruits = {"apple", "orange", "grape"} modified_iterating_set.py:12:1: PLE4703 [*] Iterated set `fruits` is modified within the `for` loop | @@ -54,15 +36,6 @@ modified_iterating_set.py:12:1: PLE4703 [*] Iterated set `fruits` is modified wi | = help: Iterate over a copy of `fruits` -ℹ Unsafe fix -9 9 | animals.pop("cow") -10 10 | -11 11 | fruits = {"apple", "orange", "grape"} -12 |-for fruit in fruits: - 12 |+for fruit in fruits.copy(): -13 13 | fruits.clear() -14 14 | -15 15 | planets = {"mercury", "venus", "earth"} modified_iterating_set.py:16:1: PLE4703 [*] Iterated set `planets` is modified within the `for` loop | @@ -75,15 +48,6 @@ modified_iterating_set.py:16:1: PLE4703 [*] Iterated set `planets` is modified w | = help: Iterate over a copy of `planets` -ℹ Unsafe fix -13 13 | fruits.clear() -14 14 | -15 15 | planets = {"mercury", "venus", "earth"} -16 |-for planet in planets: - 16 |+for planet in planets.copy(): -17 17 | planets.discard("mercury") -18 18 | -19 19 | colors = {"red", "green", "blue"} modified_iterating_set.py:20:1: PLE4703 [*] Iterated set `colors` is modified within the `for` loop | @@ -96,15 +60,6 @@ modified_iterating_set.py:20:1: PLE4703 [*] Iterated set `colors` is modified wi | = help: Iterate over a copy of `colors` -ℹ Unsafe fix -17 17 | planets.discard("mercury") -18 18 | -19 19 | colors = {"red", "green", "blue"} -20 |-for color in colors: - 20 |+for color in colors.copy(): -21 21 | colors.remove("red") -22 22 | -23 23 | odds = {1, 3, 5} modified_iterating_set.py:24:1: PLE4703 [*] Iterated set `odds` is modified within the `for` loop | @@ -117,13 +72,3 @@ modified_iterating_set.py:24:1: PLE4703 [*] Iterated set `odds` is modified with 28 | # OK | = help: Iterate over a copy of `odds` - -ℹ Unsafe fix -21 21 | colors.remove("red") -22 22 | -23 23 | odds = {1, 3, 5} -24 |-for num in odds: - 24 |+for num in odds.copy(): -25 25 | if num > 1: -26 26 | odds.add(num + 1) -27 27 | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0202_no_method_decorator.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0202_no_method_decorator.py.snap index 8824f3dd57915..16c65a1c88885 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0202_no_method_decorator.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0202_no_method_decorator.py.snap @@ -12,7 +12,6 @@ no_method_decorator.py:9:5: PLR0202 [*] Class method defined without decorator | = help: Add @classmethod decorator -ℹ Safe fix 6 6 | def __init__(self, color): 7 7 | self.color = color 8 8 | @@ -35,7 +34,6 @@ no_method_decorator.py:22:5: PLR0202 [*] Class method defined without decorator | = help: Add @classmethod decorator -ℹ Safe fix 19 19 | pick_one_color = staticmethod(pick_one_color) 20 20 | 21 21 | class Class: diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0203_no_method_decorator.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0203_no_method_decorator.py.snap index c4f9d811b4552..c9863bfe0e55a 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0203_no_method_decorator.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0203_no_method_decorator.py.snap @@ -12,7 +12,6 @@ no_method_decorator.py:15:5: PLR0203 [*] Static method defined without decorator | = help: Add @staticmethod decorator -ℹ Safe fix 12 12 | 13 13 | pick_colors = classmethod(pick_colors) 14 14 | @@ -36,7 +35,6 @@ no_method_decorator.py:27:5: PLR0203 [*] Static method defined without decorator | = help: Add @staticmethod decorator -ℹ Safe fix 24 24 | 25 25 | class_method = classmethod(class_method);another_statement 26 26 | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0402_import_aliasing.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0402_import_aliasing.py.snap index 75384428f6ca1..0d59dd39adb80 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0402_import_aliasing.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0402_import_aliasing.py.snap @@ -12,7 +12,6 @@ import_aliasing.py:9:8: PLR0402 [*] Use `from os import path` in lieu of alias | = help: Replace with `from os import path` -ℹ Safe fix 6 6 | import collections as collections # [useless-import-alias] 7 7 | from collections import OrderedDict as OrderedDict # [useless-import-alias] 8 8 | from collections import OrderedDict as o_dict @@ -33,7 +32,6 @@ import_aliasing.py:11:8: PLR0402 [*] Use `from foo.bar import foobar` in lieu of | = help: Replace with `from foo.bar import foobar` -ℹ Safe fix 8 8 | from collections import OrderedDict as o_dict 9 9 | import os.path as path # [consider-using-from-import] 10 10 | import os.path as p @@ -53,5 +51,3 @@ import_aliasing.py:12:8: PLR0402 Use `from foo.bar import foobar` in lieu of ali 14 | import os as OS | = help: Replace with `from foo.bar import foobar` - - diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1711_useless_return.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1711_useless_return.py.snap index cf914458f4c8b..01d29c73d0e22 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1711_useless_return.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1711_useless_return.py.snap @@ -10,7 +10,6 @@ useless_return.py:6:5: PLR1711 [*] Useless `return` statement at end of function | = help: Remove useless `return` statement -ℹ Safe fix 3 3 | 4 4 | def print_python_version(): 5 5 | print(sys.version) @@ -28,7 +27,6 @@ useless_return.py:11:5: PLR1711 [*] Useless `return` statement at end of functio | = help: Remove useless `return` statement -ℹ Safe fix 8 8 | 9 9 | def print_python_version(): 10 10 | print(sys.version) @@ -46,7 +44,6 @@ useless_return.py:16:5: PLR1711 [*] Useless `return` statement at end of functio | = help: Remove useless `return` statement -ℹ Safe fix 13 13 | 14 14 | def print_python_version(): 15 15 | print(sys.version) @@ -64,7 +61,6 @@ useless_return.py:22:9: PLR1711 [*] Useless `return` statement at end of functio | = help: Remove useless `return` statement -ℹ Safe fix 19 19 | class SomeClass: 20 20 | def print_python_version(self): 21 21 | print(sys.version) @@ -82,7 +78,6 @@ useless_return.py:50:5: PLR1711 [*] Useless `return` statement at end of functio | = help: Remove useless `return` statement -ℹ Safe fix 47 47 | def print_python_version(): 48 48 | """This function returns None.""" 49 49 | print(sys.version) @@ -100,10 +95,7 @@ useless_return.py:60:9: PLR1711 [*] Useless `return` statement at end of functio | = help: Remove useless `return` statement -ℹ Safe fix 57 57 | 58 58 | def get(self, key: str) -> None: 59 59 | print(f"{key} not found") 60 |- return None - - diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1714_repeated_equality_comparison.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1714_repeated_equality_comparison.py.snap index 0c02246b06b19..5d67471505f8f 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1714_repeated_equality_comparison.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1714_repeated_equality_comparison.py.snap @@ -11,13 +11,6 @@ repeated_equality_comparison.py:2:1: PLR1714 [*] Consider merging multiple compa | = help: Merge multiple comparisons -ℹ Unsafe fix -1 1 | # Errors. -2 |-foo == "a" or foo == "b" - 2 |+foo in ("a", "b") -3 3 | -4 4 | foo != "a" and foo != "b" -5 5 | repeated_equality_comparison.py:4:1: PLR1714 [*] Consider merging multiple comparisons: `foo not in ("a", "b")`. Use a `set` if the elements are hashable. | @@ -30,15 +23,6 @@ repeated_equality_comparison.py:4:1: PLR1714 [*] Consider merging multiple compa | = help: Merge multiple comparisons -ℹ Unsafe fix -1 1 | # Errors. -2 2 | foo == "a" or foo == "b" -3 3 | -4 |-foo != "a" and foo != "b" - 4 |+foo not in ("a", "b") -5 5 | -6 6 | foo == "a" or foo == "b" or foo == "c" -7 7 | repeated_equality_comparison.py:6:1: PLR1714 [*] Consider merging multiple comparisons: `foo in ("a", "b", "c")`. Use a `set` if the elements are hashable. | @@ -51,15 +35,6 @@ repeated_equality_comparison.py:6:1: PLR1714 [*] Consider merging multiple compa | = help: Merge multiple comparisons -ℹ Unsafe fix -3 3 | -4 4 | foo != "a" and foo != "b" -5 5 | -6 |-foo == "a" or foo == "b" or foo == "c" - 6 |+foo in ("a", "b", "c") -7 7 | -8 8 | foo != "a" and foo != "b" and foo != "c" -9 9 | repeated_equality_comparison.py:8:1: PLR1714 [*] Consider merging multiple comparisons: `foo not in ("a", "b", "c")`. Use a `set` if the elements are hashable. | @@ -72,15 +47,6 @@ repeated_equality_comparison.py:8:1: PLR1714 [*] Consider merging multiple compa | = help: Merge multiple comparisons -ℹ Unsafe fix -5 5 | -6 6 | foo == "a" or foo == "b" or foo == "c" -7 7 | -8 |-foo != "a" and foo != "b" and foo != "c" - 8 |+foo not in ("a", "b", "c") -9 9 | -10 10 | foo == a or foo == "b" or foo == 3 # Mixed types. -11 11 | repeated_equality_comparison.py:10:1: PLR1714 [*] Consider merging multiple comparisons: `foo in (a, "b", 3)`. Use a `set` if the elements are hashable. | @@ -93,15 +59,6 @@ repeated_equality_comparison.py:10:1: PLR1714 [*] Consider merging multiple comp | = help: Merge multiple comparisons -ℹ Unsafe fix -7 7 | -8 8 | foo != "a" and foo != "b" and foo != "c" -9 9 | -10 |-foo == a or foo == "b" or foo == 3 # Mixed types. - 10 |+foo in (a, "b", 3) # Mixed types. -11 11 | -12 12 | "a" == foo or "b" == foo or "c" == foo -13 13 | repeated_equality_comparison.py:12:1: PLR1714 [*] Consider merging multiple comparisons: `foo in ("a", "b", "c")`. Use a `set` if the elements are hashable. | @@ -114,15 +71,6 @@ repeated_equality_comparison.py:12:1: PLR1714 [*] Consider merging multiple comp | = help: Merge multiple comparisons -ℹ Unsafe fix -9 9 | -10 10 | foo == a or foo == "b" or foo == 3 # Mixed types. -11 11 | -12 |-"a" == foo or "b" == foo or "c" == foo - 12 |+foo in ("a", "b", "c") -13 13 | -14 14 | "a" != foo and "b" != foo and "c" != foo -15 15 | repeated_equality_comparison.py:14:1: PLR1714 [*] Consider merging multiple comparisons: `foo not in ("a", "b", "c")`. Use a `set` if the elements are hashable. | @@ -135,15 +83,6 @@ repeated_equality_comparison.py:14:1: PLR1714 [*] Consider merging multiple comp | = help: Merge multiple comparisons -ℹ Unsafe fix -11 11 | -12 12 | "a" == foo or "b" == foo or "c" == foo -13 13 | -14 |-"a" != foo and "b" != foo and "c" != foo - 14 |+foo not in ("a", "b", "c") -15 15 | -16 16 | "a" == foo or foo == "b" or "c" == foo -17 17 | repeated_equality_comparison.py:16:1: PLR1714 [*] Consider merging multiple comparisons: `foo in ("a", "b", "c")`. Use a `set` if the elements are hashable. | @@ -156,15 +95,6 @@ repeated_equality_comparison.py:16:1: PLR1714 [*] Consider merging multiple comp | = help: Merge multiple comparisons -ℹ Unsafe fix -13 13 | -14 14 | "a" != foo and "b" != foo and "c" != foo -15 15 | -16 |-"a" == foo or foo == "b" or "c" == foo - 16 |+foo in ("a", "b", "c") -17 17 | -18 18 | foo == bar or baz == foo or qux == foo -19 19 | repeated_equality_comparison.py:18:1: PLR1714 [*] Consider merging multiple comparisons: `foo in (bar, baz, qux)`. Use a `set` if the elements are hashable. | @@ -177,15 +107,6 @@ repeated_equality_comparison.py:18:1: PLR1714 [*] Consider merging multiple comp | = help: Merge multiple comparisons -ℹ Unsafe fix -15 15 | -16 16 | "a" == foo or foo == "b" or "c" == foo -17 17 | -18 |-foo == bar or baz == foo or qux == foo - 18 |+foo in (bar, baz, qux) -19 19 | -20 20 | foo == "a" or "b" == foo or foo == "c" -21 21 | repeated_equality_comparison.py:20:1: PLR1714 [*] Consider merging multiple comparisons: `foo in ("a", "b", "c")`. Use a `set` if the elements are hashable. | @@ -198,15 +119,6 @@ repeated_equality_comparison.py:20:1: PLR1714 [*] Consider merging multiple comp | = help: Merge multiple comparisons -ℹ Unsafe fix -17 17 | -18 18 | foo == bar or baz == foo or qux == foo -19 19 | -20 |-foo == "a" or "b" == foo or foo == "c" - 20 |+foo in ("a", "b", "c") -21 21 | -22 22 | foo != "a" and "b" != foo and foo != "c" -23 23 | repeated_equality_comparison.py:22:1: PLR1714 [*] Consider merging multiple comparisons: `foo not in ("a", "b", "c")`. Use a `set` if the elements are hashable. | @@ -219,15 +131,6 @@ repeated_equality_comparison.py:22:1: PLR1714 [*] Consider merging multiple comp | = help: Merge multiple comparisons -ℹ Unsafe fix -19 19 | -20 20 | foo == "a" or "b" == foo or foo == "c" -21 21 | -22 |-foo != "a" and "b" != foo and foo != "c" - 22 |+foo not in ("a", "b", "c") -23 23 | -24 24 | foo == "a" or foo == "b" or "c" == bar or "d" == bar # Multiple targets -25 25 | repeated_equality_comparison.py:24:1: PLR1714 [*] Consider merging multiple comparisons: `foo in ("a", "b")`. Use a `set` if the elements are hashable. | @@ -240,15 +143,6 @@ repeated_equality_comparison.py:24:1: PLR1714 [*] Consider merging multiple comp | = help: Merge multiple comparisons -ℹ Unsafe fix -21 21 | -22 22 | foo != "a" and "b" != foo and foo != "c" -23 23 | -24 |-foo == "a" or foo == "b" or "c" == bar or "d" == bar # Multiple targets - 24 |+foo in ("a", "b") or "c" == bar or "d" == bar # Multiple targets -25 25 | -26 26 | foo.bar == "a" or foo.bar == "b" # Attributes. -27 27 | repeated_equality_comparison.py:24:1: PLR1714 [*] Consider merging multiple comparisons: `bar in ("c", "d")`. Use a `set` if the elements are hashable. | @@ -261,15 +155,6 @@ repeated_equality_comparison.py:24:1: PLR1714 [*] Consider merging multiple comp | = help: Merge multiple comparisons -ℹ Unsafe fix -21 21 | -22 22 | foo != "a" and "b" != foo and foo != "c" -23 23 | -24 |-foo == "a" or foo == "b" or "c" == bar or "d" == bar # Multiple targets - 24 |+foo == "a" or foo == "b" or bar in ("c", "d") # Multiple targets -25 25 | -26 26 | foo.bar == "a" or foo.bar == "b" # Attributes. -27 27 | repeated_equality_comparison.py:26:1: PLR1714 [*] Consider merging multiple comparisons: `foo.bar in ("a", "b")`. Use a `set` if the elements are hashable. | @@ -282,15 +167,6 @@ repeated_equality_comparison.py:26:1: PLR1714 [*] Consider merging multiple comp | = help: Merge multiple comparisons -ℹ Unsafe fix -23 23 | -24 24 | foo == "a" or foo == "b" or "c" == bar or "d" == bar # Multiple targets -25 25 | -26 |-foo.bar == "a" or foo.bar == "b" # Attributes. - 26 |+foo.bar in ("a", "b") # Attributes. -27 27 | -28 28 | # OK -29 29 | foo == "a" and foo == "b" and foo == "c" # `and` mixed with `==`. repeated_equality_comparison.py:61:16: PLR1714 [*] Consider merging multiple comparisons: `bar in ("c", "d")`. Use a `set` if the elements are hashable. | @@ -303,15 +179,6 @@ repeated_equality_comparison.py:61:16: PLR1714 [*] Consider merging multiple com | = help: Merge multiple comparisons -ℹ Unsafe fix -58 58 | -59 59 | foo == "a" or "c" == bar or foo == "b" or "d" == bar # Multiple targets -60 60 | -61 |-foo == "a" or ("c" == bar or "d" == bar) or foo == "b" # Multiple targets - 61 |+foo == "a" or (bar in ("c", "d")) or foo == "b" # Multiple targets -62 62 | -63 63 | foo == "a" or foo == "b" or "c" != bar and "d" != bar # Multiple targets -64 64 | repeated_equality_comparison.py:63:1: PLR1714 [*] Consider merging multiple comparisons: `foo in ("a", "b")`. Use a `set` if the elements are hashable. | @@ -324,15 +191,6 @@ repeated_equality_comparison.py:63:1: PLR1714 [*] Consider merging multiple comp | = help: Merge multiple comparisons -ℹ Unsafe fix -60 60 | -61 61 | foo == "a" or ("c" == bar or "d" == bar) or foo == "b" # Multiple targets -62 62 | -63 |-foo == "a" or foo == "b" or "c" != bar and "d" != bar # Multiple targets - 63 |+foo in ("a", "b") or "c" != bar and "d" != bar # Multiple targets -64 64 | -65 65 | foo == "a" or ("c" != bar and "d" != bar) or foo == "b" # Multiple targets -66 66 | repeated_equality_comparison.py:63:29: PLR1714 [*] Consider merging multiple comparisons: `bar not in ("c", "d")`. Use a `set` if the elements are hashable. | @@ -345,15 +203,6 @@ repeated_equality_comparison.py:63:29: PLR1714 [*] Consider merging multiple com | = help: Merge multiple comparisons -ℹ Unsafe fix -60 60 | -61 61 | foo == "a" or ("c" == bar or "d" == bar) or foo == "b" # Multiple targets -62 62 | -63 |-foo == "a" or foo == "b" or "c" != bar and "d" != bar # Multiple targets - 63 |+foo == "a" or foo == "b" or bar not in ("c", "d") # Multiple targets -64 64 | -65 65 | foo == "a" or ("c" != bar and "d" != bar) or foo == "b" # Multiple targets -66 66 | repeated_equality_comparison.py:65:16: PLR1714 [*] Consider merging multiple comparisons: `bar not in ("c", "d")`. Use a `set` if the elements are hashable. | @@ -365,12 +214,3 @@ repeated_equality_comparison.py:65:16: PLR1714 [*] Consider merging multiple com 67 | foo == "a" and "c" != bar or foo == "b" and "d" != bar # Multiple targets | = help: Merge multiple comparisons - -ℹ Unsafe fix -62 62 | -63 63 | foo == "a" or foo == "b" or "c" != bar and "d" != bar # Multiple targets -64 64 | -65 |-foo == "a" or ("c" != bar and "d" != bar) or foo == "b" # Multiple targets - 65 |+foo == "a" or (bar not in ("c", "d")) or foo == "b" # Multiple targets -66 66 | -67 67 | foo == "a" and "c" != bar or foo == "b" and "d" != bar # Multiple targets diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_0.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_0.py.snap index 290c2cc893219..7f557186093cc 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_0.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_0.py.snap @@ -9,13 +9,6 @@ sys_exit_alias_0.py:1:1: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Unsafe fix -1 |-exit(0) - 1 |+import sys - 2 |+sys.exit(0) -2 3 | quit(0) -3 4 | -4 5 | sys_exit_alias_0.py:2:1: PLR1722 [*] Use `sys.exit()` instead of `quit` | @@ -25,14 +18,6 @@ sys_exit_alias_0.py:2:1: PLR1722 [*] Use `sys.exit()` instead of `quit` | = help: Replace `quit` with `sys.exit()` -ℹ Unsafe fix - 1 |+import sys -1 2 | exit(0) -2 |-quit(0) - 3 |+sys.exit(0) -3 4 | -4 5 | -5 6 | def main(): sys_exit_alias_0.py:6:5: PLR1722 [*] Use `sys.exit()` instead of `exit` | @@ -43,16 +28,6 @@ sys_exit_alias_0.py:6:5: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Unsafe fix - 1 |+import sys -1 2 | exit(0) -2 3 | quit(0) -3 4 | -4 5 | -5 6 | def main(): -6 |- exit(2) - 7 |+ sys.exit(2) -7 8 | quit(2) sys_exit_alias_0.py:7:5: PLR1722 [*] Use `sys.exit()` instead of `quit` | @@ -62,16 +37,3 @@ sys_exit_alias_0.py:7:5: PLR1722 [*] Use `sys.exit()` instead of `quit` | ^^^^ PLR1722 | = help: Replace `quit` with `sys.exit()` - -ℹ Unsafe fix - 1 |+import sys -1 2 | exit(0) -2 3 | quit(0) -3 4 | -4 5 | -5 6 | def main(): -6 7 | exit(2) -7 |- quit(2) - 8 |+ sys.exit(2) - - diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_1.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_1.py.snap index f2124e8dedb5d..d187dce7b2ade 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_1.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_1.py.snap @@ -11,14 +11,6 @@ sys_exit_alias_1.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Unsafe fix -1 1 | import sys -2 2 | -3 |-exit(0) - 3 |+sys.exit(0) -4 4 | quit(0) -5 5 | -6 6 | sys_exit_alias_1.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` | @@ -28,15 +20,6 @@ sys_exit_alias_1.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` | = help: Replace `quit` with `sys.exit()` -ℹ Unsafe fix -1 1 | import sys -2 2 | -3 3 | exit(0) -4 |-quit(0) - 4 |+sys.exit(0) -5 5 | -6 6 | -7 7 | def main(): sys_exit_alias_1.py:8:5: PLR1722 [*] Use `sys.exit()` instead of `exit` | @@ -47,15 +30,6 @@ sys_exit_alias_1.py:8:5: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Unsafe fix -5 5 | -6 6 | -7 7 | def main(): -8 |- exit(1) - 8 |+ sys.exit(1) -9 9 | quit(1) -10 10 | -11 11 | sys_exit_alias_1.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` | @@ -66,15 +40,6 @@ sys_exit_alias_1.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` | = help: Replace `quit` with `sys.exit()` -ℹ Unsafe fix -6 6 | -7 7 | def main(): -8 8 | exit(1) -9 |- quit(1) - 9 |+ sys.exit(1) -10 10 | -11 11 | -12 12 | def main(): sys_exit_alias_1.py:15:5: PLR1722 Use `sys.exit()` instead of `exit` | @@ -93,5 +58,3 @@ sys_exit_alias_1.py:16:5: PLR1722 Use `sys.exit()` instead of `quit` | ^^^^ PLR1722 | = help: Replace `quit` with `sys.exit()` - - diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_11.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_11.py.snap index 4f537fcd13484..6df22e134d458 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_11.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_11.py.snap @@ -9,12 +9,3 @@ sys_exit_alias_11.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` | ^^^^ PLR1722 | = help: Replace `exit` with `sys.exit()` - -ℹ Unsafe fix -1 1 | from sys import * - 2 |+import sys -2 3 | -3 |-exit(0) - 4 |+sys.exit(0) - - diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_12.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_12.py.snap index 8221f82db5848..f844030dd86c5 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_12.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_12.py.snap @@ -9,12 +9,3 @@ sys_exit_alias_12.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` | ^^^^ PLR1722 | = help: Replace `exit` with `sys.exit()` - -ℹ Unsafe fix -1 |-import os \ - 1 |+import os; import sys \ -2 2 | -3 |-exit(0) - 3 |+sys.exit(0) - - diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_2.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_2.py.snap index d5faaa92dafae..ef0ee7ba6cb3f 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_2.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_2.py.snap @@ -11,14 +11,6 @@ sys_exit_alias_2.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Unsafe fix -1 1 | import sys as sys2 -2 2 | -3 |-exit(0) - 3 |+sys2.exit(0) -4 4 | quit(0) -5 5 | -6 6 | sys_exit_alias_2.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` | @@ -28,15 +20,6 @@ sys_exit_alias_2.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` | = help: Replace `quit` with `sys.exit()` -ℹ Unsafe fix -1 1 | import sys as sys2 -2 2 | -3 3 | exit(0) -4 |-quit(0) - 4 |+sys2.exit(0) -5 5 | -6 6 | -7 7 | def main(): sys_exit_alias_2.py:8:5: PLR1722 [*] Use `sys.exit()` instead of `exit` | @@ -47,13 +30,6 @@ sys_exit_alias_2.py:8:5: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Unsafe fix -5 5 | -6 6 | -7 7 | def main(): -8 |- exit(1) - 8 |+ sys2.exit(1) -9 9 | quit(1) sys_exit_alias_2.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` | @@ -63,12 +39,3 @@ sys_exit_alias_2.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` | ^^^^ PLR1722 | = help: Replace `quit` with `sys.exit()` - -ℹ Unsafe fix -6 6 | -7 7 | def main(): -8 8 | exit(1) -9 |- quit(1) - 9 |+ sys2.exit(1) - - diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_3.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_3.py.snap index c7faa956b3164..528f0394f9969 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_3.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_3.py.snap @@ -9,15 +9,6 @@ sys_exit_alias_3.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` | = help: Replace `quit` with `sys.exit()` -ℹ Unsafe fix -1 1 | from sys import exit -2 2 | -3 3 | exit(0) -4 |-quit(0) - 4 |+exit(0) -5 5 | -6 6 | -7 7 | def main(): sys_exit_alias_3.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` | @@ -28,15 +19,6 @@ sys_exit_alias_3.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` | = help: Replace `quit` with `sys.exit()` -ℹ Unsafe fix -6 6 | -7 7 | def main(): -8 8 | exit(1) -9 |- quit(1) - 9 |+ exit(1) -10 10 | -11 11 | -12 12 | def main(): sys_exit_alias_3.py:16:5: PLR1722 Use `sys.exit()` instead of `quit` | @@ -45,5 +27,3 @@ sys_exit_alias_3.py:16:5: PLR1722 Use `sys.exit()` instead of `quit` | ^^^^ PLR1722 | = help: Replace `quit` with `sys.exit()` - - diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_4.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_4.py.snap index 9a41754444964..6d38aa252642c 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_4.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_4.py.snap @@ -11,14 +11,6 @@ sys_exit_alias_4.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Unsafe fix -1 1 | from sys import exit as exit2 -2 2 | -3 |-exit(0) - 3 |+exit2(0) -4 4 | quit(0) -5 5 | -6 6 | sys_exit_alias_4.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` | @@ -28,15 +20,6 @@ sys_exit_alias_4.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` | = help: Replace `quit` with `sys.exit()` -ℹ Unsafe fix -1 1 | from sys import exit as exit2 -2 2 | -3 3 | exit(0) -4 |-quit(0) - 4 |+exit2(0) -5 5 | -6 6 | -7 7 | def main(): sys_exit_alias_4.py:8:5: PLR1722 [*] Use `sys.exit()` instead of `exit` | @@ -47,13 +30,6 @@ sys_exit_alias_4.py:8:5: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Unsafe fix -5 5 | -6 6 | -7 7 | def main(): -8 |- exit(1) - 8 |+ exit2(1) -9 9 | quit(1) sys_exit_alias_4.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` | @@ -63,12 +39,3 @@ sys_exit_alias_4.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` | ^^^^ PLR1722 | = help: Replace `quit` with `sys.exit()` - -ℹ Unsafe fix -6 6 | -7 7 | def main(): -8 8 | exit(1) -9 |- quit(1) - 9 |+ exit2(1) - - diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_5.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_5.py.snap index 8a6bbc5f3eadd..e06a824d5e7d1 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_5.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_5.py.snap @@ -11,15 +11,6 @@ sys_exit_alias_5.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Unsafe fix -1 1 | from sys import * - 2 |+import sys -2 3 | -3 |-exit(0) - 4 |+sys.exit(0) -4 5 | quit(0) -5 6 | -6 7 | sys_exit_alias_5.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` | @@ -29,16 +20,6 @@ sys_exit_alias_5.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` | = help: Replace `quit` with `sys.exit()` -ℹ Unsafe fix -1 1 | from sys import * - 2 |+import sys -2 3 | -3 4 | exit(0) -4 |-quit(0) - 5 |+sys.exit(0) -5 6 | -6 7 | -7 8 | def main(): sys_exit_alias_5.py:8:5: PLR1722 [*] Use `sys.exit()` instead of `exit` | @@ -49,18 +30,6 @@ sys_exit_alias_5.py:8:5: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Unsafe fix -1 1 | from sys import * - 2 |+import sys -2 3 | -3 4 | exit(0) -4 5 | quit(0) -5 6 | -6 7 | -7 8 | def main(): -8 |- exit(1) - 9 |+ sys.exit(1) -9 10 | quit(1) sys_exit_alias_5.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` | @@ -70,18 +39,3 @@ sys_exit_alias_5.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` | ^^^^ PLR1722 | = help: Replace `quit` with `sys.exit()` - -ℹ Unsafe fix -1 1 | from sys import * - 2 |+import sys -2 3 | -3 4 | exit(0) -4 5 | quit(0) --------------------------------------------------------------------------------- -6 7 | -7 8 | def main(): -8 9 | exit(1) -9 |- quit(1) - 10 |+ sys.exit(1) - - diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_6.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_6.py.snap index 87119e06653e7..0445fe5d1cdcf 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_6.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_6.py.snap @@ -9,13 +9,6 @@ sys_exit_alias_6.py:1:1: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Unsafe fix -1 |-exit(0) - 1 |+import sys - 2 |+sys.exit(0) -2 3 | quit(0) -3 4 | -4 5 | sys_exit_alias_6.py:2:1: PLR1722 [*] Use `sys.exit()` instead of `quit` | @@ -24,14 +17,3 @@ sys_exit_alias_6.py:2:1: PLR1722 [*] Use `sys.exit()` instead of `quit` | ^^^^ PLR1722 | = help: Replace `quit` with `sys.exit()` - -ℹ Unsafe fix - 1 |+import sys -1 2 | exit(0) -2 |-quit(0) - 3 |+sys.exit(0) -3 4 | -4 5 | -5 6 | def exit(e): - - diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_7.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_7.py.snap index 4c32e7cc3a49e..4b641154936f6 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_7.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_7.py.snap @@ -8,14 +8,3 @@ sys_exit_alias_7.py:2:5: PLR1722 [*] Use `sys.exit()` instead of `exit` | ^^^^ PLR1722 | = help: Replace `exit` with `sys.exit()` - -ℹ Unsafe fix - 1 |+import sys -1 2 | def main(): -2 |- exit(0) - 3 |+ sys.exit(0) -3 4 | -4 5 | -5 6 | import functools - - diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_8.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_8.py.snap index 1423a41dba204..78989894f649c 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_8.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_8.py.snap @@ -8,12 +8,3 @@ sys_exit_alias_8.py:5:5: PLR1722 [*] Use `sys.exit()` instead of `exit` | ^^^^ PLR1722 | = help: Replace `exit` with `sys.exit()` - -ℹ Unsafe fix -1 |-from sys import argv - 1 |+from sys import argv, exit -2 2 | -3 3 | -4 4 | def main(): - - diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_9.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_9.py.snap index 23107f606658f..fafd6967976d0 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_9.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_9.py.snap @@ -8,14 +8,3 @@ sys_exit_alias_9.py:2:5: PLR1722 [*] Use `sys.exit()` instead of `exit` | ^^^^ PLR1722 | = help: Replace `exit` with `sys.exit()` - -ℹ Unsafe fix - 1 |+import sys -1 2 | def main(): -2 |- exit(0) - 3 |+ sys.exit(0) -3 4 | -4 5 | -5 6 | from sys import argv - - diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1730_if_stmt_min_max.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1730_if_stmt_min_max.py.snap index 52baee302a31d..1c9b90ac67502 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1730_if_stmt_min_max.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1730_if_stmt_min_max.py.snap @@ -12,7 +12,6 @@ if_stmt_min_max.py:8:1: PLR1730 [*] Replace `if` statement with `value = max(val | = help: Replace with `value = max(value, 10)` -ℹ Safe fix 5 5 | value3 = 3 6 6 | 7 7 | # Positive @@ -35,7 +34,6 @@ if_stmt_min_max.py:11:1: PLR1730 [*] Replace `if` statement with `value = max(10 | = help: Replace with `value = max(10, value)` -ℹ Safe fix 8 8 | if value < 10: # [max-instead-of-if] 9 9 | value = 10 10 10 | @@ -58,7 +56,6 @@ if_stmt_min_max.py:14:1: PLR1730 [*] Replace `if` statement with `value = max(va | = help: Replace with `value = max(value, value2)` -ℹ Safe fix 11 11 | if value <= 10: # [max-instead-of-if] 12 12 | value = 10 13 13 | @@ -81,7 +78,6 @@ if_stmt_min_max.py:17:1: PLR1730 [*] Replace `if` statement with `value = min(va | = help: Replace with `value = min(value, 10)` -ℹ Safe fix 14 14 | if value < value2: # [max-instead-of-if] 15 15 | value = value2 16 16 | @@ -104,7 +100,6 @@ if_stmt_min_max.py:20:1: PLR1730 [*] Replace `if` statement with `value = min(10 | = help: Replace with `value = min(10, value)` -ℹ Safe fix 17 17 | if value > 10: # [min-instead-of-if] 18 18 | value = 10 19 19 | @@ -125,7 +120,6 @@ if_stmt_min_max.py:23:1: PLR1730 [*] Replace `if` statement with `value = min(va | = help: Replace with `value = min(value, value2)` -ℹ Safe fix 20 20 | if value >= 10: # [min-instead-of-if] 21 21 | value = 10 22 22 | @@ -147,7 +141,6 @@ if_stmt_min_max.py:33:1: PLR1730 [*] Replace `if` statement with `A1.value = max | = help: Replace with `A1.value = max(A1.value, 10)` -ℹ Safe fix 30 30 | 31 31 | 32 32 | A1 = A() @@ -168,7 +161,6 @@ if_stmt_min_max.py:36:1: PLR1730 [*] Replace `if` statement with `A1.value = min | = help: Replace with `A1.value = min(A1.value, 10)` -ℹ Safe fix 33 33 | if A1.value < 10: # [max-instead-of-if] 34 34 | A1.value = 10 35 35 | @@ -191,7 +183,6 @@ if_stmt_min_max.py:60:1: PLR1730 [*] Replace `if` statement with `A2 = max(A2, A | = help: Replace with `A2 = max(A2, A1)` -ℹ Safe fix 57 57 | A1 = AA(0) 58 58 | A2 = AA(3) 59 59 | @@ -214,7 +205,6 @@ if_stmt_min_max.py:63:1: PLR1730 [*] Replace `if` statement with `A2 = max(A1, A | = help: Replace with `A2 = max(A1, A2)` -ℹ Safe fix 60 60 | if A2 < A1: # [max-instead-of-if] 61 61 | A2 = A1 62 62 | @@ -237,7 +227,6 @@ if_stmt_min_max.py:66:1: PLR1730 [*] Replace `if` statement with `A2 = min(A2, A | = help: Replace with `A2 = min(A2, A1)` -ℹ Safe fix 63 63 | if A2 <= A1: # [max-instead-of-if] 64 64 | A2 = A1 65 65 | @@ -260,7 +249,6 @@ if_stmt_min_max.py:69:1: PLR1730 [*] Replace `if` statement with `A2 = min(A1, A | = help: Replace with `A2 = min(A1, A2)` -ℹ Safe fix 66 66 | if A2 > A1: # [min-instead-of-if] 67 67 | A2 = A1 68 68 | @@ -285,7 +273,6 @@ if_stmt_min_max.py:132:1: PLR1730 [*] Replace `if` statement with `min` call | = help: Replace with `min` call -ℹ Safe fix 129 129 | value = 2 130 130 | 131 131 | # Parenthesized expressions @@ -312,7 +299,6 @@ if_stmt_min_max.py:143:9: PLR1730 [*] Replace `if` statement with `self._min = m | = help: Replace with `self._min = min(value, self._min)` -ℹ Safe fix 140 140 | _max = 0 141 141 | 142 142 | def foo(self, value) -> None: @@ -336,7 +322,6 @@ if_stmt_min_max.py:145:9: PLR1730 [*] Replace `if` statement with `self._max = m | = help: Replace with `self._max = max(value, self._max)` -ℹ Safe fix 142 142 | def foo(self, value) -> None: 143 143 | if value < self._min: 144 144 | self._min = value @@ -360,7 +345,6 @@ if_stmt_min_max.py:148:9: PLR1730 [*] Replace `if` statement with `self._min = m | = help: Replace with `self._min = max(self._min, value)` -ℹ Safe fix 145 145 | if value > self._max: 146 146 | self._max = value 147 147 | @@ -384,7 +368,6 @@ if_stmt_min_max.py:150:9: PLR1730 [*] Replace `if` statement with `self._max = m | = help: Replace with `self._max = min(self._max, value)` -ℹ Safe fix 147 147 | 148 148 | if self._min < value: 149 149 | self._min = value @@ -408,7 +391,6 @@ if_stmt_min_max.py:153:9: PLR1730 [*] Replace `if` statement with `self._min = m | = help: Replace with `self._min = min(self._min, value)` -ℹ Safe fix 150 150 | if self._max > value: 151 151 | self._max = value 152 152 | @@ -432,7 +414,6 @@ if_stmt_min_max.py:155:9: PLR1730 [*] Replace `if` statement with `self._max = m | = help: Replace with `self._max = max(self._max, value)` -ℹ Safe fix 152 152 | 153 153 | if value <= self._min: 154 154 | self._min = value @@ -456,7 +437,6 @@ if_stmt_min_max.py:158:9: PLR1730 [*] Replace `if` statement with `self._min = m | = help: Replace with `self._min = max(value, self._min)` -ℹ Safe fix 155 155 | if value >= self._max: 156 156 | self._max = value 157 157 | @@ -477,7 +457,6 @@ if_stmt_min_max.py:160:9: PLR1730 [*] Replace `if` statement with `self._max = m | = help: Replace with `self._max = min(value, self._max)` -ℹ Safe fix 157 157 | 158 158 | if self._min <= value: 159 159 | self._min = value diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1733_unnecessary_dict_index_lookup.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1733_unnecessary_dict_index_lookup.py.snap index 1f52c2ffe1329..ca77bedf83fb1 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1733_unnecessary_dict_index_lookup.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1733_unnecessary_dict_index_lookup.py.snap @@ -11,7 +11,6 @@ unnecessary_dict_index_lookup.py:4:6: PLR1733 [*] Unnecessary lookup of dictiona | = help: Use existing variable -ℹ Safe fix 1 1 | FRUITS = {"apple": 1, "orange": 10, "berry": 22} 2 2 | 3 3 | def fix_these(): @@ -31,7 +30,6 @@ unnecessary_dict_index_lookup.py:5:6: PLR1733 [*] Unnecessary lookup of dictiona | = help: Use existing variable -ℹ Safe fix 2 2 | 3 3 | def fix_these(): 4 4 | [FRUITS[fruit_name] for fruit_name, fruit_count in FRUITS.items()] # PLR1733 @@ -52,7 +50,6 @@ unnecessary_dict_index_lookup.py:6:18: PLR1733 [*] Unnecessary lookup of diction | = help: Use existing variable -ℹ Safe fix 3 3 | def fix_these(): 4 4 | [FRUITS[fruit_name] for fruit_name, fruit_count in FRUITS.items()] # PLR1733 5 5 | {FRUITS[fruit_name] for fruit_name, fruit_count in FRUITS.items()} # PLR1733 @@ -72,7 +69,6 @@ unnecessary_dict_index_lookup.py:9:15: PLR1733 [*] Unnecessary lookup of diction | = help: Use existing variable -ℹ Safe fix 6 6 | {fruit_name: FRUITS[fruit_name] for fruit_name, fruit_count in FRUITS.items()} # PLR1733 7 7 | 8 8 | for fruit_name, fruit_count in FRUITS.items(): @@ -92,7 +88,6 @@ unnecessary_dict_index_lookup.py:10:16: PLR1733 [*] Unnecessary lookup of dictio | = help: Use existing variable -ℹ Safe fix 7 7 | 8 8 | for fruit_name, fruit_count in FRUITS.items(): 9 9 | print(FRUITS[fruit_name]) # PLR1733 @@ -111,7 +106,6 @@ unnecessary_dict_index_lookup.py:11:16: PLR1733 [*] Unnecessary lookup of dictio | = help: Use existing variable -ℹ Safe fix 8 8 | for fruit_name, fruit_count in FRUITS.items(): 9 9 | print(FRUITS[fruit_name]) # PLR1733 10 10 | blah = FRUITS[fruit_name] # PLR1733 @@ -120,5 +114,3 @@ unnecessary_dict_index_lookup.py:11:16: PLR1733 [*] Unnecessary lookup of dictio 12 12 | 13 13 | 14 14 | def dont_fix_these(): - - diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1736_unnecessary_list_index_lookup.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1736_unnecessary_list_index_lookup.py.snap index a212e600b2cf7..59c27e2ac187a 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1736_unnecessary_list_index_lookup.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1736_unnecessary_list_index_lookup.py.snap @@ -11,7 +11,6 @@ unnecessary_list_index_lookup.py:7:6: PLR1736 [*] List index lookup in `enumerat | = help: Use the loop variable directly -ℹ Safe fix 4 4 | 5 5 | 6 6 | def fix_these(): @@ -31,7 +30,6 @@ unnecessary_list_index_lookup.py:8:6: PLR1736 [*] List index lookup in `enumerat | = help: Use the loop variable directly -ℹ Safe fix 5 5 | 6 6 | def fix_these(): 7 7 | [letters[index] for index, letter in enumerate(letters)] # PLR1736 @@ -52,7 +50,6 @@ unnecessary_list_index_lookup.py:9:14: PLR1736 [*] List index lookup in `enumera | = help: Use the loop variable directly -ℹ Safe fix 6 6 | def fix_these(): 7 7 | [letters[index] for index, letter in enumerate(letters)] # PLR1736 8 8 | {letters[index] for index, letter in enumerate(letters)} # PLR1736 @@ -72,7 +69,6 @@ unnecessary_list_index_lookup.py:12:15: PLR1736 [*] List index lookup in `enumer | = help: Use the loop variable directly -ℹ Safe fix 9 9 | {letter: letters[index] for index, letter in enumerate(letters)} # PLR1736 10 10 | 11 11 | for index, letter in enumerate(letters): @@ -92,7 +88,6 @@ unnecessary_list_index_lookup.py:13:16: PLR1736 [*] List index lookup in `enumer | = help: Use the loop variable directly -ℹ Safe fix 10 10 | 11 11 | for index, letter in enumerate(letters): 12 12 | print(letters[index]) # PLR1736 @@ -113,7 +108,6 @@ unnecessary_list_index_lookup.py:14:16: PLR1736 [*] List index lookup in `enumer | = help: Use the loop variable directly -ℹ Safe fix 11 11 | for index, letter in enumerate(letters): 12 12 | print(letters[index]) # PLR1736 13 13 | blah = letters[index] # PLR1736 @@ -133,7 +127,6 @@ unnecessary_list_index_lookup.py:17:15: PLR1736 [*] List index lookup in `enumer | = help: Use the loop variable directly -ℹ Safe fix 14 14 | assert letters[index] == "d" # PLR1736 15 15 | 16 16 | for index, letter in builtins.enumerate(letters): @@ -153,7 +146,6 @@ unnecessary_list_index_lookup.py:18:16: PLR1736 [*] List index lookup in `enumer | = help: Use the loop variable directly -ℹ Safe fix 15 15 | 16 16 | for index, letter in builtins.enumerate(letters): 17 17 | print(letters[index]) # PLR1736 @@ -172,7 +164,6 @@ unnecessary_list_index_lookup.py:19:16: PLR1736 [*] List index lookup in `enumer | = help: Use the loop variable directly -ℹ Safe fix 16 16 | for index, letter in builtins.enumerate(letters): 17 17 | print(letters[index]) # PLR1736 18 18 | blah = letters[index] # PLR1736 diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR2044_empty_comment.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR2044_empty_comment.py.snap index 94bb9acab3d1c..8992118556bdd 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR2044_empty_comment.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR2044_empty_comment.py.snap @@ -12,7 +12,6 @@ empty_comment.py:3:1: PLR2044 [*] Line with empty comment | = help: Delete the empty comment -ℹ Safe fix 1 1 | # this line has a non-empty comment and is OK 2 2 | # this line is also OK, but the three following lines are not 3 |-# @@ -30,7 +29,6 @@ empty_comment.py:4:5: PLR2044 [*] Line with empty comment | = help: Delete the empty comment -ℹ Safe fix 1 1 | # this line has a non-empty comment and is OK 2 2 | # this line is also OK, but the three following lines are not 3 3 | # @@ -50,7 +48,6 @@ empty_comment.py:5:9: PLR2044 [*] Line with empty comment | = help: Delete the empty comment -ℹ Safe fix 2 2 | # this line is also OK, but the three following lines are not 3 3 | # 4 4 | # @@ -67,7 +64,6 @@ empty_comment.py:18:11: PLR2044 [*] Line with empty comment | = help: Delete the empty comment -ℹ Safe fix 15 15 | 16 16 | 17 17 | def foo(): # this comment is OK, the one below is not @@ -87,7 +83,6 @@ empty_comment.py:44:1: PLR2044 [*] Line with empty comment | = help: Delete the empty comment -ℹ Safe fix 42 42 | # These should be removed, despite being an empty "block comment". 43 43 | 44 44 | # @@ -106,7 +101,6 @@ empty_comment.py:45:1: PLR2044 [*] Line with empty comment | = help: Delete the empty comment -ℹ Safe fix 42 42 | # These should be removed, despite being an empty "block comment". 43 43 | 44 44 | # @@ -123,11 +117,8 @@ empty_comment.py:58:2: PLR2044 [*] Line with empty comment | = help: Delete the empty comment -ℹ Safe fix 55 55 | # This should be removed. 56 56 | 57 57 | α = 1 58 |-α# 58 |+α - - diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR5501_collapsible_else_if.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR5501_collapsible_else_if.py.snap index 4d13e11126c9a..85177591c14c1 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR5501_collapsible_else_if.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR5501_collapsible_else_if.py.snap @@ -13,7 +13,6 @@ collapsible_else_if.py:37:5: PLR5501 [*] Use `elif` instead of `else` then `if`, | = help: Convert to `elif` -ℹ Safe fix 34 34 | def not_ok0(): 35 35 | if 1: 36 36 | pass @@ -39,7 +38,6 @@ collapsible_else_if.py:45:5: PLR5501 [*] Use `elif` instead of `else` then `if`, | = help: Convert to `elif` -ℹ Safe fix 42 42 | def not_ok1(): 43 43 | if 1: 44 44 | pass @@ -69,7 +67,6 @@ collapsible_else_if.py:55:5: PLR5501 [*] Use `elif` instead of `else` then `if`, | = help: Convert to `elif` -ℹ Safe fix 52 52 | def not_ok1_with_comments(): 53 53 | if 1: 54 54 | pass @@ -99,7 +96,6 @@ collapsible_else_if.py:69:5: PLR5501 [*] Use `elif` instead of `else` then `if`, | = help: Convert to `elif` -ℹ Safe fix 66 66 | print(1) 67 67 | elif True: 68 68 | print(2) @@ -127,7 +123,6 @@ collapsible_else_if.py:79:5: PLR5501 [*] Use `elif` instead of `else` then `if`, | = help: Convert to `elif` -ℹ Safe fix 76 76 | def not_ok3(): 77 77 | if 1: 78 78 | pass @@ -153,7 +148,6 @@ collapsible_else_if.py:87:5: PLR5501 [*] Use `elif` instead of `else` then `if`, | = help: Convert to `elif` -ℹ Safe fix 84 84 | def not_ok4(): 85 85 | if 1: 86 86 | pass @@ -180,7 +174,6 @@ collapsible_else_if.py:96:5: PLR5501 [*] Use `elif` instead of `else` then `if`, | = help: Convert to `elif` -ℹ Safe fix 93 93 | def not_ok5(): 94 94 | if 1: 95 95 | pass @@ -191,5 +184,3 @@ collapsible_else_if.py:96:5: PLR5501 [*] Use `elif` instead of `else` then `if`, 96 |+ elif 2: 97 |+ pass 98 |+ else: pass - - diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6104_non_augmented_assignment.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6104_non_augmented_assignment.py.snap index a676c83cb8bae..ef2a96c577256 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6104_non_augmented_assignment.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6104_non_augmented_assignment.py.snap @@ -12,15 +12,6 @@ non_augmented_assignment.py:16:1: PLR6104 [*] Use `+=` to perform an augmented a | = help: Replace with augmented assignment -ℹ Unsafe fix -13 13 | some_set = {"elem"} -14 14 | mat1, mat2 = None, None -15 15 | -16 |-some_string = some_string + "a very long end of string" - 16 |+some_string += "a very long end of string" -17 17 | index = index - 1 -18 18 | a_list = a_list + ["to concat"] -19 19 | some_set = some_set | {"to concat"} non_augmented_assignment.py:17:1: PLR6104 [*] Use `-=` to perform an augmented assignment directly | @@ -32,15 +23,6 @@ non_augmented_assignment.py:17:1: PLR6104 [*] Use `-=` to perform an augmented a | = help: Replace with augmented assignment -ℹ Unsafe fix -14 14 | mat1, mat2 = None, None -15 15 | -16 16 | some_string = some_string + "a very long end of string" -17 |-index = index - 1 - 17 |+index -= 1 -18 18 | a_list = a_list + ["to concat"] -19 19 | some_set = some_set | {"to concat"} -20 20 | to_multiply = to_multiply * 5 non_augmented_assignment.py:18:1: PLR6104 [*] Use `+=` to perform an augmented assignment directly | @@ -53,15 +35,6 @@ non_augmented_assignment.py:18:1: PLR6104 [*] Use `+=` to perform an augmented a | = help: Replace with augmented assignment -ℹ Unsafe fix -15 15 | -16 16 | some_string = some_string + "a very long end of string" -17 17 | index = index - 1 -18 |-a_list = a_list + ["to concat"] - 18 |+a_list += ["to concat"] -19 19 | some_set = some_set | {"to concat"} -20 20 | to_multiply = to_multiply * 5 -21 21 | to_multiply = 5 * to_multiply non_augmented_assignment.py:19:1: PLR6104 [*] Use `|=` to perform an augmented assignment directly | @@ -74,15 +47,6 @@ non_augmented_assignment.py:19:1: PLR6104 [*] Use `|=` to perform an augmented a | = help: Replace with augmented assignment -ℹ Unsafe fix -16 16 | some_string = some_string + "a very long end of string" -17 17 | index = index - 1 -18 18 | a_list = a_list + ["to concat"] -19 |-some_set = some_set | {"to concat"} - 19 |+some_set |= {"to concat"} -20 20 | to_multiply = to_multiply * 5 -21 21 | to_multiply = 5 * to_multiply -22 22 | to_multiply = to_multiply * to_multiply non_augmented_assignment.py:20:1: PLR6104 [*] Use `*=` to perform an augmented assignment directly | @@ -95,15 +59,6 @@ non_augmented_assignment.py:20:1: PLR6104 [*] Use `*=` to perform an augmented a | = help: Replace with augmented assignment -ℹ Unsafe fix -17 17 | index = index - 1 -18 18 | a_list = a_list + ["to concat"] -19 19 | some_set = some_set | {"to concat"} -20 |-to_multiply = to_multiply * 5 - 20 |+to_multiply *= 5 -21 21 | to_multiply = 5 * to_multiply -22 22 | to_multiply = to_multiply * to_multiply -23 23 | to_divide = to_divide / 5 non_augmented_assignment.py:21:1: PLR6104 [*] Use `*=` to perform an augmented assignment directly | @@ -116,15 +71,6 @@ non_augmented_assignment.py:21:1: PLR6104 [*] Use `*=` to perform an augmented a | = help: Replace with augmented assignment -ℹ Unsafe fix -18 18 | a_list = a_list + ["to concat"] -19 19 | some_set = some_set | {"to concat"} -20 20 | to_multiply = to_multiply * 5 -21 |-to_multiply = 5 * to_multiply - 21 |+to_multiply *= 5 -22 22 | to_multiply = to_multiply * to_multiply -23 23 | to_divide = to_divide / 5 -24 24 | to_divide = to_divide // 5 non_augmented_assignment.py:22:1: PLR6104 [*] Use `*=` to perform an augmented assignment directly | @@ -137,15 +83,6 @@ non_augmented_assignment.py:22:1: PLR6104 [*] Use `*=` to perform an augmented a | = help: Replace with augmented assignment -ℹ Unsafe fix -19 19 | some_set = some_set | {"to concat"} -20 20 | to_multiply = to_multiply * 5 -21 21 | to_multiply = 5 * to_multiply -22 |-to_multiply = to_multiply * to_multiply - 22 |+to_multiply *= to_multiply -23 23 | to_divide = to_divide / 5 -24 24 | to_divide = to_divide // 5 -25 25 | to_cube = to_cube**3 non_augmented_assignment.py:23:1: PLR6104 [*] Use `/=` to perform an augmented assignment directly | @@ -158,15 +95,6 @@ non_augmented_assignment.py:23:1: PLR6104 [*] Use `/=` to perform an augmented a | = help: Replace with augmented assignment -ℹ Unsafe fix -20 20 | to_multiply = to_multiply * 5 -21 21 | to_multiply = 5 * to_multiply -22 22 | to_multiply = to_multiply * to_multiply -23 |-to_divide = to_divide / 5 - 23 |+to_divide /= 5 -24 24 | to_divide = to_divide // 5 -25 25 | to_cube = to_cube**3 -26 26 | to_cube = 3**to_cube non_augmented_assignment.py:24:1: PLR6104 [*] Use `//=` to perform an augmented assignment directly | @@ -179,15 +107,6 @@ non_augmented_assignment.py:24:1: PLR6104 [*] Use `//=` to perform an augmented | = help: Replace with augmented assignment -ℹ Unsafe fix -21 21 | to_multiply = 5 * to_multiply -22 22 | to_multiply = to_multiply * to_multiply -23 23 | to_divide = to_divide / 5 -24 |-to_divide = to_divide // 5 - 24 |+to_divide //= 5 -25 25 | to_cube = to_cube**3 -26 26 | to_cube = 3**to_cube -27 27 | to_cube = to_cube**to_cube non_augmented_assignment.py:25:1: PLR6104 [*] Use `**=` to perform an augmented assignment directly | @@ -200,15 +119,6 @@ non_augmented_assignment.py:25:1: PLR6104 [*] Use `**=` to perform an augmented | = help: Replace with augmented assignment -ℹ Unsafe fix -22 22 | to_multiply = to_multiply * to_multiply -23 23 | to_divide = to_divide / 5 -24 24 | to_divide = to_divide // 5 -25 |-to_cube = to_cube**3 - 25 |+to_cube **= 3 -26 26 | to_cube = 3**to_cube -27 27 | to_cube = to_cube**to_cube -28 28 | timeDiffSeconds = timeDiffSeconds % 60 non_augmented_assignment.py:27:1: PLR6104 [*] Use `**=` to perform an augmented assignment directly | @@ -221,15 +131,6 @@ non_augmented_assignment.py:27:1: PLR6104 [*] Use `**=` to perform an augmented | = help: Replace with augmented assignment -ℹ Unsafe fix -24 24 | to_divide = to_divide // 5 -25 25 | to_cube = to_cube**3 -26 26 | to_cube = 3**to_cube -27 |-to_cube = to_cube**to_cube - 27 |+to_cube **= to_cube -28 28 | timeDiffSeconds = timeDiffSeconds % 60 -29 29 | flags = flags & 0x1 -30 30 | flags = flags | 0x1 non_augmented_assignment.py:28:1: PLR6104 [*] Use `%=` to perform an augmented assignment directly | @@ -242,15 +143,6 @@ non_augmented_assignment.py:28:1: PLR6104 [*] Use `%=` to perform an augmented a | = help: Replace with augmented assignment -ℹ Unsafe fix -25 25 | to_cube = to_cube**3 -26 26 | to_cube = 3**to_cube -27 27 | to_cube = to_cube**to_cube -28 |-timeDiffSeconds = timeDiffSeconds % 60 - 28 |+timeDiffSeconds %= 60 -29 29 | flags = flags & 0x1 -30 30 | flags = flags | 0x1 -31 31 | flags = flags ^ 0x1 non_augmented_assignment.py:29:1: PLR6104 [*] Use `&=` to perform an augmented assignment directly | @@ -263,15 +155,6 @@ non_augmented_assignment.py:29:1: PLR6104 [*] Use `&=` to perform an augmented a | = help: Replace with augmented assignment -ℹ Unsafe fix -26 26 | to_cube = 3**to_cube -27 27 | to_cube = to_cube**to_cube -28 28 | timeDiffSeconds = timeDiffSeconds % 60 -29 |-flags = flags & 0x1 - 29 |+flags &= 1 -30 30 | flags = flags | 0x1 -31 31 | flags = flags ^ 0x1 -32 32 | flags = flags << 1 non_augmented_assignment.py:30:1: PLR6104 [*] Use `|=` to perform an augmented assignment directly | @@ -284,15 +167,6 @@ non_augmented_assignment.py:30:1: PLR6104 [*] Use `|=` to perform an augmented a | = help: Replace with augmented assignment -ℹ Unsafe fix -27 27 | to_cube = to_cube**to_cube -28 28 | timeDiffSeconds = timeDiffSeconds % 60 -29 29 | flags = flags & 0x1 -30 |-flags = flags | 0x1 - 30 |+flags |= 1 -31 31 | flags = flags ^ 0x1 -32 32 | flags = flags << 1 -33 33 | flags = flags >> 1 non_augmented_assignment.py:31:1: PLR6104 [*] Use `^=` to perform an augmented assignment directly | @@ -305,15 +179,6 @@ non_augmented_assignment.py:31:1: PLR6104 [*] Use `^=` to perform an augmented a | = help: Replace with augmented assignment -ℹ Unsafe fix -28 28 | timeDiffSeconds = timeDiffSeconds % 60 -29 29 | flags = flags & 0x1 -30 30 | flags = flags | 0x1 -31 |-flags = flags ^ 0x1 - 31 |+flags ^= 1 -32 32 | flags = flags << 1 -33 33 | flags = flags >> 1 -34 34 | mat1 = mat1 @ mat2 non_augmented_assignment.py:32:1: PLR6104 [*] Use `<<=` to perform an augmented assignment directly | @@ -326,15 +191,6 @@ non_augmented_assignment.py:32:1: PLR6104 [*] Use `<<=` to perform an augmented | = help: Replace with augmented assignment -ℹ Unsafe fix -29 29 | flags = flags & 0x1 -30 30 | flags = flags | 0x1 -31 31 | flags = flags ^ 0x1 -32 |-flags = flags << 1 - 32 |+flags <<= 1 -33 33 | flags = flags >> 1 -34 34 | mat1 = mat1 @ mat2 -35 35 | a_list[1] = a_list[1] + 1 non_augmented_assignment.py:33:1: PLR6104 [*] Use `>>=` to perform an augmented assignment directly | @@ -347,15 +203,6 @@ non_augmented_assignment.py:33:1: PLR6104 [*] Use `>>=` to perform an augmented | = help: Replace with augmented assignment -ℹ Unsafe fix -30 30 | flags = flags | 0x1 -31 31 | flags = flags ^ 0x1 -32 32 | flags = flags << 1 -33 |-flags = flags >> 1 - 33 |+flags >>= 1 -34 34 | mat1 = mat1 @ mat2 -35 35 | a_list[1] = a_list[1] + 1 -36 36 | non_augmented_assignment.py:34:1: PLR6104 [*] Use `@=` to perform an augmented assignment directly | @@ -367,15 +214,6 @@ non_augmented_assignment.py:34:1: PLR6104 [*] Use `@=` to perform an augmented a | = help: Replace with augmented assignment -ℹ Unsafe fix -31 31 | flags = flags ^ 0x1 -32 32 | flags = flags << 1 -33 33 | flags = flags >> 1 -34 |-mat1 = mat1 @ mat2 - 34 |+mat1 @= mat2 -35 35 | a_list[1] = a_list[1] + 1 -36 36 | -37 37 | a_list[0:2] = a_list[0:2] * 3 non_augmented_assignment.py:35:1: PLR6104 [*] Use `+=` to perform an augmented assignment directly | @@ -388,15 +226,6 @@ non_augmented_assignment.py:35:1: PLR6104 [*] Use `+=` to perform an augmented a | = help: Replace with augmented assignment -ℹ Unsafe fix -32 32 | flags = flags << 1 -33 33 | flags = flags >> 1 -34 34 | mat1 = mat1 @ mat2 -35 |-a_list[1] = a_list[1] + 1 - 35 |+a_list[1] += 1 -36 36 | -37 37 | a_list[0:2] = a_list[0:2] * 3 -38 38 | a_list[:2] = a_list[:2] * 3 non_augmented_assignment.py:37:1: PLR6104 [*] Use `*=` to perform an augmented assignment directly | @@ -409,15 +238,6 @@ non_augmented_assignment.py:37:1: PLR6104 [*] Use `*=` to perform an augmented a | = help: Replace with augmented assignment -ℹ Unsafe fix -34 34 | mat1 = mat1 @ mat2 -35 35 | a_list[1] = a_list[1] + 1 -36 36 | -37 |-a_list[0:2] = a_list[0:2] * 3 - 37 |+a_list[0:2] *= 3 -38 38 | a_list[:2] = a_list[:2] * 3 -39 39 | a_list[1:] = a_list[1:] * 3 -40 40 | a_list[:] = a_list[:] * 3 non_augmented_assignment.py:38:1: PLR6104 [*] Use `*=` to perform an augmented assignment directly | @@ -429,15 +249,6 @@ non_augmented_assignment.py:38:1: PLR6104 [*] Use `*=` to perform an augmented a | = help: Replace with augmented assignment -ℹ Unsafe fix -35 35 | a_list[1] = a_list[1] + 1 -36 36 | -37 37 | a_list[0:2] = a_list[0:2] * 3 -38 |-a_list[:2] = a_list[:2] * 3 - 38 |+a_list[:2] *= 3 -39 39 | a_list[1:] = a_list[1:] * 3 -40 40 | a_list[:] = a_list[:] * 3 -41 41 | non_augmented_assignment.py:39:1: PLR6104 [*] Use `*=` to perform an augmented assignment directly | @@ -449,15 +260,6 @@ non_augmented_assignment.py:39:1: PLR6104 [*] Use `*=` to perform an augmented a | = help: Replace with augmented assignment -ℹ Unsafe fix -36 36 | -37 37 | a_list[0:2] = a_list[0:2] * 3 -38 38 | a_list[:2] = a_list[:2] * 3 -39 |-a_list[1:] = a_list[1:] * 3 - 39 |+a_list[1:] *= 3 -40 40 | a_list[:] = a_list[:] * 3 -41 41 | -42 42 | index = index * (index + 10) non_augmented_assignment.py:40:1: PLR6104 [*] Use `*=` to perform an augmented assignment directly | @@ -470,15 +272,6 @@ non_augmented_assignment.py:40:1: PLR6104 [*] Use `*=` to perform an augmented a | = help: Replace with augmented assignment -ℹ Unsafe fix -37 37 | a_list[0:2] = a_list[0:2] * 3 -38 38 | a_list[:2] = a_list[:2] * 3 -39 39 | a_list[1:] = a_list[1:] * 3 -40 |-a_list[:] = a_list[:] * 3 - 40 |+a_list[:] *= 3 -41 41 | -42 42 | index = index * (index + 10) -43 43 | non_augmented_assignment.py:42:1: PLR6104 [*] Use `*=` to perform an augmented assignment directly | @@ -489,15 +282,6 @@ non_augmented_assignment.py:42:1: PLR6104 [*] Use `*=` to perform an augmented a | = help: Replace with augmented assignment -ℹ Unsafe fix -39 39 | a_list[1:] = a_list[1:] * 3 -40 40 | a_list[:] = a_list[:] * 3 -41 41 | -42 |-index = index * (index + 10) - 42 |+index *= index + 10 -43 43 | -44 44 | -45 45 | class T: non_augmented_assignment.py:47:9: PLR6104 [*] Use `+=` to perform an augmented assignment directly | @@ -508,15 +292,6 @@ non_augmented_assignment.py:47:9: PLR6104 [*] Use `+=` to perform an augmented a | = help: Replace with augmented assignment -ℹ Unsafe fix -44 44 | -45 45 | class T: -46 46 | def t(self): -47 |- self.a = self.a + 1 - 47 |+ self.a += 1 -48 48 | -49 49 | -50 50 | obj = T() non_augmented_assignment.py:51:1: PLR6104 [*] Use `+=` to perform an augmented assignment directly | @@ -527,13 +302,3 @@ non_augmented_assignment.py:51:1: PLR6104 [*] Use `+=` to perform an augmented a 53 | # OK | = help: Replace with augmented assignment - -ℹ Unsafe fix -48 48 | -49 49 | -50 50 | obj = T() -51 |-obj.a = obj.a + 1 - 51 |+obj.a += 1 -52 52 | -53 53 | # OK -54 54 | a_list[0] = a_list[:] * 3 diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6201_literal_membership.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6201_literal_membership.py.snap index 98cd73be366af..476a323e4078e 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6201_literal_membership.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6201_literal_membership.py.snap @@ -11,13 +11,6 @@ literal_membership.py:2:6: PLR6201 [*] Use a set literal when testing for member | = help: Convert to `set` -ℹ Unsafe fix -1 1 | # Errors -2 |-1 in [1, 2, 3] - 2 |+1 in {1, 2, 3} -3 3 | 1 in (1, 2, 3) -4 4 | 1 in ( -5 5 | 1, 2, 3 literal_membership.py:3:6: PLR6201 [*] Use a set literal when testing for membership | @@ -30,14 +23,6 @@ literal_membership.py:3:6: PLR6201 [*] Use a set literal when testing for member | = help: Convert to `set` -ℹ Unsafe fix -1 1 | # Errors -2 2 | 1 in [1, 2, 3] -3 |-1 in (1, 2, 3) - 3 |+1 in {1, 2, 3} -4 4 | 1 in ( -5 5 | 1, 2, 3 -6 6 | ) literal_membership.py:4:6: PLR6201 [*] Use a set literal when testing for membership | @@ -53,18 +38,6 @@ literal_membership.py:4:6: PLR6201 [*] Use a set literal when testing for member | = help: Convert to `set` -ℹ Unsafe fix -1 1 | # Errors -2 2 | 1 in [1, 2, 3] -3 3 | 1 in (1, 2, 3) -4 |-1 in ( - 4 |+1 in { -5 5 | 1, 2, 3 -6 |-) - 6 |+} -7 7 | fruits = ["cherry", "grapes"] -8 8 | "cherry" in fruits -9 9 | _ = {key: value for key, value in {"a": 1, "b": 2}.items() if key in ("a", "b")} literal_membership.py:9:70: PLR6201 [*] Use a set literal when testing for membership | @@ -76,13 +49,3 @@ literal_membership.py:9:70: PLR6201 [*] Use a set literal when testing for membe 11 | # OK | = help: Convert to `set` - -ℹ Unsafe fix -6 6 | ) -7 7 | fruits = ["cherry", "grapes"] -8 8 | "cherry" in fruits -9 |-_ = {key: value for key, value in {"a": 1, "b": 2}.items() if key in ("a", "b")} - 9 |+_ = {key: value for key, value in {"a": 1, "b": 2}.items() if key in {"a", "b"}} -10 10 | -11 11 | # OK -12 12 | fruits in [[1, 2, 3], [4, 5, 6]] diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0108_unnecessary_lambda.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0108_unnecessary_lambda.py.snap index 74af7a647f7b6..e9f6154e0e8ba 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0108_unnecessary_lambda.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0108_unnecessary_lambda.py.snap @@ -9,12 +9,6 @@ unnecessary_lambda.py:1:5: PLW0108 [*] Lambda may be unnecessary; consider inlin | = help: Inline function call -ℹ Unsafe fix -1 |-_ = lambda: print() # [unnecessary-lambda] - 1 |+_ = print # [unnecessary-lambda] -2 2 | _ = lambda x, y: min(x, y) # [unnecessary-lambda] -3 3 | -4 4 | _ = lambda *args: f(*args) # [unnecessary-lambda] unnecessary_lambda.py:2:5: PLW0108 [*] Lambda may be unnecessary; consider inlining inner function | @@ -26,13 +20,6 @@ unnecessary_lambda.py:2:5: PLW0108 [*] Lambda may be unnecessary; consider inlin | = help: Inline function call -ℹ Unsafe fix -1 1 | _ = lambda: print() # [unnecessary-lambda] -2 |-_ = lambda x, y: min(x, y) # [unnecessary-lambda] - 2 |+_ = min # [unnecessary-lambda] -3 3 | -4 4 | _ = lambda *args: f(*args) # [unnecessary-lambda] -5 5 | _ = lambda **kwargs: f(**kwargs) # [unnecessary-lambda] unnecessary_lambda.py:4:5: PLW0108 [*] Lambda may be unnecessary; consider inlining inner function | @@ -45,15 +32,6 @@ unnecessary_lambda.py:4:5: PLW0108 [*] Lambda may be unnecessary; consider inlin | = help: Inline function call -ℹ Unsafe fix -1 1 | _ = lambda: print() # [unnecessary-lambda] -2 2 | _ = lambda x, y: min(x, y) # [unnecessary-lambda] -3 3 | -4 |-_ = lambda *args: f(*args) # [unnecessary-lambda] - 4 |+_ = f # [unnecessary-lambda] -5 5 | _ = lambda **kwargs: f(**kwargs) # [unnecessary-lambda] -6 6 | _ = lambda *args, **kwargs: f(*args, **kwargs) # [unnecessary-lambda] -7 7 | _ = lambda x, y, z, *args, **kwargs: f(x, y, z, *args, **kwargs) # [unnecessary-lambda] unnecessary_lambda.py:5:5: PLW0108 [*] Lambda may be unnecessary; consider inlining inner function | @@ -65,15 +43,6 @@ unnecessary_lambda.py:5:5: PLW0108 [*] Lambda may be unnecessary; consider inlin | = help: Inline function call -ℹ Unsafe fix -2 2 | _ = lambda x, y: min(x, y) # [unnecessary-lambda] -3 3 | -4 4 | _ = lambda *args: f(*args) # [unnecessary-lambda] -5 |-_ = lambda **kwargs: f(**kwargs) # [unnecessary-lambda] - 5 |+_ = f # [unnecessary-lambda] -6 6 | _ = lambda *args, **kwargs: f(*args, **kwargs) # [unnecessary-lambda] -7 7 | _ = lambda x, y, z, *args, **kwargs: f(x, y, z, *args, **kwargs) # [unnecessary-lambda] -8 8 | unnecessary_lambda.py:6:5: PLW0108 [*] Lambda may be unnecessary; consider inlining inner function | @@ -85,15 +54,6 @@ unnecessary_lambda.py:6:5: PLW0108 [*] Lambda may be unnecessary; consider inlin | = help: Inline function call -ℹ Unsafe fix -3 3 | -4 4 | _ = lambda *args: f(*args) # [unnecessary-lambda] -5 5 | _ = lambda **kwargs: f(**kwargs) # [unnecessary-lambda] -6 |-_ = lambda *args, **kwargs: f(*args, **kwargs) # [unnecessary-lambda] - 6 |+_ = f # [unnecessary-lambda] -7 7 | _ = lambda x, y, z, *args, **kwargs: f(x, y, z, *args, **kwargs) # [unnecessary-lambda] -8 8 | -9 9 | _ = lambda x: f(lambda x: x)(x) # [unnecessary-lambda] unnecessary_lambda.py:7:5: PLW0108 [*] Lambda may be unnecessary; consider inlining inner function | @@ -106,15 +66,6 @@ unnecessary_lambda.py:7:5: PLW0108 [*] Lambda may be unnecessary; consider inlin | = help: Inline function call -ℹ Unsafe fix -4 4 | _ = lambda *args: f(*args) # [unnecessary-lambda] -5 5 | _ = lambda **kwargs: f(**kwargs) # [unnecessary-lambda] -6 6 | _ = lambda *args, **kwargs: f(*args, **kwargs) # [unnecessary-lambda] -7 |-_ = lambda x, y, z, *args, **kwargs: f(x, y, z, *args, **kwargs) # [unnecessary-lambda] - 7 |+_ = f # [unnecessary-lambda] -8 8 | -9 9 | _ = lambda x: f(lambda x: x)(x) # [unnecessary-lambda] -10 10 | _ = lambda x, y: f(lambda x, y: x + y)(x, y) # [unnecessary-lambda] unnecessary_lambda.py:9:5: PLW0108 [*] Lambda may be unnecessary; consider inlining inner function | @@ -126,15 +77,6 @@ unnecessary_lambda.py:9:5: PLW0108 [*] Lambda may be unnecessary; consider inlin | = help: Inline function call -ℹ Unsafe fix -6 6 | _ = lambda *args, **kwargs: f(*args, **kwargs) # [unnecessary-lambda] -7 7 | _ = lambda x, y, z, *args, **kwargs: f(x, y, z, *args, **kwargs) # [unnecessary-lambda] -8 8 | -9 |-_ = lambda x: f(lambda x: x)(x) # [unnecessary-lambda] - 9 |+_ = f(lambda x: x) # [unnecessary-lambda] -10 10 | _ = lambda x, y: f(lambda x, y: x + y)(x, y) # [unnecessary-lambda] -11 11 | -12 12 | # default value in lambda parameters unnecessary_lambda.py:10:5: PLW0108 [*] Lambda may be unnecessary; consider inlining inner function | @@ -145,13 +87,3 @@ unnecessary_lambda.py:10:5: PLW0108 [*] Lambda may be unnecessary; consider inli 12 | # default value in lambda parameters | = help: Inline function call - -ℹ Unsafe fix -7 7 | _ = lambda x, y, z, *args, **kwargs: f(x, y, z, *args, **kwargs) # [unnecessary-lambda] -8 8 | -9 9 | _ = lambda x: f(lambda x: x)(x) # [unnecessary-lambda] -10 |-_ = lambda x, y: f(lambda x, y: x + y)(x, y) # [unnecessary-lambda] - 10 |+_ = f(lambda x, y: x + y) # [unnecessary-lambda] -11 11 | -12 12 | # default value in lambda parameters -13 13 | _ = lambda x=42: print(x) diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0120_useless_else_on_loop.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0120_useless_else_on_loop.py.snap index ea72439be9eb0..6bfc484389908 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0120_useless_else_on_loop.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0120_useless_else_on_loop.py.snap @@ -12,7 +12,6 @@ useless_else_on_loop.py:9:5: PLW0120 [*] `else` clause on loop without a `break` | = help: Remove `else` -ℹ Safe fix 6 6 | for i in range(10): 7 7 | if i % 2: 8 8 | return i @@ -34,7 +33,6 @@ useless_else_on_loop.py:18:5: PLW0120 [*] `else` clause on loop without a `break | = help: Remove `else` -ℹ Safe fix 15 15 | """else + return is not acceptable.""" 16 16 | while True: 17 17 | return 1 @@ -55,7 +53,6 @@ useless_else_on_loop.py:30:1: PLW0120 [*] `else` clause on loop without a `break | = help: Remove `else` -ℹ Safe fix 27 27 | for _ in range(10): 28 28 | break 29 29 | @@ -76,7 +73,6 @@ useless_else_on_loop.py:37:1: PLW0120 [*] `else` clause on loop without a `break | = help: Remove `else` -ℹ Safe fix 34 34 | while True: 35 35 | while False: 36 36 | break @@ -98,7 +94,6 @@ useless_else_on_loop.py:42:1: PLW0120 [*] `else` clause on loop without a `break | = help: Remove `else` -ℹ Safe fix 39 39 | 40 40 | for j in range(10): 41 41 | pass @@ -124,7 +119,6 @@ useless_else_on_loop.py:88:5: PLW0120 [*] `else` clause on loop without a `break | = help: Remove `else` -ℹ Safe fix 85 85 | break 86 86 | else: 87 87 | print("all right") @@ -146,7 +140,6 @@ useless_else_on_loop.py:98:9: PLW0120 [*] `else` clause on loop without a `break | = help: Remove `else` -ℹ Safe fix 95 95 | for _ in range(10): 96 96 | for _ in range(3): 97 97 | pass @@ -170,7 +163,6 @@ useless_else_on_loop.py:144:5: PLW0120 [*] `else` clause on loop without a `brea | = help: Remove `else` -ℹ Safe fix 141 141 | """Retain the comment within the `else` block""" 142 142 | for j in range(10): 143 143 | pass @@ -183,5 +175,3 @@ useless_else_on_loop.py:144:5: PLW0120 [*] `else` clause on loop without a `brea 145 |+ print("fat chance") 146 |+ for j in range(10): 147 |+ break - - diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0133_useless_exception_statement.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0133_useless_exception_statement.py.snap index 4b5ed1085d6e0..45515d952558c 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0133_useless_exception_statement.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0133_useless_exception_statement.py.snap @@ -10,15 +10,6 @@ useless_exception_statement.py:7:5: PLW0133 [*] Missing `raise` statement on exc | = help: Add `raise` keyword -ℹ Unsafe fix -4 4 | -5 5 | # Test case 1: Useless exception statement -6 6 | def func(): -7 |- AssertionError("This is an assertion error") # PLW0133 - 7 |+ raise AssertionError("This is an assertion error") # PLW0133 -8 8 | -9 9 | -10 10 | # Test case 2: Useless exception statement in try-except block useless_exception_statement.py:13:9: PLW0133 [*] Missing `raise` statement on exception | @@ -31,15 +22,6 @@ useless_exception_statement.py:13:9: PLW0133 [*] Missing `raise` statement on ex | = help: Add `raise` keyword -ℹ Unsafe fix -10 10 | # Test case 2: Useless exception statement in try-except block -11 11 | def func(): -12 12 | try: -13 |- Exception("This is an exception") # PLW0133 - 13 |+ raise Exception("This is an exception") # PLW0133 -14 14 | except Exception as err: -15 15 | pass -16 16 | useless_exception_statement.py:21:9: PLW0133 [*] Missing `raise` statement on exception | @@ -50,15 +32,6 @@ useless_exception_statement.py:21:9: PLW0133 [*] Missing `raise` statement on ex | = help: Add `raise` keyword -ℹ Unsafe fix -18 18 | # Test case 3: Useless exception statement in if statement -19 19 | def func(): -20 20 | if True: -21 |- RuntimeError("This is an exception") # PLW0133 - 21 |+ raise RuntimeError("This is an exception") # PLW0133 -22 22 | -23 23 | -24 24 | # Test case 4: Useless exception statement in class useless_exception_statement.py:28:13: PLW0133 [*] Missing `raise` statement on exception | @@ -69,15 +42,6 @@ useless_exception_statement.py:28:13: PLW0133 [*] Missing `raise` statement on e | = help: Add `raise` keyword -ℹ Unsafe fix -25 25 | def func(): -26 26 | class Class: -27 27 | def __init__(self): -28 |- TypeError("This is an exception") # PLW0133 - 28 |+ raise TypeError("This is an exception") # PLW0133 -29 29 | -30 30 | -31 31 | # Test case 5: Useless exception statement in function useless_exception_statement.py:34:9: PLW0133 [*] Missing `raise` statement on exception | @@ -90,15 +54,6 @@ useless_exception_statement.py:34:9: PLW0133 [*] Missing `raise` statement on ex | = help: Add `raise` keyword -ℹ Unsafe fix -31 31 | # Test case 5: Useless exception statement in function -32 32 | def func(): -33 33 | def inner(): -34 |- IndexError("This is an exception") # PLW0133 - 34 |+ raise IndexError("This is an exception") # PLW0133 -35 35 | -36 36 | inner() -37 37 | useless_exception_statement.py:42:9: PLW0133 [*] Missing `raise` statement on exception | @@ -109,15 +64,6 @@ useless_exception_statement.py:42:9: PLW0133 [*] Missing `raise` statement on ex | = help: Add `raise` keyword -ℹ Unsafe fix -39 39 | # Test case 6: Useless exception statement in while loop -40 40 | def func(): -41 41 | while True: -42 |- KeyError("This is an exception") # PLW0133 - 42 |+ raise KeyError("This is an exception") # PLW0133 -43 43 | -44 44 | -45 45 | # Test case 7: Useless exception statement in abstract class useless_exception_statement.py:50:13: PLW0133 [*] Missing `raise` statement on exception | @@ -128,15 +74,6 @@ useless_exception_statement.py:50:13: PLW0133 [*] Missing `raise` statement on e | = help: Add `raise` keyword -ℹ Unsafe fix -47 47 | class Class(ABC): -48 48 | @abstractmethod -49 49 | def method(self): -50 |- NotImplementedError("This is an exception") # PLW0133 - 50 |+ raise NotImplementedError("This is an exception") # PLW0133 -51 51 | -52 52 | -53 53 | # Test case 8: Useless exception statement inside context manager useless_exception_statement.py:56:9: PLW0133 [*] Missing `raise` statement on exception | @@ -147,15 +84,6 @@ useless_exception_statement.py:56:9: PLW0133 [*] Missing `raise` statement on ex | = help: Add `raise` keyword -ℹ Unsafe fix -53 53 | # Test case 8: Useless exception statement inside context manager -54 54 | def func(): -55 55 | with suppress(AttributeError): -56 |- AttributeError("This is an exception") # PLW0133 - 56 |+ raise AttributeError("This is an exception") # PLW0133 -57 57 | -58 58 | -59 59 | # Test case 9: Useless exception statement in parentheses useless_exception_statement.py:61:5: PLW0133 [*] Missing `raise` statement on exception | @@ -166,15 +94,6 @@ useless_exception_statement.py:61:5: PLW0133 [*] Missing `raise` statement on ex | = help: Add `raise` keyword -ℹ Unsafe fix -58 58 | -59 59 | # Test case 9: Useless exception statement in parentheses -60 60 | def func(): -61 |- (RuntimeError("This is an exception")) # PLW0133 - 61 |+ raise (RuntimeError("This is an exception")) # PLW0133 -62 62 | -63 63 | -64 64 | # Test case 10: Useless exception statement in continuation useless_exception_statement.py:66:12: PLW0133 [*] Missing `raise` statement on exception | @@ -185,15 +104,6 @@ useless_exception_statement.py:66:12: PLW0133 [*] Missing `raise` statement on e | = help: Add `raise` keyword -ℹ Unsafe fix -63 63 | -64 64 | # Test case 10: Useless exception statement in continuation -65 65 | def func(): -66 |- x = 1; (RuntimeError("This is an exception")); y = 2 # PLW0133 - 66 |+ x = 1; raise (RuntimeError("This is an exception")); y = 2 # PLW0133 -67 67 | -68 68 | -69 69 | # Test case 11: Useless warning statement useless_exception_statement.py:71:5: PLW0133 [*] Missing `raise` statement on exception | @@ -203,13 +113,3 @@ useless_exception_statement.py:71:5: PLW0133 [*] Missing `raise` statement on ex | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0133 | = help: Add `raise` keyword - -ℹ Unsafe fix -68 68 | -69 69 | # Test case 11: Useless warning statement -70 70 | def func(): -71 |- UserWarning("This is an assertion error") # PLW0133 - 71 |+ raise UserWarning("This is an assertion error") # PLW0133 -72 72 | -73 73 | -74 74 | # Non-violation test cases: PLW0133 diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0245_super_without_brackets.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0245_super_without_brackets.py.snap index d2abe86131b9d..894c9599ada2f 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0245_super_without_brackets.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0245_super_without_brackets.py.snap @@ -11,7 +11,6 @@ super_without_brackets.py:10:26: PLW0245 [*] `super` call is missing parentheses | = help: Add parentheses to `super` call -ℹ Safe fix 7 7 | class BadDog(Animal): 8 8 | @staticmethod 9 9 | def speak(): @@ -19,6 +18,4 @@ super_without_brackets.py:10:26: PLW0245 [*] `super` call is missing parentheses 10 |+ original_speak = super().speak() # PLW0245 11 11 | return f"{original_speak} But as a dog, it barks!" 12 12 | -13 13 | - - +13 13 | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1510_subprocess_run_without_check.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1510_subprocess_run_without_check.py.snap index 7419c16569584..98c60fb0a69a5 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1510_subprocess_run_without_check.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1510_subprocess_run_without_check.py.snap @@ -11,7 +11,6 @@ subprocess_run_without_check.py:4:1: PLW1510 [*] `subprocess.run` without explic | = help: Add explicit `check=False` -ℹ Safe fix 1 1 | import subprocess 2 2 | 3 3 | # Errors. @@ -32,7 +31,6 @@ subprocess_run_without_check.py:5:1: PLW1510 [*] `subprocess.run` without explic | = help: Add explicit `check=False` -ℹ Safe fix 2 2 | 3 3 | # Errors. 4 4 | subprocess.run("ls") @@ -53,7 +51,6 @@ subprocess_run_without_check.py:6:1: PLW1510 [*] `subprocess.run` without explic | = help: Add explicit `check=False` -ℹ Safe fix 5 5 | subprocess.run("ls", shell=True) 6 6 | subprocess.run( 7 7 | ["ls"], @@ -73,15 +70,3 @@ subprocess_run_without_check.py:10:1: PLW1510 [*] `subprocess.run` without expli 12 | # Non-errors. | = help: Add explicit `check=False` - -ℹ Unsafe fix -7 7 | ["ls"], -8 8 | shell=False, -9 9 | ) -10 |-subprocess.run(["ls"], **kwargs) - 10 |+subprocess.run(["ls"], **kwargs, check=False) -11 11 | -12 12 | # Non-errors. -13 13 | subprocess.run("ls", check=True) - - diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1514_unspecified_encoding.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1514_unspecified_encoding.py.snap index 9b6ebb6c85814..849dc344eed0b 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1514_unspecified_encoding.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1514_unspecified_encoding.py.snap @@ -11,15 +11,6 @@ unspecified_encoding.py:8:1: PLW1514 [*] `open` in text mode without explicit `e | = help: Add explicit `encoding` argument -ℹ Unsafe fix -5 5 | import codecs -6 6 | -7 7 | # Errors. -8 |-open("test.txt") - 8 |+open("test.txt", encoding="utf-8") -9 9 | io.TextIOWrapper(io.FileIO("test.txt")) -10 10 | hugo.TextIOWrapper(hugo.FileIO("test.txt")) -11 11 | tempfile.NamedTemporaryFile("w") unspecified_encoding.py:9:1: PLW1514 [*] `io.TextIOWrapper` without explicit `encoding` argument | @@ -32,15 +23,6 @@ unspecified_encoding.py:9:1: PLW1514 [*] `io.TextIOWrapper` without explicit `en | = help: Add explicit `encoding` argument -ℹ Unsafe fix -6 6 | -7 7 | # Errors. -8 8 | open("test.txt") -9 |-io.TextIOWrapper(io.FileIO("test.txt")) - 9 |+io.TextIOWrapper(io.FileIO("test.txt"), encoding="utf-8") -10 10 | hugo.TextIOWrapper(hugo.FileIO("test.txt")) -11 11 | tempfile.NamedTemporaryFile("w") -12 12 | tempfile.TemporaryFile("w") unspecified_encoding.py:10:1: PLW1514 [*] `io.TextIOWrapper` without explicit `encoding` argument | @@ -53,15 +35,6 @@ unspecified_encoding.py:10:1: PLW1514 [*] `io.TextIOWrapper` without explicit `e | = help: Add explicit `encoding` argument -ℹ Unsafe fix -7 7 | # Errors. -8 8 | open("test.txt") -9 9 | io.TextIOWrapper(io.FileIO("test.txt")) -10 |-hugo.TextIOWrapper(hugo.FileIO("test.txt")) - 10 |+hugo.TextIOWrapper(hugo.FileIO("test.txt"), encoding="utf-8") -11 11 | tempfile.NamedTemporaryFile("w") -12 12 | tempfile.TemporaryFile("w") -13 13 | codecs.open("test.txt") unspecified_encoding.py:11:1: PLW1514 [*] `tempfile.NamedTemporaryFile` in text mode without explicit `encoding` argument | @@ -74,15 +47,6 @@ unspecified_encoding.py:11:1: PLW1514 [*] `tempfile.NamedTemporaryFile` in text | = help: Add explicit `encoding` argument -ℹ Unsafe fix -8 8 | open("test.txt") -9 9 | io.TextIOWrapper(io.FileIO("test.txt")) -10 10 | hugo.TextIOWrapper(hugo.FileIO("test.txt")) -11 |-tempfile.NamedTemporaryFile("w") - 11 |+tempfile.NamedTemporaryFile("w", encoding="utf-8") -12 12 | tempfile.TemporaryFile("w") -13 13 | codecs.open("test.txt") -14 14 | tempfile.SpooledTemporaryFile(0, "w") unspecified_encoding.py:12:1: PLW1514 [*] `tempfile.TemporaryFile` in text mode without explicit `encoding` argument | @@ -95,15 +59,6 @@ unspecified_encoding.py:12:1: PLW1514 [*] `tempfile.TemporaryFile` in text mode | = help: Add explicit `encoding` argument -ℹ Unsafe fix -9 9 | io.TextIOWrapper(io.FileIO("test.txt")) -10 10 | hugo.TextIOWrapper(hugo.FileIO("test.txt")) -11 11 | tempfile.NamedTemporaryFile("w") -12 |-tempfile.TemporaryFile("w") - 12 |+tempfile.TemporaryFile("w", encoding="utf-8") -13 13 | codecs.open("test.txt") -14 14 | tempfile.SpooledTemporaryFile(0, "w") -15 15 | unspecified_encoding.py:13:1: PLW1514 [*] `codecs.open` in text mode without explicit `encoding` argument | @@ -115,15 +70,6 @@ unspecified_encoding.py:13:1: PLW1514 [*] `codecs.open` in text mode without exp | = help: Add explicit `encoding` argument -ℹ Unsafe fix -10 10 | hugo.TextIOWrapper(hugo.FileIO("test.txt")) -11 11 | tempfile.NamedTemporaryFile("w") -12 12 | tempfile.TemporaryFile("w") -13 |-codecs.open("test.txt") - 13 |+codecs.open("test.txt", encoding="utf-8") -14 14 | tempfile.SpooledTemporaryFile(0, "w") -15 15 | -16 16 | # Non-errors. unspecified_encoding.py:14:1: PLW1514 [*] `tempfile.SpooledTemporaryFile` in text mode without explicit `encoding` argument | @@ -136,15 +82,6 @@ unspecified_encoding.py:14:1: PLW1514 [*] `tempfile.SpooledTemporaryFile` in tex | = help: Add explicit `encoding` argument -ℹ Unsafe fix -11 11 | tempfile.NamedTemporaryFile("w") -12 12 | tempfile.TemporaryFile("w") -13 13 | codecs.open("test.txt") -14 |-tempfile.SpooledTemporaryFile(0, "w") - 14 |+tempfile.SpooledTemporaryFile(0, "w", encoding="utf-8") -15 15 | -16 16 | # Non-errors. -17 17 | open("test.txt", encoding="utf-8") unspecified_encoding.py:46:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument | @@ -157,15 +94,6 @@ unspecified_encoding.py:46:1: PLW1514 [*] `open` in text mode without explicit ` | = help: Add explicit `encoding` argument -ℹ Unsafe fix -43 43 | tempfile.SpooledTemporaryFile(0, "wb") -44 44 | tempfile.SpooledTemporaryFile(0, ) -45 45 | -46 |-open("test.txt",) - 46 |+open("test.txt", encoding="utf-8",) -47 47 | open() -48 48 | open( -49 49 | "test.txt", # comment unspecified_encoding.py:47:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument | @@ -177,15 +105,6 @@ unspecified_encoding.py:47:1: PLW1514 [*] `open` in text mode without explicit ` | = help: Add explicit `encoding` argument -ℹ Unsafe fix -44 44 | tempfile.SpooledTemporaryFile(0, ) -45 45 | -46 46 | open("test.txt",) -47 |-open() - 47 |+open(encoding="utf-8") -48 48 | open( -49 49 | "test.txt", # comment -50 50 | ) unspecified_encoding.py:48:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument | @@ -198,15 +117,6 @@ unspecified_encoding.py:48:1: PLW1514 [*] `open` in text mode without explicit ` | = help: Add explicit `encoding` argument -ℹ Unsafe fix -46 46 | open("test.txt",) -47 47 | open() -48 48 | open( -49 |- "test.txt", # comment - 49 |+ "test.txt", encoding="utf-8", # comment -50 50 | ) -51 51 | open( -52 52 | "test.txt", unspecified_encoding.py:51:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument | @@ -219,15 +129,6 @@ unspecified_encoding.py:51:1: PLW1514 [*] `open` in text mode without explicit ` | = help: Add explicit `encoding` argument -ℹ Unsafe fix -49 49 | "test.txt", # comment -50 50 | ) -51 51 | open( -52 |- "test.txt", - 52 |+ "test.txt", encoding="utf-8", -53 53 | # comment -54 54 | ) -55 55 | open(("test.txt"),) unspecified_encoding.py:55:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument | @@ -240,15 +141,6 @@ unspecified_encoding.py:55:1: PLW1514 [*] `open` in text mode without explicit ` | = help: Add explicit `encoding` argument -ℹ Unsafe fix -52 52 | "test.txt", -53 53 | # comment -54 54 | ) -55 |-open(("test.txt"),) - 55 |+open(("test.txt"), encoding="utf-8",) -56 56 | open( -57 57 | ("test.txt"), # comment -58 58 | ) unspecified_encoding.py:56:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument | @@ -261,15 +153,6 @@ unspecified_encoding.py:56:1: PLW1514 [*] `open` in text mode without explicit ` | = help: Add explicit `encoding` argument -ℹ Unsafe fix -54 54 | ) -55 55 | open(("test.txt"),) -56 56 | open( -57 |- ("test.txt"), # comment - 57 |+ ("test.txt"), encoding="utf-8", # comment -58 58 | ) -59 59 | open( -60 60 | ("test.txt"), unspecified_encoding.py:59:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument | @@ -282,15 +165,6 @@ unspecified_encoding.py:59:1: PLW1514 [*] `open` in text mode without explicit ` | = help: Add explicit `encoding` argument -ℹ Unsafe fix -57 57 | ("test.txt"), # comment -58 58 | ) -59 59 | open( -60 |- ("test.txt"), - 60 |+ ("test.txt"), encoding="utf-8", -61 61 | # comment -62 62 | ) -63 63 | unspecified_encoding.py:64:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument | @@ -303,15 +177,6 @@ unspecified_encoding.py:64:1: PLW1514 [*] `open` in text mode without explicit ` | = help: Add explicit `encoding` argument -ℹ Unsafe fix -61 61 | # comment -62 62 | ) -63 63 | -64 |-open((("test.txt")),) - 64 |+open((("test.txt")), encoding="utf-8",) -65 65 | open( -66 66 | (("test.txt")), # comment -67 67 | ) unspecified_encoding.py:65:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument | @@ -323,15 +188,6 @@ unspecified_encoding.py:65:1: PLW1514 [*] `open` in text mode without explicit ` | = help: Add explicit `encoding` argument -ℹ Unsafe fix -63 63 | -64 64 | open((("test.txt")),) -65 65 | open( -66 |- (("test.txt")), # comment - 66 |+ (("test.txt")), encoding="utf-8", # comment -67 67 | ) -68 68 | open( -69 69 | (("test.txt")), unspecified_encoding.py:68:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument | @@ -344,15 +200,6 @@ unspecified_encoding.py:68:1: PLW1514 [*] `open` in text mode without explicit ` | = help: Add explicit `encoding` argument -ℹ Unsafe fix -66 66 | (("test.txt")), # comment -67 67 | ) -68 68 | open( -69 |- (("test.txt")), - 69 |+ (("test.txt")), encoding="utf-8", -70 70 | # comment -71 71 | ) -72 72 | unspecified_encoding.py:77:1: PLW1514 [*] `pathlib.Path(...).open` in text mode without explicit `encoding` argument | @@ -364,15 +211,6 @@ unspecified_encoding.py:77:1: PLW1514 [*] `pathlib.Path(...).open` in text mode | = help: Add explicit `encoding` argument -ℹ Unsafe fix -74 74 | from pathlib import Path -75 75 | -76 76 | # Errors. -77 |-Path("foo.txt").open() - 77 |+Path("foo.txt").open(encoding="utf-8") -78 78 | Path("foo.txt").open("w") -79 79 | text = Path("foo.txt").read_text() -80 80 | Path("foo.txt").write_text(text) unspecified_encoding.py:78:1: PLW1514 [*] `pathlib.Path(...).open` in text mode without explicit `encoding` argument | @@ -385,15 +223,6 @@ unspecified_encoding.py:78:1: PLW1514 [*] `pathlib.Path(...).open` in text mode | = help: Add explicit `encoding` argument -ℹ Unsafe fix -75 75 | -76 76 | # Errors. -77 77 | Path("foo.txt").open() -78 |-Path("foo.txt").open("w") - 78 |+Path("foo.txt").open("w", encoding="utf-8") -79 79 | text = Path("foo.txt").read_text() -80 80 | Path("foo.txt").write_text(text) -81 81 | unspecified_encoding.py:79:8: PLW1514 [*] `pathlib.Path(...).read_text` without explicit `encoding` argument | @@ -405,15 +234,6 @@ unspecified_encoding.py:79:8: PLW1514 [*] `pathlib.Path(...).read_text` without | = help: Add explicit `encoding` argument -ℹ Unsafe fix -76 76 | # Errors. -77 77 | Path("foo.txt").open() -78 78 | Path("foo.txt").open("w") -79 |-text = Path("foo.txt").read_text() - 79 |+text = Path("foo.txt").read_text(encoding="utf-8") -80 80 | Path("foo.txt").write_text(text) -81 81 | -82 82 | # Non-errors. unspecified_encoding.py:80:1: PLW1514 [*] `pathlib.Path(...).write_text` without explicit `encoding` argument | @@ -425,13 +245,3 @@ unspecified_encoding.py:80:1: PLW1514 [*] `pathlib.Path(...).write_text` without 82 | # Non-errors. | = help: Add explicit `encoding` argument - -ℹ Unsafe fix -77 77 | Path("foo.txt").open() -78 78 | Path("foo.txt").open("w") -79 79 | text = Path("foo.txt").read_text() -80 |-Path("foo.txt").write_text(text) - 80 |+Path("foo.txt").write_text(text, encoding="utf-8") -81 81 | -82 82 | # Non-errors. -83 83 | Path("foo.txt").open(encoding="utf-8") diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW3301_nested_min_max.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW3301_nested_min_max.py.snap index c30473aea7e73..4532469f4172b 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW3301_nested_min_max.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW3301_nested_min_max.py.snap @@ -11,13 +11,6 @@ nested_min_max.py:2:1: PLW3301 [*] Nested `min` calls can be flattened | = help: Flatten nested `min` calls -ℹ Unsafe fix -1 1 | min(1, 2, 3) -2 |-min(1, min(2, 3)) - 2 |+min(1, 2, 3) -3 3 | min(1, min(2, min(3, 4))) -4 4 | min(1, foo("a", "b"), min(3, 4)) -5 5 | min(1, max(2, 3)) nested_min_max.py:3:1: PLW3301 [*] Nested `min` calls can be flattened | @@ -30,14 +23,6 @@ nested_min_max.py:3:1: PLW3301 [*] Nested `min` calls can be flattened | = help: Flatten nested `min` calls -ℹ Unsafe fix -1 1 | min(1, 2, 3) -2 2 | min(1, min(2, 3)) -3 |-min(1, min(2, min(3, 4))) - 3 |+min(1, 2, 3, 4) -4 4 | min(1, foo("a", "b"), min(3, 4)) -5 5 | min(1, max(2, 3)) -6 6 | max(1, 2, 3) nested_min_max.py:3:8: PLW3301 [*] Nested `min` calls can be flattened | @@ -50,14 +35,6 @@ nested_min_max.py:3:8: PLW3301 [*] Nested `min` calls can be flattened | = help: Flatten nested `min` calls -ℹ Unsafe fix -1 1 | min(1, 2, 3) -2 2 | min(1, min(2, 3)) -3 |-min(1, min(2, min(3, 4))) - 3 |+min(1, min(2, 3, 4)) -4 4 | min(1, foo("a", "b"), min(3, 4)) -5 5 | min(1, max(2, 3)) -6 6 | max(1, 2, 3) nested_min_max.py:4:1: PLW3301 [*] Nested `min` calls can be flattened | @@ -70,15 +47,6 @@ nested_min_max.py:4:1: PLW3301 [*] Nested `min` calls can be flattened | = help: Flatten nested `min` calls -ℹ Unsafe fix -1 1 | min(1, 2, 3) -2 2 | min(1, min(2, 3)) -3 3 | min(1, min(2, min(3, 4))) -4 |-min(1, foo("a", "b"), min(3, 4)) - 4 |+min(1, foo("a", "b"), 3, 4) -5 5 | min(1, max(2, 3)) -6 6 | max(1, 2, 3) -7 7 | max(1, max(2, 3)) nested_min_max.py:7:1: PLW3301 [*] Nested `max` calls can be flattened | @@ -91,15 +59,6 @@ nested_min_max.py:7:1: PLW3301 [*] Nested `max` calls can be flattened | = help: Flatten nested `max` calls -ℹ Unsafe fix -4 4 | min(1, foo("a", "b"), min(3, 4)) -5 5 | min(1, max(2, 3)) -6 6 | max(1, 2, 3) -7 |-max(1, max(2, 3)) - 7 |+max(1, 2, 3) -8 8 | max(1, max(2, max(3, 4))) -9 9 | max(1, foo("a", "b"), max(3, 4)) -10 10 | nested_min_max.py:8:1: PLW3301 [*] Nested `max` calls can be flattened | @@ -111,15 +70,6 @@ nested_min_max.py:8:1: PLW3301 [*] Nested `max` calls can be flattened | = help: Flatten nested `max` calls -ℹ Unsafe fix -5 5 | min(1, max(2, 3)) -6 6 | max(1, 2, 3) -7 7 | max(1, max(2, 3)) -8 |-max(1, max(2, max(3, 4))) - 8 |+max(1, 2, 3, 4) -9 9 | max(1, foo("a", "b"), max(3, 4)) -10 10 | -11 11 | # These should not trigger; we do not flag cases with keyword args. nested_min_max.py:8:8: PLW3301 [*] Nested `max` calls can be flattened | @@ -131,15 +81,6 @@ nested_min_max.py:8:8: PLW3301 [*] Nested `max` calls can be flattened | = help: Flatten nested `max` calls -ℹ Unsafe fix -5 5 | min(1, max(2, 3)) -6 6 | max(1, 2, 3) -7 7 | max(1, max(2, 3)) -8 |-max(1, max(2, max(3, 4))) - 8 |+max(1, max(2, 3, 4)) -9 9 | max(1, foo("a", "b"), max(3, 4)) -10 10 | -11 11 | # These should not trigger; we do not flag cases with keyword args. nested_min_max.py:9:1: PLW3301 [*] Nested `max` calls can be flattened | @@ -152,15 +93,6 @@ nested_min_max.py:9:1: PLW3301 [*] Nested `max` calls can be flattened | = help: Flatten nested `max` calls -ℹ Unsafe fix -6 6 | max(1, 2, 3) -7 7 | max(1, max(2, 3)) -8 8 | max(1, max(2, max(3, 4))) -9 |-max(1, foo("a", "b"), max(3, 4)) - 9 |+max(1, foo("a", "b"), 3, 4) -10 10 | -11 11 | # These should not trigger; we do not flag cases with keyword args. -12 12 | min(1, min(2, 3), key=test) nested_min_max.py:15:1: PLW3301 [*] Nested `min` calls can be flattened | @@ -173,15 +105,6 @@ nested_min_max.py:15:1: PLW3301 [*] Nested `min` calls can be flattened | = help: Flatten nested `min` calls -ℹ Unsafe fix -12 12 | min(1, min(2, 3), key=test) -13 13 | min(1, min(2, 3, key=test)) -14 14 | # This will still trigger, to merge the calls without keyword args. -15 |-min(1, min(2, 3, key=test), min(4, 5)) - 15 |+min(1, min(2, 3, key=test), 4, 5) -16 16 | -17 17 | # Don't provide a fix if there are comments within the call. -18 18 | min( nested_min_max.py:18:1: PLW3301 Nested `min` calls can be flattened | @@ -206,15 +129,6 @@ nested_min_max.py:24:1: PLW3301 [*] Nested `min` calls can be flattened | = help: Flatten nested `min` calls -ℹ Unsafe fix -21 21 | ) -22 22 | -23 23 | # Handle iterable expressions. -24 |-min(1, min(a)) - 24 |+min(1, *a) -25 25 | min(1, min(i for i in range(10))) -26 26 | max(1, max(a)) -27 27 | max(1, max(i for i in range(10))) nested_min_max.py:25:1: PLW3301 [*] Nested `min` calls can be flattened | @@ -227,15 +141,6 @@ nested_min_max.py:25:1: PLW3301 [*] Nested `min` calls can be flattened | = help: Flatten nested `min` calls -ℹ Unsafe fix -22 22 | -23 23 | # Handle iterable expressions. -24 24 | min(1, min(a)) -25 |-min(1, min(i for i in range(10))) - 25 |+min(1, *(i for i in range(10))) -26 26 | max(1, max(a)) -27 27 | max(1, max(i for i in range(10))) -28 28 | nested_min_max.py:26:1: PLW3301 [*] Nested `max` calls can be flattened | @@ -247,15 +152,6 @@ nested_min_max.py:26:1: PLW3301 [*] Nested `max` calls can be flattened | = help: Flatten nested `max` calls -ℹ Unsafe fix -23 23 | # Handle iterable expressions. -24 24 | min(1, min(a)) -25 25 | min(1, min(i for i in range(10))) -26 |-max(1, max(a)) - 26 |+max(1, *a) -27 27 | max(1, max(i for i in range(10))) -28 28 | -29 29 | tuples_list = [ nested_min_max.py:27:1: PLW3301 [*] Nested `max` calls can be flattened | @@ -268,15 +164,6 @@ nested_min_max.py:27:1: PLW3301 [*] Nested `max` calls can be flattened | = help: Flatten nested `max` calls -ℹ Unsafe fix -24 24 | min(1, min(a)) -25 25 | min(1, min(i for i in range(10))) -26 26 | max(1, max(a)) -27 |-max(1, max(i for i in range(10))) - 27 |+max(1, *(i for i in range(10))) -28 28 | -29 29 | tuples_list = [ -30 30 | (1, 2), nested_min_max.py:41:1: PLW3301 [*] Nested `max` calls can be flattened | @@ -288,15 +175,6 @@ nested_min_max.py:41:1: PLW3301 [*] Nested `max` calls can be flattened | = help: Flatten nested `max` calls -ℹ Unsafe fix -38 38 | max(max(tuples_list)) -39 39 | -40 40 | # Starred argument should be copied as it is. -41 |-max(1, max(*a)) - 41 |+max(1, *a) -42 42 | -43 43 | import builtins -44 44 | builtins.min(1, min(2, 3)) nested_min_max.py:44:1: PLW3301 [*] Nested `min` calls can be flattened | @@ -305,10 +183,3 @@ nested_min_max.py:44:1: PLW3301 [*] Nested `min` calls can be flattened | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW3301 | = help: Flatten nested `min` calls - -ℹ Unsafe fix -41 41 | max(1, max(*a)) -42 42 | -43 43 | import builtins -44 |-builtins.min(1, min(2, 3)) - 44 |+builtins.min(1, 2, 3) diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP001.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP001.py.snap index 1b1e0774ee5de..886ffe6bab2b7 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP001.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP001.py.snap @@ -9,7 +9,6 @@ UP001.py:2:5: UP001 [*] `__metaclass__ = type` is implied | = help: Remove `__metaclass__ = type` -ℹ Safe fix 1 1 | class A: 2 |- __metaclass__ = type 2 |+ pass @@ -27,7 +26,6 @@ UP001.py:6:5: UP001 [*] `__metaclass__ = type` is implied | = help: Remove `__metaclass__ = type` -ℹ Safe fix 3 3 | 4 4 | 5 5 | class B: @@ -35,5 +33,3 @@ UP001.py:6:5: UP001 [*] `__metaclass__ = type` is implied 7 6 | 8 7 | def __init__(self) -> None: 9 8 | pass - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP003.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP003.py.snap index 4ea8ce149125c..c20a9aa3f01f1 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP003.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP003.py.snap @@ -10,7 +10,6 @@ UP003.py:1:1: UP003 [*] Use `str` instead of `type(...)` | = help: Replace `type(...)` with `str` -ℹ Safe fix 1 |-type("") 1 |+str 2 2 | type(b"") @@ -27,7 +26,6 @@ UP003.py:2:1: UP003 [*] Use `bytes` instead of `type(...)` | = help: Replace `type(...)` with `bytes` -ℹ Safe fix 1 1 | type("") 2 |-type(b"") 2 |+bytes @@ -46,7 +44,6 @@ UP003.py:3:1: UP003 [*] Use `int` instead of `type(...)` | = help: Replace `type(...)` with `int` -ℹ Safe fix 1 1 | type("") 2 2 | type(b"") 3 |-type(0) @@ -65,7 +62,6 @@ UP003.py:4:1: UP003 [*] Use `float` instead of `type(...)` | = help: Replace `type(...)` with `float` -ℹ Safe fix 1 1 | type("") 2 2 | type(b"") 3 3 | type(0) @@ -86,7 +82,6 @@ UP003.py:5:1: UP003 [*] Use `complex` instead of `type(...)` | = help: Replace `type(...)` with `complex` -ℹ Safe fix 2 2 | type(b"") 3 3 | type(0) 4 4 | type(0.0) @@ -104,11 +99,8 @@ UP003.py:14:29: UP003 [*] Use `str` instead of `type(...)` | = help: Replace `type(...)` with `str` -ℹ Safe fix 11 11 | y = x.dtype.type(0.0) 12 12 | 13 13 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722459841 14 |-assert isinstance(fullname, type("")is not True) 14 |+assert isinstance(fullname, str is not True) - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP004.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP004.py.snap index 0c4b87c5d9dbf..2e78dfa14d4ce 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP004.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP004.py.snap @@ -9,7 +9,6 @@ UP004.py:5:9: UP004 [*] Class `A` inherits from `object` | = help: Remove `object` inheritance -ℹ Safe fix 2 2 | ... 3 3 | 4 4 | @@ -29,7 +28,6 @@ UP004.py:10:5: UP004 [*] Class `A` inherits from `object` | = help: Remove `object` inheritance -ℹ Safe fix 6 6 | ... 7 7 | 8 8 | @@ -51,7 +49,6 @@ UP004.py:16:5: UP004 [*] Class `A` inherits from `object` | = help: Remove `object` inheritance -ℹ Safe fix 12 12 | ... 13 13 | 14 14 | @@ -75,7 +72,6 @@ UP004.py:24:5: UP004 [*] Class `A` inherits from `object` | = help: Remove `object` inheritance -ℹ Safe fix 19 19 | ... 20 20 | 21 21 | @@ -99,7 +95,6 @@ UP004.py:31:5: UP004 [*] Class `A` inherits from `object` | = help: Remove `object` inheritance -ℹ Safe fix 26 26 | ... 27 27 | 28 28 | @@ -122,7 +117,6 @@ UP004.py:37:5: UP004 [*] Class `A` inherits from `object` | = help: Remove `object` inheritance -ℹ Safe fix 33 33 | ... 34 34 | 35 35 | @@ -146,7 +140,6 @@ UP004.py:45:5: UP004 [*] Class `A` inherits from `object` | = help: Remove `object` inheritance -ℹ Safe fix 40 40 | ... 41 41 | 42 42 | @@ -171,7 +164,6 @@ UP004.py:53:5: UP004 [*] Class `A` inherits from `object` | = help: Remove `object` inheritance -ℹ Safe fix 48 48 | ... 49 49 | 50 50 | @@ -196,7 +188,6 @@ UP004.py:61:5: UP004 [*] Class `A` inherits from `object` | = help: Remove `object` inheritance -ℹ Safe fix 56 56 | ... 57 57 | 58 58 | @@ -221,7 +212,6 @@ UP004.py:69:5: UP004 [*] Class `A` inherits from `object` | = help: Remove `object` inheritance -ℹ Safe fix 64 64 | ... 65 65 | 66 66 | @@ -243,7 +233,6 @@ UP004.py:75:12: UP004 [*] Class `B` inherits from `object` | = help: Remove `object` inheritance -ℹ Safe fix 72 72 | ... 73 73 | 74 74 | @@ -261,7 +250,6 @@ UP004.py:79:9: UP004 [*] Class `B` inherits from `object` | = help: Remove `object` inheritance -ℹ Safe fix 76 76 | ... 77 77 | 78 78 | @@ -281,7 +269,6 @@ UP004.py:84:5: UP004 [*] Class `B` inherits from `object` | = help: Remove `object` inheritance -ℹ Safe fix 81 81 | 82 82 | 83 83 | class B( @@ -301,7 +288,6 @@ UP004.py:92:5: UP004 [*] Class `B` inherits from `object` | = help: Remove `object` inheritance -ℹ Safe fix 89 89 | 90 90 | class B( 91 91 | A, @@ -320,7 +306,6 @@ UP004.py:98:5: UP004 [*] Class `B` inherits from `object` | = help: Remove `object` inheritance -ℹ Safe fix 95 95 | 96 96 | 97 97 | class B( @@ -340,7 +325,6 @@ UP004.py:108:5: UP004 [*] Class `B` inherits from `object` | = help: Remove `object` inheritance -ℹ Safe fix 105 105 | class B( 106 106 | # Comment on A. 107 107 | A, @@ -359,7 +343,6 @@ UP004.py:119:5: UP004 [*] Class `A` inherits from `object` | = help: Remove `object` inheritance -ℹ Safe fix 115 115 | ... 116 116 | 117 117 | @@ -381,7 +364,6 @@ UP004.py:125:5: UP004 [*] Class `A` inherits from `object` | = help: Remove `object` inheritance -ℹ Safe fix 121 121 | ... 122 122 | 123 123 | @@ -403,7 +385,6 @@ UP004.py:131:5: UP004 [*] Class `A` inherits from `object` | = help: Remove `object` inheritance -ℹ Safe fix 127 127 | ... 128 128 | 129 129 | @@ -424,7 +405,6 @@ UP004.py:137:9: UP004 [*] Class `A` inherits from `object` | = help: Remove `object` inheritance -ℹ Safe fix 134 134 | ... 135 135 | 136 136 | @@ -442,7 +422,6 @@ UP004.py:137:17: UP004 [*] Class `A` inherits from `object` | = help: Remove `object` inheritance -ℹ Safe fix 134 134 | ... 135 135 | 136 136 | @@ -461,7 +440,6 @@ UP004.py:142:9: UP004 [*] Class `A` inherits from `object` | = help: Remove `object` inheritance -ℹ Safe fix 139 139 | 140 140 | 141 141 | @decorator() @@ -480,7 +458,6 @@ UP004.py:146:9: UP004 [*] Class `A` inherits from `object` | = help: Remove `object` inheritance -ℹ Safe fix 143 143 | ... 144 144 | 145 145 | @decorator() # class A(object): @@ -500,7 +477,6 @@ UP004.py:159:15: UP004 [*] Class `Unusual` inherits from `object` | = help: Remove `object` inheritance -ℹ Safe fix 156 156 | 157 157 | import builtins 158 158 | diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP005.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP005.py.snap index 21d08d5d28243..91d4323bf19d6 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP005.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP005.py.snap @@ -12,7 +12,6 @@ UP005.py:6:9: UP005 [*] `assertEquals` is deprecated, use `assertEqual` | = help: Replace `assertEqual` with `assertEquals` -ℹ Safe fix 3 3 | 4 4 | class Suite(unittest.TestCase): 5 5 | def test(self) -> None: @@ -33,7 +32,6 @@ UP005.py:7:9: UP005 [*] `assertEquals` is deprecated, use `assertEqual` | = help: Replace `assertEqual` with `assertEquals` -ℹ Safe fix 4 4 | class Suite(unittest.TestCase): 5 5 | def test(self) -> None: 6 6 | self.assertEquals (1, 2) @@ -53,7 +51,6 @@ UP005.py:9:9: UP005 [*] `failUnlessAlmostEqual` is deprecated, use `assertAlmost | = help: Replace `assertAlmostEqual` with `failUnlessAlmostEqual` -ℹ Safe fix 6 6 | self.assertEquals (1, 2) 7 7 | self.assertEquals(1, 2) 8 8 | self.assertEqual(3, 4) @@ -70,11 +67,8 @@ UP005.py:10:9: UP005 [*] `assertNotRegexpMatches` is deprecated, use `assertNotR | = help: Replace `assertNotRegex` with `assertNotRegexpMatches` -ℹ Safe fix 7 7 | self.assertEquals(1, 2) 8 8 | self.assertEqual(3, 4) 9 9 | self.failUnlessAlmostEqual(1, 1.1) 10 |- self.assertNotRegexpMatches("a", "b") 10 |+ self.assertNotRegex("a", "b") - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_0.py.snap index 283b6f1b0c1a4..aa426276f80d4 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_0.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_0.py.snap @@ -9,7 +9,6 @@ UP006_0.py:4:10: UP006 [*] Use `list` instead of `typing.List` for type annotati | = help: Replace with `list` -ℹ Safe fix 1 1 | import typing 2 2 | 3 3 | @@ -27,7 +26,6 @@ UP006_0.py:11:10: UP006 [*] Use `list` instead of `List` for type annotation | = help: Replace with `list` -ℹ Safe fix 8 8 | from typing import List 9 9 | 10 10 | @@ -45,7 +43,6 @@ UP006_0.py:18:10: UP006 [*] Use `list` instead of `t.List` for type annotation | = help: Replace with `list` -ℹ Safe fix 15 15 | import typing as t 16 16 | 17 17 | @@ -63,7 +60,6 @@ UP006_0.py:25:10: UP006 [*] Use `list` instead of `IList` for type annotation | = help: Replace with `list` -ℹ Safe fix 22 22 | from typing import List as IList 23 23 | 24 24 | @@ -81,7 +77,6 @@ UP006_0.py:29:11: UP006 [*] Use `list` instead of `List` for type annotation | = help: Replace with `list` -ℹ Safe fix 26 26 | ... 27 27 | 28 28 | @@ -99,7 +94,6 @@ UP006_0.py:33:12: UP006 [*] Use `list` instead of `List` for type annotation | = help: Replace with `list` -ℹ Safe fix 30 30 | ... 31 31 | 32 32 | @@ -117,7 +111,6 @@ UP006_0.py:37:11: UP006 [*] Use `list` instead of `List` for type annotation | = help: Replace with `list` -ℹ Safe fix 34 34 | ... 35 35 | 36 36 | @@ -135,7 +128,6 @@ UP006_0.py:41:13: UP006 [*] Use `list` instead of `List` for type annotation | = help: Replace with `list` -ℹ Safe fix 38 38 | ... 39 39 | 40 40 | @@ -161,7 +153,6 @@ UP006_0.py:49:11: UP006 [*] Use `list` instead of `List` for type annotation | = help: Replace with `list` -ℹ Safe fix 46 46 | ... 47 47 | 48 48 | @@ -179,7 +170,6 @@ UP006_0.py:49:17: UP006 [*] Use `list` instead of `List` for type annotation | = help: Replace with `list` -ℹ Safe fix 46 46 | ... 47 47 | 48 48 | @@ -197,7 +187,6 @@ UP006_0.py:53:11: UP006 [*] Use `list` instead of `List` for type annotation | = help: Replace with `list` -ℹ Safe fix 50 50 | ... 51 51 | 52 52 | @@ -239,7 +228,6 @@ UP006_0.py:61:10: UP006 [*] Use `collections.deque` instead of `typing.Deque` fo | = help: Replace with `collections.deque` -ℹ Safe fix 20 20 | 21 21 | 22 22 | from typing import List as IList @@ -265,7 +253,6 @@ UP006_0.py:65:10: UP006 [*] Use `collections.defaultdict` instead of `typing.Def | = help: Replace with `collections.defaultdict` -ℹ Safe fix 20 20 | 21 21 | 22 22 | from typing import List as IList @@ -280,5 +267,3 @@ UP006_0.py:65:10: UP006 [*] Use `collections.defaultdict` instead of `typing.Def 65 |-def f(x: typing.DefaultDict[str, str]) -> None: 66 |+def f(x: defaultdict[str, str]) -> None: 66 67 | ... - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_1.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_1.py.snap index 23d2e79f9a43f..f3bbc98010531 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_1.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_1.py.snap @@ -9,12 +9,9 @@ UP006_1.py:9:10: UP006 [*] Use `collections.defaultdict` instead of `typing.Defa | = help: Replace with `collections.defaultdict` -ℹ Safe fix 6 6 | from collections import defaultdict 7 7 | 8 8 | 9 |-def f(x: typing.DefaultDict[str, str]) -> None: 9 |+def f(x: defaultdict[str, str]) -> None: 10 10 | ... - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_3.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_3.py.snap index 6e49fa82351ff..28276ac27958c 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_3.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_3.py.snap @@ -9,12 +9,9 @@ UP006_3.py:7:11: UP006 [*] Use `collections.defaultdict` instead of `typing.Defa | = help: Replace with `collections.defaultdict` -ℹ Safe fix 4 4 | from collections import defaultdict 5 5 | 6 6 | 7 |-def f(x: "typing.DefaultDict[str, str]") -> None: 7 |+def f(x: "defaultdict[str, str]") -> None: 8 8 | ... - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP007.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP007.py.snap index a607401c39adf..92639257686bf 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP007.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP007.py.snap @@ -9,7 +9,6 @@ UP007.py:6:10: UP007 [*] Use `X | Y` for type annotations | = help: Convert to `X | Y` -ℹ Safe fix 3 3 | from typing import Union 4 4 | 5 5 | @@ -27,7 +26,6 @@ UP007.py:10:10: UP007 [*] Use `X | Y` for type annotations | = help: Convert to `X | Y` -ℹ Safe fix 7 7 | ... 8 8 | 9 9 | @@ -45,7 +43,6 @@ UP007.py:14:10: UP007 [*] Use `X | Y` for type annotations | = help: Convert to `X | Y` -ℹ Safe fix 11 11 | ... 12 12 | 13 13 | @@ -63,7 +60,6 @@ UP007.py:14:26: UP007 [*] Use `X | Y` for type annotations | = help: Convert to `X | Y` -ℹ Safe fix 11 11 | ... 12 12 | 13 13 | @@ -81,7 +77,6 @@ UP007.py:18:10: UP007 [*] Use `X | Y` for type annotations | = help: Convert to `X | Y` -ℹ Safe fix 15 15 | ... 16 16 | 17 17 | @@ -99,7 +94,6 @@ UP007.py:22:10: UP007 [*] Use `X | Y` for type annotations | = help: Convert to `X | Y` -ℹ Safe fix 19 19 | ... 20 20 | 21 21 | @@ -117,7 +111,6 @@ UP007.py:26:10: UP007 [*] Use `X | Y` for type annotations | = help: Convert to `X | Y` -ℹ Safe fix 23 23 | ... 24 24 | 25 25 | @@ -135,7 +128,6 @@ UP007.py:30:10: UP007 [*] Use `X | Y` for type annotations | = help: Convert to `X | Y` -ℹ Safe fix 27 27 | ... 28 28 | 29 29 | @@ -153,7 +145,6 @@ UP007.py:34:10: UP007 [*] Use `X | Y` for type annotations | = help: Convert to `X | Y` -ℹ Safe fix 31 31 | ... 32 32 | 33 33 | @@ -171,7 +162,6 @@ UP007.py:38:11: UP007 [*] Use `X | Y` for type annotations | = help: Convert to `X | Y` -ℹ Safe fix 35 35 | ... 36 36 | 37 37 | @@ -189,7 +179,6 @@ UP007.py:38:27: UP007 [*] Use `X | Y` for type annotations | = help: Convert to `X | Y` -ℹ Safe fix 35 35 | ... 36 36 | 37 37 | @@ -207,7 +196,6 @@ UP007.py:42:11: UP007 [*] Use `X | Y` for type annotations | = help: Convert to `X | Y` -ℹ Safe fix 39 39 | ... 40 40 | 41 41 | @@ -226,7 +214,6 @@ UP007.py:55:8: UP007 [*] Use `X | Y` for type annotations | = help: Convert to `X | Y` -ℹ Safe fix 52 52 | 53 53 | 54 54 | def f() -> None: @@ -268,7 +255,6 @@ UP007.py:60:8: UP007 [*] Use `X | Y` for type annotations | = help: Convert to `X | Y` -ℹ Safe fix 57 57 | 58 58 | x = Union[str, int] 59 59 | x = Union["str", "int"] @@ -287,7 +273,6 @@ UP007.py:61:8: UP007 [*] Use `X | Y` for type annotations | = help: Convert to `X | Y` -ℹ Safe fix 58 58 | x = Union[str, int] 59 59 | x = Union["str", "int"] 60 60 | x: Union[str, int] @@ -382,7 +367,6 @@ UP007.py:102:28: UP007 [*] Use `X | Y` for type annotations | = help: Convert to `X | Y` -ℹ Safe fix 99 99 | 100 100 | # Regression test for: https://github.com/astral-sh/ruff/issues/7131 101 101 | class ServiceRefOrValue: @@ -404,7 +388,6 @@ UP007.py:110:28: UP007 [*] Use `X | Y` for type annotations | = help: Convert to `X | Y` -ℹ Safe fix 107 107 | 108 108 | # Regression test for: https://github.com/astral-sh/ruff/issues/7201 109 109 | class ServiceRefOrValue: @@ -423,12 +406,9 @@ UP007.py:120:10: UP007 [*] Use `X | Y` for type annotations | = help: Convert to `X | Y` -ℹ Safe fix 117 117 | 118 118 | 119 119 | # Regression test for: https://github.com/astral-sh/ruff/issues/8609 120 |-def f(x: Union[int, str, bytes]) -> None: 120 |+def f(x: int | str | bytes) -> None: 121 121 | ... - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP008.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP008.py.snap index da6e68284da36..5414388c27bf7 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP008.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP008.py.snap @@ -11,15 +11,6 @@ UP008.py:17:23: UP008 [*] Use `super()` instead of `super(__class__, self)` | = help: Remove `__super__` parameters -ℹ Unsafe fix -14 14 | Parent.super(1, 2) # ok -15 15 | -16 16 | def wrong(self): -17 |- parent = super(Child, self) # wrong - 17 |+ parent = super() # wrong -18 18 | super(Child, self).method # wrong -19 19 | super( -20 20 | Child, UP008.py:18:14: UP008 [*] Use `super()` instead of `super(__class__, self)` | @@ -32,15 +23,6 @@ UP008.py:18:14: UP008 [*] Use `super()` instead of `super(__class__, self)` | = help: Remove `__super__` parameters -ℹ Unsafe fix -15 15 | -16 16 | def wrong(self): -17 17 | parent = super(Child, self) # wrong -18 |- super(Child, self).method # wrong - 18 |+ super().method # wrong -19 19 | super( -20 20 | Child, -21 21 | self, UP008.py:19:14: UP008 [*] Use `super()` instead of `super(__class__, self)` | @@ -55,18 +37,6 @@ UP008.py:19:14: UP008 [*] Use `super()` instead of `super(__class__, self)` | = help: Remove `__super__` parameters -ℹ Unsafe fix -16 16 | def wrong(self): -17 17 | parent = super(Child, self) # wrong -18 18 | super(Child, self).method # wrong -19 |- super( -20 |- Child, -21 |- self, -22 |- ).method() # wrong - 19 |+ super().method() # wrong -23 20 | -24 21 | -25 22 | class BaseClass: UP008.py:36:14: UP008 [*] Use `super()` instead of `super(__class__, self)` | @@ -78,15 +48,6 @@ UP008.py:36:14: UP008 [*] Use `super()` instead of `super(__class__, self)` | = help: Remove `__super__` parameters -ℹ Unsafe fix -33 33 | -34 34 | class MyClass(BaseClass): -35 35 | def normal(self): -36 |- super(MyClass, self).f() # can use super() - 36 |+ super().f() # can use super() -37 37 | super().f() -38 38 | -39 39 | def different_argument(self, other): UP008.py:50:18: UP008 [*] Use `super()` instead of `super(__class__, self)` | @@ -97,15 +58,6 @@ UP008.py:50:18: UP008 [*] Use `super()` instead of `super(__class__, self)` | = help: Remove `__super__` parameters -ℹ Unsafe fix -47 47 | super(MyClass, self).f() # CANNOT use super() -48 48 | -49 49 | def inner_argument(self): -50 |- super(MyClass, self).f() # can use super() - 50 |+ super().f() # can use super() -51 51 | super().f() -52 52 | -53 53 | outer_argument() UP008.py:74:14: UP008 [*] Use `super()` instead of `super(__class__, self)` | @@ -116,13 +68,3 @@ UP008.py:74:14: UP008 [*] Use `super()` instead of `super(__class__, self)` 75 | super().f() # OK | = help: Remove `__super__` parameters - -ℹ Unsafe fix -71 71 | @dataclass -72 72 | class DataClass: -73 73 | def normal(self): -74 |- super(DataClass, self).f() # Error - 74 |+ super().f() # Error -75 75 | super().f() # OK -76 76 | -77 77 | diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_0.py.snap index c4e69c7ea1376..5d7309d619601 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_0.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_0.py.snap @@ -10,9 +10,6 @@ UP009_0.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary | = help: Remove unnecessary coding comment -ℹ Safe fix 1 |-# coding=utf8 2 1 | 3 2 | print("Hello world") - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_1.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_1.py.snap index b1b25e0d3299f..baeb863feebd1 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_1.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_1.py.snap @@ -11,10 +11,7 @@ UP009_1.py:2:1: UP009 [*] UTF-8 encoding declaration is unnecessary | = help: Remove unnecessary coding comment -ℹ Safe fix 1 1 | #!/usr/bin/python 2 |-# -*- coding: utf-8 -*- 3 2 | 4 3 | print('Hello world') - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_6.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_6.py.snap index 01bbf87c0012d..ae21eb8af5341 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_6.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_6.py.snap @@ -9,10 +9,7 @@ UP009_6.py:1:2: UP009 [*] UTF-8 encoding declaration is unnecessary | = help: Remove unnecessary coding comment -ℹ Safe fix 1 |- # coding=utf8 2 1 | print("Hello world") 3 2 | 4 3 | """ - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_7.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_7.py.snap index 8439a0715cb29..a1ad81111b2b0 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_7.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_7.py.snap @@ -9,10 +9,7 @@ UP009_7.py:1:2: UP009 [*] UTF-8 encoding declaration is unnecessary | = help: Remove unnecessary coding comment -ℹ Safe fix 1 |- # coding=utf8 2 1 | print("Hello world") 3 2 | 4 3 | """ - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP010.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP010.py.snap index d72c8e2fbbd25..7dc270010a217 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP010.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP010.py.snap @@ -10,7 +10,6 @@ UP010.py:1:1: UP010 [*] Unnecessary `__future__` imports `generators`, `nested_s | = help: Remove unnecessary `__future__` import -ℹ Safe fix 1 |-from __future__ import nested_scopes, generators 2 1 | from __future__ import with_statement, unicode_literals 3 2 | from __future__ import absolute_import, division @@ -26,7 +25,6 @@ UP010.py:2:1: UP010 [*] Unnecessary `__future__` imports `unicode_literals`, `wi | = help: Remove unnecessary `__future__` import -ℹ Safe fix 1 1 | from __future__ import nested_scopes, generators 2 |-from __future__ import with_statement, unicode_literals 3 2 | from __future__ import absolute_import, division @@ -44,7 +42,6 @@ UP010.py:3:1: UP010 [*] Unnecessary `__future__` imports `absolute_import`, `div | = help: Remove unnecessary `__future__` import -ℹ Safe fix 1 1 | from __future__ import nested_scopes, generators 2 2 | from __future__ import with_statement, unicode_literals 3 |-from __future__ import absolute_import, division @@ -63,7 +60,6 @@ UP010.py:4:1: UP010 [*] Unnecessary `__future__` import `generator_stop` for tar | = help: Remove unnecessary `__future__` import -ℹ Safe fix 1 1 | from __future__ import nested_scopes, generators 2 2 | from __future__ import with_statement, unicode_literals 3 3 | from __future__ import absolute_import, division @@ -82,7 +78,6 @@ UP010.py:5:1: UP010 [*] Unnecessary `__future__` imports `generator_stop`, `prin | = help: Remove unnecessary `__future__` import -ℹ Safe fix 2 2 | from __future__ import with_statement, unicode_literals 3 3 | from __future__ import absolute_import, division 4 4 | from __future__ import generator_stop @@ -102,7 +97,6 @@ UP010.py:6:1: UP010 [*] Unnecessary `__future__` import `generators` for target | = help: Remove unnecessary `__future__` import -ℹ Safe fix 3 3 | from __future__ import absolute_import, division 4 4 | from __future__ import generator_stop 5 5 | from __future__ import print_function, generator_stop @@ -121,7 +115,6 @@ UP010.py:9:5: UP010 [*] Unnecessary `__future__` import `generator_stop` for tar | = help: Remove unnecessary `__future__` import -ℹ Safe fix 6 6 | from __future__ import invalid_module, generators 7 7 | 8 8 | if True: @@ -141,7 +134,6 @@ UP010.py:10:5: UP010 [*] Unnecessary `__future__` import `generators` for target | = help: Remove unnecessary `__future__` import -ℹ Safe fix 7 7 | 8 8 | if True: 9 9 | from __future__ import generator_stop @@ -159,7 +151,6 @@ UP010.py:13:5: UP010 [*] Unnecessary `__future__` import `generator_stop` for ta | = help: Remove unnecessary `__future__` import -ℹ Safe fix 10 10 | from __future__ import generators 11 11 | 12 12 | if True: @@ -175,11 +166,8 @@ UP010.py:14:5: UP010 [*] Unnecessary `__future__` import `generators` for target | = help: Remove unnecessary `__future__` import -ℹ Safe fix 11 11 | 12 12 | if True: 13 13 | from __future__ import generator_stop 14 |- from __future__ import invalid_module, generators 14 |+ from __future__ import invalid_module - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP011.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP011.py.snap index e672749216748..7deefe6c38342 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP011.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP011.py.snap @@ -10,7 +10,6 @@ UP011.py:5:21: UP011 [*] Unnecessary parentheses to `functools.lru_cache` | = help: Remove unnecessary parentheses -ℹ Safe fix 2 2 | from functools import lru_cache 3 3 | 4 4 | @@ -29,7 +28,6 @@ UP011.py:10:11: UP011 [*] Unnecessary parentheses to `functools.lru_cache` | = help: Remove unnecessary parentheses -ℹ Safe fix 7 7 | pass 8 8 | 9 9 | @@ -49,7 +47,6 @@ UP011.py:16:21: UP011 [*] Unnecessary parentheses to `functools.lru_cache` | = help: Remove unnecessary parentheses -ℹ Safe fix 13 13 | 14 14 | 15 15 | @other_decorator @@ -68,7 +65,6 @@ UP011.py:21:21: UP011 [*] Unnecessary parentheses to `functools.lru_cache` | = help: Remove unnecessary parentheses -ℹ Safe fix 18 18 | pass 19 19 | 20 20 | @@ -77,5 +73,3 @@ UP011.py:21:21: UP011 [*] Unnecessary parentheses to `functools.lru_cache` 22 22 | @other_decorator 23 23 | def fixme(): 24 24 | pass - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP012.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP012.py.snap index f19df78488866..cbdbf148ec1bb 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP012.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP012.py.snap @@ -11,7 +11,6 @@ UP012.py:2:1: UP012 [*] Unnecessary call to `encode` as UTF-8 | = help: Rewrite as bytes literal -ℹ Safe fix 1 1 | # ASCII literals should be replaced by a bytes literal 2 |-"foo".encode("utf-8") # b"foo" 2 |+b"foo" # b"foo" @@ -30,7 +29,6 @@ UP012.py:3:1: UP012 [*] Unnecessary call to `encode` as UTF-8 | = help: Rewrite as bytes literal -ℹ Safe fix 1 1 | # ASCII literals should be replaced by a bytes literal 2 2 | "foo".encode("utf-8") # b"foo" 3 |-"foo".encode("u8") # b"foo" @@ -50,7 +48,6 @@ UP012.py:4:1: UP012 [*] Unnecessary call to `encode` as UTF-8 | = help: Rewrite as bytes literal -ℹ Safe fix 1 1 | # ASCII literals should be replaced by a bytes literal 2 2 | "foo".encode("utf-8") # b"foo" 3 3 | "foo".encode("u8") # b"foo" @@ -71,7 +68,6 @@ UP012.py:5:1: UP012 [*] Unnecessary call to `encode` as UTF-8 | = help: Rewrite as bytes literal -ℹ Safe fix 2 2 | "foo".encode("utf-8") # b"foo" 3 3 | "foo".encode("u8") # b"foo" 4 4 | "foo".encode() # b"foo" @@ -92,7 +88,6 @@ UP012.py:6:1: UP012 [*] Unnecessary call to `encode` as UTF-8 | = help: Rewrite as bytes literal -ℹ Safe fix 3 3 | "foo".encode("u8") # b"foo" 4 4 | "foo".encode() # b"foo" 5 5 | "foo".encode("UTF8") # b"foo" @@ -113,7 +108,6 @@ UP012.py:7:1: UP012 [*] Unnecessary call to `encode` as UTF-8 | = help: Rewrite as bytes literal -ℹ Safe fix 4 4 | "foo".encode() # b"foo" 5 5 | "foo".encode("UTF8") # b"foo" 6 6 | U"foo".encode("utf-8") # b"foo" @@ -140,7 +134,6 @@ UP012.py:8:1: UP012 [*] Unnecessary call to `encode` as UTF-8 | = help: Rewrite as bytes literal -ℹ Safe fix 5 5 | "foo".encode("UTF8") # b"foo" 6 6 | U"foo".encode("utf-8") # b"foo" 7 7 | "foo".encode(encoding="utf-8") # b"foo" @@ -170,7 +163,6 @@ UP012.py:16:5: UP012 [*] Unnecessary call to `encode` as UTF-8 | = help: Rewrite as bytes literal -ℹ Safe fix 13 13 | "utf-8" 14 14 | ) 15 15 | ( @@ -195,7 +187,6 @@ UP012.py:20:5: UP012 [*] Unnecessary call to `encode` as UTF-8 | = help: Rewrite as bytes literal -ℹ Safe fix 17 17 | "Ipsum".encode() 18 18 | ) 19 19 | ( @@ -217,7 +208,6 @@ UP012.py:24:5: UP012 [*] Unnecessary call to `encode` as UTF-8 | = help: Rewrite as bytes literal -ℹ Safe fix 21 21 | "Ipsum".encode() # Comment 22 22 | ) 23 23 | ( @@ -237,7 +227,6 @@ UP012.py:32:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` | = help: Remove unnecessary `encoding` argument -ℹ Safe fix 29 29 | string.encode("utf-8") 30 30 | 31 31 | bar = "bar" @@ -260,7 +249,6 @@ UP012.py:36:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` | = help: Remove unnecessary `encoding` argument -ℹ Safe fix 33 33 | encoding = "latin" 34 34 | "foo".encode(encoding) 35 35 | f"foo{bar}".encode(encoding) @@ -282,7 +270,6 @@ UP012.py:53:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` | = help: Remove unnecessary `encoding` argument -ℹ Safe fix 50 50 | "unicode text©".encode(encoding="utf-8", errors="replace") 51 51 | 52 52 | # Unicode literals should only be stripped of default encoding. @@ -303,7 +290,6 @@ UP012.py:55:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` | = help: Remove unnecessary `encoding` argument -ℹ Safe fix 52 52 | # Unicode literals should only be stripped of default encoding. 53 53 | "unicode text©".encode("utf-8") # "unicode text©".encode() 54 54 | "unicode text©".encode() @@ -324,7 +310,6 @@ UP012.py:57:1: UP012 [*] Unnecessary call to `encode` as UTF-8 | = help: Rewrite as bytes literal -ℹ Safe fix 54 54 | "unicode text©".encode() 55 55 | "unicode text©".encode(encoding="UTF8") # "unicode text©".encode() 56 56 | @@ -344,7 +329,6 @@ UP012.py:58:1: UP012 [*] Unnecessary call to `encode` as UTF-8 | = help: Rewrite as bytes literal -ℹ Safe fix 55 55 | "unicode text©".encode(encoding="UTF8") # "unicode text©".encode() 56 56 | 57 57 | r"foo\o".encode("utf-8") # br"foo\o" @@ -365,7 +349,6 @@ UP012.py:59:1: UP012 [*] Unnecessary call to `encode` as UTF-8 | = help: Rewrite as bytes literal -ℹ Safe fix 56 56 | 57 57 | r"foo\o".encode("utf-8") # br"foo\o" 58 58 | u"foo".encode("utf-8") # b"foo" @@ -385,7 +368,6 @@ UP012.py:60:1: UP012 [*] Unnecessary call to `encode` as UTF-8 | = help: Rewrite as bytes literal -ℹ Safe fix 57 57 | r"foo\o".encode("utf-8") # br"foo\o" 58 58 | u"foo".encode("utf-8") # b"foo" 59 59 | R"foo\o".encode("utf-8") # br"foo\o" @@ -406,7 +388,6 @@ UP012.py:61:7: UP012 [*] Unnecessary call to `encode` as UTF-8 | = help: Rewrite as bytes literal -ℹ Safe fix 58 58 | u"foo".encode("utf-8") # b"foo" 59 59 | R"foo\o".encode("utf-8") # br"foo\o" 60 60 | U"foo".encode("utf-8") # b"foo" @@ -429,7 +410,6 @@ UP012.py:64:1: UP012 [*] Unnecessary call to `encode` as UTF-8 | = help: Rewrite as bytes literal -ℹ Safe fix 62 62 | 63 63 | # `encode` on parenthesized strings. 64 64 | ( @@ -457,7 +437,6 @@ UP012.py:69:1: UP012 [*] Unnecessary call to `encode` as UTF-8 | = help: Rewrite as bytes literal -ℹ Safe fix 67 67 | ).encode() 68 68 | 69 69 | (( @@ -482,7 +461,6 @@ UP012.py:74:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` | = help: Remove unnecessary `encoding` argument -ℹ Safe fix 71 71 | "def" 72 72 | )).encode() 73 73 | @@ -502,7 +480,6 @@ UP012.py:75:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` | = help: Remove unnecessary `encoding` argument -ℹ Safe fix 72 72 | )).encode() 73 73 | 74 74 | (f"foo{bar}").encode("utf-8") @@ -522,7 +499,6 @@ UP012.py:76:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` | = help: Remove unnecessary `encoding` argument -ℹ Safe fix 73 73 | 74 74 | (f"foo{bar}").encode("utf-8") 75 75 | (f"foo{bar}").encode(encoding="utf-8") @@ -541,7 +517,6 @@ UP012.py:77:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` | = help: Remove unnecessary `encoding` argument -ℹ Safe fix 74 74 | (f"foo{bar}").encode("utf-8") 75 75 | (f"foo{bar}").encode(encoding="utf-8") 76 76 | ("unicode text©").encode("utf-8") @@ -562,7 +537,6 @@ UP012.py:82:17: UP012 [*] Unnecessary call to `encode` as UTF-8 | = help: Rewrite as bytes literal -ℹ Safe fix 79 79 | 80 80 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722459882 81 81 | def _match_ignore(line): @@ -581,7 +555,6 @@ UP012.py:86:5: UP012 [*] Unnecessary call to `encode` as UTF-8 | = help: Rewrite as bytes literal -ℹ Safe fix 83 83 | 84 84 | # Not a valid type annotation but this test shouldn't result in a panic. 85 85 | # Refer: https://github.com/astral-sh/ruff/issues/11736 diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP013.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP013.py.snap index d03ec38c485f4..d3adbb8a515f8 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP013.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP013.py.snap @@ -11,7 +11,6 @@ UP013.py:5:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class sy | = help: Convert `MyType` to class syntax -ℹ Safe fix 2 2 | import typing 3 3 | 4 4 | # dict literal @@ -33,7 +32,6 @@ UP013.py:8:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class sy | = help: Convert `MyType` to class syntax -ℹ Safe fix 5 5 | MyType = TypedDict("MyType", {"a": int, "b": str}) 6 6 | 7 7 | # dict call @@ -55,7 +53,6 @@ UP013.py:11:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class s | = help: Convert `MyType` to class syntax -ℹ Safe fix 8 8 | MyType = TypedDict("MyType", dict(a=int, b=str)) 9 9 | 10 10 | # kwargs @@ -77,7 +74,6 @@ UP013.py:14:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class s | = help: Convert `MyType` to class syntax -ℹ Safe fix 11 11 | MyType = TypedDict("MyType", a=int, b=str) 12 12 | 13 13 | # Empty TypedDict @@ -97,7 +93,6 @@ UP013.py:17:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class s | = help: Convert `MyType` to class syntax -ℹ Safe fix 14 14 | MyType = TypedDict("MyType") 15 15 | 16 16 | # Literal values @@ -119,7 +114,6 @@ UP013.py:18:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class s | = help: Convert `MyType` to class syntax -ℹ Safe fix 15 15 | 16 16 | # Literal values 17 17 | MyType = TypedDict("MyType", {"a": "hello"}) @@ -140,7 +134,6 @@ UP013.py:21:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class s | = help: Convert `MyType` to class syntax -ℹ Safe fix 18 18 | MyType = TypedDict("MyType", a="hello") 19 19 | 20 20 | # NotRequired @@ -161,7 +154,6 @@ UP013.py:24:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class s | = help: Convert `MyType` to class syntax -ℹ Safe fix 21 21 | MyType = TypedDict("MyType", {"a": NotRequired[dict]}) 22 22 | 23 23 | # total @@ -183,7 +175,6 @@ UP013.py:27:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class s | = help: Convert `MyType` to class syntax -ℹ Safe fix 24 24 | MyType = TypedDict("MyType", {"x": int, "y": int}, total=False) 25 25 | 26 26 | # using Literal type @@ -204,7 +195,6 @@ UP013.py:30:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class s | = help: Convert `MyType` to class syntax -ℹ Safe fix 27 27 | MyType = TypedDict("MyType", {"key": Literal["value"]}) 28 28 | 29 29 | # using namespace TypedDict @@ -225,7 +215,6 @@ UP013.py:40:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class s | = help: Convert `MyType` to class syntax -ℹ Safe fix 37 37 | MyType = TypedDict("MyType", {"a": int, "b": str, **c}) 38 38 | 39 39 | # Empty dict literal @@ -244,12 +233,9 @@ UP013.py:43:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class s | = help: Convert `MyType` to class syntax -ℹ Safe fix 40 40 | MyType = TypedDict("MyType", {}) 41 41 | 42 42 | # Empty dict call 43 |-MyType = TypedDict("MyType", dict()) 43 |+class MyType(TypedDict): 44 |+ pass - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP014.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP014.py.snap index 71ce3308f55a5..1d7ad1d7b9e9b 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP014.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP014.py.snap @@ -11,7 +11,6 @@ UP014.py:5:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class s | = help: Convert `MyType` to class syntax -ℹ Safe fix 2 2 | import typing 3 3 | 4 4 | # with complex annotations @@ -33,7 +32,6 @@ UP014.py:8:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class s | = help: Convert `MyType` to class syntax -ℹ Safe fix 5 5 | MyType = NamedTuple("MyType", [("a", int), ("b", tuple[str, ...])]) 6 6 | 7 7 | # with namespace @@ -55,7 +53,6 @@ UP014.py:14:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class | = help: Convert `MyType` to class syntax -ℹ Safe fix 11 11 | MyType = NamedTuple("MyType", [("x-y", int), ("b", tuple[str, ...])]) 12 12 | 13 13 | # no fields @@ -76,7 +73,6 @@ UP014.py:17:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class | = help: Convert `MyType` to class syntax -ℹ Safe fix 14 14 | MyType = typing.NamedTuple("MyType") 15 15 | 16 16 | # empty fields @@ -97,7 +93,6 @@ UP014.py:20:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class | = help: Convert `MyType` to class syntax -ℹ Safe fix 17 17 | MyType = typing.NamedTuple("MyType", []) 18 18 | 19 19 | # keywords @@ -108,5 +103,3 @@ UP014.py:20:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class 21 23 | 22 24 | # unfixable 23 25 | MyType = typing.NamedTuple("MyType", [("a", int)], [("b", str)]) - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP015.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP015.py.snap index d85977a74ec80..c3301f1910ada 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP015.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP015.py.snap @@ -10,7 +10,6 @@ UP015.py:1:1: UP015 [*] Unnecessary open mode parameters | = help: Remove open mode parameters -ℹ Safe fix 1 |-open("foo", "U") 1 |+open("foo") 2 2 | open("foo", "Ur") @@ -27,7 +26,6 @@ UP015.py:2:1: UP015 [*] Unnecessary open mode parameters | = help: Remove open mode parameters -ℹ Safe fix 1 1 | open("foo", "U") 2 |-open("foo", "Ur") 2 |+open("foo") @@ -46,7 +44,6 @@ UP015.py:3:1: UP015 [*] Unnecessary open mode parameters, use ""rb"" | = help: Replace with ""rb"" -ℹ Safe fix 1 1 | open("foo", "U") 2 2 | open("foo", "Ur") 3 |-open("foo", "Ub") @@ -66,7 +63,6 @@ UP015.py:4:1: UP015 [*] Unnecessary open mode parameters, use ""rb"" | = help: Replace with ""rb"" -ℹ Safe fix 1 1 | open("foo", "U") 2 2 | open("foo", "Ur") 3 3 | open("foo", "Ub") @@ -87,7 +83,6 @@ UP015.py:5:1: UP015 [*] Unnecessary open mode parameters | = help: Remove open mode parameters -ℹ Safe fix 2 2 | open("foo", "Ur") 3 3 | open("foo", "Ub") 4 4 | open("foo", "rUb") @@ -108,7 +103,6 @@ UP015.py:6:1: UP015 [*] Unnecessary open mode parameters | = help: Remove open mode parameters -ℹ Safe fix 3 3 | open("foo", "Ub") 4 4 | open("foo", "rUb") 5 5 | open("foo", "r") @@ -128,7 +122,6 @@ UP015.py:7:1: UP015 [*] Unnecessary open mode parameters | = help: Remove open mode parameters -ℹ Safe fix 4 4 | open("foo", "rUb") 5 5 | open("foo", "r") 6 6 | open("foo", "rt") @@ -149,7 +142,6 @@ UP015.py:8:1: UP015 [*] Unnecessary open mode parameters, use ""w"" | = help: Replace with ""w"" -ℹ Safe fix 5 5 | open("foo", "r") 6 6 | open("foo", "rt") 7 7 | open("f", "r", encoding="UTF-8") @@ -170,7 +162,6 @@ UP015.py:10:6: UP015 [*] Unnecessary open mode parameters | = help: Remove open mode parameters -ℹ Safe fix 7 7 | open("f", "r", encoding="UTF-8") 8 8 | open("f", "wt") 9 9 | @@ -191,7 +182,6 @@ UP015.py:12:6: UP015 [*] Unnecessary open mode parameters | = help: Remove open mode parameters -ℹ Safe fix 9 9 | 10 10 | with open("foo", "U") as f: 11 11 | pass @@ -212,7 +202,6 @@ UP015.py:14:6: UP015 [*] Unnecessary open mode parameters, use ""rb"" | = help: Replace with ""rb"" -ℹ Safe fix 11 11 | pass 12 12 | with open("foo", "Ur") as f: 13 13 | pass @@ -233,7 +222,6 @@ UP015.py:16:6: UP015 [*] Unnecessary open mode parameters, use ""rb"" | = help: Replace with ""rb"" -ℹ Safe fix 13 13 | pass 14 14 | with open("foo", "Ub") as f: 15 15 | pass @@ -254,7 +242,6 @@ UP015.py:18:6: UP015 [*] Unnecessary open mode parameters | = help: Remove open mode parameters -ℹ Safe fix 15 15 | pass 16 16 | with open("foo", "rUb") as f: 17 17 | pass @@ -275,7 +262,6 @@ UP015.py:20:6: UP015 [*] Unnecessary open mode parameters | = help: Remove open mode parameters -ℹ Safe fix 17 17 | pass 18 18 | with open("foo", "r") as f: 19 19 | pass @@ -296,7 +282,6 @@ UP015.py:22:6: UP015 [*] Unnecessary open mode parameters | = help: Remove open mode parameters -ℹ Safe fix 19 19 | pass 20 20 | with open("foo", "rt") as f: 21 21 | pass @@ -316,7 +301,6 @@ UP015.py:24:6: UP015 [*] Unnecessary open mode parameters, use ""w"" | = help: Replace with ""w"" -ℹ Safe fix 21 21 | pass 22 22 | with open("foo", "r", encoding="UTF-8") as f: 23 23 | pass @@ -336,7 +320,6 @@ UP015.py:27:1: UP015 [*] Unnecessary open mode parameters | = help: Remove open mode parameters -ℹ Safe fix 24 24 | with open("foo", "wt") as f: 25 25 | pass 26 26 | @@ -356,7 +339,6 @@ UP015.py:28:1: UP015 [*] Unnecessary open mode parameters, use ""rb"" | = help: Replace with ""rb"" -ℹ Safe fix 25 25 | pass 26 26 | 27 27 | open(f("a", "b", "c"), "U") @@ -377,7 +359,6 @@ UP015.py:30:6: UP015 [*] Unnecessary open mode parameters | = help: Remove open mode parameters -ℹ Safe fix 27 27 | open(f("a", "b", "c"), "U") 28 28 | open(f("a", "b", "c"), "Ub") 29 29 | @@ -397,7 +378,6 @@ UP015.py:32:6: UP015 [*] Unnecessary open mode parameters, use ""rb"" | = help: Replace with ""rb"" -ℹ Safe fix 29 29 | 30 30 | with open(f("a", "b", "c"), "U") as f: 31 31 | pass @@ -418,7 +398,6 @@ UP015.py:35:6: UP015 [*] Unnecessary open mode parameters | = help: Remove open mode parameters -ℹ Safe fix 32 32 | with open(f("a", "b", "c"), "Ub") as f: 33 33 | pass 34 34 | @@ -439,7 +418,6 @@ UP015.py:35:30: UP015 [*] Unnecessary open mode parameters | = help: Remove open mode parameters -ℹ Safe fix 32 32 | with open(f("a", "b", "c"), "Ub") as f: 33 33 | pass 34 34 | @@ -459,7 +437,6 @@ UP015.py:37:6: UP015 [*] Unnecessary open mode parameters, use ""rb"" | = help: Replace with ""rb"" -ℹ Safe fix 34 34 | 35 35 | with open("foo", "U") as fa, open("bar", "U") as fb: 36 36 | pass @@ -479,7 +456,6 @@ UP015.py:37:31: UP015 [*] Unnecessary open mode parameters, use ""rb"" | = help: Replace with ""rb"" -ℹ Safe fix 34 34 | 35 35 | with open("foo", "U") as fa, open("bar", "U") as fb: 36 36 | pass @@ -500,7 +476,6 @@ UP015.py:40:1: UP015 [*] Unnecessary open mode parameters | = help: Remove open mode parameters -ℹ Safe fix 37 37 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb: 38 38 | pass 39 39 | @@ -519,7 +494,6 @@ UP015.py:41:1: UP015 [*] Unnecessary open mode parameters | = help: Remove open mode parameters -ℹ Safe fix 38 38 | pass 39 39 | 40 40 | open("foo", mode="U") @@ -540,7 +514,6 @@ UP015.py:42:1: UP015 [*] Unnecessary open mode parameters | = help: Remove open mode parameters -ℹ Safe fix 39 39 | 40 40 | open("foo", mode="U") 41 41 | open(name="foo", mode="U") @@ -561,7 +534,6 @@ UP015.py:44:6: UP015 [*] Unnecessary open mode parameters | = help: Remove open mode parameters -ℹ Safe fix 41 41 | open(name="foo", mode="U") 42 42 | open(mode="U", name="foo") 43 43 | @@ -582,7 +554,6 @@ UP015.py:46:6: UP015 [*] Unnecessary open mode parameters | = help: Remove open mode parameters -ℹ Safe fix 43 43 | 44 44 | with open("foo", mode="U") as f: 45 45 | pass @@ -602,7 +573,6 @@ UP015.py:48:6: UP015 [*] Unnecessary open mode parameters | = help: Remove open mode parameters -ℹ Safe fix 45 45 | pass 46 46 | with open(name="foo", mode="U") as f: 47 47 | pass @@ -623,7 +593,6 @@ UP015.py:51:1: UP015 [*] Unnecessary open mode parameters, use ""rb"" | = help: Replace with ""rb"" -ℹ Safe fix 48 48 | with open(mode="U", name="foo") as f: 49 49 | pass 50 50 | @@ -642,7 +611,6 @@ UP015.py:52:1: UP015 [*] Unnecessary open mode parameters, use ""rb"" | = help: Replace with ""rb"" -ℹ Safe fix 49 49 | pass 50 50 | 51 51 | open("foo", mode="Ub") @@ -663,7 +631,6 @@ UP015.py:53:1: UP015 [*] Unnecessary open mode parameters, use ""rb"" | = help: Replace with ""rb"" -ℹ Safe fix 50 50 | 51 51 | open("foo", mode="Ub") 52 52 | open(name="foo", mode="Ub") @@ -684,7 +651,6 @@ UP015.py:55:6: UP015 [*] Unnecessary open mode parameters, use ""rb"" | = help: Replace with ""rb"" -ℹ Safe fix 52 52 | open(name="foo", mode="Ub") 53 53 | open(mode="Ub", name="foo") 54 54 | @@ -705,7 +671,6 @@ UP015.py:57:6: UP015 [*] Unnecessary open mode parameters, use ""rb"" | = help: Replace with ""rb"" -ℹ Safe fix 54 54 | 55 55 | with open("foo", mode="Ub") as f: 56 56 | pass @@ -725,7 +690,6 @@ UP015.py:59:6: UP015 [*] Unnecessary open mode parameters, use ""rb"" | = help: Replace with ""rb"" -ℹ Safe fix 56 56 | pass 57 57 | with open(name="foo", mode="Ub") as f: 58 58 | pass @@ -746,7 +710,6 @@ UP015.py:62:1: UP015 [*] Unnecessary open mode parameters | = help: Remove open mode parameters -ℹ Safe fix 59 59 | with open(mode="Ub", name="foo") as f: 60 60 | pass 61 61 | @@ -766,7 +729,6 @@ UP015.py:63:1: UP015 [*] Unnecessary open mode parameters | = help: Remove open mode parameters -ℹ Safe fix 60 60 | pass 61 61 | 62 62 | open(file="foo", mode='U', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) @@ -786,7 +748,6 @@ UP015.py:64:1: UP015 [*] Unnecessary open mode parameters | = help: Remove open mode parameters -ℹ Safe fix 61 61 | 62 62 | open(file="foo", mode='U', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) 63 63 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U') @@ -807,7 +768,6 @@ UP015.py:65:1: UP015 [*] Unnecessary open mode parameters | = help: Remove open mode parameters -ℹ Safe fix 62 62 | open(file="foo", mode='U', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) 63 63 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U') 64 64 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None) @@ -828,7 +788,6 @@ UP015.py:67:1: UP015 [*] Unnecessary open mode parameters, use ""rb"" | = help: Replace with ""rb"" -ℹ Safe fix 64 64 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None) 65 65 | open(mode='U', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) 66 66 | @@ -848,7 +807,6 @@ UP015.py:68:1: UP015 [*] Unnecessary open mode parameters, use ""rb"" | = help: Replace with ""rb"" -ℹ Safe fix 65 65 | open(mode='U', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) 66 66 | 67 67 | open(file="foo", mode='Ub', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) @@ -868,7 +826,6 @@ UP015.py:69:1: UP015 [*] Unnecessary open mode parameters, use ""rb"" | = help: Replace with ""rb"" -ℹ Safe fix 66 66 | 67 67 | open(file="foo", mode='Ub', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) 68 68 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub') @@ -889,7 +846,6 @@ UP015.py:70:1: UP015 [*] Unnecessary open mode parameters, use ""rb"" | = help: Replace with ""rb"" -ℹ Safe fix 67 67 | open(file="foo", mode='Ub', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) 68 68 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub') 69 69 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None) @@ -898,5 +854,3 @@ UP015.py:70:1: UP015 [*] Unnecessary open mode parameters, use ""rb"" 71 71 | 72 72 | open = 1 73 73 | open("foo", "U") - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP015_1.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP015_1.py.snap index 03a9caacb8921..427f55ae5b6a3 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP015_1.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP015_1.py.snap @@ -10,7 +10,6 @@ UP015_1.py:3:5: UP015 [*] Unnecessary open mode parameters | = help: Remove open mode parameters -ℹ Safe fix 1 1 | # Not a valid type annotation but this test shouldn't result in a panic. 2 2 | # Refer: https://github.com/astral-sh/ruff/issues/11736 3 |-x: 'open("foo", "r")' diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP018.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP018.py.snap index a0a1f44188172..6ba375dfd57ab 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP018.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP018.py.snap @@ -11,7 +11,6 @@ UP018.py:37:1: UP018 [*] Unnecessary `str` call (rewrite as a literal) | = help: Replace with string literal -ℹ Safe fix 34 34 | int().denominator 35 35 | 36 36 | # These become literals @@ -32,7 +31,6 @@ UP018.py:38:1: UP018 [*] Unnecessary `str` call (rewrite as a literal) | = help: Replace with string literal -ℹ Safe fix 35 35 | 36 36 | # These become literals 37 37 | str() @@ -54,7 +52,6 @@ UP018.py:39:1: UP018 [*] Unnecessary `str` call (rewrite as a literal) | = help: Replace with string literal -ℹ Safe fix 36 36 | # These become literals 37 37 | str() 38 38 | str("foo") @@ -77,7 +74,6 @@ UP018.py:41:1: UP018 [*] Unnecessary `bytes` call (rewrite as a literal) | = help: Replace with bytes literal -ℹ Safe fix 38 38 | str("foo") 39 39 | str(""" 40 40 | foo""") @@ -98,7 +94,6 @@ UP018.py:42:1: UP018 [*] Unnecessary `bytes` call (rewrite as a literal) | = help: Replace with bytes literal -ℹ Safe fix 39 39 | str(""" 40 40 | foo""") 41 41 | bytes() @@ -120,7 +115,6 @@ UP018.py:43:1: UP018 [*] Unnecessary `bytes` call (rewrite as a literal) | = help: Replace with bytes literal -ℹ Safe fix 40 40 | foo""") 41 41 | bytes() 42 42 | bytes(b"foo") @@ -143,7 +137,6 @@ UP018.py:45:4: UP018 [*] Unnecessary `str` call (rewrite as a literal) | = help: Replace with string literal -ℹ Safe fix 42 42 | bytes(b"foo") 43 43 | bytes(b""" 44 44 | foo""") @@ -164,7 +157,6 @@ UP018.py:46:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) | = help: Replace with integer literal -ℹ Safe fix 43 43 | bytes(b""" 44 44 | foo""") 45 45 | f"{str()}" @@ -185,7 +177,6 @@ UP018.py:47:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) | = help: Replace with integer literal -ℹ Safe fix 44 44 | foo""") 45 45 | f"{str()}" 46 46 | int() @@ -206,7 +197,6 @@ UP018.py:48:1: UP018 [*] Unnecessary `float` call (rewrite as a literal) | = help: Replace with float literal -ℹ Safe fix 45 45 | f"{str()}" 46 46 | int() 47 47 | int(1) @@ -227,7 +217,6 @@ UP018.py:49:1: UP018 [*] Unnecessary `float` call (rewrite as a literal) | = help: Replace with float literal -ℹ Safe fix 46 46 | int() 47 47 | int(1) 48 48 | float() @@ -248,7 +237,6 @@ UP018.py:50:1: UP018 [*] Unnecessary `bool` call (rewrite as a literal) | = help: Replace with boolean literal -ℹ Safe fix 47 47 | int(1) 48 48 | float() 49 49 | float(1.0) @@ -268,7 +256,6 @@ UP018.py:51:1: UP018 [*] Unnecessary `bool` call (rewrite as a literal) | = help: Replace with boolean literal -ℹ Safe fix 48 48 | float() 49 49 | float(1.0) 50 50 | bool() @@ -289,7 +276,6 @@ UP018.py:52:1: UP018 [*] Unnecessary `bool` call (rewrite as a literal) | = help: Replace with boolean literal -ℹ Safe fix 49 49 | float(1.0) 50 50 | bool() 51 51 | bool(True) @@ -309,7 +295,6 @@ UP018.py:55:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) | = help: Replace with integer literal -ℹ Safe fix 52 52 | bool(False) 53 53 | 54 54 | # These become a literal but retain parentheses @@ -329,7 +314,6 @@ UP018.py:58:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) | = help: Replace with integer literal -ℹ Safe fix 55 55 | int(1).denominator 56 56 | 57 57 | # These too are literals in spirit @@ -350,7 +334,6 @@ UP018.py:59:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) | = help: Replace with integer literal -ℹ Safe fix 56 56 | 57 57 | # These too are literals in spirit 58 58 | int(+1) @@ -369,7 +352,6 @@ UP018.py:60:1: UP018 [*] Unnecessary `float` call (rewrite as a literal) | = help: Replace with float literal -ℹ Safe fix 57 57 | # These too are literals in spirit 58 58 | int(+1) 59 59 | int(-1) @@ -386,11 +368,8 @@ UP018.py:61:1: UP018 [*] Unnecessary `float` call (rewrite as a literal) | = help: Replace with float literal -ℹ Safe fix 58 58 | int(+1) 59 59 | int(-1) 60 60 | float(+1.0) 61 |-float(-1.0) 61 |+-1.0 - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP019.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP019.py.snap index 389ee5e9736a5..bd4fc7d87b6b0 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP019.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP019.py.snap @@ -9,7 +9,6 @@ UP019.py:7:22: UP019 [*] `typing.Text` is deprecated, use `str` | = help: Replace with `str` -ℹ Safe fix 4 4 | from typing import Text as Goodbye 5 5 | 6 6 | @@ -27,7 +26,6 @@ UP019.py:11:29: UP019 [*] `typing.Text` is deprecated, use `str` | = help: Replace with `str` -ℹ Safe fix 8 8 | print(word) 9 9 | 10 10 | @@ -45,7 +43,6 @@ UP019.py:15:28: UP019 [*] `typing.Text` is deprecated, use `str` | = help: Replace with `str` -ℹ Safe fix 12 12 | print(word) 13 13 | 14 14 | @@ -63,12 +60,9 @@ UP019.py:19:29: UP019 [*] `typing.Text` is deprecated, use `str` | = help: Replace with `str` -ℹ Safe fix 16 16 | print(word) 17 17 | 18 18 | 19 |-def print_fourth_word(word: Goodbye) -> None: 19 |+def print_fourth_word(word: str) -> None: 20 20 | print(word) - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP020.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP020.py.snap index d8d5ed3948468..99fc67ea00f9a 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP020.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP020.py.snap @@ -11,7 +11,6 @@ UP020.py:3:6: UP020 [*] Use builtin `open` | = help: Replace with builtin `open` -ℹ Safe fix 1 1 | import io 2 2 | 3 |-with io.open("f.txt", mode="r", buffering=-1, **kwargs) as f: @@ -30,7 +29,6 @@ UP020.py:8:6: UP020 [*] Use builtin `open` | = help: Replace with builtin `open` -ℹ Safe fix 4 4 | print(f.read()) 5 5 | 6 6 | from io import open diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP021.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP021.py.snap index 128a9c9d7396a..5de07ac3c6be4 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP021.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP021.py.snap @@ -11,7 +11,6 @@ UP021.py:5:25: UP021 [*] `universal_newlines` is deprecated, use `text` | = help: Replace with `text` keyword argument -ℹ Safe fix 2 2 | from subprocess import run 3 3 | 4 4 | # Errors @@ -31,7 +30,6 @@ UP021.py:6:25: UP021 [*] `universal_newlines` is deprecated, use `text` | = help: Replace with `text` keyword argument -ℹ Safe fix 3 3 | 4 4 | # Errors 5 5 | subprocess.run(["foo"], universal_newlines=True, check=True) @@ -52,7 +50,6 @@ UP021.py:7:14: UP021 [*] `universal_newlines` is deprecated, use `text` | = help: Replace with `text` keyword argument -ℹ Safe fix 4 4 | # Errors 5 5 | subprocess.run(["foo"], universal_newlines=True, check=True) 6 6 | subprocess.run(["foo"], universal_newlines=True, text=True) @@ -61,5 +58,3 @@ UP021.py:7:14: UP021 [*] `universal_newlines` is deprecated, use `text` 8 8 | 9 9 | # OK 10 10 | subprocess.run(["foo"], check=True) - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP022.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP022.py.snap index c6680d1ce5277..81816108c2a91 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP022.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP022.py.snap @@ -12,15 +12,6 @@ UP022.py:4:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `stde | = help: Replace with `capture_output` keyword argument -ℹ Unsafe fix -1 1 | from subprocess import run -2 2 | import subprocess -3 3 | -4 |-output = run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - 4 |+output = run(["foo"], capture_output=True) -5 5 | -6 6 | output = subprocess.run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) -7 7 | UP022.py:6:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` | @@ -33,15 +24,6 @@ UP022.py:6:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `stde | = help: Replace with `capture_output` keyword argument -ℹ Unsafe fix -3 3 | -4 4 | output = run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) -5 5 | -6 |-output = subprocess.run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - 6 |+output = subprocess.run(["foo"], capture_output=True) -7 7 | -8 8 | output = subprocess.run(stdout=subprocess.PIPE, args=["foo"], stderr=subprocess.PIPE) -9 9 | UP022.py:8:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` | @@ -54,15 +36,6 @@ UP022.py:8:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `stde | = help: Replace with `capture_output` keyword argument -ℹ Unsafe fix -5 5 | -6 6 | output = subprocess.run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) -7 7 | -8 |-output = subprocess.run(stdout=subprocess.PIPE, args=["foo"], stderr=subprocess.PIPE) - 8 |+output = subprocess.run(capture_output=True, args=["foo"]) -9 9 | -10 10 | output = subprocess.run( -11 11 | ["foo"], stdout=subprocess.PIPE, check=True, stderr=subprocess.PIPE UP022.py:10:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` | @@ -78,15 +51,6 @@ UP022.py:10:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `std | = help: Replace with `capture_output` keyword argument -ℹ Unsafe fix -8 8 | output = subprocess.run(stdout=subprocess.PIPE, args=["foo"], stderr=subprocess.PIPE) -9 9 | -10 10 | output = subprocess.run( -11 |- ["foo"], stdout=subprocess.PIPE, check=True, stderr=subprocess.PIPE - 11 |+ ["foo"], capture_output=True, check=True -12 12 | ) -13 13 | -14 14 | output = subprocess.run( UP022.py:14:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` | @@ -102,15 +66,6 @@ UP022.py:14:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `std | = help: Replace with `capture_output` keyword argument -ℹ Unsafe fix -12 12 | ) -13 13 | -14 14 | output = subprocess.run( -15 |- ["foo"], stderr=subprocess.PIPE, check=True, stdout=subprocess.PIPE - 15 |+ ["foo"], capture_output=True, check=True -16 16 | ) -17 17 | -18 18 | output = subprocess.run( UP022.py:18:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` | @@ -132,17 +87,6 @@ UP022.py:18:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `std | = help: Replace with `capture_output` keyword argument -ℹ Unsafe fix -17 17 | -18 18 | output = subprocess.run( -19 19 | ["foo"], -20 |- stdout=subprocess.PIPE, - 20 |+ capture_output=True, -21 21 | check=True, -22 |- stderr=subprocess.PIPE, -23 22 | text=True, -24 23 | encoding="utf-8", -25 24 | close_fds=True, UP022.py:29:14: UP022 [*] Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` | @@ -162,17 +106,6 @@ UP022.py:29:14: UP022 [*] Prefer `capture_output` over sending `stdout` and `std | = help: Replace with `capture_output` keyword argument -ℹ Unsafe fix -28 28 | if output: -29 29 | output = subprocess.run( -30 30 | ["foo"], -31 |- stdout=subprocess.PIPE, - 31 |+ capture_output=True, -32 32 | check=True, -33 |- stderr=subprocess.PIPE, -34 33 | text=True, -35 34 | encoding="utf-8", -36 35 | ) UP022.py:38:10: UP022 Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` | @@ -215,5 +148,3 @@ UP022.py:46:10: UP022 Prefer `capture_output` over sending `stdout` and `stderr` 50 | # OK | = help: Replace with `capture_output` keyword argument - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP023.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP023.py.snap index 2f5d2cb75b5af..6137c8fb34cf2 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP023.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP023.py.snap @@ -10,7 +10,6 @@ UP023.py:2:1: UP023 [*] `cElementTree` is deprecated, use `ElementTree` | = help: Replace with `ElementTree` -ℹ Safe fix 1 1 | # These two imports have something after cElementTree, so they should be fixed. 2 |-from xml.etree.cElementTree import XML, Element, SubElement 2 |+from xml.etree.ElementTree import XML, Element, SubElement @@ -29,7 +28,6 @@ UP023.py:3:8: UP023 [*] `cElementTree` is deprecated, use `ElementTree` | = help: Replace with `ElementTree` -ℹ Safe fix 1 1 | # These two imports have something after cElementTree, so they should be fixed. 2 2 | from xml.etree.cElementTree import XML, Element, SubElement 3 |-import xml.etree.cElementTree as ET @@ -47,7 +45,6 @@ UP023.py:6:1: UP023 [*] `cElementTree` is deprecated, use `ElementTree` | = help: Replace with `ElementTree` -ℹ Safe fix 3 3 | import xml.etree.cElementTree as ET 4 4 | 5 5 | # Weird spacing should not cause issues. @@ -68,7 +65,6 @@ UP023.py:7:11: UP023 [*] `cElementTree` is deprecated, use `ElementTree` | = help: Replace with `ElementTree` -ℹ Safe fix 4 4 | 5 5 | # Weird spacing should not cause issues. 6 6 | from xml.etree.cElementTree import XML @@ -92,7 +88,6 @@ UP023.py:10:1: UP023 [*] `cElementTree` is deprecated, use `ElementTree` | = help: Replace with `ElementTree` -ℹ Safe fix 7 7 | import xml.etree.cElementTree as ET 8 8 | 9 9 | # Multi line imports should also work fine. @@ -112,7 +107,6 @@ UP023.py:16:12: UP023 [*] `cElementTree` is deprecated, use `ElementTree` | = help: Replace with `ElementTree` -ℹ Safe fix 13 13 | SubElement, 14 14 | ) 15 15 | if True: @@ -133,7 +127,6 @@ UP023.py:17:27: UP023 [*] `cElementTree` is deprecated, use `ElementTree` | = help: Replace with `ElementTree` -ℹ Safe fix 14 14 | ) 15 15 | if True: 16 16 | import xml.etree.cElementTree as ET @@ -154,7 +147,6 @@ UP023.py:19:23: UP023 [*] `cElementTree` is deprecated, use `ElementTree` | = help: Replace with `ElementTree` -ℹ Safe fix 16 16 | import xml.etree.cElementTree as ET 17 17 | from xml.etree import cElementTree as CET 18 18 | @@ -175,7 +167,6 @@ UP023.py:21:20: UP023 [*] `cElementTree` is deprecated, use `ElementTree` | = help: Replace with `ElementTree` -ℹ Safe fix 18 18 | 19 19 | from xml.etree import cElementTree as ET 20 20 | @@ -195,7 +186,6 @@ UP023.py:24:32: UP023 [*] `cElementTree` is deprecated, use `ElementTree` | = help: Replace with `ElementTree` -ℹ Safe fix 21 21 | import contextlib, xml.etree.cElementTree as ET 22 22 | 23 23 | # This should fix the second, but not the first invocation. @@ -204,5 +194,3 @@ UP023.py:24:32: UP023 [*] `cElementTree` is deprecated, use `ElementTree` 25 25 | 26 26 | # The below items should NOT be changed. 27 27 | import xml.etree.cElementTree - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_0.py.snap index bb7879fbc7c06..806b40ae822be 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_0.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_0.py.snap @@ -11,7 +11,6 @@ UP024_0.py:6:8: UP024 [*] Replace aliased errors with `OSError` | = help: Replace `EnvironmentError` with builtin `OSError` -ℹ Safe fix 3 3 | # These should be fixed 4 4 | try: 5 5 | pass @@ -31,7 +30,6 @@ UP024_0.py:11:8: UP024 [*] Replace aliased errors with `OSError` | = help: Replace `IOError` with builtin `OSError` -ℹ Safe fix 8 8 | 9 9 | try: 10 10 | pass @@ -51,7 +49,6 @@ UP024_0.py:16:8: UP024 [*] Replace aliased errors with `OSError` | = help: Replace `WindowsError` with builtin `OSError` -ℹ Safe fix 13 13 | 14 14 | try: 15 15 | pass @@ -71,7 +68,6 @@ UP024_0.py:21:8: UP024 [*] Replace aliased errors with `OSError` | = help: Replace `mmap.error` with builtin `OSError` -ℹ Safe fix 18 18 | 19 19 | try: 20 20 | pass @@ -91,7 +87,6 @@ UP024_0.py:26:8: UP024 [*] Replace aliased errors with `OSError` | = help: Replace `select.error` with builtin `OSError` -ℹ Safe fix 23 23 | 24 24 | try: 25 25 | pass @@ -111,7 +106,6 @@ UP024_0.py:31:8: UP024 [*] Replace aliased errors with `OSError` | = help: Replace `socket.error` with builtin `OSError` -ℹ Safe fix 28 28 | 29 29 | try: 30 30 | pass @@ -131,7 +125,6 @@ UP024_0.py:36:8: UP024 [*] Replace aliased errors with `OSError` | = help: Replace `error` with builtin `OSError` -ℹ Safe fix 33 33 | 34 34 | try: 35 35 | pass @@ -152,7 +145,6 @@ UP024_0.py:43:8: UP024 [*] Replace aliased errors with `OSError` | = help: Replace with builtin `OSError` -ℹ Safe fix 40 40 | 41 41 | try: 42 42 | pass @@ -173,7 +165,6 @@ UP024_0.py:47:8: UP024 [*] Replace aliased errors with `OSError` | = help: Replace with builtin `OSError` -ℹ Safe fix 44 44 | pass 45 45 | try: 46 46 | pass @@ -193,7 +184,6 @@ UP024_0.py:51:8: UP024 [*] Replace aliased errors with `OSError` | = help: Replace with builtin `OSError` -ℹ Safe fix 48 48 | pass 49 49 | try: 50 50 | pass @@ -213,7 +203,6 @@ UP024_0.py:58:8: UP024 [*] Replace aliased errors with `OSError` | = help: Replace with builtin `OSError` -ℹ Safe fix 55 55 | 56 56 | try: 57 57 | pass @@ -234,7 +223,6 @@ UP024_0.py:65:8: UP024 [*] Replace aliased errors with `OSError` | = help: Replace with builtin `OSError` -ℹ Safe fix 62 62 | from .mmap import error 63 63 | try: 64 64 | pass @@ -254,7 +242,6 @@ UP024_0.py:87:8: UP024 [*] Replace aliased errors with `OSError` | = help: Replace `mmap.error` with builtin `OSError` -ℹ Safe fix 84 84 | pass 85 85 | try: 86 86 | pass @@ -274,7 +261,6 @@ UP024_0.py:105:11: UP024 [*] Replace aliased errors with `OSError` | = help: Replace with builtin `OSError` -ℹ Safe fix 102 102 | def get_owner_id_from_mac_address(): 103 103 | try: 104 104 | mac_address = get_primary_mac_address() @@ -294,12 +280,9 @@ UP024_0.py:114:8: UP024 [*] Replace aliased errors with `OSError` | = help: Replace `os.error` with builtin `OSError` -ℹ Safe fix 111 111 | 112 112 | try: 113 113 | pass 114 |-except os.error: 114 |+except OSError: 115 115 | pass - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_1.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_1.py.snap index d0a723a1b9f67..30ff808e5960f 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_1.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_1.py.snap @@ -12,7 +12,6 @@ UP024_1.py:5:8: UP024 [*] Replace aliased errors with `OSError` | = help: Replace with builtin `OSError` -ℹ Safe fix 2 2 | 3 3 | try: 4 4 | pass @@ -32,7 +31,6 @@ UP024_1.py:7:8: UP024 [*] Replace aliased errors with `OSError` | = help: Replace with builtin `OSError` -ℹ Safe fix 4 4 | pass 5 5 | except (OSError, mmap.error, IOError): 6 6 | pass @@ -57,7 +55,6 @@ UP024_1.py:12:8: UP024 [*] Replace aliased errors with `OSError` | = help: Replace with builtin `OSError` -ℹ Safe fix 9 9 | 10 10 | try: 11 11 | pass @@ -68,5 +65,3 @@ UP024_1.py:12:8: UP024 [*] Replace aliased errors with `OSError` 16 |-): 12 |+except OSError: 17 13 | pass - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_2.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_2.py.snap index eecdf5fea5e17..eb7cddf1044d8 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_2.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_2.py.snap @@ -12,7 +12,6 @@ UP024_2.py:10:7: UP024 [*] Replace aliased errors with `OSError` | = help: Replace `socket.error` with builtin `OSError` -ℹ Safe fix 7 7 | 8 8 | # Testing the modules 9 9 | import socket, mmap, select @@ -32,7 +31,6 @@ UP024_2.py:11:7: UP024 [*] Replace aliased errors with `OSError` | = help: Replace `mmap.error` with builtin `OSError` -ℹ Safe fix 8 8 | # Testing the modules 9 9 | import socket, mmap, select 10 10 | raise socket.error @@ -53,7 +51,6 @@ UP024_2.py:12:7: UP024 [*] Replace aliased errors with `OSError` | = help: Replace `select.error` with builtin `OSError` -ℹ Safe fix 9 9 | import socket, mmap, select 10 10 | raise socket.error 11 11 | raise mmap.error @@ -74,7 +71,6 @@ UP024_2.py:14:7: UP024 [*] Replace aliased errors with `OSError` | = help: Replace `socket.error` with builtin `OSError` -ℹ Safe fix 11 11 | raise mmap.error 12 12 | raise select.error 13 13 | @@ -93,7 +89,6 @@ UP024_2.py:15:7: UP024 [*] Replace aliased errors with `OSError` | = help: Replace `mmap.error` with builtin `OSError` -ℹ Safe fix 12 12 | raise select.error 13 13 | 14 14 | raise socket.error() @@ -114,7 +109,6 @@ UP024_2.py:16:7: UP024 [*] Replace aliased errors with `OSError` | = help: Replace `select.error` with builtin `OSError` -ℹ Safe fix 13 13 | 14 14 | raise socket.error() 15 15 | raise mmap.error(1) @@ -135,7 +129,6 @@ UP024_2.py:18:7: UP024 [*] Replace aliased errors with `OSError` | = help: Replace `socket.error` with builtin `OSError` -ℹ Safe fix 15 15 | raise mmap.error(1) 16 16 | raise select.error(1, 2) 17 17 | @@ -155,7 +148,6 @@ UP024_2.py:25:7: UP024 [*] Replace aliased errors with `OSError` | = help: Replace `error` with builtin `OSError` -ℹ Safe fix 22 22 | ) 23 23 | 24 24 | from mmap import error @@ -175,7 +167,6 @@ UP024_2.py:28:7: UP024 [*] Replace aliased errors with `OSError` | = help: Replace `error` with builtin `OSError` -ℹ Safe fix 25 25 | raise error 26 26 | 27 27 | from socket import error @@ -195,7 +186,6 @@ UP024_2.py:31:7: UP024 [*] Replace aliased errors with `OSError` | = help: Replace `error` with builtin `OSError` -ℹ Safe fix 28 28 | raise error(1) 29 29 | 30 30 | from select import error @@ -215,7 +205,6 @@ UP024_2.py:34:7: UP024 [*] Replace aliased errors with `OSError` | = help: Replace `EnvironmentError` with builtin `OSError` -ℹ Safe fix 31 31 | raise error(1, 2) 32 32 | 33 33 | # Testing the names @@ -235,7 +224,6 @@ UP024_2.py:35:7: UP024 [*] Replace aliased errors with `OSError` | = help: Replace `IOError` with builtin `OSError` -ℹ Safe fix 32 32 | 33 33 | # Testing the names 34 34 | raise EnvironmentError @@ -256,7 +244,6 @@ UP024_2.py:36:7: UP024 [*] Replace aliased errors with `OSError` | = help: Replace `WindowsError` with builtin `OSError` -ℹ Safe fix 33 33 | # Testing the names 34 34 | raise EnvironmentError 35 35 | raise IOError @@ -277,7 +264,6 @@ UP024_2.py:38:7: UP024 [*] Replace aliased errors with `OSError` | = help: Replace `EnvironmentError` with builtin `OSError` -ℹ Safe fix 35 35 | raise IOError 36 36 | raise WindowsError 37 37 | @@ -296,7 +282,6 @@ UP024_2.py:39:7: UP024 [*] Replace aliased errors with `OSError` | = help: Replace `IOError` with builtin `OSError` -ℹ Safe fix 36 36 | raise WindowsError 37 37 | 38 38 | raise EnvironmentError() @@ -317,7 +302,6 @@ UP024_2.py:40:7: UP024 [*] Replace aliased errors with `OSError` | = help: Replace `WindowsError` with builtin `OSError` -ℹ Safe fix 37 37 | 38 38 | raise EnvironmentError() 39 39 | raise IOError(1) @@ -338,7 +322,6 @@ UP024_2.py:42:7: UP024 [*] Replace aliased errors with `OSError` | = help: Replace `EnvironmentError` with builtin `OSError` -ℹ Safe fix 39 39 | raise IOError(1) 40 40 | raise WindowsError(1, 2) 41 41 | @@ -359,7 +342,6 @@ UP024_2.py:48:7: UP024 [*] Replace aliased errors with `OSError` | = help: Replace `WindowsError` with builtin `OSError` -ℹ Safe fix 45 45 | 3, 46 46 | ) 47 47 | @@ -377,7 +359,6 @@ UP024_2.py:49:7: UP024 [*] Replace aliased errors with `OSError` | = help: Replace `EnvironmentError` with builtin `OSError` -ℹ Safe fix 46 46 | ) 47 47 | 48 48 | raise WindowsError @@ -394,11 +375,8 @@ UP024_2.py:50:7: UP024 [*] Replace aliased errors with `OSError` | = help: Replace `IOError` with builtin `OSError` -ℹ Safe fix 47 47 | 48 48 | raise WindowsError 49 49 | raise EnvironmentError(1) 50 |-raise IOError(1, 2) 50 |+raise OSError(1, 2) - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_4.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_4.py.snap index 40f6fbea4b00a..6abe55a0170d9 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_4.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_4.py.snap @@ -11,12 +11,9 @@ UP024_4.py:9:8: UP024 [*] Replace aliased errors with `OSError` | = help: Replace with builtin `OSError` -ℹ Safe fix 6 6 | conn = Connection(settings.CELERY_BROKER_URL) 7 7 | conn.ensure_connection(max_retries=2) 8 8 | conn._close() 9 |-except (socket.error, exceptions.OperationalError): 9 |+except (OSError, exceptions.OperationalError): 10 10 | return HttpResponseServerError("cache: cannot connect to broker.") - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP025.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP025.py.snap index e5cd73cc97314..755dfb9156f87 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP025.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP025.py.snap @@ -10,7 +10,6 @@ UP025.py:1:1: UP025 [*] Remove unicode literals from strings | = help: Remove unicode prefix -ℹ Safe fix 1 |-u"Hello" 1 |+"Hello" 2 2 | @@ -28,7 +27,6 @@ UP025.py:3:5: UP025 [*] Remove unicode literals from strings | = help: Remove unicode prefix -ℹ Safe fix 1 1 | u"Hello" 2 2 | 3 |-x = u"Hello" # UP025 @@ -48,7 +46,6 @@ UP025.py:5:1: UP025 [*] Remove unicode literals from strings | = help: Remove unicode prefix -ℹ Safe fix 2 2 | 3 3 | x = u"Hello" # UP025 4 4 | @@ -69,7 +66,6 @@ UP025.py:7:7: UP025 [*] Remove unicode literals from strings | = help: Remove unicode prefix -ℹ Safe fix 4 4 | 5 5 | u'world' # UP025 6 6 | @@ -90,7 +86,6 @@ UP025.py:9:7: UP025 [*] Remove unicode literals from strings | = help: Remove unicode prefix -ℹ Safe fix 6 6 | 7 7 | print(u"Hello") # UP025 8 8 | @@ -111,7 +106,6 @@ UP025.py:13:5: UP025 [*] Remove unicode literals from strings | = help: Remove unicode prefix -ℹ Safe fix 10 10 | 11 11 | import foo 12 12 | @@ -132,7 +126,6 @@ UP025.py:13:15: UP025 [*] Remove unicode literals from strings | = help: Remove unicode prefix -ℹ Safe fix 10 10 | 11 11 | import foo 12 12 | @@ -153,7 +146,6 @@ UP025.py:13:27: UP025 [*] Remove unicode literals from strings | = help: Remove unicode prefix -ℹ Safe fix 10 10 | 11 11 | import foo 12 12 | @@ -174,7 +166,6 @@ UP025.py:13:39: UP025 [*] Remove unicode literals from strings | = help: Remove unicode prefix -ℹ Safe fix 10 10 | 11 11 | import foo 12 12 | @@ -194,7 +185,6 @@ UP025.py:16:5: UP025 [*] Remove unicode literals from strings | = help: Remove unicode prefix -ℹ Safe fix 13 13 | foo(u"Hello", U"world", a=u"Hello", b=u"world") # UP025 14 14 | 15 15 | # Retain quotes when fixing. @@ -215,7 +205,6 @@ UP025.py:17:5: UP025 [*] Remove unicode literals from strings | = help: Remove unicode prefix -ℹ Safe fix 14 14 | 15 15 | # Retain quotes when fixing. 16 16 | x = u'hello' # UP025 @@ -235,7 +224,6 @@ UP025.py:18:5: UP025 [*] Remove unicode literals from strings | = help: Remove unicode prefix -ℹ Safe fix 15 15 | # Retain quotes when fixing. 16 16 | x = u'hello' # UP025 17 17 | x = u"""hello""" # UP025 @@ -256,7 +244,6 @@ UP025.py:19:5: UP025 [*] Remove unicode literals from strings | = help: Remove unicode prefix -ℹ Safe fix 16 16 | x = u'hello' # UP025 17 17 | x = u"""hello""" # UP025 18 18 | x = u'''hello''' # UP025 @@ -276,7 +263,6 @@ UP025.py:27:7: UP025 [*] Remove unicode literals from strings | = help: Remove unicode prefix -ℹ Safe fix 24 24 | def hello(): 25 25 | return"Hello" # OK 26 26 | @@ -292,11 +278,8 @@ UP025.py:28:8: UP025 [*] Remove unicode literals from strings | = help: Remove unicode prefix -ℹ Safe fix 25 25 | return"Hello" # OK 26 26 | 27 27 | f"foo"u"bar" # OK 28 |-f"foo" u"bar" # OK 28 |+f"foo" "bar" # OK - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP026.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP026.py.snap index 56d9e70f2cb27..d1b41cb4d0149 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP026.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP026.py.snap @@ -12,7 +12,6 @@ UP026.py:3:12: UP026 [*] `mock` is deprecated, use `unittest.mock` | = help: Import from `unittest.mock` instead -ℹ Safe fix 1 1 | # Error (`from unittest import mock`) 2 2 | if True: 3 |- import mock @@ -32,7 +31,6 @@ UP026.py:7:12: UP026 [*] `mock` is deprecated, use `unittest.mock` | = help: Import from `unittest.mock` instead -ℹ Safe fix 4 4 | 5 5 | # Error (`from unittest import mock`) 6 6 | if True: @@ -54,7 +52,6 @@ UP026.py:11:5: UP026 [*] `mock` is deprecated, use `unittest.mock` | = help: Import from `unittest.mock` instead -ℹ Safe fix 8 8 | 9 9 | # Error (`from unittest.mock import *`) 10 10 | if True: @@ -74,7 +71,6 @@ UP026.py:14:8: UP026 [*] `mock` is deprecated, use `unittest.mock` | = help: Import from `unittest.mock` instead -ℹ Safe fix 11 11 | from mock import * 12 12 | 13 13 | # Error (`from unittest import mock`) @@ -94,7 +90,6 @@ UP026.py:17:20: UP026 [*] `mock` is deprecated, use `unittest.mock` | = help: Import from `unittest.mock` instead -ℹ Safe fix 14 14 | import mock.mock 15 15 | 16 16 | # Error (`from unittest import mock`) @@ -114,7 +109,6 @@ UP026.py:20:8: UP026 [*] `mock` is deprecated, use `unittest.mock` | = help: Import from `unittest.mock` instead -ℹ Safe fix 17 17 | import contextlib, mock, sys 18 18 | 19 19 | # Error (`from unittest import mock`) @@ -135,7 +129,6 @@ UP026.py:24:1: UP026 [*] `mock` is deprecated, use `unittest.mock` | = help: Import from `unittest.mock` instead -ℹ Safe fix 21 21 | x = "This code should be preserved one line below the mock" 22 22 | 23 23 | # Error (`from unittest import mock`) @@ -160,7 +153,6 @@ UP026.py:27:1: UP026 [*] `mock` is deprecated, use `unittest.mock` | = help: Import from `unittest.mock` instead -ℹ Safe fix 24 24 | from mock import mock 25 25 | 26 26 | # Error (keep trailing comma) @@ -192,7 +184,6 @@ UP026.py:33:1: UP026 [*] `mock` is deprecated, use `unittest.mock` | = help: Import from `unittest.mock` instead -ℹ Safe fix 30 30 | b, 31 31 | c, 32 32 | ) @@ -223,7 +214,6 @@ UP026.py:41:1: UP026 [*] `mock` is deprecated, use `unittest.mock` | = help: Import from `unittest.mock` instead -ℹ Safe fix 38 38 | ) 39 39 | 40 40 | # Error (avoid trailing comma) @@ -255,7 +245,6 @@ UP026.py:47:1: UP026 [*] `mock` is deprecated, use `unittest.mock` | = help: Import from `unittest.mock` instead -ℹ Safe fix 44 44 | b, 45 45 | c 46 46 | ) @@ -282,7 +271,6 @@ UP026.py:53:1: UP026 [*] `mock` is deprecated, use `unittest.mock` | = help: Import from `unittest.mock` instead -ℹ Safe fix 50 50 | c, 51 51 | mock 52 52 | ) @@ -304,7 +292,6 @@ UP026.py:54:1: UP026 [*] `mock` is deprecated, use `unittest.mock` | = help: Import from `unittest.mock` instead -ℹ Safe fix 51 51 | mock 52 52 | ) 53 53 | from mock import mock, a, b, c @@ -332,7 +319,6 @@ UP026.py:58:9: UP026 [*] `mock` is deprecated, use `unittest.mock` | = help: Import from `unittest.mock` instead -ℹ Safe fix 55 55 | 56 56 | if True: 57 57 | if False: @@ -358,7 +344,6 @@ UP026.py:69:8: UP026 [*] `mock` is deprecated, use `unittest.mock` | = help: Import from `unittest.mock` instead -ℹ Safe fix 66 66 | import os, io 67 67 | 68 68 | # Error (`from unittest import mock`) @@ -379,7 +364,6 @@ UP026.py:69:14: UP026 [*] `mock` is deprecated, use `unittest.mock` | = help: Import from `unittest.mock` instead -ℹ Safe fix 66 66 | import os, io 67 67 | 68 68 | # Error (`from unittest import mock`) @@ -400,7 +384,6 @@ UP026.py:72:8: UP026 [*] `mock` is deprecated, use `unittest.mock` | = help: Import from `unittest.mock` instead -ℹ Safe fix 69 69 | import mock, mock 70 70 | 71 71 | # Error (`from unittest import mock as foo`) @@ -420,7 +403,6 @@ UP026.py:75:1: UP026 [*] `mock` is deprecated, use `unittest.mock` | = help: Import from `unittest.mock` instead -ℹ Safe fix 72 72 | import mock as foo 73 73 | 74 74 | # Error (`from unittest import mock as foo`) @@ -441,7 +423,6 @@ UP026.py:79:12: UP026 [*] `mock` is deprecated, use `unittest.mock` | = help: Import from `unittest.mock` instead -ℹ Safe fix 76 76 | 77 77 | if True: 78 78 | # This should yield multiple, aliased imports. @@ -464,7 +445,6 @@ UP026.py:79:25: UP026 [*] `mock` is deprecated, use `unittest.mock` | = help: Import from `unittest.mock` instead -ℹ Safe fix 76 76 | 77 77 | if True: 78 78 | # This should yield multiple, aliased imports. @@ -487,7 +467,6 @@ UP026.py:79:38: UP026 [*] `mock` is deprecated, use `unittest.mock` | = help: Import from `unittest.mock` instead -ℹ Safe fix 76 76 | 77 77 | if True: 78 78 | # This should yield multiple, aliased imports. @@ -509,7 +488,6 @@ UP026.py:82:12: UP026 [*] `mock` is deprecated, use `unittest.mock` | = help: Import from `unittest.mock` instead -ℹ Safe fix 79 79 | import mock as foo, mock as bar, mock 80 80 | 81 81 | # This should yield multiple, aliased imports, and preserve `os`. @@ -532,7 +510,6 @@ UP026.py:82:25: UP026 [*] `mock` is deprecated, use `unittest.mock` | = help: Import from `unittest.mock` instead -ℹ Safe fix 79 79 | import mock as foo, mock as bar, mock 80 80 | 81 81 | # This should yield multiple, aliased imports, and preserve `os`. @@ -555,7 +532,6 @@ UP026.py:82:38: UP026 [*] `mock` is deprecated, use `unittest.mock` | = help: Import from `unittest.mock` instead -ℹ Safe fix 79 79 | import mock as foo, mock as bar, mock 80 80 | 81 81 | # This should yield multiple, aliased imports, and preserve `os`. @@ -577,7 +553,6 @@ UP026.py:86:5: UP026 [*] `mock` is deprecated, use `unittest.mock` | = help: Import from `unittest.mock` instead -ℹ Safe fix 83 83 | 84 84 | if True: 85 85 | # This should yield multiple, aliased imports. @@ -597,11 +572,8 @@ UP026.py:93:5: UP026 [*] `mock` is deprecated, use `unittest.mock` | = help: Replace `mock.mock` with `mock` -ℹ Safe fix 90 90 | x = mock.Mock() 91 91 | 92 92 | # Error (`mock.Mock()`). 93 |-x = mock.mock.Mock() 93 |+x = mock.Mock() - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP027.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP027.py.snap index c177a26b81e2b..49eff2ccedca9 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP027.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP027.py.snap @@ -11,7 +11,6 @@ UP027.py:2:17: UP027 [*] Replace unpacked list comprehension with a generator ex | = help: Replace with generator expression -ℹ Safe fix 1 1 | # Should change 2 |-foo, bar, baz = [fn(x) for x in items] 2 |+foo, bar, baz = (fn(x) for x in items) @@ -30,7 +29,6 @@ UP027.py:4:16: UP027 [*] Replace unpacked list comprehension with a generator ex | = help: Replace with generator expression -ℹ Safe fix 1 1 | # Should change 2 2 | foo, bar, baz = [fn(x) for x in items] 3 3 | @@ -51,7 +49,6 @@ UP027.py:6:26: UP027 [*] Replace unpacked list comprehension with a generator ex | = help: Replace with generator expression -ℹ Safe fix 3 3 | 4 4 | foo, bar, baz =[fn(x) for x in items] 5 5 | @@ -72,7 +69,6 @@ UP027.py:8:17: UP027 [*] Replace unpacked list comprehension with a generator ex | = help: Replace with generator expression -ℹ Safe fix 5 5 | 6 6 | foo, bar, baz = [fn(x) for x in items] 7 7 | @@ -97,7 +93,6 @@ UP027.py:10:17: UP027 [*] Replace unpacked list comprehension with a generator e | = help: Replace with generator expression -ℹ Safe fix 7 7 | 8 8 | foo, bar, baz = [[i for i in fn(x)] for x in items] 9 9 | diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP028_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP028_0.py.snap index 8d5334bbd0da6..badb54487f685 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP028_0.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP028_0.py.snap @@ -11,14 +11,6 @@ UP028_0.py:2:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | = help: Replace with `yield from` -ℹ Unsafe fix -1 1 | def f(): -2 |- for x in y: -3 |- yield x - 2 |+ yield from y -4 3 | -5 4 | -6 5 | def g(): UP028_0.py:7:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | @@ -30,16 +22,6 @@ UP028_0.py:7:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | = help: Replace with `yield from` -ℹ Unsafe fix -4 4 | -5 5 | -6 6 | def g(): -7 |- for x, y in z: -8 |- yield (x, y) - 7 |+ yield from z -9 8 | -10 9 | -11 10 | def h(): UP028_0.py:12:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | @@ -51,16 +33,6 @@ UP028_0.py:12:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | = help: Replace with `yield from` -ℹ Unsafe fix -9 9 | -10 10 | -11 11 | def h(): -12 |- for x in [1, 2, 3]: -13 |- yield x - 12 |+ yield from [1, 2, 3] -14 13 | -15 14 | -16 15 | def i(): UP028_0.py:17:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | @@ -72,16 +44,6 @@ UP028_0.py:17:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | = help: Replace with `yield from` -ℹ Unsafe fix -14 14 | -15 15 | -16 16 | def i(): -17 |- for x in {x for x in y}: -18 |- yield x - 17 |+ yield from {x for x in y} -19 18 | -20 19 | -21 20 | def j(): UP028_0.py:22:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | @@ -93,16 +55,6 @@ UP028_0.py:22:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | = help: Replace with `yield from` -ℹ Unsafe fix -19 19 | -20 20 | -21 21 | def j(): -22 |- for x in (1, 2, 3): -23 |- yield x - 22 |+ yield from (1, 2, 3) -24 23 | -25 24 | -26 25 | def k(): UP028_0.py:27:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | @@ -114,16 +66,6 @@ UP028_0.py:27:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | = help: Replace with `yield from` -ℹ Unsafe fix -24 24 | -25 25 | -26 26 | def k(): -27 |- for x, y in {3: "x", 6: "y"}: -28 |- yield x, y - 27 |+ yield from {3: "x", 6: "y"} -29 28 | -30 29 | -31 30 | def f(): # Comment one\n' UP028_0.py:33:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | @@ -142,22 +84,6 @@ UP028_0.py:33:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | = help: Replace with `yield from` -ℹ Unsafe fix -30 30 | -31 31 | def f(): # Comment one\n' -32 32 | # Comment two\n' -33 |- for x, y in { # Comment three\n' - 33 |+ yield from { # Comment three\n' -34 34 | 3: "x", # Comment four\n' -35 35 | # Comment five\n' -36 36 | 6: "y", # Comment six\n' -37 |- }: # Comment seven\n' -38 |- # Comment eight\n' -39 |- yield x, y # Comment nine\n' - 37 |+ } # Comment nine\n' -40 38 | # Comment ten', -41 39 | -42 40 | UP028_0.py:44:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | @@ -169,16 +95,6 @@ UP028_0.py:44:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | = help: Replace with `yield from` -ℹ Unsafe fix -41 41 | -42 42 | -43 43 | def f(): -44 |- for x, y in [{3: (3, [44, "long ss"]), 6: "y"}]: -45 |- yield x, y - 44 |+ yield from [{3: (3, [44, "long ss"]), 6: "y"}] -46 45 | -47 46 | -48 47 | def f(): UP028_0.py:49:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | @@ -192,16 +108,6 @@ UP028_0.py:49:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | = help: Replace with `yield from` -ℹ Unsafe fix -46 46 | -47 47 | -48 48 | def f(): -49 |- for x, y in z(): -50 |- yield x, y - 49 |+ yield from z() -51 50 | -52 51 | def f(): -53 52 | def func(): UP028_0.py:55:9: UP028 [*] Replace `yield` over `for` loop with `yield from` | @@ -217,17 +123,6 @@ UP028_0.py:55:9: UP028 [*] Replace `yield` over `for` loop with `yield from` | = help: Replace with `yield from` -ℹ Unsafe fix -52 52 | def f(): -53 53 | def func(): -54 54 | # This comment is preserved\n' -55 |- for x, y in z(): # Comment one\n' -56 |- # Comment two\n' -57 |- yield x, y # Comment three\n' - 55 |+ yield from z() # Comment three\n' -58 56 | # Comment four\n' -59 57 | # Comment\n' -60 58 | def g(): UP028_0.py:67:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | @@ -240,16 +135,6 @@ UP028_0.py:67:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | = help: Replace with `yield from` -ℹ Unsafe fix -64 64 | def f(): -65 65 | for x in y: -66 66 | yield x -67 |- for z in x: -68 |- yield z - 67 |+ yield from x -69 68 | -70 69 | -71 70 | def f(): UP028_0.py:72:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | @@ -262,16 +147,6 @@ UP028_0.py:72:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | = help: Replace with `yield from` -ℹ Unsafe fix -69 69 | -70 70 | -71 71 | def f(): -72 |- for x, y in z(): -73 |- yield x, y - 72 |+ yield from z() -74 73 | x = 1 -75 74 | -76 75 | UP028_0.py:79:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | @@ -286,17 +161,3 @@ UP028_0.py:79:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | |_______________^ UP028 | = help: Replace with `yield from` - -ℹ Unsafe fix -76 76 | -77 77 | # Regression test for: https://github.com/astral-sh/ruff/issues/7103 -78 78 | def _serve_method(fn): -79 |- for h in ( - 79 |+ yield from ( -80 80 | TaggedText.from_file(args.input) -81 81 | .markup(highlight=args.region) -82 |- ): -83 |- yield h - 82 |+ ) - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP029.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP029.py.snap index 5dcbd5e6c95e8..1bcdf2c9e63ea 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP029.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP029.py.snap @@ -10,11 +10,6 @@ UP029.py:1:1: UP029 [*] Unnecessary builtin import: `*` | = help: Remove unnecessary builtin import -ℹ Unsafe fix -1 |-from builtins import * -2 1 | from builtins import ascii, bytes, compile -3 2 | from builtins import str as _str -4 3 | from six.moves import filter, zip, zip_longest UP029.py:2:1: UP029 [*] Unnecessary builtin imports: `ascii`, `bytes` | @@ -26,13 +21,6 @@ UP029.py:2:1: UP029 [*] Unnecessary builtin imports: `ascii`, `bytes` | = help: Remove unnecessary builtin import -ℹ Unsafe fix -1 1 | from builtins import * -2 |-from builtins import ascii, bytes, compile - 2 |+from builtins import compile -3 3 | from builtins import str as _str -4 4 | from six.moves import filter, zip, zip_longest -5 5 | from io import open UP029.py:4:1: UP029 [*] Unnecessary builtin imports: `filter`, `zip` | @@ -45,15 +33,6 @@ UP029.py:4:1: UP029 [*] Unnecessary builtin imports: `filter`, `zip` | = help: Remove unnecessary builtin import -ℹ Unsafe fix -1 1 | from builtins import * -2 2 | from builtins import ascii, bytes, compile -3 3 | from builtins import str as _str -4 |-from six.moves import filter, zip, zip_longest - 4 |+from six.moves import zip_longest -5 5 | from io import open -6 6 | import io -7 7 | import six UP029.py:5:1: UP029 [*] Unnecessary builtin import: `open` | @@ -65,14 +44,3 @@ UP029.py:5:1: UP029 [*] Unnecessary builtin import: `open` 7 | import six | = help: Remove unnecessary builtin import - -ℹ Unsafe fix -2 2 | from builtins import ascii, bytes, compile -3 3 | from builtins import str as _str -4 4 | from six.moves import filter, zip, zip_longest -5 |-from io import open -6 5 | import io -7 6 | import six -8 7 | import six.moves - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP030_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP030_0.py.snap index 936bfd6887969..f22eab4dad322 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP030_0.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP030_0.py.snap @@ -12,14 +12,6 @@ UP030_0.py:3:1: UP030 [*] Use implicit references for positional format fields | = help: Remove explicit positional indices -ℹ Unsafe fix -1 1 | # Invalid calls; errors expected. -2 2 | -3 |-"{0}" "{1}" "{2}".format(1, 2, 3) - 3 |+"{}" "{}" "{}".format(1, 2, 3) -4 4 | -5 5 | "a {3} complicated {1} string with {0} {2}".format( -6 6 | "first", "second", "third", "fourth" UP030_0.py:5:1: UP030 [*] Use implicit references for positional format fields | @@ -34,17 +26,6 @@ UP030_0.py:5:1: UP030 [*] Use implicit references for positional format fields | = help: Remove explicit positional indices -ℹ Unsafe fix -2 2 | -3 3 | "{0}" "{1}" "{2}".format(1, 2, 3) -4 4 | -5 |-"a {3} complicated {1} string with {0} {2}".format( -6 |- "first", "second", "third", "fourth" - 5 |+"a {} complicated {} string with {} {}".format( - 6 |+ "fourth", "second", "first", "third" -7 7 | ) -8 8 | -9 9 | '{0}'.format(1) UP030_0.py:9:1: UP030 [*] Use implicit references for positional format fields | @@ -57,15 +38,6 @@ UP030_0.py:9:1: UP030 [*] Use implicit references for positional format fields | = help: Remove explicit positional indices -ℹ Unsafe fix -6 6 | "first", "second", "third", "fourth" -7 7 | ) -8 8 | -9 |-'{0}'.format(1) - 9 |+'{}'.format(1) -10 10 | -11 11 | '{0:x}'.format(30) -12 12 | UP030_0.py:11:1: UP030 [*] Use implicit references for positional format fields | @@ -78,15 +50,6 @@ UP030_0.py:11:1: UP030 [*] Use implicit references for positional format fields | = help: Remove explicit positional indices -ℹ Unsafe fix -8 8 | -9 9 | '{0}'.format(1) -10 10 | -11 |-'{0:x}'.format(30) - 11 |+'{:x}'.format(30) -12 12 | -13 13 | x = '{0}'.format(1) -14 14 | UP030_0.py:13:5: UP030 [*] Use implicit references for positional format fields | @@ -99,15 +62,6 @@ UP030_0.py:13:5: UP030 [*] Use implicit references for positional format fields | = help: Remove explicit positional indices -ℹ Unsafe fix -10 10 | -11 11 | '{0:x}'.format(30) -12 12 | -13 |-x = '{0}'.format(1) - 13 |+x = '{}'.format(1) -14 14 | -15 15 | '''{0}\n{1}\n'''.format(1, 2) -16 16 | UP030_0.py:15:1: UP030 [*] Use implicit references for positional format fields | @@ -120,15 +74,6 @@ UP030_0.py:15:1: UP030 [*] Use implicit references for positional format fields | = help: Remove explicit positional indices -ℹ Unsafe fix -12 12 | -13 13 | x = '{0}'.format(1) -14 14 | -15 |-'''{0}\n{1}\n'''.format(1, 2) - 15 |+'''{}\n{}\n'''.format(1, 2) -16 16 | -17 17 | x = "foo {0}" \ -18 18 | "bar {1}".format(1, 2) UP030_0.py:17:5: UP030 [*] Use implicit references for positional format fields | @@ -143,17 +88,6 @@ UP030_0.py:17:5: UP030 [*] Use implicit references for positional format fields | = help: Remove explicit positional indices -ℹ Unsafe fix -14 14 | -15 15 | '''{0}\n{1}\n'''.format(1, 2) -16 16 | -17 |-x = "foo {0}" \ -18 |- "bar {1}".format(1, 2) - 17 |+x = "foo {}" \ - 18 |+ "bar {}".format(1, 2) -19 19 | -20 20 | ("{0}").format(1) -21 21 | UP030_0.py:20:1: UP030 [*] Use implicit references for positional format fields | @@ -166,15 +100,6 @@ UP030_0.py:20:1: UP030 [*] Use implicit references for positional format fields | = help: Remove explicit positional indices -ℹ Unsafe fix -17 17 | x = "foo {0}" \ -18 18 | "bar {1}".format(1, 2) -19 19 | -20 |-("{0}").format(1) - 20 |+("{}").format(1) -21 21 | -22 22 | "\N{snowman} {0}".format(1) -23 23 | UP030_0.py:22:1: UP030 [*] Use implicit references for positional format fields | @@ -187,15 +112,6 @@ UP030_0.py:22:1: UP030 [*] Use implicit references for positional format fields | = help: Remove explicit positional indices -ℹ Unsafe fix -19 19 | -20 20 | ("{0}").format(1) -21 21 | -22 |-"\N{snowman} {0}".format(1) - 22 |+"\N{snowman} {}".format(1) -23 23 | -24 24 | print( -25 25 | 'foo{0}' UP030_0.py:25:5: UP030 [*] Use implicit references for positional format fields | @@ -208,17 +124,6 @@ UP030_0.py:25:5: UP030 [*] Use implicit references for positional format fields | = help: Remove explicit positional indices -ℹ Unsafe fix -22 22 | "\N{snowman} {0}".format(1) -23 23 | -24 24 | print( -25 |- 'foo{0}' -26 |- 'bar{1}'.format(1, 2) - 25 |+ 'foo{}' - 26 |+ 'bar{}'.format(1, 2) -27 27 | ) -28 28 | -29 29 | print( UP030_0.py:30:5: UP030 [*] Use implicit references for positional format fields | @@ -231,17 +136,6 @@ UP030_0.py:30:5: UP030 [*] Use implicit references for positional format fields | = help: Remove explicit positional indices -ℹ Unsafe fix -27 27 | ) -28 28 | -29 29 | print( -30 |- 'foo{0}' # ohai\n" -31 |- 'bar{1}'.format(1, 2) - 30 |+ 'foo{}' # ohai\n" - 31 |+ 'bar{}'.format(1, 2) -32 32 | ) -33 33 | -34 34 | '{' '0}'.format(1) UP030_0.py:34:1: UP030 Use implicit references for positional format fields | @@ -265,15 +159,6 @@ UP030_0.py:39:1: UP030 [*] Use implicit references for positional format fields | = help: Remove explicit positional indices -ℹ Unsafe fix -36 36 | args = list(range(10)) -37 37 | kwargs = {x: x for x in range(10)} -38 38 | -39 |-"{0}".format(*args) - 39 |+"{}".format(*args) -40 40 | -41 41 | "{0}".format(**kwargs) -42 42 | UP030_0.py:41:1: UP030 [*] Use implicit references for positional format fields | @@ -286,15 +171,6 @@ UP030_0.py:41:1: UP030 [*] Use implicit references for positional format fields | = help: Remove explicit positional indices -ℹ Unsafe fix -38 38 | -39 39 | "{0}".format(*args) -40 40 | -41 |-"{0}".format(**kwargs) - 41 |+"{}".format(**kwargs) -42 42 | -43 43 | "{0}_{1}".format(*args) -44 44 | UP030_0.py:43:1: UP030 [*] Use implicit references for positional format fields | @@ -307,15 +183,6 @@ UP030_0.py:43:1: UP030 [*] Use implicit references for positional format fields | = help: Remove explicit positional indices -ℹ Unsafe fix -40 40 | -41 41 | "{0}".format(**kwargs) -42 42 | -43 |-"{0}_{1}".format(*args) - 43 |+"{}_{}".format(*args) -44 44 | -45 45 | "{0}_{1}".format(1, *args) -46 46 | UP030_0.py:45:1: UP030 [*] Use implicit references for positional format fields | @@ -328,15 +195,6 @@ UP030_0.py:45:1: UP030 [*] Use implicit references for positional format fields | = help: Remove explicit positional indices -ℹ Unsafe fix -42 42 | -43 43 | "{0}_{1}".format(*args) -44 44 | -45 |-"{0}_{1}".format(1, *args) - 45 |+"{}_{}".format(1, *args) -46 46 | -47 47 | "{0}_{1}".format(1, 2, *args) -48 48 | UP030_0.py:47:1: UP030 [*] Use implicit references for positional format fields | @@ -349,15 +207,6 @@ UP030_0.py:47:1: UP030 [*] Use implicit references for positional format fields | = help: Remove explicit positional indices -ℹ Unsafe fix -44 44 | -45 45 | "{0}_{1}".format(1, *args) -46 46 | -47 |-"{0}_{1}".format(1, 2, *args) - 47 |+"{}_{}".format(1, 2, *args) -48 48 | -49 49 | "{0}_{1}".format(*args, 1, 2) -50 50 | UP030_0.py:49:1: UP030 [*] Use implicit references for positional format fields | @@ -370,15 +219,6 @@ UP030_0.py:49:1: UP030 [*] Use implicit references for positional format fields | = help: Remove explicit positional indices -ℹ Unsafe fix -46 46 | -47 47 | "{0}_{1}".format(1, 2, *args) -48 48 | -49 |-"{0}_{1}".format(*args, 1, 2) - 49 |+"{}_{}".format(*args, 1, 2) -50 50 | -51 51 | "{0}_{1}_{2}".format(1, **kwargs) -52 52 | UP030_0.py:51:1: UP030 [*] Use implicit references for positional format fields | @@ -391,15 +231,6 @@ UP030_0.py:51:1: UP030 [*] Use implicit references for positional format fields | = help: Remove explicit positional indices -ℹ Unsafe fix -48 48 | -49 49 | "{0}_{1}".format(*args, 1, 2) -50 50 | -51 |-"{0}_{1}_{2}".format(1, **kwargs) - 51 |+"{}_{}_{}".format(1, **kwargs) -52 52 | -53 53 | "{0}_{1}_{2}".format(1, 2, **kwargs) -54 54 | UP030_0.py:53:1: UP030 [*] Use implicit references for positional format fields | @@ -412,15 +243,6 @@ UP030_0.py:53:1: UP030 [*] Use implicit references for positional format fields | = help: Remove explicit positional indices -ℹ Unsafe fix -50 50 | -51 51 | "{0}_{1}_{2}".format(1, **kwargs) -52 52 | -53 |-"{0}_{1}_{2}".format(1, 2, **kwargs) - 53 |+"{}_{}_{}".format(1, 2, **kwargs) -54 54 | -55 55 | "{0}_{1}_{2}".format(1, 2, 3, **kwargs) -56 56 | UP030_0.py:55:1: UP030 [*] Use implicit references for positional format fields | @@ -433,15 +255,6 @@ UP030_0.py:55:1: UP030 [*] Use implicit references for positional format fields | = help: Remove explicit positional indices -ℹ Unsafe fix -52 52 | -53 53 | "{0}_{1}_{2}".format(1, 2, **kwargs) -54 54 | -55 |-"{0}_{1}_{2}".format(1, 2, 3, **kwargs) - 55 |+"{}_{}_{}".format(1, 2, 3, **kwargs) -56 56 | -57 57 | "{0}_{1}_{2}".format(1, 2, 3, *args, **kwargs) -58 58 | UP030_0.py:57:1: UP030 [*] Use implicit references for positional format fields | @@ -454,15 +267,6 @@ UP030_0.py:57:1: UP030 [*] Use implicit references for positional format fields | = help: Remove explicit positional indices -ℹ Unsafe fix -54 54 | -55 55 | "{0}_{1}_{2}".format(1, 2, 3, **kwargs) -56 56 | -57 |-"{0}_{1}_{2}".format(1, 2, 3, *args, **kwargs) - 57 |+"{}_{}_{}".format(1, 2, 3, *args, **kwargs) -58 58 | -59 59 | "{1}_{0}".format(1, 2, *args) -60 60 | UP030_0.py:59:1: UP030 [*] Use implicit references for positional format fields | @@ -475,14 +279,6 @@ UP030_0.py:59:1: UP030 [*] Use implicit references for positional format fields | = help: Remove explicit positional indices -ℹ Unsafe fix -56 56 | -57 57 | "{0}_{1}_{2}".format(1, 2, 3, *args, **kwargs) -58 58 | -59 |-"{1}_{0}".format(1, 2, *args) - 59 |+"{}_{}".format(2, 1, ) -60 60 | -61 61 | "{1}_{0}".format(1, 2) UP030_0.py:61:1: UP030 [*] Use implicit references for positional format fields | @@ -492,12 +288,3 @@ UP030_0.py:61:1: UP030 [*] Use implicit references for positional format fields | ^^^^^^^^^^^^^^^^^^^^^^ UP030 | = help: Remove explicit positional indices - -ℹ Unsafe fix -58 58 | -59 59 | "{1}_{0}".format(1, 2, *args) -60 60 | -61 |-"{1}_{0}".format(1, 2) - 61 |+"{}_{}".format(2, 1) - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP031_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP031_0.py.snap index 01a7e21e92527..27597295e70f3 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP031_0.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP031_0.py.snap @@ -11,15 +11,6 @@ UP031_0.py:4:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -1 1 | a, b, x, y = 1, 2, 3, 4 -2 2 | -3 3 | # UP031 -4 |-print('%s %s' % (a, b)) - 4 |+print('{} {}'.format(a, b)) -5 5 | -6 6 | print('%s%s' % (a, b)) -7 7 | UP031_0.py:6:7: UP031 [*] Use format specifiers instead of percent format | @@ -32,15 +23,6 @@ UP031_0.py:6:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -3 3 | # UP031 -4 4 | print('%s %s' % (a, b)) -5 5 | -6 |-print('%s%s' % (a, b)) - 6 |+print('{}{}'.format(a, b)) -7 7 | -8 8 | print("trivial" % ()) -9 9 | UP031_0.py:8:7: UP031 [*] Use format specifiers instead of percent format | @@ -53,15 +35,6 @@ UP031_0.py:8:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -5 5 | -6 6 | print('%s%s' % (a, b)) -7 7 | -8 |-print("trivial" % ()) - 8 |+print("trivial".format()) -9 9 | -10 10 | print("%s" % ("simple",)) -11 11 | UP031_0.py:10:7: UP031 [*] Use format specifiers instead of percent format | @@ -74,15 +47,6 @@ UP031_0.py:10:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -7 7 | -8 8 | print("trivial" % ()) -9 9 | -10 |-print("%s" % ("simple",)) - 10 |+print("{}".format("simple")) -11 11 | -12 12 | print("%s" % ("%s" % ("nested",),)) -13 13 | UP031_0.py:12:7: UP031 [*] Use format specifiers instead of percent format | @@ -95,15 +59,6 @@ UP031_0.py:12:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -9 9 | -10 10 | print("%s" % ("simple",)) -11 11 | -12 |-print("%s" % ("%s" % ("nested",),)) - 12 |+print("{}".format("%s" % ("nested",))) -13 13 | -14 14 | print("%s%% percent" % (15,)) -15 15 | UP031_0.py:12:15: UP031 [*] Use format specifiers instead of percent format | @@ -116,15 +71,6 @@ UP031_0.py:12:15: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -9 9 | -10 10 | print("%s" % ("simple",)) -11 11 | -12 |-print("%s" % ("%s" % ("nested",),)) - 12 |+print("%s" % ("{}".format("nested"),)) -13 13 | -14 14 | print("%s%% percent" % (15,)) -15 15 | UP031_0.py:14:7: UP031 [*] Use format specifiers instead of percent format | @@ -137,15 +83,6 @@ UP031_0.py:14:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -11 11 | -12 12 | print("%s" % ("%s" % ("nested",),)) -13 13 | -14 |-print("%s%% percent" % (15,)) - 14 |+print("{}% percent".format(15)) -15 15 | -16 16 | print("%f" % (15,)) -17 17 | UP031_0.py:16:7: UP031 [*] Use format specifiers instead of percent format | @@ -158,15 +95,6 @@ UP031_0.py:16:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -13 13 | -14 14 | print("%s%% percent" % (15,)) -15 15 | -16 |-print("%f" % (15,)) - 16 |+print("{:f}".format(15)) -17 17 | -18 18 | print("%.f" % (15,)) -19 19 | UP031_0.py:18:7: UP031 [*] Use format specifiers instead of percent format | @@ -179,15 +107,6 @@ UP031_0.py:18:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -15 15 | -16 16 | print("%f" % (15,)) -17 17 | -18 |-print("%.f" % (15,)) - 18 |+print("{:.0f}".format(15)) -19 19 | -20 20 | print("%.3f" % (15,)) -21 21 | UP031_0.py:20:7: UP031 [*] Use format specifiers instead of percent format | @@ -200,15 +119,6 @@ UP031_0.py:20:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -17 17 | -18 18 | print("%.f" % (15,)) -19 19 | -20 |-print("%.3f" % (15,)) - 20 |+print("{:.3f}".format(15)) -21 21 | -22 22 | print("%3f" % (15,)) -23 23 | UP031_0.py:22:7: UP031 [*] Use format specifiers instead of percent format | @@ -221,15 +131,6 @@ UP031_0.py:22:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -19 19 | -20 20 | print("%.3f" % (15,)) -21 21 | -22 |-print("%3f" % (15,)) - 22 |+print("{:3f}".format(15)) -23 23 | -24 24 | print("%-5f" % (5,)) -25 25 | UP031_0.py:24:7: UP031 [*] Use format specifiers instead of percent format | @@ -242,15 +143,6 @@ UP031_0.py:24:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -21 21 | -22 22 | print("%3f" % (15,)) -23 23 | -24 |-print("%-5f" % (5,)) - 24 |+print("{:<5f}".format(5)) -25 25 | -26 26 | print("%9f" % (5,)) -27 27 | UP031_0.py:26:7: UP031 [*] Use format specifiers instead of percent format | @@ -263,15 +155,6 @@ UP031_0.py:26:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -23 23 | -24 24 | print("%-5f" % (5,)) -25 25 | -26 |-print("%9f" % (5,)) - 26 |+print("{:9f}".format(5)) -27 27 | -28 28 | print("%#o" % (123,)) -29 29 | UP031_0.py:28:7: UP031 [*] Use format specifiers instead of percent format | @@ -284,15 +167,6 @@ UP031_0.py:28:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -25 25 | -26 26 | print("%9f" % (5,)) -27 27 | -28 |-print("%#o" % (123,)) - 28 |+print("{:#o}".format(123)) -29 29 | -30 30 | print("brace {} %s" % (1,)) -31 31 | UP031_0.py:30:7: UP031 [*] Use format specifiers instead of percent format | @@ -305,15 +179,6 @@ UP031_0.py:30:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -27 27 | -28 28 | print("%#o" % (123,)) -29 29 | -30 |-print("brace {} %s" % (1,)) - 30 |+print("brace {{}} {}".format(1)) -31 31 | -32 32 | print(( -33 33 | "foo %s " UP031_0.py:33:5: UP031 [*] Use format specifiers instead of percent format | @@ -326,17 +191,6 @@ UP031_0.py:33:5: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -30 30 | print("brace {} %s" % (1,)) -31 31 | -32 32 | print(( -33 |- "foo %s " -34 |- "bar %s" % (x, y) - 33 |+ "foo {} " - 34 |+ "bar {}".format(x, y) -35 35 | )) -36 36 | -37 37 | print( UP031_0.py:38:3: UP031 [*] Use format specifiers instead of percent format | @@ -350,15 +204,6 @@ UP031_0.py:38:3: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -35 35 | )) -36 36 | -37 37 | print( -38 |- "%s" % ( - 38 |+ "{}".format( -39 39 | "trailing comma", -40 40 | ) -41 41 | ) UP031_0.py:43:7: UP031 [*] Use format specifiers instead of percent format | @@ -371,15 +216,6 @@ UP031_0.py:43:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -40 40 | ) -41 41 | ) -42 42 | -43 |-print("foo %s " % (x,)) - 43 |+print("foo {} ".format(x)) -44 44 | -45 45 | print("%(k)s" % {"k": "v"}) -46 46 | UP031_0.py:45:7: UP031 [*] Use format specifiers instead of percent format | @@ -392,15 +228,6 @@ UP031_0.py:45:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -42 42 | -43 43 | print("foo %s " % (x,)) -44 44 | -45 |-print("%(k)s" % {"k": "v"}) - 45 |+print("{k}".format(k="v")) -46 46 | -47 47 | print("%(k)s" % { -48 48 | "k": "v", UP031_0.py:47:7: UP031 [*] Use format specifiers instead of percent format | @@ -417,21 +244,6 @@ UP031_0.py:47:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -44 44 | -45 45 | print("%(k)s" % {"k": "v"}) -46 46 | -47 |-print("%(k)s" % { -48 |- "k": "v", -49 |- "i": "j" -50 |-}) - 47 |+print("{k}".format( - 48 |+ k="v", - 49 |+ i="j", - 50 |+)) -51 51 | -52 52 | print("%(to_list)s" % {"to_list": []}) -53 53 | UP031_0.py:52:7: UP031 [*] Use format specifiers instead of percent format | @@ -444,15 +256,6 @@ UP031_0.py:52:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -49 49 | "i": "j" -50 50 | }) -51 51 | -52 |-print("%(to_list)s" % {"to_list": []}) - 52 |+print("{to_list}".format(to_list=[])) -53 53 | -54 54 | print("%(k)s" % {"k": "v", "i": 1, "j": []}) -55 55 | UP031_0.py:54:7: UP031 [*] Use format specifiers instead of percent format | @@ -465,15 +268,6 @@ UP031_0.py:54:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -51 51 | -52 52 | print("%(to_list)s" % {"to_list": []}) -53 53 | -54 |-print("%(k)s" % {"k": "v", "i": 1, "j": []}) - 54 |+print("{k}".format(k="v", i=1, j=[])) -55 55 | -56 56 | print("%(ab)s" % {"a" "b": 1}) -57 57 | UP031_0.py:56:7: UP031 [*] Use format specifiers instead of percent format | @@ -486,15 +280,6 @@ UP031_0.py:56:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -53 53 | -54 54 | print("%(k)s" % {"k": "v", "i": 1, "j": []}) -55 55 | -56 |-print("%(ab)s" % {"a" "b": 1}) - 56 |+print("{ab}".format(ab=1)) -57 57 | -58 58 | print("%(a)s" % {"a" : 1}) -59 59 | UP031_0.py:58:7: UP031 [*] Use format specifiers instead of percent format | @@ -505,15 +290,6 @@ UP031_0.py:58:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -55 55 | -56 56 | print("%(ab)s" % {"a" "b": 1}) -57 57 | -58 |-print("%(a)s" % {"a" : 1}) - 58 |+print("{a}".format(a=1)) -59 59 | -60 60 | -61 61 | print( UP031_0.py:62:5: UP031 [*] Use format specifiers instead of percent format | @@ -526,17 +302,6 @@ UP031_0.py:62:5: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -59 59 | -60 60 | -61 61 | print( -62 |- "foo %(foo)s " -63 |- "bar %(bar)s" % {"foo": x, "bar": y} - 62 |+ "foo {foo} " - 63 |+ "bar {bar}".format(foo=x, bar=y) -64 64 | ) -65 65 | -66 66 | bar = {"bar": y} UP031_0.py:68:5: UP031 [*] Use format specifiers instead of percent format | @@ -550,17 +315,6 @@ UP031_0.py:68:5: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -65 65 | -66 66 | bar = {"bar": y} -67 67 | print( -68 |- "foo %(foo)s " -69 |- "bar %(bar)s" % {"foo": x, **bar} - 68 |+ "foo {foo} " - 69 |+ "bar {bar}".format(foo=x, **bar) -70 70 | ) -71 71 | -72 72 | print("%s \N{snowman}" % (a,)) UP031_0.py:72:7: UP031 [*] Use format specifiers instead of percent format | @@ -573,15 +327,6 @@ UP031_0.py:72:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -69 69 | "bar %(bar)s" % {"foo": x, **bar} -70 70 | ) -71 71 | -72 |-print("%s \N{snowman}" % (a,)) - 72 |+print("{} \N{snowman}".format(a)) -73 73 | -74 74 | print("%(foo)s \N{snowman}" % {"foo": 1}) -75 75 | UP031_0.py:74:7: UP031 [*] Use format specifiers instead of percent format | @@ -594,15 +339,6 @@ UP031_0.py:74:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -71 71 | -72 72 | print("%s \N{snowman}" % (a,)) -73 73 | -74 |-print("%(foo)s \N{snowman}" % {"foo": 1}) - 74 |+print("{foo} \N{snowman}".format(foo=1)) -75 75 | -76 76 | print(("foo %s " "bar %s") % (x, y)) -77 77 | UP031_0.py:76:7: UP031 [*] Use format specifiers instead of percent format | @@ -615,15 +351,6 @@ UP031_0.py:76:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -73 73 | -74 74 | print("%(foo)s \N{snowman}" % {"foo": 1}) -75 75 | -76 |-print(("foo %s " "bar %s") % (x, y)) - 76 |+print(("foo {} " "bar {}").format(x, y)) -77 77 | -78 78 | # Single-value expressions -79 79 | print('Hello %s' % "World") UP031_0.py:79:7: UP031 [*] Use format specifiers instead of percent format | @@ -635,15 +362,6 @@ UP031_0.py:79:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -76 76 | print(("foo %s " "bar %s") % (x, y)) -77 77 | -78 78 | # Single-value expressions -79 |-print('Hello %s' % "World") - 79 |+print('Hello {}'.format("World")) -80 80 | print('Hello %s' % f"World") -81 81 | print('Hello %s (%s)' % bar) -82 82 | print('Hello %s (%s)' % bar.baz) UP031_0.py:80:7: UP031 [*] Use format specifiers instead of percent format | @@ -656,15 +374,6 @@ UP031_0.py:80:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -77 77 | -78 78 | # Single-value expressions -79 79 | print('Hello %s' % "World") -80 |-print('Hello %s' % f"World") - 80 |+print('Hello {}'.format(f"World")) -81 81 | print('Hello %s (%s)' % bar) -82 82 | print('Hello %s (%s)' % bar.baz) -83 83 | print('Hello %s (%s)' % bar['bop']) UP031_0.py:81:7: UP031 [*] Use format specifiers instead of percent format | @@ -677,15 +386,6 @@ UP031_0.py:81:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -78 78 | # Single-value expressions -79 79 | print('Hello %s' % "World") -80 80 | print('Hello %s' % f"World") -81 |-print('Hello %s (%s)' % bar) - 81 |+print('Hello {} ({})'.format(*bar)) -82 82 | print('Hello %s (%s)' % bar.baz) -83 83 | print('Hello %s (%s)' % bar['bop']) -84 84 | print('Hello %(arg)s' % bar) UP031_0.py:82:7: UP031 [*] Use format specifiers instead of percent format | @@ -698,15 +398,6 @@ UP031_0.py:82:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -79 79 | print('Hello %s' % "World") -80 80 | print('Hello %s' % f"World") -81 81 | print('Hello %s (%s)' % bar) -82 |-print('Hello %s (%s)' % bar.baz) - 82 |+print('Hello {} ({})'.format(*bar.baz)) -83 83 | print('Hello %s (%s)' % bar['bop']) -84 84 | print('Hello %(arg)s' % bar) -85 85 | print('Hello %(arg)s' % bar.baz) UP031_0.py:83:7: UP031 [*] Use format specifiers instead of percent format | @@ -719,15 +410,6 @@ UP031_0.py:83:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -80 80 | print('Hello %s' % f"World") -81 81 | print('Hello %s (%s)' % bar) -82 82 | print('Hello %s (%s)' % bar.baz) -83 |-print('Hello %s (%s)' % bar['bop']) - 83 |+print('Hello {} ({})'.format(*bar['bop'])) -84 84 | print('Hello %(arg)s' % bar) -85 85 | print('Hello %(arg)s' % bar.baz) -86 86 | print('Hello %(arg)s' % bar['bop']) UP031_0.py:84:7: UP031 [*] Use format specifiers instead of percent format | @@ -740,15 +422,6 @@ UP031_0.py:84:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -81 81 | print('Hello %s (%s)' % bar) -82 82 | print('Hello %s (%s)' % bar.baz) -83 83 | print('Hello %s (%s)' % bar['bop']) -84 |-print('Hello %(arg)s' % bar) - 84 |+print('Hello {arg}'.format(**bar)) -85 85 | print('Hello %(arg)s' % bar.baz) -86 86 | print('Hello %(arg)s' % bar['bop']) -87 87 | UP031_0.py:85:7: UP031 [*] Use format specifiers instead of percent format | @@ -760,15 +433,6 @@ UP031_0.py:85:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -82 82 | print('Hello %s (%s)' % bar.baz) -83 83 | print('Hello %s (%s)' % bar['bop']) -84 84 | print('Hello %(arg)s' % bar) -85 |-print('Hello %(arg)s' % bar.baz) - 85 |+print('Hello {arg}'.format(**bar.baz)) -86 86 | print('Hello %(arg)s' % bar['bop']) -87 87 | -88 88 | # Hanging modulos UP031_0.py:86:7: UP031 [*] Use format specifiers instead of percent format | @@ -781,15 +445,6 @@ UP031_0.py:86:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -83 83 | print('Hello %s (%s)' % bar['bop']) -84 84 | print('Hello %(arg)s' % bar) -85 85 | print('Hello %(arg)s' % bar.baz) -86 |-print('Hello %(arg)s' % bar['bop']) - 86 |+print('Hello {arg}'.format(**bar['bop'])) -87 87 | -88 88 | # Hanging modulos -89 89 | ( UP031_0.py:89:1: UP031 [*] Use format specifiers instead of percent format | @@ -804,19 +459,6 @@ UP031_0.py:89:1: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -87 87 | -88 88 | # Hanging modulos -89 89 | ( -90 |- "foo %s " -91 |- "bar %s" -92 |-) % (x, y) - 90 |+ "foo {} " - 91 |+ "bar {}" - 92 |+).format(x, y) -93 93 | -94 94 | ( -95 95 | "foo %(foo)s " UP031_0.py:94:1: UP031 [*] Use format specifiers instead of percent format | @@ -832,19 +474,6 @@ UP031_0.py:94:1: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -92 92 | ) % (x, y) -93 93 | -94 94 | ( -95 |- "foo %(foo)s " -96 |- "bar %(bar)s" -97 |-) % {"foo": x, "bar": y} - 95 |+ "foo {foo} " - 96 |+ "bar {bar}" - 97 |+).format(foo=x, bar=y) -98 98 | -99 99 | ( -100 100 | """foo %s""" UP031_0.py:100:5: UP031 [*] Use format specifiers instead of percent format | @@ -857,16 +486,6 @@ UP031_0.py:100:5: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -97 97 | ) % {"foo": x, "bar": y} -98 98 | -99 99 | ( -100 |- """foo %s""" -101 |- % (x,) - 100 |+ """foo {}""".format(x) -102 101 | ) -103 102 | -104 103 | ( UP031_0.py:105:5: UP031 [*] Use format specifiers instead of percent format | @@ -881,18 +500,6 @@ UP031_0.py:105:5: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -103 103 | -104 104 | ( -105 105 | """ -106 |- foo %s -107 |- """ -108 |- % (x,) - 106 |+ foo {} - 107 |+ """.format(x) -109 108 | ) -110 109 | -111 110 | "%s" % ( UP031_0.py:111:1: UP031 [*] Use format specifiers instead of percent format | @@ -905,15 +512,6 @@ UP031_0.py:111:1: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -108 108 | % (x,) -109 109 | ) -110 110 | -111 |-"%s" % ( - 111 |+"{}".format( -112 112 | x, # comment -113 113 | ) -114 114 | UP031_0.py:116:8: UP031 [*] Use format specifiers instead of percent format | @@ -929,15 +527,6 @@ UP031_0.py:116:8: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -113 113 | ) -114 114 | -115 115 | -116 |-path = "%s-%s-%s.pem" % ( - 116 |+path = "{}-{}-{}.pem".format( -117 117 | safe_domain_name(cn), # common name, which should be filename safe because it is IDNA-encoded, but in case of a malformed cert make sure it's ok to use as a filename -118 118 | cert.not_valid_after.date().isoformat().replace("-", ""), # expiration date -119 119 | hexlify(cert.fingerprint(hashes.SHA256())).decode("ascii")[0:8], # fingerprint prefix UP031_0.py:123:1: UP031 [*] Use format specifiers instead of percent format | @@ -949,15 +538,6 @@ UP031_0.py:123:1: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -120 120 | ) -121 121 | -122 122 | # UP031 (no longer false negatives; now offer potentially unsafe fixes) -123 |-'Hello %s' % bar - 123 |+'Hello {}'.format(bar) -124 124 | -125 125 | 'Hello %s' % bar.baz -126 126 | UP031_0.py:125:1: UP031 [*] Use format specifiers instead of percent format | @@ -970,15 +550,6 @@ UP031_0.py:125:1: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -122 122 | # UP031 (no longer false negatives; now offer potentially unsafe fixes) -123 123 | 'Hello %s' % bar -124 124 | -125 |-'Hello %s' % bar.baz - 125 |+'Hello {}'.format(bar.baz) -126 126 | -127 127 | 'Hello %s' % bar['bop'] -128 128 | UP031_0.py:127:1: UP031 [*] Use format specifiers instead of percent format | @@ -991,15 +562,6 @@ UP031_0.py:127:1: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -124 124 | -125 125 | 'Hello %s' % bar.baz -126 126 | -127 |-'Hello %s' % bar['bop'] - 127 |+'Hello {}'.format(bar['bop']) -128 128 | -129 129 | # Not a valid type annotation but this test shouldn't result in a panic. -130 130 | # Refer: https://github.com/astral-sh/ruff/issues/11736 UP031_0.py:131:5: UP031 [*] Use format specifiers instead of percent format | @@ -1012,15 +574,6 @@ UP031_0.py:131:5: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -128 128 | -129 129 | # Not a valid type annotation but this test shouldn't result in a panic. -130 130 | # Refer: https://github.com/astral-sh/ruff/issues/11736 -131 |-x: "'%s + %s' % (1, 2)" - 131 |+x: "'{} + {}'.format(1, 2)" -132 132 | -133 133 | # See: https://github.com/astral-sh/ruff/issues/12421 -134 134 | print("%.2X" % 1) UP031_0.py:134:7: UP031 [*] Use format specifiers instead of percent format | @@ -1032,15 +585,6 @@ UP031_0.py:134:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -131 131 | x: "'%s + %s' % (1, 2)" -132 132 | -133 133 | # See: https://github.com/astral-sh/ruff/issues/12421 -134 |-print("%.2X" % 1) - 134 |+print("{:02X}".format(1)) -135 135 | print("%.02X" % 1) -136 136 | print("%02X" % 1) -137 137 | print("%.00002X" % 1) UP031_0.py:135:7: UP031 [*] Use format specifiers instead of percent format | @@ -1053,15 +597,6 @@ UP031_0.py:135:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -132 132 | -133 133 | # See: https://github.com/astral-sh/ruff/issues/12421 -134 134 | print("%.2X" % 1) -135 |-print("%.02X" % 1) - 135 |+print("{:02X}".format(1)) -136 136 | print("%02X" % 1) -137 137 | print("%.00002X" % 1) -138 138 | print("%.20X" % 1) UP031_0.py:136:7: UP031 [*] Use format specifiers instead of percent format | @@ -1074,15 +609,6 @@ UP031_0.py:136:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -133 133 | # See: https://github.com/astral-sh/ruff/issues/12421 -134 134 | print("%.2X" % 1) -135 135 | print("%.02X" % 1) -136 |-print("%02X" % 1) - 136 |+print("{:02X}".format(1)) -137 137 | print("%.00002X" % 1) -138 138 | print("%.20X" % 1) -139 139 | UP031_0.py:137:7: UP031 [*] Use format specifiers instead of percent format | @@ -1094,15 +620,6 @@ UP031_0.py:137:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -134 134 | print("%.2X" % 1) -135 135 | print("%.02X" % 1) -136 136 | print("%02X" % 1) -137 |-print("%.00002X" % 1) - 137 |+print("{:02X}".format(1)) -138 138 | print("%.20X" % 1) -139 139 | -140 140 | print("%2X" % 1) UP031_0.py:138:7: UP031 [*] Use format specifiers instead of percent format | @@ -1115,15 +632,6 @@ UP031_0.py:138:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -135 135 | print("%.02X" % 1) -136 136 | print("%02X" % 1) -137 137 | print("%.00002X" % 1) -138 |-print("%.20X" % 1) - 138 |+print("{:020X}".format(1)) -139 139 | -140 140 | print("%2X" % 1) -141 141 | print("%02X" % 1) UP031_0.py:140:7: UP031 [*] Use format specifiers instead of percent format | @@ -1135,13 +643,6 @@ UP031_0.py:140:7: UP031 [*] Use format specifiers instead of percent format | = help: Replace with format specifiers -ℹ Unsafe fix -137 137 | print("%.00002X" % 1) -138 138 | print("%.20X" % 1) -139 139 | -140 |-print("%2X" % 1) - 140 |+print("{:2X}".format(1)) -141 141 | print("%02X" % 1) UP031_0.py:141:7: UP031 [*] Use format specifiers instead of percent format | @@ -1150,10 +651,3 @@ UP031_0.py:141:7: UP031 [*] Use format specifiers instead of percent format | ^^^^^^^^^^ UP031 | = help: Replace with format specifiers - -ℹ Unsafe fix -138 138 | print("%.20X" % 1) -139 139 | -140 140 | print("%2X" % 1) -141 |-print("%02X" % 1) - 141 |+print("{:02X}".format(1)) diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_0.py.snap index 487e05372715f..68fb19eeae28b 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_0.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_0.py.snap @@ -12,7 +12,6 @@ UP032_0.py:5:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 2 2 | # Errors 3 3 | ### 4 4 | @@ -33,7 +32,6 @@ UP032_0.py:7:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 4 4 | 5 5 | "{} {}".format(a, b) 6 6 | @@ -54,7 +52,6 @@ UP032_0.py:9:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 6 6 | 7 7 | "{1} {0}".format(a, b) 8 8 | @@ -75,7 +72,6 @@ UP032_0.py:11:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 8 8 | 9 9 | "{0} {1} {0}".format(a, b) 10 10 | @@ -96,7 +92,6 @@ UP032_0.py:13:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 10 10 | 11 11 | "{x.y}".format(x=z) 12 12 | @@ -117,7 +112,6 @@ UP032_0.py:15:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 12 12 | 13 13 | "{x} {y} {x}".format(x=a, y=b) 14 14 | @@ -138,7 +132,6 @@ UP032_0.py:17:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 14 14 | 15 15 | "{.x} {.y}".format(a, b) 16 16 | @@ -159,7 +152,6 @@ UP032_0.py:19:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 16 16 | 17 17 | "{} {}".format(a.b, c.d) 18 18 | @@ -180,7 +172,6 @@ UP032_0.py:21:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 18 18 | 19 19 | "{}".format(a()) 20 20 | @@ -201,7 +192,6 @@ UP032_0.py:23:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 20 20 | 21 21 | "{}".format(a.b()) 22 22 | @@ -222,7 +212,6 @@ UP032_0.py:25:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 22 22 | 23 23 | "{}".format(a.b().c()) 24 24 | @@ -243,7 +232,6 @@ UP032_0.py:27:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 24 24 | 25 25 | "hello {}!".format(name) 26 26 | @@ -264,7 +252,6 @@ UP032_0.py:29:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 26 26 | 27 27 | "{}{b}{}".format(a, c, b=b) 28 28 | @@ -285,7 +272,6 @@ UP032_0.py:31:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 28 28 | 29 29 | "{}".format(0x0) 30 30 | @@ -306,7 +292,6 @@ UP032_0.py:33:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 30 30 | 31 31 | "{} {}".format(a, b) 32 32 | @@ -327,7 +312,6 @@ UP032_0.py:35:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 32 32 | 33 33 | """{} {}""".format(a, b) 34 34 | @@ -348,7 +332,6 @@ UP032_0.py:37:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 34 34 | 35 35 | "foo{}".format(1) 36 36 | @@ -369,7 +352,6 @@ UP032_0.py:39:5: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 36 36 | 37 37 | r"foo{}".format(1) 38 38 | @@ -390,7 +372,6 @@ UP032_0.py:41:7: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 38 38 | 39 39 | x = "{a}".format(a=1) 40 40 | @@ -411,7 +392,6 @@ UP032_0.py:43:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 40 40 | 41 41 | print("foo {} ".format(x)) 42 42 | @@ -432,7 +412,6 @@ UP032_0.py:45:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 42 42 | 43 43 | "{a[b]}".format(a=a) 44 44 | @@ -453,7 +432,6 @@ UP032_0.py:47:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 44 44 | 45 45 | "{a.a[b]}".format(a=a) 46 46 | @@ -474,7 +452,6 @@ UP032_0.py:49:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 46 46 | 47 47 | "{}{{}}{}".format(escaped, y) 48 48 | @@ -495,7 +472,6 @@ UP032_0.py:51:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 48 48 | 49 49 | "{}".format(a) 50 50 | @@ -516,7 +492,6 @@ UP032_0.py:53:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 50 50 | 51 51 | '({}={{0!e}})'.format(a) 52 52 | @@ -537,7 +512,6 @@ UP032_0.py:55:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 52 52 | 53 53 | "{[b]}".format(a) 54 54 | @@ -558,7 +532,6 @@ UP032_0.py:57:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 54 54 | 55 55 | '{[b]}'.format(a) 56 56 | @@ -579,7 +552,6 @@ UP032_0.py:59:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 56 56 | 57 57 | """{[b]}""".format(a) 58 58 | @@ -602,7 +574,6 @@ UP032_0.py:61:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 58 58 | 59 59 | '''{[b]}'''.format(a) 60 60 | @@ -627,7 +598,6 @@ UP032_0.py:65:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 62 62 | 1 63 63 | ) 64 64 | @@ -652,7 +622,6 @@ UP032_0.py:69:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 66 66 | 1111111111111111111111111111111111111111111111111111111111111111111111111, 67 67 | ) 68 68 | @@ -681,7 +650,6 @@ UP032_0.py:73:85: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 70 70 | {} 71 71 | """.format(1) 72 72 | @@ -708,7 +676,6 @@ UP032_0.py:79:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 76 76 | 111111 77 77 | ) 78 78 | @@ -732,7 +699,6 @@ UP032_0.py:81:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 79 79 | "{a}" "{b}".format(a=1, b=1) 80 80 | 81 81 | ( @@ -762,7 +728,6 @@ UP032_0.py:86:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 84 84 | ).format(a=1, b=1) 85 85 | 86 86 | ( @@ -795,7 +760,6 @@ UP032_0.py:94:5: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 93 93 | ( 94 94 | ( 95 95 | # comment @@ -824,7 +788,6 @@ UP032_0.py:104:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 102 102 | ) 103 103 | 104 104 | ( @@ -845,7 +808,6 @@ UP032_0.py:111:11: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 108 108 | 109 109 | 110 110 | def d(osname, version, release): @@ -863,7 +825,6 @@ UP032_0.py:115:10: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 112 112 | 113 113 | 114 114 | def e(): @@ -880,7 +841,6 @@ UP032_0.py:118:7: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 115 115 | yield"{}".format(1) 116 116 | 117 117 | @@ -898,7 +858,6 @@ UP032_0.py:122:12: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 119 119 | 120 120 | 121 121 | async def c(): @@ -916,7 +875,6 @@ UP032_0.py:126:12: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 123 123 | 124 124 | 125 125 | async def c(): @@ -935,7 +893,6 @@ UP032_0.py:129:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 126 126 | return "{}".format(1 + await 3) 127 127 | 128 128 | @@ -958,7 +915,6 @@ UP032_0.py:160:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 157 157 | 158 158 | r'"\N{snowman} {}".format(a)' 159 159 | @@ -989,7 +945,6 @@ UP032_0.py:164:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 161 161 | 11111111111111111111111111111111111111111111111111111111111111111111111111, 162 162 | ) 163 163 | @@ -1025,7 +980,6 @@ UP032_0.py:174:84: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 171 171 | 111111111111111111111111111111111111111111111111111111111111111111111111111111111111111, 172 172 | ) 173 173 | @@ -1061,7 +1015,6 @@ UP032_0.py:209:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 206 206 | 207 207 | # The fixed string will exceed the line length, but it's still smaller than the 208 208 | # existing line length, so it's fine. @@ -1083,7 +1036,6 @@ UP032_0.py:212:18: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 209 209 | "".format(self.internal_ids, self.external_ids, self.properties, self.tags, self.others) 210 210 | 211 211 | # When fixing, trim the trailing empty string. @@ -1106,7 +1058,6 @@ UP032_0.py:216:18: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 213 213 | "".format(new_dict, d)) 214 214 | 215 215 | # When fixing, trim the trailing empty string. @@ -1129,7 +1080,6 @@ UP032_0.py:220:5: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 217 217 | .format(new_dict, d)) 218 218 | 219 219 | raise ValueError( @@ -1152,7 +1102,6 @@ UP032_0.py:225:5: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 222 222 | ) 223 223 | 224 224 | raise ValueError( @@ -1176,7 +1125,6 @@ UP032_0.py:231:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 229 229 | 230 230 | # The first string will be converted to an f-string and the curly braces in the second should be converted to be unescaped 231 231 | ( @@ -1198,7 +1146,6 @@ UP032_0.py:236:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 233 233 | "{{}}" 234 234 | ).format(a) 235 235 | @@ -1221,7 +1168,6 @@ UP032_0.py:240:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 238 238 | 239 239 | # Both strings will be converted to an f-string and the curly braces in the second should left escaped 240 240 | ( @@ -1246,7 +1192,6 @@ UP032_0.py:245:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 242 242 | "{{{}}}" 243 243 | ).format(a, b) 244 244 | @@ -1266,7 +1211,6 @@ UP032_0.py:248:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 245 245 | ("{}" "{{{}}}").format(a, b) 246 246 | 247 247 | # The dictionary should be parenthesized. @@ -1286,7 +1230,6 @@ UP032_0.py:251:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 248 248 | "{}".format({0: 1}[0]) 249 249 | 250 250 | # The dictionary should be parenthesized. @@ -1306,7 +1249,6 @@ UP032_0.py:254:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 251 251 | "{}".format({0: 1}.bar) 252 252 | 253 253 | # The dictionary should be parenthesized. @@ -1326,7 +1268,6 @@ UP032_0.py:261:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 258 258 | "{0} {0}".format(foo()) 259 259 | 260 260 | # The string _should_ be converted, since the function call is repeated in the arguments. @@ -1346,7 +1287,6 @@ UP032_0.py:264:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 261 261 | "{0} {1}".format(foo(), foo()) 262 262 | 263 263 | # The call should be removed, but the string itself should remain. @@ -1366,7 +1306,6 @@ UP032_0.py:267:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 264 264 | ''.format(self.project) 265 265 | 266 266 | # The call should be removed, but the string itself should remain. @@ -1385,7 +1324,6 @@ UP032_0.py:271:5: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 268 268 | 269 269 | # Not a valid type annotation but this test shouldn't result in a panic. 270 270 | # Refer: https://github.com/astral-sh/ruff/issues/11736 diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_1.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_1.py.snap index 221526314e6fb..21e6da29d4a30 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_1.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_1.py.snap @@ -8,6 +8,5 @@ UP032_1.py:1:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 1 |-"{} {}".format(a, b) # Intentionally at start-of-file, to ensure graceful handling. 1 |+f"{a} {b}" # Intentionally at start-of-file, to ensure graceful handling. diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_2.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_2.py.snap index 7ad4096da6182..5f1cb6ea0da40 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_2.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_2.py.snap @@ -11,7 +11,6 @@ UP032_2.py:2:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 1 1 | # Errors 2 |-"{.real}".format(1) 2 |+f"{(1).real}" @@ -29,7 +28,6 @@ UP032_2.py:3:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 1 1 | # Errors 2 2 | "{.real}".format(1) 3 |-"{0.real}".format(1) @@ -49,7 +47,6 @@ UP032_2.py:4:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 1 1 | # Errors 2 2 | "{.real}".format(1) 3 3 | "{0.real}".format(1) @@ -70,7 +67,6 @@ UP032_2.py:6:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 3 3 | "{0.real}".format(1) 4 4 | "{a.real}".format(a=1) 5 5 | @@ -89,7 +85,6 @@ UP032_2.py:7:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 4 4 | "{a.real}".format(a=1) 5 5 | 6 6 | "{.real}".format(1.0) @@ -110,7 +105,6 @@ UP032_2.py:8:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 5 5 | 6 6 | "{.real}".format(1.0) 7 7 | "{0.real}".format(1.0) @@ -131,7 +125,6 @@ UP032_2.py:10:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 7 7 | "{0.real}".format(1.0) 8 8 | "{a.real}".format(a=1.0) 9 9 | @@ -150,7 +143,6 @@ UP032_2.py:11:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 8 8 | "{a.real}".format(a=1.0) 9 9 | 10 10 | "{.real}".format(1j) @@ -171,7 +163,6 @@ UP032_2.py:12:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 9 9 | 10 10 | "{.real}".format(1j) 11 11 | "{0.real}".format(1j) @@ -192,7 +183,6 @@ UP032_2.py:14:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 11 11 | "{0.real}".format(1j) 12 12 | "{a.real}".format(a=1j) 13 13 | @@ -211,7 +201,6 @@ UP032_2.py:15:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 12 12 | "{a.real}".format(a=1j) 13 13 | 14 14 | "{.real}".format(0b01) @@ -232,7 +221,6 @@ UP032_2.py:16:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 13 13 | 14 14 | "{.real}".format(0b01) 15 15 | "{0.real}".format(0b01) @@ -253,7 +241,6 @@ UP032_2.py:18:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 15 15 | "{0.real}".format(0b01) 16 16 | "{a.real}".format(a=0b01) 17 17 | @@ -273,7 +260,6 @@ UP032_2.py:19:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 16 16 | "{a.real}".format(a=0b01) 17 17 | 18 18 | "{}".format(1 + 2) @@ -294,7 +280,6 @@ UP032_2.py:20:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 17 17 | 18 18 | "{}".format(1 + 2) 19 19 | "{}".format([1, 2]) @@ -314,7 +299,6 @@ UP032_2.py:21:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 18 18 | "{}".format(1 + 2) 19 19 | "{}".format([1, 2]) 20 20 | "{}".format({1, 2}) @@ -335,7 +319,6 @@ UP032_2.py:22:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 19 19 | "{}".format([1, 2]) 20 20 | "{}".format({1, 2}) 21 21 | "{}".format({1: 2, 3: 4}) @@ -356,7 +339,6 @@ UP032_2.py:24:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 21 21 | "{}".format({1: 2, 3: 4}) 22 22 | "{}".format((i for i in range(2))) 23 23 | @@ -376,7 +358,6 @@ UP032_2.py:25:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 22 22 | "{}".format((i for i in range(2))) 23 23 | 24 24 | "{.real}".format(1 + 2) @@ -397,7 +378,6 @@ UP032_2.py:26:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 23 23 | 24 24 | "{.real}".format(1 + 2) 25 25 | "{.real}".format([1, 2]) @@ -416,7 +396,6 @@ UP032_2.py:27:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 24 24 | "{.real}".format(1 + 2) 25 25 | "{.real}".format([1, 2]) 26 26 | "{.real}".format({1, 2}) @@ -433,7 +412,6 @@ UP032_2.py:28:1: UP032 [*] Use f-string instead of `format` call | = help: Convert to f-string -ℹ Safe fix 25 25 | "{.real}".format([1, 2]) 26 26 | "{.real}".format({1, 2}) 27 27 | "{.real}".format({1: 2, 3: 4}) diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP033_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP033_0.py.snap index 8d6d1475d226c..fbdee645ee2bf 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP033_0.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP033_0.py.snap @@ -10,7 +10,6 @@ UP033_0.py:4:21: UP033 [*] Use `@functools.cache` instead of `@functools.lru_cac | = help: Rewrite with `@functools.cache -ℹ Safe fix 1 1 | import functools 2 2 | 3 3 | @@ -30,7 +29,6 @@ UP033_0.py:10:21: UP033 [*] Use `@functools.cache` instead of `@functools.lru_ca | = help: Rewrite with `@functools.cache -ℹ Safe fix 7 7 | 8 8 | 9 9 | @other_decorator @@ -49,7 +47,6 @@ UP033_0.py:15:21: UP033 [*] Use `@functools.cache` instead of `@functools.lru_ca | = help: Rewrite with `@functools.cache -ℹ Safe fix 12 12 | pass 13 13 | 14 14 | @@ -58,5 +55,3 @@ UP033_0.py:15:21: UP033 [*] Use `@functools.cache` instead of `@functools.lru_ca 16 16 | @other_decorator 17 17 | def fixme(): 18 18 | pass - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP033_1.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP033_1.py.snap index 5b106d25411d2..a232329211d81 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP033_1.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP033_1.py.snap @@ -10,7 +10,6 @@ UP033_1.py:4:11: UP033 [*] Use `@functools.cache` instead of `@functools.lru_cac | = help: Rewrite with `@functools.cache -ℹ Safe fix 1 |-from functools import lru_cache 1 |+from functools import lru_cache, cache 2 2 | @@ -31,7 +30,6 @@ UP033_1.py:10:11: UP033 [*] Use `@functools.cache` instead of `@functools.lru_ca | = help: Rewrite with `@functools.cache -ℹ Safe fix 1 |-from functools import lru_cache 1 |+from functools import lru_cache, cache 2 2 | @@ -56,7 +54,6 @@ UP033_1.py:15:11: UP033 [*] Use `@functools.cache` instead of `@functools.lru_ca | = help: Rewrite with `@functools.cache -ℹ Safe fix 1 |-from functools import lru_cache 1 |+from functools import lru_cache, cache 2 2 | @@ -71,5 +68,3 @@ UP033_1.py:15:11: UP033 [*] Use `@functools.cache` instead of `@functools.lru_ca 16 16 | @other_decorator 17 17 | def fixme(): 18 18 | pass - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP034.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP034.py.snap index 52e90884c17da..96c5ece3dc4d5 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP034.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP034.py.snap @@ -11,7 +11,6 @@ UP034.py:2:7: UP034 [*] Avoid extraneous parentheses | = help: Remove extraneous parentheses -ℹ Safe fix 1 1 | # UP034 2 |-print(("foo")) 2 |+print("foo") @@ -29,7 +28,6 @@ UP034.py:5:7: UP034 [*] Avoid extraneous parentheses | = help: Remove extraneous parentheses -ℹ Safe fix 2 2 | print(("foo")) 3 3 | 4 4 | # UP034 @@ -49,7 +47,6 @@ UP034.py:8:7: UP034 [*] Avoid extraneous parentheses | = help: Remove extraneous parentheses -ℹ Safe fix 5 5 | print(("hell((goodybe))o")) 6 6 | 7 7 | # UP034 @@ -69,7 +66,6 @@ UP034.py:11:7: UP034 [*] Avoid extraneous parentheses | = help: Remove extraneous parentheses -ℹ Safe fix 8 8 | print((("foo"))) 9 9 | 10 10 | # UP034 @@ -89,7 +85,6 @@ UP034.py:14:7: UP034 [*] Avoid extraneous parentheses | = help: Remove extraneous parentheses -ℹ Safe fix 11 11 | print((((1)))) 12 12 | 13 13 | # UP034 @@ -109,7 +104,6 @@ UP034.py:18:5: UP034 [*] Avoid extraneous parentheses | = help: Remove extraneous parentheses -ℹ Safe fix 15 15 | 16 16 | # UP034 17 17 | print( @@ -132,7 +126,6 @@ UP034.py:23:5: UP034 [*] Avoid extraneous parentheses | = help: Remove extraneous parentheses -ℹ Safe fix 20 20 | 21 21 | # UP034 22 22 | print( @@ -156,7 +149,6 @@ UP034.py:30:13: UP034 [*] Avoid extraneous parentheses | = help: Remove extraneous parentheses -ℹ Safe fix 27 27 | 28 28 | # UP034 29 29 | def f(): @@ -176,7 +168,6 @@ UP034.py:35:9: UP034 [*] Avoid extraneous parentheses | = help: Remove extraneous parentheses -ℹ Safe fix 32 32 | # UP034 33 33 | if True: 34 34 | print( @@ -196,7 +187,6 @@ UP034.py:39:7: UP034 [*] Avoid extraneous parentheses | = help: Remove extraneous parentheses -ℹ Safe fix 36 36 | ) 37 37 | 38 38 | # UP034 @@ -205,5 +195,3 @@ UP034.py:39:7: UP034 [*] Avoid extraneous parentheses 40 40 | 41 41 | # OK 42 42 | print("foo") - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP035.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP035.py.snap index e83b5d88e3ec8..cdd1e507e1f88 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP035.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP035.py.snap @@ -11,7 +11,6 @@ UP035.py:2:1: UP035 [*] Import from `collections.abc` instead: `Mapping` | = help: Import from `collections.abc` -ℹ Safe fix 1 1 | # UP035 2 |-from collections import Mapping 2 |+from collections.abc import Mapping @@ -30,7 +29,6 @@ UP035.py:4:1: UP035 [*] Import from `collections.abc` instead: `Mapping` | = help: Import from `collections.abc` -ℹ Safe fix 1 1 | # UP035 2 2 | from collections import Mapping 3 3 | @@ -51,7 +49,6 @@ UP035.py:6:1: UP035 [*] Import from `collections.abc` instead: `Mapping`, `Seque | = help: Import from `collections.abc` -ℹ Safe fix 3 3 | 4 4 | from collections import Mapping as MAP 5 5 | @@ -72,7 +69,6 @@ UP035.py:8:1: UP035 [*] Import from `collections.abc` instead: `Mapping` | = help: Import from `collections.abc` -ℹ Safe fix 5 5 | 6 6 | from collections import Mapping, Sequence 7 7 | @@ -94,7 +90,6 @@ UP035.py:10:1: UP035 [*] Import from `collections.abc` instead: `Mapping` | = help: Import from `collections.abc` -ℹ Safe fix 7 7 | 8 8 | from collections import Counter, Mapping 9 9 | @@ -117,7 +112,6 @@ UP035.py:12:1: UP035 [*] Import from `collections.abc` instead: `Mapping` | = help: Import from `collections.abc` -ℹ Safe fix 9 9 | 10 10 | from collections import (Counter, Mapping) 11 11 | @@ -141,7 +135,6 @@ UP035.py:15:1: UP035 [*] Import from `collections.abc` instead: `Mapping` | = help: Import from `collections.abc` -ℹ Safe fix 12 12 | from collections import (Counter, 13 13 | Mapping) 14 14 | @@ -164,7 +157,6 @@ UP035.py:18:1: UP035 [*] Import from `collections.abc` instead: `Mapping`, `Sequ | = help: Import from `collections.abc` -ℹ Safe fix 15 15 | from collections import Counter, \ 16 16 | Mapping 17 17 | @@ -186,7 +178,6 @@ UP035.py:20:1: UP035 [*] Import from `collections.abc` instead: `Mapping` | = help: Import from `collections.abc` -ℹ Safe fix 17 17 | 18 18 | from collections import Counter, Mapping, Sequence 19 19 | @@ -207,7 +198,6 @@ UP035.py:23:5: UP035 [*] Import from `collections.abc` instead: `Mapping` | = help: Import from `collections.abc` -ℹ Safe fix 20 20 | from collections import Mapping as mapping, Counter 21 21 | 22 22 | if True: @@ -229,7 +219,6 @@ UP035.py:28:5: UP035 [*] Import from `collections.abc` instead: `Mapping` | = help: Import from `collections.abc` -ℹ Safe fix 25 25 | if True: 26 26 | if True: 27 27 | pass @@ -251,7 +240,6 @@ UP035.py:30:10: UP035 [*] Import from `collections.abc` instead: `Mapping` | = help: Import from `collections.abc` -ℹ Safe fix 27 27 | pass 28 28 | from collections import Mapping, Counter 29 29 | @@ -270,7 +258,6 @@ UP035.py:33:1: UP035 [*] Import from `collections.abc` instead: `Mapping` | = help: Import from `collections.abc` -ℹ Safe fix 30 30 | if True: from collections import Mapping 31 31 | 32 32 | import os @@ -297,7 +284,6 @@ UP035.py:37:5: UP035 [*] Import from `collections.abc` instead: `Mapping`, `Call | = help: Import from `collections.abc` -ℹ Safe fix 35 35 | 36 36 | if True: 37 37 | from collections import ( @@ -322,7 +308,6 @@ UP035.py:44:1: UP035 [*] Import from `collections.abc` instead: `Callable` | = help: Import from `collections.abc` -ℹ Safe fix 41 41 | Good, 42 42 | ) 43 43 | @@ -344,7 +329,6 @@ UP035.py:44:1: UP035 [*] Import from `collections` instead: `OrderedDict` | = help: Import from `collections` -ℹ Safe fix 41 41 | Good, 42 42 | ) 43 43 | @@ -366,7 +350,6 @@ UP035.py:44:1: UP035 [*] Import from `re` instead: `Match`, `Pattern` | = help: Import from `re` -ℹ Safe fix 41 41 | Good, 42 42 | ) 43 43 | @@ -440,7 +423,6 @@ UP035.py:51:1: UP035 [*] Import from `collections` instead: `OrderedDict` | = help: Import from `collections` -ℹ Safe fix 48 48 | 49 49 | # Bad imports from PYI027 that are now handled by PYI022 (UP035) 50 50 | from typing import ContextManager @@ -461,7 +443,6 @@ UP035.py:52:1: UP035 [*] Import from `typing` instead: `OrderedDict` | = help: Import from `typing` -ℹ Safe fix 49 49 | # Bad imports from PYI027 that are now handled by PYI022 (UP035) 50 50 | from typing import ContextManager 51 51 | from typing import OrderedDict @@ -482,7 +463,6 @@ UP035.py:53:1: UP035 [*] Import from `collections.abc` instead: `Callable` | = help: Import from `collections.abc` -ℹ Safe fix 50 50 | from typing import ContextManager 51 51 | from typing import OrderedDict 52 52 | from typing_extensions import OrderedDict @@ -503,7 +483,6 @@ UP035.py:54:1: UP035 [*] Import from `collections.abc` instead: `ByteString` | = help: Import from `collections.abc` -ℹ Safe fix 51 51 | from typing import OrderedDict 52 52 | from typing_extensions import OrderedDict 53 53 | from typing import Callable @@ -524,7 +503,6 @@ UP035.py:55:1: UP035 [*] Import from `collections.abc` instead: `Container` | = help: Import from `collections.abc` -ℹ Safe fix 52 52 | from typing_extensions import OrderedDict 53 53 | from typing import Callable 54 54 | from typing import ByteString @@ -545,7 +523,6 @@ UP035.py:56:1: UP035 [*] Import from `collections.abc` instead: `Hashable` | = help: Import from `collections.abc` -ℹ Safe fix 53 53 | from typing import Callable 54 54 | from typing import ByteString 55 55 | from typing import Container @@ -566,7 +543,6 @@ UP035.py:57:1: UP035 [*] Import from `collections.abc` instead: `ItemsView` | = help: Import from `collections.abc` -ℹ Safe fix 54 54 | from typing import ByteString 55 55 | from typing import Container 56 56 | from typing import Hashable @@ -587,7 +563,6 @@ UP035.py:58:1: UP035 [*] Import from `collections.abc` instead: `Iterable` | = help: Import from `collections.abc` -ℹ Safe fix 55 55 | from typing import Container 56 56 | from typing import Hashable 57 57 | from typing import ItemsView @@ -608,7 +583,6 @@ UP035.py:59:1: UP035 [*] Import from `collections.abc` instead: `Iterator` | = help: Import from `collections.abc` -ℹ Safe fix 56 56 | from typing import Hashable 57 57 | from typing import ItemsView 58 58 | from typing import Iterable @@ -629,7 +603,6 @@ UP035.py:60:1: UP035 [*] Import from `collections.abc` instead: `KeysView` | = help: Import from `collections.abc` -ℹ Safe fix 57 57 | from typing import ItemsView 58 58 | from typing import Iterable 59 59 | from typing import Iterator @@ -650,7 +623,6 @@ UP035.py:61:1: UP035 [*] Import from `collections.abc` instead: `Mapping` | = help: Import from `collections.abc` -ℹ Safe fix 58 58 | from typing import Iterable 59 59 | from typing import Iterator 60 60 | from typing import KeysView @@ -671,7 +643,6 @@ UP035.py:62:1: UP035 [*] Import from `collections.abc` instead: `MappingView` | = help: Import from `collections.abc` -ℹ Safe fix 59 59 | from typing import Iterator 60 60 | from typing import KeysView 61 61 | from typing import Mapping @@ -692,7 +663,6 @@ UP035.py:63:1: UP035 [*] Import from `collections.abc` instead: `MutableMapping` | = help: Import from `collections.abc` -ℹ Safe fix 60 60 | from typing import KeysView 61 61 | from typing import Mapping 62 62 | from typing import MappingView @@ -713,7 +683,6 @@ UP035.py:64:1: UP035 [*] Import from `collections.abc` instead: `MutableSequence | = help: Import from `collections.abc` -ℹ Safe fix 61 61 | from typing import Mapping 62 62 | from typing import MappingView 63 63 | from typing import MutableMapping @@ -734,7 +703,6 @@ UP035.py:65:1: UP035 [*] Import from `collections.abc` instead: `MutableSet` | = help: Import from `collections.abc` -ℹ Safe fix 62 62 | from typing import MappingView 63 63 | from typing import MutableMapping 64 64 | from typing import MutableSequence @@ -755,7 +723,6 @@ UP035.py:66:1: UP035 [*] Import from `collections.abc` instead: `Sequence` | = help: Import from `collections.abc` -ℹ Safe fix 63 63 | from typing import MutableMapping 64 64 | from typing import MutableSequence 65 65 | from typing import MutableSet @@ -776,7 +743,6 @@ UP035.py:67:1: UP035 [*] Import from `collections.abc` instead: `Sized` | = help: Import from `collections.abc` -ℹ Safe fix 64 64 | from typing import MutableSequence 65 65 | from typing import MutableSet 66 66 | from typing import Sequence @@ -797,7 +763,6 @@ UP035.py:68:1: UP035 [*] Import from `collections.abc` instead: `ValuesView` | = help: Import from `collections.abc` -ℹ Safe fix 65 65 | from typing import MutableSet 66 66 | from typing import Sequence 67 67 | from typing import Sized @@ -818,7 +783,6 @@ UP035.py:69:1: UP035 [*] Import from `collections.abc` instead: `Awaitable` | = help: Import from `collections.abc` -ℹ Safe fix 66 66 | from typing import Sequence 67 67 | from typing import Sized 68 68 | from typing import ValuesView @@ -839,7 +803,6 @@ UP035.py:70:1: UP035 [*] Import from `collections.abc` instead: `AsyncIterator` | = help: Import from `collections.abc` -ℹ Safe fix 67 67 | from typing import Sized 68 68 | from typing import ValuesView 69 69 | from typing import Awaitable @@ -860,7 +823,6 @@ UP035.py:71:1: UP035 [*] Import from `collections.abc` instead: `AsyncIterable` | = help: Import from `collections.abc` -ℹ Safe fix 68 68 | from typing import ValuesView 69 69 | from typing import Awaitable 70 70 | from typing import AsyncIterator @@ -881,7 +843,6 @@ UP035.py:72:1: UP035 [*] Import from `collections.abc` instead: `Coroutine` | = help: Import from `collections.abc` -ℹ Safe fix 69 69 | from typing import Awaitable 70 70 | from typing import AsyncIterator 71 71 | from typing import AsyncIterable @@ -902,7 +863,6 @@ UP035.py:73:1: UP035 [*] Import from `collections.abc` instead: `Collection` | = help: Import from `collections.abc` -ℹ Safe fix 70 70 | from typing import AsyncIterator 71 71 | from typing import AsyncIterable 72 72 | from typing import Coroutine @@ -923,7 +883,6 @@ UP035.py:74:1: UP035 [*] Import from `collections.abc` instead: `AsyncGenerator` | = help: Import from `collections.abc` -ℹ Safe fix 71 71 | from typing import AsyncIterable 72 72 | from typing import Coroutine 73 73 | from typing import Collection @@ -944,7 +903,6 @@ UP035.py:75:1: UP035 [*] Import from `collections.abc` instead: `Reversible` | = help: Import from `collections.abc` -ℹ Safe fix 72 72 | from typing import Coroutine 73 73 | from typing import Collection 74 74 | from typing import AsyncGenerator @@ -965,7 +923,6 @@ UP035.py:76:1: UP035 [*] Import from `collections.abc` instead: `Generator` | = help: Import from `collections.abc` -ℹ Safe fix 73 73 | from typing import Collection 74 74 | from typing import AsyncGenerator 75 75 | from typing import Reversible @@ -985,7 +942,6 @@ UP035.py:77:1: UP035 [*] Import from `collections.abc` instead: `Callable` | = help: Import from `collections.abc` -ℹ Safe fix 74 74 | from typing import AsyncGenerator 75 75 | from typing import Reversible 76 76 | from typing import Generator @@ -1005,7 +961,6 @@ UP035.py:84:1: UP035 [*] Import from `typing` instead: `SupportsIndex` | = help: Import from `typing` -ℹ Safe fix 81 81 | from a import b 82 82 | 83 83 | # UP035 on py312+ only @@ -1025,7 +980,6 @@ UP035.py:87:1: UP035 [*] Import from `typing` instead: `NamedTuple` | = help: Import from `typing` -ℹ Safe fix 84 84 | from typing_extensions import SupportsIndex 85 85 | 86 86 | # UP035 on py312+ only @@ -1045,7 +999,6 @@ UP035.py:90:1: UP035 [*] Import from `typing` instead: `dataclass_transform` | = help: Import from `typing` -ℹ Safe fix 87 87 | from typing_extensions import NamedTuple 88 88 | 89 89 | # UP035 on py312+ only: `typing_extensions` supports `frozen_default` (backported from 3.12). @@ -1065,7 +1018,6 @@ UP035.py:93:1: UP035 [*] Import from `enum` instead: `StrEnum` | = help: Import from `enum` -ℹ Safe fix 90 90 | from typing_extensions import dataclass_transform 91 91 | 92 92 | # UP035 @@ -1085,7 +1037,6 @@ UP035.py:96:1: UP035 [*] Import from `typing` instead: `override` | = help: Import from `typing` -ℹ Safe fix 93 93 | from backports.strenum import StrEnum 94 94 | 95 95 | # UP035 @@ -1105,7 +1056,6 @@ UP035.py:99:1: UP035 [*] Import from `collections.abc` instead: `Buffer` | = help: Import from `collections.abc` -ℹ Safe fix 96 96 | from typing_extensions import override 97 97 | 98 98 | # UP035 @@ -1125,7 +1075,6 @@ UP035.py:102:1: UP035 [*] Import from `types` instead: `get_original_bases` | = help: Import from `types` -ℹ Safe fix 99 99 | from typing_extensions import Buffer 100 100 | 101 101 | # UP035 @@ -1145,7 +1094,6 @@ UP035.py:105:1: UP035 [*] Import from `typing` instead: `TypeVar` | = help: Import from `typing` -ℹ Safe fix 102 102 | from typing_extensions import get_original_bases 103 103 | 104 104 | # UP035 on py313+ only @@ -1165,7 +1113,6 @@ UP035.py:108:1: UP035 [*] Import from `types` instead: `CapsuleType` | = help: Import from `types` -ℹ Safe fix 105 105 | from typing_extensions import TypeVar 106 106 | 107 107 | # UP035 on py313+ only @@ -1183,7 +1130,6 @@ UP035.py:111:1: UP035 [*] Import from `warnings` instead: `deprecated` | = help: Import from `warnings` -ℹ Safe fix 108 108 | from typing_extensions import CapsuleType 109 109 | 110 110 | # UP035 on py313+ only diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_0.py.snap index 329642fd56850..0db00341585ee 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_0.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_0.py.snap @@ -12,17 +12,6 @@ UP036_0.py:3:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -1 1 | import sys -2 2 | -3 |-if sys.version_info < (3,0): -4 |- print("py2") -5 |-else: -6 |- print("py3") - 3 |+print("py3") -7 4 | -8 5 | if sys.version_info < (3,0): -9 6 | if True: UP036_0.py:8:4: UP036 [*] Version block is outdated for minimum Python version | @@ -35,21 +24,6 @@ UP036_0.py:8:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -5 5 | else: -6 6 | print("py3") -7 7 | -8 |-if sys.version_info < (3,0): -9 |- if True: -10 |- print("py2!") -11 |- else: -12 |- print("???") -13 |-else: -14 |- print("py3") - 8 |+print("py3") -15 9 | -16 10 | if sys.version_info < (3,0): print("PY2!") -17 11 | else: print("PY3!") UP036_0.py:16:4: UP036 [*] Version block is outdated for minimum Python version | @@ -61,16 +35,6 @@ UP036_0.py:16:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -13 13 | else: -14 14 | print("py3") -15 15 | -16 |-if sys.version_info < (3,0): print("PY2!") -17 |-else: print("PY3!") - 16 |+print("PY3!") -18 17 | -19 18 | if True: -20 19 | if sys.version_info < (3,0): UP036_0.py:20:8: UP036 [*] Version block is outdated for minimum Python version | @@ -82,18 +46,6 @@ UP036_0.py:20:8: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -17 17 | else: print("PY3!") -18 18 | -19 19 | if True: -20 |- if sys.version_info < (3,0): -21 |- print("PY2") -22 |- else: -23 |- print("PY3") - 20 |+ print("PY3") -24 21 | -25 22 | if sys.version_info < (3,0): print(1 if True else 3) -26 23 | else: UP036_0.py:25:4: UP036 [*] Version block is outdated for minimum Python version | @@ -106,17 +58,6 @@ UP036_0.py:25:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -22 22 | else: -23 23 | print("PY3") -24 24 | -25 |-if sys.version_info < (3,0): print(1 if True else 3) -26 |-else: -27 |- print("py3") - 25 |+print("py3") -28 26 | -29 27 | if sys.version_info < (3,0): -30 28 | def f(): UP036_0.py:29:4: UP036 [*] Version block is outdated for minimum Python version | @@ -129,23 +70,6 @@ UP036_0.py:29:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -26 26 | else: -27 27 | print("py3") -28 28 | -29 |-if sys.version_info < (3,0): -30 |- def f(): -31 |- print("py2") -32 |-else: -33 |- def f(): -34 |- print("py3") -35 |- print("This the next") - 29 |+def f(): - 30 |+ print("py3") - 31 |+ print("This the next") -36 32 | -37 33 | if sys.version_info > (3,0): -38 34 | print("py3") UP036_0.py:37:4: UP036 [*] Version block is outdated for minimum Python version | @@ -158,18 +82,6 @@ UP036_0.py:37:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -34 34 | print("py3") -35 35 | print("This the next") -36 36 | -37 |-if sys.version_info > (3,0): -38 |- print("py3") -39 |-else: -40 |- print("py2") - 37 |+print("py3") -41 38 | -42 39 | -43 40 | x = 1 UP036_0.py:45:4: UP036 [*] Version block is outdated for minimum Python version | @@ -182,18 +94,6 @@ UP036_0.py:45:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -42 42 | -43 43 | x = 1 -44 44 | -45 |-if sys.version_info > (3,0): -46 |- print("py3") -47 |-else: -48 |- print("py2") - 45 |+print("py3") -49 46 | # ohai -50 47 | -51 48 | x = 1 UP036_0.py:53:4: UP036 [*] Version block is outdated for minimum Python version | @@ -205,16 +105,6 @@ UP036_0.py:53:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -50 50 | -51 51 | x = 1 -52 52 | -53 |-if sys.version_info > (3,0): print("py3") -54 |-else: print("py2") - 53 |+print("py3") -55 54 | -56 55 | if sys.version_info > (3,): -57 56 | print("py3") UP036_0.py:56:4: UP036 [*] Version block is outdated for minimum Python version | @@ -227,18 +117,6 @@ UP036_0.py:56:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -53 53 | if sys.version_info > (3,0): print("py3") -54 54 | else: print("py2") -55 55 | -56 |-if sys.version_info > (3,): -57 |- print("py3") -58 |-else: -59 |- print("py2") - 56 |+print("py3") -60 57 | -61 58 | if True: -62 59 | if sys.version_info > (3,): UP036_0.py:62:8: UP036 [*] Version block is outdated for minimum Python version | @@ -250,18 +128,6 @@ UP036_0.py:62:8: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -59 59 | print("py2") -60 60 | -61 61 | if True: -62 |- if sys.version_info > (3,): -63 |- print("py3") -64 |- else: -65 |- print("py2") - 62 |+ print("py3") -66 63 | -67 64 | if sys.version_info < (3,): -68 65 | print("py2") UP036_0.py:67:4: UP036 [*] Version block is outdated for minimum Python version | @@ -274,18 +140,6 @@ UP036_0.py:67:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -64 64 | else: -65 65 | print("py2") -66 66 | -67 |-if sys.version_info < (3,): -68 |- print("py2") -69 |-else: -70 |- print("py3") - 67 |+print("py3") -71 68 | -72 69 | def f(): -73 70 | if sys.version_info < (3,0): UP036_0.py:73:8: UP036 [*] Version block is outdated for minimum Python version | @@ -297,21 +151,6 @@ UP036_0.py:73:8: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -70 70 | print("py3") -71 71 | -72 72 | def f(): -73 |- if sys.version_info < (3,0): -74 |- try: -75 |- yield -76 |- finally: -77 |- pass -78 |- else: -79 |- yield - 73 |+ yield -80 74 | -81 75 | -82 76 | class C: UP036_0.py:86:8: UP036 [*] Version block is outdated for minimum Python version | @@ -324,21 +163,6 @@ UP036_0.py:86:8: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -83 83 | def g(): -84 84 | pass -85 85 | -86 |- if sys.version_info < (3,0): -87 |- def f(py2): -88 |- pass -89 |- else: -90 |- def f(py3): -91 |- pass - 86 |+ def f(py3): - 87 |+ pass -92 88 | -93 89 | def h(): -94 90 | pass UP036_0.py:97:8: UP036 [*] Version block is outdated for minimum Python version | @@ -350,18 +174,6 @@ UP036_0.py:97:8: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -94 94 | pass -95 95 | -96 96 | if True: -97 |- if sys.version_info < (3,0): -98 |- 2 -99 |- else: -100 |- 3 - 97 |+ 3 -101 98 | -102 99 | # comment -103 100 | UP036_0.py:104:4: UP036 [*] Version block is outdated for minimum Python version | @@ -374,27 +186,6 @@ UP036_0.py:104:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -101 101 | -102 102 | # comment -103 103 | -104 |-if sys.version_info < (3,0): -105 |- def f(): -106 |- print("py2") -107 |- def g(): -108 |- print("py2") -109 |-else: -110 |- def f(): -111 |- print("py3") -112 |- def g(): -113 |- print("py3") - 104 |+def f(): - 105 |+ print("py3") - 106 |+def g(): - 107 |+ print("py3") -114 108 | -115 109 | if True: -116 110 | if sys.version_info > (3,): UP036_0.py:116:8: UP036 [*] Version block is outdated for minimum Python version | @@ -406,16 +197,6 @@ UP036_0.py:116:8: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -113 113 | print("py3") -114 114 | -115 115 | if True: -116 |- if sys.version_info > (3,): -117 |- print(3) - 116 |+ print(3) -118 117 | # comment -119 118 | print(2+3) -120 119 | UP036_0.py:122:8: UP036 [*] Version block is outdated for minimum Python version | @@ -427,15 +208,6 @@ UP036_0.py:122:8: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -119 119 | print(2+3) -120 120 | -121 121 | if True: -122 |- if sys.version_info > (3,): print(3) - 122 |+ print(3) -123 123 | -124 124 | if True: -125 125 | if sys.version_info > (3,): UP036_0.py:125:8: UP036 [*] Version block is outdated for minimum Python version | @@ -446,16 +218,6 @@ UP036_0.py:125:8: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -122 122 | if sys.version_info > (3,): print(3) -123 123 | -124 124 | if True: -125 |- if sys.version_info > (3,): -126 |- print(3) - 125 |+ print(3) -127 126 | -128 127 | -129 128 | if True: UP036_0.py:130:8: UP036 [*] Version block is outdated for minimum Python version | @@ -467,23 +229,6 @@ UP036_0.py:130:8: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -127 127 | -128 128 | -129 129 | if True: -130 |- if sys.version_info <= (3, 0): -131 |- expected_error = [] -132 |- else: -133 |- expected_error = [ - 130 |+ expected_error = [ -134 131 | ":1:5: Generator expression must be parenthesized", -135 132 | "max(1 for i in range(10), key=lambda x: x+1)", -136 133 | " ^", -137 |- ] - 134 |+ ] -138 135 | -139 136 | -140 137 | if sys.version_info <= (3, 0): UP036_0.py:140:4: UP036 [*] Version block is outdated for minimum Python version | @@ -494,23 +239,6 @@ UP036_0.py:140:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -137 137 | ] -138 138 | -139 139 | -140 |-if sys.version_info <= (3, 0): -141 |- expected_error = [] -142 |-else: -143 |- expected_error = [ - 140 |+expected_error = [ -144 141 | ":1:5: Generator expression must be parenthesized", -145 142 | "max(1 for i in range(10), key=lambda x: x+1)", -146 143 | " ^", -147 |- ] - 144 |+] -148 145 | -149 146 | -150 147 | if sys.version_info > (3,0): UP036_0.py:150:4: UP036 [*] Version block is outdated for minimum Python version | @@ -521,30 +249,6 @@ UP036_0.py:150:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -147 147 | ] -148 148 | -149 149 | -150 |-if sys.version_info > (3,0): -151 |- """this - 150 |+"""this -152 151 | is valid""" -153 152 | -154 |- """the indentation on - 153 |+"""the indentation on -155 154 | this line is significant""" -156 155 | -157 |- "this is" \ - 156 |+"this is" \ -158 157 | "allowed too" -159 158 | -160 |- ("so is" -161 |- "this for some reason") - 159 |+("so is" - 160 |+ "this for some reason") -162 161 | -163 162 | if sys.version_info > (3, 0): expected_error = \ -164 163 | [] UP036_0.py:163:4: UP036 [*] Version block is outdated for minimum Python version | @@ -556,15 +260,6 @@ UP036_0.py:163:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -160 160 | ("so is" -161 161 | "this for some reason") -162 162 | -163 |-if sys.version_info > (3, 0): expected_error = \ - 163 |+expected_error = \ -164 164 | [] -165 165 | -166 166 | if sys.version_info > (3, 0): expected_error = [] UP036_0.py:166:4: UP036 [*] Version block is outdated for minimum Python version | @@ -577,15 +272,6 @@ UP036_0.py:166:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -163 163 | if sys.version_info > (3, 0): expected_error = \ -164 164 | [] -165 165 | -166 |-if sys.version_info > (3, 0): expected_error = [] - 166 |+expected_error = [] -167 167 | -168 168 | if sys.version_info > (3, 0): \ -169 169 | expected_error = [] UP036_0.py:168:4: UP036 [*] Version block is outdated for minimum Python version | @@ -597,16 +283,6 @@ UP036_0.py:168:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -165 165 | -166 166 | if sys.version_info > (3, 0): expected_error = [] -167 167 | -168 |-if sys.version_info > (3, 0): \ -169 |- expected_error = [] - 168 |+expected_error = [] -170 169 | -171 170 | if True: -172 171 | if sys.version_info > (3, 0): expected_error = \ UP036_0.py:172:8: UP036 [*] Version block is outdated for minimum Python version | @@ -617,15 +293,6 @@ UP036_0.py:172:8: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -169 169 | expected_error = [] -170 170 | -171 171 | if True: -172 |- if sys.version_info > (3, 0): expected_error = \ - 172 |+ expected_error = \ -173 173 | [] -174 174 | -175 175 | if True: UP036_0.py:176:8: UP036 [*] Version block is outdated for minimum Python version | @@ -637,15 +304,6 @@ UP036_0.py:176:8: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -173 173 | [] -174 174 | -175 175 | if True: -176 |- if sys.version_info > (3, 0): expected_error = [] - 176 |+ expected_error = [] -177 177 | -178 178 | if True: -179 179 | if sys.version_info > (3, 0): \ UP036_0.py:179:8: UP036 [*] Version block is outdated for minimum Python version | @@ -656,14 +314,6 @@ UP036_0.py:179:8: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -176 176 | if sys.version_info > (3, 0): expected_error = [] -177 177 | -178 178 | if True: -179 |- if sys.version_info > (3, 0): \ -180 179 | expected_error = [] -181 180 | -182 181 | if sys.version_info < (3,13): UP036_0.py:182:4: UP036 [*] Version block is outdated for minimum Python version | @@ -675,15 +325,6 @@ UP036_0.py:182:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -179 179 | if sys.version_info > (3, 0): \ -180 180 | expected_error = [] -181 181 | -182 |-if sys.version_info < (3,13): -183 |- print("py3") -184 182 | -185 183 | if sys.version_info <= (3,13): -186 184 | print("py3") UP036_0.py:191:24: UP036 Version specifier is invalid | @@ -722,16 +363,6 @@ UP036_0.py:203:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -200 200 | if sys.version_info > (3,13): -201 201 | print("py3") -202 202 | -203 |-if sys.version_info >= (3,13): -204 |- print("py3") - 203 |+print("py3") -205 204 | -206 205 | # Slices on `sys.version_info` should be treated equivalently. -207 206 | if sys.version_info[:2] >= (3,0): UP036_0.py:207:4: UP036 [*] Version block is outdated for minimum Python version | @@ -742,16 +373,6 @@ UP036_0.py:207:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -204 204 | print("py3") -205 205 | -206 206 | # Slices on `sys.version_info` should be treated equivalently. -207 |-if sys.version_info[:2] >= (3,0): -208 |- print("py3") - 207 |+print("py3") -209 208 | -210 209 | if sys.version_info[:3] >= (3,0): -211 210 | print("py3") UP036_0.py:210:4: UP036 [*] Version block is outdated for minimum Python version | @@ -763,16 +384,6 @@ UP036_0.py:210:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -207 207 | if sys.version_info[:2] >= (3,0): -208 208 | print("py3") -209 209 | -210 |-if sys.version_info[:3] >= (3,0): -211 |- print("py3") - 210 |+print("py3") -212 211 | -213 212 | if sys.version_info[:2] > (3,14): -214 213 | print("py3") UP036_0.py:219:4: UP036 [*] Version block is outdated for minimum Python version | @@ -784,20 +395,3 @@ UP036_0.py:219:4: UP036 [*] Version block is outdated for minimum Python version 221 | allowed too" | = help: Remove outdated version block - -ℹ Unsafe fix -216 216 | if sys.version_info[:3] > (3,14): -217 217 | print("py3") -218 218 | -219 |-if sys.version_info > (3,0): -220 |- f"this is\ - 219 |+f"this is\ -221 220 | allowed too" -222 221 | -223 |- f"""the indentation on - 222 |+f"""the indentation on -224 223 | this line is significant""" -225 224 | -226 |- "this is\ - 225 |+"this is\ -227 226 | allowed too" diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_1.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_1.py.snap index e89393c5a4a1a..50c4631901aa9 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_1.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_1.py.snap @@ -12,17 +12,6 @@ UP036_1.py:3:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -1 1 | import sys -2 2 | -3 |-if sys.version_info == 2: -4 |- 2 -5 |-else: -6 |- 3 - 3 |+3 -7 4 | -8 5 | if sys.version_info < (3,): -9 6 | 2 UP036_1.py:8:4: UP036 [*] Version block is outdated for minimum Python version | @@ -35,18 +24,6 @@ UP036_1.py:8:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -5 5 | else: -6 6 | 3 -7 7 | -8 |-if sys.version_info < (3,): -9 |- 2 -10 |-else: -11 |- 3 - 8 |+3 -12 9 | -13 10 | if sys.version_info < (3,0): -14 11 | 2 UP036_1.py:13:4: UP036 [*] Version block is outdated for minimum Python version | @@ -59,18 +36,6 @@ UP036_1.py:13:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -10 10 | else: -11 11 | 3 -12 12 | -13 |-if sys.version_info < (3,0): -14 |- 2 -15 |-else: -16 |- 3 - 13 |+3 -17 14 | -18 15 | if sys.version_info == 3: -19 16 | 3 UP036_1.py:18:4: UP036 [*] Version block is outdated for minimum Python version | @@ -83,18 +48,6 @@ UP036_1.py:18:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -15 15 | else: -16 16 | 3 -17 17 | -18 |-if sys.version_info == 3: -19 |- 3 -20 |-else: -21 |- 2 - 18 |+3 -22 19 | -23 20 | if sys.version_info > (3,): -24 21 | 3 UP036_1.py:23:4: UP036 [*] Version block is outdated for minimum Python version | @@ -107,18 +60,6 @@ UP036_1.py:23:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -20 20 | else: -21 21 | 2 -22 22 | -23 |-if sys.version_info > (3,): -24 |- 3 -25 |-else: -26 |- 2 - 23 |+3 -27 24 | -28 25 | if sys.version_info >= (3,): -29 26 | 3 UP036_1.py:28:4: UP036 [*] Version block is outdated for minimum Python version | @@ -131,18 +72,6 @@ UP036_1.py:28:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -25 25 | else: -26 26 | 2 -27 27 | -28 |-if sys.version_info >= (3,): -29 |- 3 -30 |-else: -31 |- 2 - 28 |+3 -32 29 | -33 30 | from sys import version_info -34 31 | UP036_1.py:35:4: UP036 [*] Version block is outdated for minimum Python version | @@ -155,18 +84,6 @@ UP036_1.py:35:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -32 32 | -33 33 | from sys import version_info -34 34 | -35 |-if version_info > (3,): -36 |- 3 -37 |-else: -38 |- 2 - 35 |+3 -39 36 | -40 37 | if True: -41 38 | print(1) UP036_1.py:42:6: UP036 [*] Version block is outdated for minimum Python version | @@ -179,15 +96,6 @@ UP036_1.py:42:6: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -39 39 | -40 40 | if True: -41 41 | print(1) -42 |-elif sys.version_info < (3,0): -43 |- print(2) -44 42 | else: -45 43 | print(3) -46 44 | UP036_1.py:49:6: UP036 [*] Version block is outdated for minimum Python version | @@ -200,18 +108,6 @@ UP036_1.py:49:6: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -46 46 | -47 47 | if True: -48 48 | print(1) -49 |-elif sys.version_info > (3,): - 49 |+else: -50 50 | print(3) -51 |-else: -52 |- print(2) -53 51 | -54 52 | if True: -55 53 | print(1) UP036_1.py:56:6: UP036 [*] Version block is outdated for minimum Python version | @@ -223,15 +119,6 @@ UP036_1.py:56:6: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -53 53 | -54 54 | if True: -55 55 | print(1) -56 |-elif sys.version_info > (3,): - 56 |+else: -57 57 | print(3) -58 58 | -59 59 | def f(): UP036_1.py:62:10: UP036 [*] Version block is outdated for minimum Python version | @@ -243,15 +130,6 @@ UP036_1.py:62:10: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -59 59 | def f(): -60 60 | if True: -61 61 | print(1) -62 |- elif sys.version_info > (3,): - 62 |+ else: -63 63 | print(3) -64 64 | -65 65 | if True: UP036_1.py:67:6: UP036 [*] Version block is outdated for minimum Python version | @@ -264,15 +142,6 @@ UP036_1.py:67:6: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -64 64 | -65 65 | if True: -66 66 | print(1) -67 |-elif sys.version_info < (3,0): -68 |- print(2) -69 67 | else: -70 68 | print(3) -71 69 | UP036_1.py:75:10: UP036 [*] Version block is outdated for minimum Python version | @@ -283,13 +152,3 @@ UP036_1.py:75:10: UP036 [*] Version block is outdated for minimum Python version 76 | print(3) | = help: Remove outdated version block - -ℹ Unsafe fix -72 72 | def f(): -73 73 | if True: -74 74 | print(1) -75 |- elif sys.version_info > (3,): - 75 |+ else: -76 76 | print(3) - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_2.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_2.py.snap index 0a280dc5054e9..56ff5eb22ca5a 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_2.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_2.py.snap @@ -12,18 +12,6 @@ UP036_2.py:4:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -1 1 | import sys -2 2 | from sys import version_info -3 3 | -4 |-if sys.version_info > (3, 5): -5 |- 3+6 -6 |-else: -7 |- 3-5 - 4 |+3+6 -8 5 | -9 6 | if version_info > (3, 5): -10 7 | 3+6 UP036_2.py:9:4: UP036 [*] Version block is outdated for minimum Python version | @@ -36,18 +24,6 @@ UP036_2.py:9:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -6 6 | else: -7 7 | 3-5 -8 8 | -9 |-if version_info > (3, 5): -10 |- 3+6 -11 |-else: -12 |- 3-5 - 9 |+3+6 -13 10 | -14 11 | if sys.version_info >= (3,6): -15 12 | 3+6 UP036_2.py:14:4: UP036 [*] Version block is outdated for minimum Python version | @@ -60,18 +36,6 @@ UP036_2.py:14:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -11 11 | else: -12 12 | 3-5 -13 13 | -14 |-if sys.version_info >= (3,6): -15 |- 3+6 -16 |-else: -17 |- 3-5 - 14 |+3+6 -18 15 | -19 16 | if version_info >= (3,6): -20 17 | 3+6 UP036_2.py:19:4: UP036 [*] Version block is outdated for minimum Python version | @@ -84,18 +48,6 @@ UP036_2.py:19:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -16 16 | else: -17 17 | 3-5 -18 18 | -19 |-if version_info >= (3,6): -20 |- 3+6 -21 |-else: -22 |- 3-5 - 19 |+3+6 -23 20 | -24 21 | if sys.version_info < (3,6): -25 22 | 3-5 UP036_2.py:24:4: UP036 [*] Version block is outdated for minimum Python version | @@ -108,18 +60,6 @@ UP036_2.py:24:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -21 21 | else: -22 22 | 3-5 -23 23 | -24 |-if sys.version_info < (3,6): -25 |- 3-5 -26 |-else: -27 |- 3+6 - 24 |+3+6 -28 25 | -29 26 | if sys.version_info <= (3,5): -30 27 | 3-5 UP036_2.py:29:4: UP036 [*] Version block is outdated for minimum Python version | @@ -132,18 +72,6 @@ UP036_2.py:29:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -26 26 | else: -27 27 | 3+6 -28 28 | -29 |-if sys.version_info <= (3,5): -30 |- 3-5 -31 |-else: -32 |- 3+6 - 29 |+3+6 -33 30 | -34 31 | if sys.version_info <= (3, 5): -35 32 | 3-5 UP036_2.py:34:4: UP036 [*] Version block is outdated for minimum Python version | @@ -156,18 +84,6 @@ UP036_2.py:34:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -31 31 | else: -32 32 | 3+6 -33 33 | -34 |-if sys.version_info <= (3, 5): -35 |- 3-5 -36 |-else: -37 |- 3+6 - 34 |+3+6 -38 35 | -39 36 | if sys.version_info >= (3, 5): -40 37 | pass UP036_2.py:39:4: UP036 [*] Version block is outdated for minimum Python version | @@ -179,16 +95,6 @@ UP036_2.py:39:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -36 36 | else: -37 37 | 3+6 -38 38 | -39 |-if sys.version_info >= (3, 5): -40 |- pass - 39 |+pass -41 40 | -42 41 | if sys.version_info < (3,0): -43 42 | pass UP036_2.py:42:4: UP036 [*] Version block is outdated for minimum Python version | @@ -200,15 +106,6 @@ UP036_2.py:42:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -39 39 | if sys.version_info >= (3, 5): -40 40 | pass -41 41 | -42 |-if sys.version_info < (3,0): -43 |- pass -44 42 | -45 43 | if True: -46 44 | if sys.version_info < (3,0): UP036_2.py:46:8: UP036 [*] Version block is outdated for minimum Python version | @@ -219,16 +116,6 @@ UP036_2.py:46:8: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -43 43 | pass -44 44 | -45 45 | if True: -46 |- if sys.version_info < (3,0): -47 |- pass - 46 |+ pass -48 47 | -49 48 | if sys.version_info < (3,0): -50 49 | pass UP036_2.py:49:4: UP036 [*] Version block is outdated for minimum Python version | @@ -241,17 +128,6 @@ UP036_2.py:49:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -46 46 | if sys.version_info < (3,0): -47 47 | pass -48 48 | -49 |-if sys.version_info < (3,0): -50 |- pass -51 |-elif False: - 49 |+if False: -52 50 | pass -53 51 | -54 52 | if sys.version_info > (3,): UP036_2.py:54:4: UP036 [*] Version block is outdated for minimum Python version | @@ -263,18 +139,3 @@ UP036_2.py:54:4: UP036 [*] Version block is outdated for minimum Python version 56 | elif False: | = help: Remove outdated version block - -ℹ Unsafe fix -51 51 | elif False: -52 52 | pass -53 53 | -54 |-if sys.version_info > (3,): -55 |- pass -56 |-elif False: -57 |- pass - 54 |+pass -58 55 | -59 56 | if sys.version_info[0] > "2": -60 57 | 3 - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_3.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_3.py.snap index d22d368074431..36c552c7bb4e3 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_3.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_3.py.snap @@ -12,23 +12,6 @@ UP036_3.py:3:15: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -1 1 | import sys -2 2 | -3 |-if sys.version_info < (3,0): -4 |- print("py2") -5 |- for item in range(10): -6 |- print(f"PY2-{item}") -7 |-else : -8 |- print("py3") -9 |- for item in range(10): -10 |- print(f"PY3-{item}") - 3 |+print("py3") - 4 |+for item in range(10): - 5 |+ print(f"PY3-{item}") -11 6 | -12 7 | if False: -13 8 | if sys.version_info < (3,0): UP036_3.py:13:19: UP036 [*] Version block is outdated for minimum Python version | @@ -40,24 +23,6 @@ UP036_3.py:13:19: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -10 10 | print(f"PY3-{item}") -11 11 | -12 12 | if False: -13 |- if sys.version_info < (3,0): -14 |- print("py2") -15 |- for item in range(10): -16 |- print(f"PY2-{item}") -17 |- else : -18 |- print("py3") -19 |- for item in range(10): -20 |- print(f"PY3-{item}") - 13 |+ print("py3") - 14 |+ for item in range(10): - 15 |+ print(f"PY3-{item}") -21 16 | -22 17 | -23 18 | if sys.version_info < (3,0): print("PY2!") UP036_3.py:23:15: UP036 [*] Version block is outdated for minimum Python version | @@ -66,13 +31,3 @@ UP036_3.py:23:15: UP036 [*] Version block is outdated for minimum Python version 24 | else : print("PY3!") | = help: Remove outdated version block - -ℹ Unsafe fix -20 20 | print(f"PY3-{item}") -21 21 | -22 22 | -23 |-if sys.version_info < (3,0): print("PY2!") -24 |-else : print("PY3!") - 23 |+print("PY3!") - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_4.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_4.py.snap index db21eecad496d..c8a1cd3d0e382 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_4.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_4.py.snap @@ -10,16 +10,6 @@ UP036_4.py:4:8: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -1 1 | import sys -2 2 | -3 3 | if True: -4 |- if sys.version_info < (3, 3): -5 |- cmd = [sys.executable, "-m", "test.regrtest"] - 4 |+ pass -6 5 | -7 6 | -8 7 | if True: UP036_4.py:11:10: UP036 [*] Version block is outdated for minimum Python version | @@ -31,16 +21,6 @@ UP036_4.py:11:10: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -8 8 | if True: -9 9 | if foo: -10 10 | print() -11 |- elif sys.version_info < (3, 3): -12 |- cmd = [sys.executable, "-m", "test.regrtest"] - 11 |+ -13 12 | -14 13 | if True: -15 14 | if foo: UP036_4.py:17:10: UP036 [*] Version block is outdated for minimum Python version | @@ -53,15 +33,6 @@ UP036_4.py:17:10: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -14 14 | if True: -15 15 | if foo: -16 16 | print() -17 |- elif sys.version_info < (3, 3): -18 |- cmd = [sys.executable, "-m", "test.regrtest"] -19 17 | elif foo: -20 18 | cmd = [sys.executable, "-m", "test", "-j0"] -21 19 | UP036_4.py:24:10: UP036 [*] Version block is outdated for minimum Python version | @@ -73,16 +44,6 @@ UP036_4.py:24:10: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -21 21 | -22 22 | if foo: -23 23 | print() -24 |- elif sys.version_info < (3, 3): -25 |- cmd = [sys.executable, "-m", "test.regrtest"] - 24 |+ -26 25 | -27 26 | if sys.version_info < (3, 3): -28 27 | cmd = [sys.executable, "-m", "test.regrtest"] UP036_4.py:27:8: UP036 [*] Version block is outdated for minimum Python version | @@ -94,15 +55,6 @@ UP036_4.py:27:8: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -24 24 | elif sys.version_info < (3, 3): -25 25 | cmd = [sys.executable, "-m", "test.regrtest"] -26 26 | -27 |- if sys.version_info < (3, 3): -28 |- cmd = [sys.executable, "-m", "test.regrtest"] -29 27 | -30 28 | if foo: -31 29 | print() UP036_4.py:32:10: UP036 [*] Version block is outdated for minimum Python version | @@ -115,15 +67,6 @@ UP036_4.py:32:10: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -29 29 | -30 30 | if foo: -31 31 | print() -32 |- elif sys.version_info < (3, 3): -33 |- cmd = [sys.executable, "-m", "test.regrtest"] -34 32 | else: -35 33 | cmd = [sys.executable, "-m", "test", "-j0"] -36 34 | UP036_4.py:37:8: UP036 [*] Version block is outdated for minimum Python version | @@ -136,18 +79,6 @@ UP036_4.py:37:8: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -34 34 | else: -35 35 | cmd = [sys.executable, "-m", "test", "-j0"] -36 36 | -37 |- if sys.version_info < (3, 3): -38 |- cmd = [sys.executable, "-m", "test.regrtest"] -39 |- else: -40 |- cmd = [sys.executable, "-m", "test", "-j0"] - 37 |+ cmd = [sys.executable, "-m", "test", "-j0"] -41 38 | -42 39 | if sys.version_info < (3, 3): -43 40 | cmd = [sys.executable, "-m", "test.regrtest"] UP036_4.py:42:8: UP036 [*] Version block is outdated for minimum Python version | @@ -159,15 +90,3 @@ UP036_4.py:42:8: UP036 [*] Version block is outdated for minimum Python version 44 | elif foo: | = help: Remove outdated version block - -ℹ Unsafe fix -39 39 | else: -40 40 | cmd = [sys.executable, "-m", "test", "-j0"] -41 41 | -42 |- if sys.version_info < (3, 3): -43 |- cmd = [sys.executable, "-m", "test.regrtest"] -44 |- elif foo: - 42 |+ if foo: -45 43 | cmd = [sys.executable, "-m", "test", "-j0"] - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_5.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_5.py.snap index 5a121f09e4d72..4984039ff4b03 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_5.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_5.py.snap @@ -12,24 +12,6 @@ UP036_5.py:3:4: UP036 [*] Version block is outdated for minimum Python version | = help: Remove outdated version block -ℹ Unsafe fix -1 1 | import sys -2 2 | -3 |-if sys.version_info < (3, 8): -4 |- -5 |- def a(): -6 |- if b: -7 |- print(1) -8 |- elif c: -9 |- print(2) -10 |- return None -11 |- -12 |-else: -13 |- pass - 3 |+pass -14 4 | -15 5 | -16 6 | import sys UP036_5.py:18:4: UP036 [*] Version block is outdated for minimum Python version | @@ -40,31 +22,3 @@ UP036_5.py:18:4: UP036 [*] Version block is outdated for minimum Python version 19 | pass | = help: Remove outdated version block - -ℹ Unsafe fix -15 15 | -16 16 | import sys -17 17 | -18 |-if sys.version_info < (3, 8): -19 |- pass -20 |- -21 |-else: -22 |- -23 |- def a(): -24 |- if b: -25 |- print(1) -26 |- elif c: -27 |- print(2) -28 |- else: -29 |- print(3) -30 |- return None - 18 |+def a(): - 19 |+ if b: - 20 |+ print(1) - 21 |+ elif c: - 22 |+ print(2) - 23 |+ else: - 24 |+ print(3) - 25 |+ return None - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP037_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP037_0.py.snap index 4b4eb9e71624c..de7b43a211548 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP037_0.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP037_0.py.snap @@ -9,7 +9,6 @@ UP037_0.py:18:14: UP037 [*] Remove quotes from type annotation | = help: Remove quotes -ℹ Safe fix 15 15 | from mypy_extensions import Arg, DefaultArg, DefaultNamedArg, NamedArg, VarArg 16 16 | 17 17 | @@ -27,7 +26,6 @@ UP037_0.py:18:28: UP037 [*] Remove quotes from type annotation | = help: Remove quotes -ℹ Safe fix 15 15 | from mypy_extensions import Arg, DefaultArg, DefaultNamedArg, NamedArg, VarArg 16 16 | 17 17 | @@ -45,7 +43,6 @@ UP037_0.py:19:8: UP037 [*] Remove quotes from type annotation | = help: Remove quotes -ℹ Safe fix 16 16 | 17 17 | 18 18 | def foo(var: "MyClass") -> "MyClass": @@ -63,7 +60,6 @@ UP037_0.py:22:21: UP037 [*] Remove quotes from type annotation | = help: Remove quotes -ℹ Safe fix 19 19 | x: "MyClass" 20 20 | 21 21 | @@ -81,7 +77,6 @@ UP037_0.py:26:16: UP037 [*] Remove quotes from type annotation | = help: Remove quotes -ℹ Safe fix 23 23 | pass 24 24 | 25 25 | @@ -99,7 +94,6 @@ UP037_0.py:26:33: UP037 [*] Remove quotes from type annotation | = help: Remove quotes -ℹ Safe fix 23 23 | pass 24 24 | 25 25 | @@ -118,7 +112,6 @@ UP037_0.py:30:10: UP037 [*] Remove quotes from type annotation | = help: Remove quotes -ℹ Safe fix 27 27 | pass 28 28 | 29 29 | @@ -137,7 +130,6 @@ UP037_0.py:32:14: UP037 [*] Remove quotes from type annotation | = help: Remove quotes -ℹ Safe fix 29 29 | 30 30 | x: Tuple["MyClass"] 31 31 | @@ -155,7 +147,6 @@ UP037_0.py:36:8: UP037 [*] Remove quotes from type annotation | = help: Remove quotes -ℹ Safe fix 33 33 | 34 34 | 35 35 | class Foo(NamedTuple): @@ -173,7 +164,6 @@ UP037_0.py:40:27: UP037 [*] Remove quotes from type annotation | = help: Remove quotes -ℹ Safe fix 37 37 | 38 38 | 39 39 | class D(TypedDict): @@ -191,7 +181,6 @@ UP037_0.py:44:31: UP037 [*] Remove quotes from type annotation | = help: Remove quotes -ℹ Safe fix 41 41 | 42 42 | 43 43 | class D(TypedDict): @@ -210,7 +199,6 @@ UP037_0.py:47:14: UP037 [*] Remove quotes from type annotation | = help: Remove quotes -ℹ Safe fix 44 44 | E: TypedDict("E", {"foo": "int"}) 45 45 | 46 46 | @@ -231,7 +219,6 @@ UP037_0.py:49:8: UP037 [*] Remove quotes from type annotation | = help: Remove quotes -ℹ Safe fix 46 46 | 47 47 | x: Annotated["str", "metadata"] 48 48 | @@ -252,7 +239,6 @@ UP037_0.py:51:15: UP037 [*] Remove quotes from type annotation | = help: Remove quotes -ℹ Safe fix 48 48 | 49 49 | x: Arg("str", "name") 50 50 | @@ -273,7 +259,6 @@ UP037_0.py:53:13: UP037 [*] Remove quotes from type annotation | = help: Remove quotes -ℹ Safe fix 50 50 | 51 51 | x: DefaultArg("str", "name") 52 52 | @@ -294,7 +279,6 @@ UP037_0.py:55:20: UP037 [*] Remove quotes from type annotation | = help: Remove quotes -ℹ Safe fix 52 52 | 53 53 | x: NamedArg("str", "name") 54 54 | @@ -315,7 +299,6 @@ UP037_0.py:57:20: UP037 [*] Remove quotes from type annotation | = help: Remove quotes -ℹ Safe fix 54 54 | 55 55 | x: DefaultNamedArg("str", "name") 56 56 | @@ -336,7 +319,6 @@ UP037_0.py:59:11: UP037 [*] Remove quotes from type annotation | = help: Remove quotes -ℹ Safe fix 56 56 | 57 57 | x: DefaultNamedArg("str", name="name") 58 58 | @@ -357,7 +339,6 @@ UP037_0.py:61:19: UP037 [*] Remove quotes from type annotation | = help: Remove quotes -ℹ Safe fix 58 58 | 59 59 | x: VarArg("str") 60 60 | @@ -378,7 +359,6 @@ UP037_0.py:63:29: UP037 [*] Remove quotes from type annotation | = help: Remove quotes -ℹ Safe fix 60 60 | 61 61 | x: List[List[List["MyClass"]]] 62 62 | @@ -399,7 +379,6 @@ UP037_0.py:63:45: UP037 [*] Remove quotes from type annotation | = help: Remove quotes -ℹ Safe fix 60 60 | 61 61 | x: List[List[List["MyClass"]]] 62 62 | @@ -420,7 +399,6 @@ UP037_0.py:65:29: UP037 [*] Remove quotes from type annotation | = help: Remove quotes -ℹ Safe fix 62 62 | 63 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) 64 64 | @@ -441,7 +419,6 @@ UP037_0.py:65:36: UP037 [*] Remove quotes from type annotation | = help: Remove quotes -ℹ Safe fix 62 62 | 63 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) 64 64 | @@ -462,7 +439,6 @@ UP037_0.py:65:45: UP037 [*] Remove quotes from type annotation | = help: Remove quotes -ℹ Safe fix 62 62 | 63 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) 64 64 | @@ -483,7 +459,6 @@ UP037_0.py:65:52: UP037 [*] Remove quotes from type annotation | = help: Remove quotes -ℹ Safe fix 62 62 | 63 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) 64 64 | @@ -504,7 +479,6 @@ UP037_0.py:67:24: UP037 [*] Remove quotes from type annotation | = help: Remove quotes -ℹ Safe fix 64 64 | 65 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) 66 66 | @@ -525,7 +499,6 @@ UP037_0.py:67:38: UP037 [*] Remove quotes from type annotation | = help: Remove quotes -ℹ Safe fix 64 64 | 65 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) 66 66 | @@ -546,7 +519,6 @@ UP037_0.py:67:45: UP037 [*] Remove quotes from type annotation | = help: Remove quotes -ℹ Safe fix 64 64 | 65 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) 66 66 | diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP037_1.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP037_1.py.snap index 57379b20edbb2..af2dce3eeebdc 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP037_1.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP037_1.py.snap @@ -11,7 +11,6 @@ UP037_1.py:9:8: UP037 [*] Remove quotes from type annotation | = help: Remove quotes -ℹ Safe fix 6 6 | 7 7 | def foo(): 8 8 | # UP037 diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP038.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP038.py.snap index 7a5117ab07aad..a3b71f9c0c964 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP038.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP038.py.snap @@ -9,12 +9,6 @@ UP038.py:1:1: UP038 [*] Use `X | Y` in `isinstance` call instead of `(X, Y)` | = help: Convert to `X | Y` -ℹ Unsafe fix -1 |-isinstance(1, (int, float)) # UP038 - 1 |+isinstance(1, int | float) # UP038 -2 2 | issubclass("yes", (int, float, str)) # UP038 -3 3 | -4 4 | isinstance(1, int) # OK UP038.py:2:1: UP038 [*] Use `X | Y` in `issubclass` call instead of `(X, Y)` | @@ -25,13 +19,3 @@ UP038.py:2:1: UP038 [*] Use `X | Y` in `issubclass` call instead of `(X, Y)` 4 | isinstance(1, int) # OK | = help: Convert to `X | Y` - -ℹ Unsafe fix -1 1 | isinstance(1, (int, float)) # UP038 -2 |-issubclass("yes", (int, float, str)) # UP038 - 2 |+issubclass("yes", int | float | str) # UP038 -3 3 | -4 4 | isinstance(1, int) # OK -5 5 | issubclass("yes", int) # OK - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP039.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP039.py.snap index ff6299b6e9079..860029d4810fe 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP039.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP039.py.snap @@ -10,7 +10,6 @@ UP039.py:2:8: UP039 [*] Unnecessary parentheses after class definition | = help: Remove parentheses -ℹ Safe fix 1 1 | # Errors 2 |-class A(): 2 |+class A: @@ -27,7 +26,6 @@ UP039.py:6:8: UP039 [*] Unnecessary parentheses after class definition | = help: Remove parentheses -ℹ Safe fix 3 3 | pass 4 4 | 5 5 | @@ -46,7 +44,6 @@ UP039.py:12:9: UP039 [*] Unnecessary parentheses after class definition | = help: Remove parentheses -ℹ Safe fix 9 9 | 10 10 | 11 11 | class A \ @@ -65,7 +62,6 @@ UP039.py:17:8: UP039 [*] Unnecessary parentheses after class definition | = help: Remove parentheses -ℹ Safe fix 14 14 | 15 15 | 16 16 | @decorator() @@ -84,7 +80,6 @@ UP039.py:21:8: UP039 [*] Unnecessary parentheses after class definition | = help: Remove parentheses -ℹ Safe fix 18 18 | pass 19 19 | 20 20 | @decorator @@ -93,5 +88,3 @@ UP039.py:21:8: UP039 [*] Unnecessary parentheses after class definition 22 22 | pass 23 23 | 24 24 | # OK - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP040.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP040.py.snap index 03c7ea34d3bb6..3d9295c900973 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP040.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP040.py.snap @@ -10,15 +10,6 @@ UP040.py:5:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of th | = help: Use the `type` keyword -ℹ Unsafe fix -2 2 | from typing import TypeAlias -3 3 | -4 4 | # UP040 -5 |-x: typing.TypeAlias = int - 5 |+type x = int -6 6 | x: TypeAlias = int -7 7 | -8 8 | # UP040 simple generic UP040.py:6:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword | @@ -31,15 +22,6 @@ UP040.py:6:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of th | = help: Use the `type` keyword -ℹ Unsafe fix -3 3 | -4 4 | # UP040 -5 5 | x: typing.TypeAlias = int -6 |-x: TypeAlias = int - 6 |+type x = int -7 7 | -8 8 | # UP040 simple generic -9 9 | T = typing.TypeVar["T"] UP040.py:10:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword | @@ -52,15 +34,6 @@ UP040.py:10:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of t | = help: Use the `type` keyword -ℹ Unsafe fix -7 7 | -8 8 | # UP040 simple generic -9 9 | T = typing.TypeVar["T"] -10 |-x: typing.TypeAlias = list[T] - 10 |+type x[T] = list[T] -11 11 | -12 12 | # UP040 call style generic -13 13 | T = typing.TypeVar("T") UP040.py:14:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword | @@ -73,15 +46,6 @@ UP040.py:14:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of t | = help: Use the `type` keyword -ℹ Unsafe fix -11 11 | -12 12 | # UP040 call style generic -13 13 | T = typing.TypeVar("T") -14 |-x: typing.TypeAlias = list[T] - 14 |+type x[T] = list[T] -15 15 | -16 16 | # UP040 bounded generic -17 17 | T = typing.TypeVar("T", bound=int) UP040.py:18:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword | @@ -94,15 +58,6 @@ UP040.py:18:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of t | = help: Use the `type` keyword -ℹ Unsafe fix -15 15 | -16 16 | # UP040 bounded generic -17 17 | T = typing.TypeVar("T", bound=int) -18 |-x: typing.TypeAlias = list[T] - 18 |+type x[T: int] = list[T] -19 19 | -20 20 | # UP040 constrained generic -21 21 | T = typing.TypeVar("T", int, str) UP040.py:22:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword | @@ -115,15 +70,6 @@ UP040.py:22:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of t | = help: Use the `type` keyword -ℹ Unsafe fix -19 19 | -20 20 | # UP040 constrained generic -21 21 | T = typing.TypeVar("T", int, str) -22 |-x: typing.TypeAlias = list[T] - 22 |+type x[T: (int, str)] = list[T] -23 23 | -24 24 | # UP040 contravariant generic -25 25 | T = typing.TypeVar("T", contravariant=True) UP040.py:26:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword | @@ -136,15 +82,6 @@ UP040.py:26:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of t | = help: Use the `type` keyword -ℹ Unsafe fix -23 23 | -24 24 | # UP040 contravariant generic -25 25 | T = typing.TypeVar("T", contravariant=True) -26 |-x: typing.TypeAlias = list[T] - 26 |+type x[T] = list[T] -27 27 | -28 28 | # UP040 covariant generic -29 29 | T = typing.TypeVar("T", covariant=True) UP040.py:30:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword | @@ -157,15 +94,6 @@ UP040.py:30:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of t | = help: Use the `type` keyword -ℹ Unsafe fix -27 27 | -28 28 | # UP040 covariant generic -29 29 | T = typing.TypeVar("T", covariant=True) -30 |-x: typing.TypeAlias = list[T] - 30 |+type x[T] = list[T] -31 31 | -32 32 | # UP040 in class scope -33 33 | T = typing.TypeVar["T"] UP040.py:36:5: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword | @@ -178,15 +106,6 @@ UP040.py:36:5: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of t | = help: Use the `type` keyword -ℹ Unsafe fix -33 33 | T = typing.TypeVar["T"] -34 34 | class Foo: -35 35 | # reference to global variable -36 |- x: typing.TypeAlias = list[T] - 36 |+ type x[T] = list[T] -37 37 | -38 38 | # reference to class variable -39 39 | TCLS = typing.TypeVar["TCLS"] UP040.py:40:5: UP040 [*] Type alias `y` uses `TypeAlias` annotation instead of the `type` keyword | @@ -199,15 +118,6 @@ UP040.py:40:5: UP040 [*] Type alias `y` uses `TypeAlias` annotation instead of t | = help: Use the `type` keyword -ℹ Unsafe fix -37 37 | -38 38 | # reference to class variable -39 39 | TCLS = typing.TypeVar["TCLS"] -40 |- y: typing.TypeAlias = list[TCLS] - 40 |+ type y[TCLS] = list[TCLS] -41 41 | -42 42 | # UP040 won't add generics in fix -43 43 | T = typing.TypeVar(*args) UP040.py:44:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword | @@ -220,15 +130,6 @@ UP040.py:44:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of t | = help: Use the `type` keyword -ℹ Unsafe fix -41 41 | -42 42 | # UP040 won't add generics in fix -43 43 | T = typing.TypeVar(*args) -44 |-x: typing.TypeAlias = list[T] - 44 |+type x = list[T] -45 45 | -46 46 | # OK -47 47 | x: TypeAlias UP040.py:53:1: UP040 [*] Type alias `Decorator` uses `TypeAlias` annotation instead of the `type` keyword | @@ -239,15 +140,6 @@ UP040.py:53:1: UP040 [*] Type alias `Decorator` uses `TypeAlias` annotation inst | = help: Use the `type` keyword -ℹ Unsafe fix -50 50 | # Ensure that "T" appears only once in the type parameters for the modernized -51 51 | # type alias. -52 52 | T = typing.TypeVar["T"] -53 |-Decorator: TypeAlias = typing.Callable[[T], T] - 53 |+type Decorator[T] = typing.Callable[[T], T] -54 54 | -55 55 | -56 56 | from typing import TypeVar, Annotated, TypeAliasType UP040.py:63:1: UP040 [*] Type alias `PositiveList` uses `TypeAliasType` assignment instead of the `type` keyword | @@ -262,7 +154,6 @@ UP040.py:63:1: UP040 [*] Type alias `PositiveList` uses `TypeAliasType` assignme | = help: Use the `type` keyword -ℹ Safe fix 60 60 | 61 61 | # https://github.com/astral-sh/ruff/issues/11422 62 62 | T = TypeVar("T") @@ -287,7 +178,6 @@ UP040.py:69:1: UP040 [*] Type alias `PositiveList` uses `TypeAliasType` assignme | = help: Use the `type` keyword -ℹ Safe fix 66 66 | 67 67 | # Bound 68 68 | T = TypeVar("T", bound=SupportGt) @@ -310,7 +200,6 @@ UP040.py:77:1: UP040 [*] Type alias `Tuple3` uses `TypeAliasType` assignment ins | = help: Use the `type` keyword -ℹ Safe fix 74 74 | T1 = TypeVar("T1", bound=SupportGt) 75 75 | T2 = TypeVar("T2") 76 76 | T3 = TypeVar("T3") @@ -329,7 +218,6 @@ UP040.py:80:1: UP040 [*] Type alias `PositiveInt` uses `TypeAliasType` assignmen | = help: Use the `type` keyword -ℹ Safe fix 77 77 | Tuple3 = TypeAliasType("Tuple3", tuple[T1, T2, T3], type_params=(T1, T2, T3)) 78 78 | 79 79 | # No type_params @@ -350,7 +238,6 @@ UP040.py:81:1: UP040 [*] Type alias `PositiveInt` uses `TypeAliasType` assignmen | = help: Use the `type` keyword -ℹ Safe fix 78 78 | 79 79 | # No type_params 80 80 | PositiveInt = TypeAliasType("PositiveInt", Annotated[int, Gt(0)]) diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP040.pyi.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP040.pyi.snap index 9615265f86bc3..c221dbe21cf7b 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP040.pyi.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP040.pyi.snap @@ -11,7 +11,6 @@ UP040.pyi:6:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of t | = help: Use the `type` keyword -ℹ Safe fix 3 3 | 4 4 | # UP040 5 5 | # Fixes in type stub files should be safe to apply unlike in regular code where runtime behavior could change @@ -28,11 +27,8 @@ UP040.pyi:7:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of t | = help: Use the `type` keyword -ℹ Safe fix 4 4 | # UP040 5 5 | # Fixes in type stub files should be safe to apply unlike in regular code where runtime behavior could change 6 6 | x: typing.TypeAlias = int 7 |-x: TypeAlias = int 7 |+type x = int - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP041.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP041.py.snap index 68f66dc6de38f..43b04a62156e2 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP041.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP041.py.snap @@ -11,7 +11,6 @@ UP041.py:5:8: UP041 [*] Replace aliased errors with `TimeoutError` | = help: Replace `asyncio.TimeoutError` with builtin `TimeoutError` -ℹ Safe fix 2 2 | # These should be fixed 3 3 | try: 4 4 | pass @@ -31,7 +30,6 @@ UP041.py:10:8: UP041 [*] Replace aliased errors with `TimeoutError` | = help: Replace `socket.timeout` with builtin `TimeoutError` -ℹ Safe fix 7 7 | 8 8 | try: 9 9 | pass @@ -51,7 +49,6 @@ UP041.py:17:8: UP041 [*] Replace aliased errors with `TimeoutError` | = help: Replace with builtin `TimeoutError` -ℹ Safe fix 14 14 | 15 15 | try: 16 16 | pass @@ -71,7 +68,6 @@ UP041.py:22:8: UP041 [*] Replace aliased errors with `TimeoutError` | = help: Replace with builtin `TimeoutError` -ℹ Safe fix 19 19 | 20 20 | try: 21 21 | pass @@ -91,7 +87,6 @@ UP041.py:27:8: UP041 [*] Replace aliased errors with `TimeoutError` | = help: Replace with builtin `TimeoutError` -ℹ Safe fix 24 24 | 25 25 | try: 26 26 | pass @@ -111,7 +106,6 @@ UP041.py:34:8: UP041 [*] Replace aliased errors with `TimeoutError` | = help: Replace with builtin `TimeoutError` -ℹ Safe fix 31 31 | 32 32 | try: 33 33 | pass @@ -131,7 +125,6 @@ UP041.py:42:8: UP041 [*] Replace aliased errors with `TimeoutError` | = help: Replace with builtin `TimeoutError` -ℹ Safe fix 39 39 | from .mmap import error 40 40 | try: 41 41 | pass @@ -140,5 +133,3 @@ UP041.py:42:8: UP041 [*] Replace aliased errors with `TimeoutError` 43 43 | pass 44 44 | 45 45 | # These should not change - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP042.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP042.py.snap index e7bff6e26969f..2bfb127870527 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP042.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP042.py.snap @@ -8,16 +8,6 @@ UP042.py:4:7: UP042 [*] Class A inherits from both `str` and `enum.Enum` | = help: Inherit from `enum.StrEnum` -ℹ Unsafe fix -1 |-from enum import Enum - 1 |+from enum import Enum, StrEnum -2 2 | -3 3 | -4 |-class A(str, Enum): ... - 4 |+class A(StrEnum): ... -5 5 | -6 6 | -7 7 | class B(Enum, str): ... UP042.py:7:7: UP042 [*] Class B inherits from both `str` and `enum.Enum` | @@ -26,19 +16,6 @@ UP042.py:7:7: UP042 [*] Class B inherits from both `str` and `enum.Enum` | = help: Inherit from `enum.StrEnum` -ℹ Unsafe fix -1 |-from enum import Enum - 1 |+from enum import Enum, StrEnum -2 2 | -3 3 | -4 4 | class A(str, Enum): ... -5 5 | -6 6 | -7 |-class B(Enum, str): ... - 7 |+class B(StrEnum): ... -8 8 | -9 9 | -10 10 | class D(int, str, Enum): ... UP042.py:10:7: UP042 Class D inherits from both `str` and `enum.Enum` | diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP043.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP043.py.snap index 4198822ad3363..00a25cf0f2f40 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP043.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP043.py.snap @@ -9,7 +9,6 @@ UP043.py:4:15: UP043 [*] Unnecessary default type arguments | = help: Remove default type arguments -ℹ Safe fix 1 1 | from typing import Generator, AsyncGenerator 2 2 | 3 3 | @@ -27,7 +26,6 @@ UP043.py:8:15: UP043 [*] Unnecessary default type arguments | = help: Remove default type arguments -ℹ Safe fix 5 5 | yield 42 6 6 | 7 7 | @@ -46,7 +44,6 @@ UP043.py:21:15: UP043 [*] Unnecessary default type arguments | = help: Remove default type arguments -ℹ Safe fix 18 18 | return foo 19 19 | 20 20 | @@ -64,7 +61,6 @@ UP043.py:31:21: UP043 [*] Unnecessary default type arguments | = help: Remove default type arguments -ℹ Safe fix 28 28 | return 42 29 29 | 30 30 | diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__async_timeout_error_alias_not_applied_py310.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__async_timeout_error_alias_not_applied_py310.snap index 3197391b53919..e432e6796d2ac 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__async_timeout_error_alias_not_applied_py310.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__async_timeout_error_alias_not_applied_py310.snap @@ -11,7 +11,6 @@ UP041.py:10:8: UP041 [*] Replace aliased errors with `TimeoutError` | = help: Replace `socket.timeout` with builtin `TimeoutError` -ℹ Safe fix 7 7 | 8 8 | try: 9 9 | pass @@ -31,7 +30,6 @@ UP041.py:22:8: UP041 [*] Replace aliased errors with `TimeoutError` | = help: Replace with builtin `TimeoutError` -ℹ Safe fix 19 19 | 20 20 | try: 21 21 | pass @@ -51,7 +49,6 @@ UP041.py:27:8: UP041 [*] Replace aliased errors with `TimeoutError` | = help: Replace with builtin `TimeoutError` -ℹ Safe fix 24 24 | 25 25 | try: 26 26 | pass @@ -71,7 +68,6 @@ UP041.py:34:8: UP041 [*] Replace aliased errors with `TimeoutError` | = help: Replace with builtin `TimeoutError` -ℹ Safe fix 31 31 | 32 32 | try: 33 33 | pass @@ -80,5 +76,3 @@ UP041.py:34:8: UP041 [*] Replace aliased errors with `TimeoutError` 35 35 | pass 36 36 | 37 37 | # First should change, second should not - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__datetime_utc_alias_py311.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__datetime_utc_alias_py311.snap index 9cea3d7563066..a1e5a6d244174 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__datetime_utc_alias_py311.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__datetime_utc_alias_py311.snap @@ -10,7 +10,6 @@ UP017.py:10:11: UP017 [*] Use `datetime.UTC` alias | = help: Convert to `datetime.UTC` alias -ℹ Safe fix 1 |+from datetime import UTC 1 2 | def func(): 2 3 | import datetime @@ -34,7 +33,6 @@ UP017.py:16:11: UP017 [*] Use `datetime.UTC` alias | = help: Convert to `datetime.UTC` alias -ℹ Safe fix 1 |+from datetime import UTC 1 2 | def func(): 2 3 | import datetime @@ -58,7 +56,6 @@ UP017.py:22:11: UP017 [*] Use `datetime.UTC` alias | = help: Convert to `datetime.UTC` alias -ℹ Safe fix 19 19 | def func(): 20 20 | import datetime 21 21 | @@ -77,7 +74,6 @@ UP017.py:28:11: UP017 [*] Use `datetime.UTC` alias | = help: Convert to `datetime.UTC` alias -ℹ Safe fix 25 25 | def func(): 26 26 | import datetime as dt 27 27 | diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_keep_runtime_typing_p310.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_keep_runtime_typing_p310.snap index dc9d6c6a7f0f3..6c8d12578468a 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_keep_runtime_typing_p310.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_keep_runtime_typing_p310.snap @@ -10,7 +10,6 @@ future_annotations.py:34:18: UP006 [*] Use `list` instead of `List` for type ann | = help: Replace with `list` -ℹ Safe fix 31 31 | return cls(x=0, y=0) 32 32 | 33 33 | @@ -30,7 +29,6 @@ future_annotations.py:35:9: UP006 [*] Use `list` instead of `List` for type anno | = help: Replace with `list` -ℹ Safe fix 32 32 | 33 33 | 34 34 | def f(x: int) -> List[int]: @@ -49,7 +47,6 @@ future_annotations.py:42:27: UP006 [*] Use `list` instead of `List` for type ann | = help: Replace with `list` -ℹ Safe fix 39 39 | 40 40 | x: Optional[int] = None 41 41 | @@ -65,11 +62,8 @@ future_annotations.py:42:38: UP006 [*] Use `list` instead of `List` for type ann | = help: Replace with `list` -ℹ Safe fix 39 39 | 40 40 | x: Optional[int] = None 41 41 | 42 |-MyList: TypeAlias = Union[List[int], List[str]] 42 |+MyList: TypeAlias = Union[List[int], list[str]] - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_585_p37.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_585_p37.snap index 71eba348b3fa9..524ea9e72b94d 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_585_p37.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_585_p37.snap @@ -9,15 +9,3 @@ future_annotations.py:34:18: UP006 [*] Use `list` instead of `List` for type ann 36 | y.append(x) | = help: Replace with `list` - -ℹ Unsafe fix -31 31 | return cls(x=0, y=0) -32 32 | -33 33 | -34 |-def f(x: int) -> List[int]: - 34 |+def f(x: int) -> list[int]: -35 35 | y = List[int]() -36 36 | y.append(x) -37 37 | return y - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_585_py310.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_585_py310.snap index dc9d6c6a7f0f3..6c8d12578468a 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_585_py310.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_585_py310.snap @@ -10,7 +10,6 @@ future_annotations.py:34:18: UP006 [*] Use `list` instead of `List` for type ann | = help: Replace with `list` -ℹ Safe fix 31 31 | return cls(x=0, y=0) 32 32 | 33 33 | @@ -30,7 +29,6 @@ future_annotations.py:35:9: UP006 [*] Use `list` instead of `List` for type anno | = help: Replace with `list` -ℹ Safe fix 32 32 | 33 33 | 34 34 | def f(x: int) -> List[int]: @@ -49,7 +47,6 @@ future_annotations.py:42:27: UP006 [*] Use `list` instead of `List` for type ann | = help: Replace with `list` -ℹ Safe fix 39 39 | 40 40 | x: Optional[int] = None 41 41 | @@ -65,11 +62,8 @@ future_annotations.py:42:38: UP006 [*] Use `list` instead of `List` for type ann | = help: Replace with `list` -ℹ Safe fix 39 39 | 40 40 | x: Optional[int] = None 41 41 | 42 |-MyList: TypeAlias = Union[List[int], List[str]] 42 |+MyList: TypeAlias = Union[List[int], list[str]] - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_604_p37.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_604_p37.snap index 442d20f7a5476..3848dedf3514e 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_604_p37.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_604_p37.snap @@ -9,14 +9,3 @@ future_annotations.py:40:4: UP007 [*] Use `X | Y` for type annotations 42 | MyList: TypeAlias = Union[List[int], List[str]] | = help: Convert to `X | Y` - -ℹ Unsafe fix -37 37 | return y -38 38 | -39 39 | -40 |-x: Optional[int] = None - 40 |+x: int | None = None -41 41 | -42 42 | MyList: TypeAlias = Union[List[int], List[str]] - - diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_604_py310.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_604_py310.snap index 386e009dfa9cb..dbf4b01dfebc7 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_604_py310.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_604_py310.snap @@ -10,7 +10,6 @@ future_annotations.py:40:4: UP007 [*] Use `X | Y` for type annotations | = help: Convert to `X | Y` -ℹ Safe fix 37 37 | return y 38 38 | 39 39 | @@ -28,11 +27,8 @@ future_annotations.py:42:21: UP007 [*] Use `X | Y` for type annotations | = help: Convert to `X | Y` -ℹ Safe fix 39 39 | 40 40 | x: Optional[int] = None 41 41 | 42 |-MyList: TypeAlias = Union[List[int], List[str]] 42 |+MyList: TypeAlias = List[int] | List[str] - - diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB105_FURB105.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB105_FURB105.py.snap index f37d6398a1119..a940a12deceee 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB105_FURB105.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB105_FURB105.py.snap @@ -12,7 +12,6 @@ FURB105.py:3:1: FURB105 [*] Unnecessary empty string passed to `print` | = help: Remove empty string -ℹ Safe fix 1 1 | # Errors. 2 2 | 3 |-print("") @@ -31,7 +30,6 @@ FURB105.py:4:1: FURB105 [*] Unnecessary empty string and separator passed to `pr | = help: Remove empty string and separator -ℹ Safe fix 1 1 | # Errors. 2 2 | 3 3 | print("") @@ -52,7 +50,6 @@ FURB105.py:5:1: FURB105 [*] Unnecessary empty string passed to `print` | = help: Remove empty string -ℹ Safe fix 2 2 | 3 3 | print("") 4 4 | print("", sep=",") @@ -73,7 +70,6 @@ FURB105.py:6:1: FURB105 [*] Unnecessary empty string and separator passed to `pr | = help: Remove empty string and separator -ℹ Safe fix 3 3 | print("") 4 4 | print("", sep=",") 5 5 | print("", end="bar") @@ -94,7 +90,6 @@ FURB105.py:7:1: FURB105 [*] Unnecessary separator passed to `print` | = help: Remove separator -ℹ Safe fix 4 4 | print("", sep=",") 5 5 | print("", end="bar") 6 6 | print("", sep=",", end="bar") @@ -115,7 +110,6 @@ FURB105.py:8:1: FURB105 [*] Unnecessary empty string and separator passed to `pr | = help: Remove empty string and separator -ℹ Safe fix 5 5 | print("", end="bar") 6 6 | print("", sep=",", end="bar") 7 7 | print(sep="") @@ -136,7 +130,6 @@ FURB105.py:9:1: FURB105 [*] Unnecessary empty string and separator passed to `pr | = help: Remove empty string and separator -ℹ Safe fix 6 6 | print("", sep=",", end="bar") 7 7 | print(sep="") 8 8 | print("", sep="") @@ -157,7 +150,6 @@ FURB105.py:10:1: FURB105 [*] Unnecessary empty string and separator passed to `p | = help: Remove empty string and separator -ℹ Safe fix 7 7 | print(sep="") 8 8 | print("", sep="") 9 9 | print("", "", sep="") @@ -178,7 +170,6 @@ FURB105.py:11:1: FURB105 [*] Unnecessary empty string and separator passed to `p | = help: Remove empty string and separator -ℹ Safe fix 8 8 | print("", sep="") 9 9 | print("", "", sep="") 10 10 | print("", "", sep="", end="") @@ -199,7 +190,6 @@ FURB105.py:12:1: FURB105 [*] Unnecessary empty string and separator passed to `p | = help: Remove empty string and separator -ℹ Safe fix 9 9 | print("", "", sep="") 10 10 | print("", "", sep="", end="") 11 11 | print("", "", sep="", end="bar") @@ -220,7 +210,6 @@ FURB105.py:13:1: FURB105 [*] Unnecessary separator passed to `print` | = help: Remove separator -ℹ Safe fix 10 10 | print("", "", sep="", end="") 11 11 | print("", "", sep="", end="bar") 12 12 | print("", sep="", end="bar") @@ -241,7 +230,6 @@ FURB105.py:14:1: FURB105 [*] Unnecessary empty string and separator passed to `p | = help: Remove empty string and separator -ℹ Safe fix 11 11 | print("", "", sep="", end="bar") 12 12 | print("", sep="", end="bar") 13 13 | print(sep="", end="bar") @@ -262,7 +250,6 @@ FURB105.py:15:1: FURB105 [*] Unnecessary empty string and separator passed to `p | = help: Remove empty string and separator -ℹ Safe fix 12 12 | print("", sep="", end="bar") 13 13 | print(sep="", end="bar") 14 14 | print("", "foo", sep="") @@ -283,7 +270,6 @@ FURB105.py:16:1: FURB105 [*] Unnecessary empty string passed to `print` | = help: Remove empty string -ℹ Safe fix 13 13 | print(sep="", end="bar") 14 14 | print("", "foo", sep="") 15 15 | print("foo", "", sep="") @@ -304,7 +290,6 @@ FURB105.py:18:1: FURB105 [*] Unnecessary empty string passed to `print` | = help: Remove empty string -ℹ Safe fix 15 15 | print("foo", "", sep="") 16 16 | print("foo", "", "bar", sep="") 17 17 | print("", *args) @@ -324,7 +309,6 @@ FURB105.py:19:1: FURB105 [*] Unnecessary empty string passed to `print` | = help: Remove empty string -ℹ Safe fix 16 16 | print("foo", "", "bar", sep="") 17 17 | print("", *args) 18 18 | print("", *args, sep="") @@ -345,7 +329,6 @@ FURB105.py:20:1: FURB105 [*] Unnecessary separator passed to `print` | = help: Remove separator -ℹ Safe fix 17 17 | print("", *args) 18 18 | print("", *args, sep="") 19 19 | print("", **kwargs) @@ -353,6 +336,4 @@ FURB105.py:20:1: FURB105 [*] Unnecessary separator passed to `print` 20 |+print() 21 21 | 22 22 | # OK. -23 23 | - - +23 23 | diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB110_FURB110.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB110_FURB110.py.snap index 29e977193e329..fe51dcbd1f487 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB110_FURB110.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB110_FURB110.py.snap @@ -10,7 +10,6 @@ FURB110.py:1:5: FURB110 [*] Replace ternary `if` expression with `or` operator | = help: Replace with `or` operator -ℹ Safe fix 1 |-z = x if x else y # FURB110 1 |+z = x or y # FURB110 2 2 | @@ -30,7 +29,6 @@ FURB110.py:3:5: FURB110 [*] Replace ternary `if` expression with `or` operator | = help: Replace with `or` operator -ℹ Safe fix 1 1 | z = x if x else y # FURB110 2 2 | 3 |-z = x \ @@ -54,7 +52,6 @@ FURB110.py:6:5: FURB110 [*] Replace ternary `if` expression with `or` operator | = help: Replace with `or` operator -ℹ Safe fix 3 3 | z = x \ 4 4 | if x else y # FURB110 5 5 | @@ -77,15 +74,6 @@ FURB110.py:10:5: FURB110 [*] Replace ternary `if` expression with `or` operator | = help: Replace with `or` operator -ℹ Unsafe fix -7 7 | else \ -8 8 | y # FURB110 -9 9 | -10 |-z = x() if x() else y() # FURB110 - 10 |+z = x() or y() # FURB110 -11 11 | -12 12 | # FURB110 -13 13 | z = x if ( FURB110.py:13:5: FURB110 [*] Replace ternary `if` expression with `or` operator | @@ -104,7 +92,6 @@ FURB110.py:13:5: FURB110 [*] Replace ternary `if` expression with `or` operator | = help: Replace with `or` operator -ℹ Safe fix 10 10 | z = x() if x() else y() # FURB110 11 11 | 12 12 | # FURB110 @@ -135,7 +122,6 @@ FURB110.py:23:5: FURB110 [*] Replace ternary `if` expression with `or` operator | = help: Replace with `or` operator -ℹ Safe fix 20 20 | 21 21 | # FURB110 22 22 | z = ( @@ -165,7 +151,6 @@ FURB110.py:34:5: FURB110 [*] Replace ternary `if` expression with `or` operator | = help: Replace with `or` operator -ℹ Safe fix 31 31 | 32 32 | # FURB110 33 33 | z = ( @@ -195,7 +180,6 @@ FURB110.py:44:5: FURB110 [*] Replace ternary `if` expression with `or` operator | = help: Replace with `or` operator -ℹ Safe fix 41 41 | 42 42 | # FURB110 43 43 | z = ( diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB113_FURB113.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB113_FURB113.py.snap index 07e89d33ac934..e70eaf1248914 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB113_FURB113.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB113_FURB113.py.snap @@ -11,16 +11,6 @@ FURB113.py:23:1: FURB113 [*] Use `nums.extend((1, 2))` instead of repeatedly cal | = help: Replace with `nums.extend((1, 2))` -ℹ Unsafe fix -20 20 | -21 21 | -22 22 | # FURB113 -23 |-nums.append(1) -24 |-nums.append(2) - 23 |+nums.extend((1, 2)) -25 24 | pass -26 25 | -27 26 | FURB113.py:29:1: FURB113 [*] Use `nums3.extend((1, 2))` instead of repeatedly calling `nums3.append()` | @@ -32,16 +22,6 @@ FURB113.py:29:1: FURB113 [*] Use `nums3.extend((1, 2))` instead of repeatedly ca | = help: Replace with `nums3.extend((1, 2))` -ℹ Unsafe fix -26 26 | -27 27 | -28 28 | # FURB113 -29 |-nums3.append(1) -30 |-nums3.append(2) - 29 |+nums3.extend((1, 2)) -31 30 | pass -32 31 | -33 32 | FURB113.py:35:1: FURB113 [*] Use `nums4.extend((1, 2))` instead of repeatedly calling `nums4.append()` | @@ -53,16 +33,6 @@ FURB113.py:35:1: FURB113 [*] Use `nums4.extend((1, 2))` instead of repeatedly ca | = help: Replace with `nums4.extend((1, 2))` -ℹ Unsafe fix -32 32 | -33 33 | -34 34 | # FURB113 -35 |-nums4.append(1) -36 |-nums4.append(2) - 35 |+nums4.extend((1, 2)) -37 36 | pass -38 37 | -39 38 | FURB113.py:41:1: FURB113 Use `nums.extend((1, 2, 3))` instead of repeatedly calling `nums.append()` | @@ -118,16 +88,6 @@ FURB113.py:56:1: FURB113 [*] Use `nums4.extend((1, 2))` instead of repeatedly ca | = help: Replace with `nums4.extend((1, 2))` -ℹ Unsafe fix -53 53 | nums3.append(1) -54 54 | nums.append(3) -55 55 | # FURB113 -56 |-nums4.append(1) -57 |-nums4.append(2) - 56 |+nums4.extend((1, 2)) -58 57 | nums3.append(2) -59 58 | pass -60 59 | FURB113.py:62:1: FURB113 [*] Use `nums.extend((1, 2, 3))` instead of repeatedly calling `nums.append()` | @@ -139,17 +99,6 @@ FURB113.py:62:1: FURB113 [*] Use `nums.extend((1, 2, 3))` instead of repeatedly | = help: Replace with `nums.extend((1, 2, 3))` -ℹ Unsafe fix -59 59 | pass -60 60 | -61 61 | # FURB113 -62 |-nums.append(1) -63 |-nums.append(2) -64 |-nums.append(3) - 62 |+nums.extend((1, 2, 3)) -65 63 | -66 64 | -67 65 | if True: FURB113.py:69:5: FURB113 [*] Use `nums.extend((1, 2))` instead of repeatedly calling `nums.append()` | @@ -162,16 +111,6 @@ FURB113.py:69:5: FURB113 [*] Use `nums.extend((1, 2))` instead of repeatedly cal | = help: Replace with `nums.extend((1, 2))` -ℹ Unsafe fix -66 66 | -67 67 | if True: -68 68 | # FURB113 -69 |- nums.append(1) -70 |- nums.append(2) - 69 |+ nums.extend((1, 2)) -71 70 | -72 71 | -73 72 | if True: FURB113.py:75:5: FURB113 [*] Use `nums.extend((1, 2))` instead of repeatedly calling `nums.append()` | @@ -185,16 +124,6 @@ FURB113.py:75:5: FURB113 [*] Use `nums.extend((1, 2))` instead of repeatedly cal | = help: Replace with `nums.extend((1, 2))` -ℹ Unsafe fix -72 72 | -73 73 | if True: -74 74 | # FURB113 -75 |- nums.append(1) -76 |- nums.append(2) - 75 |+ nums.extend((1, 2)) -77 76 | pass -78 77 | -79 78 | FURB113.py:82:5: FURB113 Use `nums.extend((1, 2, 3))` instead of repeatedly calling `nums.append()` | @@ -220,16 +149,6 @@ FURB113.py:90:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly callin | = help: Replace with `x.extend((1, 2))` -ℹ Unsafe fix -87 87 | -88 88 | def yes_one(x: list[int]): -89 89 | # FURB113 -90 |- x.append(1) -91 |- x.append(2) - 90 |+ x.extend((1, 2)) -92 91 | -93 92 | -94 93 | def yes_two(x: List[int]): FURB113.py:96:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly calling `x.append()` | @@ -242,16 +161,6 @@ FURB113.py:96:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly callin | = help: Replace with `x.extend((1, 2))` -ℹ Unsafe fix -93 93 | -94 94 | def yes_two(x: List[int]): -95 95 | # FURB113 -96 |- x.append(1) -97 |- x.append(2) - 96 |+ x.extend((1, 2)) -98 97 | -99 98 | -100 99 | def yes_three(*, x: list[int]): FURB113.py:102:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly calling `x.append()` | @@ -264,16 +173,6 @@ FURB113.py:102:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly calli | = help: Replace with `x.extend((1, 2))` -ℹ Unsafe fix -99 99 | -100 100 | def yes_three(*, x: list[int]): -101 101 | # FURB113 -102 |- x.append(1) -103 |- x.append(2) - 102 |+ x.extend((1, 2)) -104 103 | -105 104 | -106 105 | def yes_four(x: list[int], /): FURB113.py:108:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly calling `x.append()` | @@ -286,16 +185,6 @@ FURB113.py:108:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly calli | = help: Replace with `x.extend((1, 2))` -ℹ Unsafe fix -105 105 | -106 106 | def yes_four(x: list[int], /): -107 107 | # FURB113 -108 |- x.append(1) -109 |- x.append(2) - 108 |+ x.extend((1, 2)) -110 109 | -111 110 | -112 111 | def yes_five(x: list[int], y: list[int]): FURB113.py:114:5: FURB113 Use `x.extend((1, 2, 3))` instead of repeatedly calling `x.append()` | @@ -321,16 +210,6 @@ FURB113.py:122:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly calli | = help: Replace with `x.extend((1, 2))` -ℹ Unsafe fix -119 119 | -120 120 | def yes_six(x: list): -121 121 | # FURB113 -122 |- x.append(1) -123 |- x.append(2) - 122 |+ x.extend((1, 2)) -124 123 | -125 124 | -126 125 | if True: FURB113.py:128:5: FURB113 Use `nums.extend((1, 2, 3))` instead of repeatedly calling `nums.append()` | @@ -345,5 +224,3 @@ FURB113.py:128:5: FURB113 Use `nums.extend((1, 2, 3))` instead of repeatedly cal | |__________________^ FURB113 | = help: Replace with `nums.extend((1, 2, 3))` - - diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB116_FURB116.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB116_FURB116.py.snap index 02e102a7ba6fb..0a141f68b3e34 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB116_FURB116.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB116_FURB116.py.snap @@ -12,7 +12,6 @@ FURB116.py:6:7: FURB116 [*] Replace `oct` call with `f"{num:o}"` | = help: Replace with `f"{num:o}"` -ℹ Safe fix 3 3 | def return_num() -> int: 4 4 | return num 5 5 | @@ -31,7 +30,6 @@ FURB116.py:7:7: FURB116 [*] Replace `hex` call with `f"{num:x}"` | = help: Replace with `f"{num:x}"` -ℹ Safe fix 4 4 | return num 5 5 | 6 6 | print(oct(num)[2:]) # FURB116 @@ -52,7 +50,6 @@ FURB116.py:8:7: FURB116 [*] Replace `bin` call with `f"{num:b}"` | = help: Replace with `f"{num:b}"` -ℹ Safe fix 5 5 | 6 6 | print(oct(num)[2:]) # FURB116 7 7 | print(hex(num)[2:]) # FURB116 @@ -73,7 +70,6 @@ FURB116.py:10:7: FURB116 [*] Replace `oct` call with `f"{1337:o}"` | = help: Replace with `f"{1337:o}"` -ℹ Safe fix 7 7 | print(hex(num)[2:]) # FURB116 8 8 | print(bin(num)[2:]) # FURB116 9 9 | @@ -92,7 +88,6 @@ FURB116.py:11:7: FURB116 [*] Replace `hex` call with `f"{1337:x}"` | = help: Replace with `f"{1337:x}"` -ℹ Safe fix 8 8 | print(bin(num)[2:]) # FURB116 9 9 | 10 10 | print(oct(1337)[2:]) # FURB116 @@ -113,7 +108,6 @@ FURB116.py:12:7: FURB116 [*] Replace `bin` call with `f"{1337:b}"` | = help: Replace with `f"{1337:b}"` -ℹ Safe fix 9 9 | 10 10 | print(oct(1337)[2:]) # FURB116 11 11 | print(hex(1337)[2:]) # FURB116 diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB118_FURB118.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB118_FURB118.py.snap index fdfe0dbfbe818..e6f0e8f9d1757 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB118_FURB118.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB118_FURB118.py.snap @@ -11,7 +11,6 @@ FURB118.py:2:13: FURB118 [*] Use `operator.invert` instead of defining a lambda | = help: Replace with `operator.invert` -ℹ Safe fix 1 1 | # Errors. 2 |-op_bitnot = lambda x: ~x 2 |+import operator @@ -31,7 +30,6 @@ FURB118.py:3:10: FURB118 [*] Use `operator.not_` instead of defining a lambda | = help: Replace with `operator.not_` -ℹ Safe fix 1 1 | # Errors. 2 |+import operator 2 3 | op_bitnot = lambda x: ~x @@ -51,7 +49,6 @@ FURB118.py:4:10: FURB118 [*] Use `operator.pos` instead of defining a lambda | = help: Replace with `operator.pos` -ℹ Safe fix 1 1 | # Errors. 2 |+import operator 2 3 | op_bitnot = lambda x: ~x @@ -73,7 +70,6 @@ FURB118.py:5:10: FURB118 [*] Use `operator.neg` instead of defining a lambda | = help: Replace with `operator.neg` -ℹ Safe fix 1 1 | # Errors. 2 |+import operator 2 3 | op_bitnot = lambda x: ~x @@ -96,7 +92,6 @@ FURB118.py:7:10: FURB118 [*] Use `operator.add` instead of defining a lambda | = help: Replace with `operator.add` -ℹ Safe fix 1 1 | # Errors. 2 |+import operator 2 3 | op_bitnot = lambda x: ~x @@ -120,7 +115,6 @@ FURB118.py:8:10: FURB118 [*] Use `operator.sub` instead of defining a lambda | = help: Replace with `operator.sub` -ℹ Safe fix 1 1 | # Errors. 2 |+import operator 2 3 | op_bitnot = lambda x: ~x @@ -146,7 +140,6 @@ FURB118.py:9:11: FURB118 [*] Use `operator.mul` instead of defining a lambda | = help: Replace with `operator.mul` -ℹ Safe fix 1 1 | # Errors. 2 |+import operator 2 3 | op_bitnot = lambda x: ~x @@ -173,7 +166,6 @@ FURB118.py:10:14: FURB118 [*] Use `operator.matmul` instead of defining a lambda | = help: Replace with `operator.matmul` -ℹ Safe fix 1 1 | # Errors. 2 |+import operator 2 3 | op_bitnot = lambda x: ~x @@ -200,7 +192,6 @@ FURB118.py:11:14: FURB118 [*] Use `operator.truediv` instead of defining a lambd | = help: Replace with `operator.truediv` -ℹ Safe fix 1 1 | # Errors. 2 |+import operator 2 3 | op_bitnot = lambda x: ~x @@ -227,7 +218,6 @@ FURB118.py:12:10: FURB118 [*] Use `operator.mod` instead of defining a lambda | = help: Replace with `operator.mod` -ℹ Safe fix 1 1 | # Errors. 2 |+import operator 2 3 | op_bitnot = lambda x: ~x @@ -254,7 +244,6 @@ FURB118.py:13:10: FURB118 [*] Use `operator.pow` instead of defining a lambda | = help: Replace with `operator.pow` -ℹ Safe fix 1 1 | # Errors. 2 |+import operator 2 3 | op_bitnot = lambda x: ~x @@ -281,7 +270,6 @@ FURB118.py:14:13: FURB118 [*] Use `operator.lshift` instead of defining a lambda | = help: Replace with `operator.lshift` -ℹ Safe fix 1 1 | # Errors. 2 |+import operator 2 3 | op_bitnot = lambda x: ~x @@ -308,7 +296,6 @@ FURB118.py:15:13: FURB118 [*] Use `operator.rshift` instead of defining a lambda | = help: Replace with `operator.rshift` -ℹ Safe fix 1 1 | # Errors. 2 |+import operator 2 3 | op_bitnot = lambda x: ~x @@ -335,7 +322,6 @@ FURB118.py:16:12: FURB118 [*] Use `operator.or_` instead of defining a lambda | = help: Replace with `operator.or_` -ℹ Safe fix 1 1 | # Errors. 2 |+import operator 2 3 | op_bitnot = lambda x: ~x @@ -362,7 +348,6 @@ FURB118.py:17:10: FURB118 [*] Use `operator.xor` instead of defining a lambda | = help: Replace with `operator.xor` -ℹ Safe fix 1 1 | # Errors. 2 |+import operator 2 3 | op_bitnot = lambda x: ~x @@ -388,7 +373,6 @@ FURB118.py:18:13: FURB118 [*] Use `operator.and_` instead of defining a lambda | = help: Replace with `operator.and_` -ℹ Safe fix 1 1 | # Errors. 2 |+import operator 2 3 | op_bitnot = lambda x: ~x @@ -415,7 +399,6 @@ FURB118.py:19:15: FURB118 [*] Use `operator.floordiv` instead of defining a lamb | = help: Replace with `operator.floordiv` -ℹ Safe fix 1 1 | # Errors. 2 |+import operator 2 3 | op_bitnot = lambda x: ~x @@ -442,7 +425,6 @@ FURB118.py:21:9: FURB118 [*] Use `operator.eq` instead of defining a lambda | = help: Replace with `operator.eq` -ℹ Safe fix 1 1 | # Errors. 2 |+import operator 2 3 | op_bitnot = lambda x: ~x @@ -468,7 +450,6 @@ FURB118.py:22:9: FURB118 [*] Use `operator.ne` instead of defining a lambda | = help: Replace with `operator.ne` -ℹ Safe fix 1 1 | # Errors. 2 |+import operator 2 3 | op_bitnot = lambda x: ~x @@ -495,7 +476,6 @@ FURB118.py:23:9: FURB118 [*] Use `operator.lt` instead of defining a lambda | = help: Replace with `operator.lt` -ℹ Safe fix 1 1 | # Errors. 2 |+import operator 2 3 | op_bitnot = lambda x: ~x @@ -522,7 +502,6 @@ FURB118.py:24:10: FURB118 [*] Use `operator.le` instead of defining a lambda | = help: Replace with `operator.le` -ℹ Safe fix 1 1 | # Errors. 2 |+import operator 2 3 | op_bitnot = lambda x: ~x @@ -549,7 +528,6 @@ FURB118.py:25:9: FURB118 [*] Use `operator.gt` instead of defining a lambda | = help: Replace with `operator.gt` -ℹ Safe fix 1 1 | # Errors. 2 |+import operator 2 3 | op_bitnot = lambda x: ~x @@ -576,7 +554,6 @@ FURB118.py:26:10: FURB118 [*] Use `operator.ge` instead of defining a lambda | = help: Replace with `operator.ge` -ℹ Safe fix 1 1 | # Errors. 2 |+import operator 2 3 | op_bitnot = lambda x: ~x @@ -603,7 +580,6 @@ FURB118.py:27:9: FURB118 [*] Use `operator.is_` instead of defining a lambda | = help: Replace with `operator.is_` -ℹ Safe fix 1 1 | # Errors. 2 |+import operator 2 3 | op_bitnot = lambda x: ~x @@ -630,7 +606,6 @@ FURB118.py:28:12: FURB118 [*] Use `operator.is_not` instead of defining a lambda | = help: Replace with `operator.is_not` -ℹ Safe fix 1 1 | # Errors. 2 |+import operator 2 3 | op_bitnot = lambda x: ~x @@ -657,7 +632,6 @@ FURB118.py:29:9: FURB118 [*] Use `operator.contains` instead of defining a lambd | = help: Replace with `operator.contains` -ℹ Safe fix 1 1 | # Errors. 2 |+import operator 2 3 | op_bitnot = lambda x: ~x @@ -684,7 +658,6 @@ FURB118.py:30:17: FURB118 [*] Use `operator.itemgetter(0)` instead of defining a | = help: Replace with `operator.itemgetter(0)` -ℹ Safe fix 1 1 | # Errors. 2 |+import operator 2 3 | op_bitnot = lambda x: ~x @@ -711,7 +684,6 @@ FURB118.py:31:17: FURB118 [*] Use `operator.itemgetter(0, 1, 2)` instead of defi | = help: Replace with `operator.itemgetter(0, 1, 2)` -ℹ Safe fix 1 1 | # Errors. 2 |+import operator 2 3 | op_bitnot = lambda x: ~x @@ -738,7 +710,6 @@ FURB118.py:32:17: FURB118 [*] Use `operator.itemgetter(slice(1, None), 2)` inste | = help: Replace with `operator.itemgetter(slice(1, None), 2)` -ℹ Safe fix 1 1 | # Errors. 2 |+import operator 2 3 | op_bitnot = lambda x: ~x @@ -765,7 +736,6 @@ FURB118.py:33:17: FURB118 [*] Use `operator.itemgetter(slice(None))` instead of | = help: Replace with `operator.itemgetter(slice(None))` -ℹ Safe fix 1 1 | # Errors. 2 |+import operator 2 3 | op_bitnot = lambda x: ~x @@ -791,7 +761,6 @@ FURB118.py:34:17: FURB118 [*] Use `operator.itemgetter((0, 1))` instead of defin | = help: Replace with `operator.itemgetter((0, 1))` -ℹ Safe fix 1 1 | # Errors. 2 |+import operator 2 3 | op_bitnot = lambda x: ~x @@ -816,7 +785,6 @@ FURB118.py:35:17: FURB118 [*] Use `operator.itemgetter((0, 1))` instead of defin | = help: Replace with `operator.itemgetter((0, 1))` -ℹ Safe fix 1 1 | # Errors. 2 |+import operator 2 3 | op_bitnot = lambda x: ~x diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB129_FURB129.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB129_FURB129.py.snap index 655f8d69591d4..b4b541ee3c089 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB129_FURB129.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB129_FURB129.py.snap @@ -12,15 +12,6 @@ FURB129.py:7:18: FURB129 [*] Instead of calling `readlines()`, iterate over file | = help: Remove `readlines()` -ℹ Unsafe fix -4 4 | -5 5 | # Errors -6 6 | with open("FURB129.py") as f: -7 |- for _line in f.readlines(): - 7 |+ for _line in f: -8 8 | pass -9 9 | a = [line.lower() for line in f.readlines()] -10 10 | b = {line.upper() for line in f.readlines()} FURB129.py:9:35: FURB129 [*] Instead of calling `readlines()`, iterate over file object directly | @@ -33,15 +24,6 @@ FURB129.py:9:35: FURB129 [*] Instead of calling `readlines()`, iterate over file | = help: Remove `readlines()` -ℹ Unsafe fix -6 6 | with open("FURB129.py") as f: -7 7 | for _line in f.readlines(): -8 8 | pass -9 |- a = [line.lower() for line in f.readlines()] - 9 |+ a = [line.lower() for line in f] -10 10 | b = {line.upper() for line in f.readlines()} -11 11 | c = {line.lower(): line.upper() for line in f.readlines()} -12 12 | FURB129.py:10:35: FURB129 [*] Instead of calling `readlines()`, iterate over file object directly | @@ -53,15 +35,6 @@ FURB129.py:10:35: FURB129 [*] Instead of calling `readlines()`, iterate over fil | = help: Remove `readlines()` -ℹ Unsafe fix -7 7 | for _line in f.readlines(): -8 8 | pass -9 9 | a = [line.lower() for line in f.readlines()] -10 |- b = {line.upper() for line in f.readlines()} - 10 |+ b = {line.upper() for line in f} -11 11 | c = {line.lower(): line.upper() for line in f.readlines()} -12 12 | -13 13 | with Path("FURB129.py").open() as f: FURB129.py:11:49: FURB129 [*] Instead of calling `readlines()`, iterate over file object directly | @@ -74,15 +47,6 @@ FURB129.py:11:49: FURB129 [*] Instead of calling `readlines()`, iterate over fil | = help: Remove `readlines()` -ℹ Unsafe fix -8 8 | pass -9 9 | a = [line.lower() for line in f.readlines()] -10 10 | b = {line.upper() for line in f.readlines()} -11 |- c = {line.lower(): line.upper() for line in f.readlines()} - 11 |+ c = {line.lower(): line.upper() for line in f} -12 12 | -13 13 | with Path("FURB129.py").open() as f: -14 14 | for _line in f.readlines(): FURB129.py:14:18: FURB129 [*] Instead of calling `readlines()`, iterate over file object directly | @@ -93,15 +57,6 @@ FURB129.py:14:18: FURB129 [*] Instead of calling `readlines()`, iterate over fil | = help: Remove `readlines()` -ℹ Unsafe fix -11 11 | c = {line.lower(): line.upper() for line in f.readlines()} -12 12 | -13 13 | with Path("FURB129.py").open() as f: -14 |- for _line in f.readlines(): - 14 |+ for _line in f: -15 15 | pass -16 16 | -17 17 | for _line in open("FURB129.py").readlines(): FURB129.py:17:14: FURB129 [*] Instead of calling `readlines()`, iterate over file object directly | @@ -113,15 +68,6 @@ FURB129.py:17:14: FURB129 [*] Instead of calling `readlines()`, iterate over fil | = help: Remove `readlines()` -ℹ Unsafe fix -14 14 | for _line in f.readlines(): -15 15 | pass -16 16 | -17 |-for _line in open("FURB129.py").readlines(): - 17 |+for _line in open("FURB129.py"): -18 18 | pass -19 19 | -20 20 | for _line in Path("FURB129.py").open().readlines(): FURB129.py:20:14: FURB129 [*] Instead of calling `readlines()`, iterate over file object directly | @@ -133,15 +79,6 @@ FURB129.py:20:14: FURB129 [*] Instead of calling `readlines()`, iterate over fil | = help: Remove `readlines()` -ℹ Unsafe fix -17 17 | for _line in open("FURB129.py").readlines(): -18 18 | pass -19 19 | -20 |-for _line in Path("FURB129.py").open().readlines(): - 20 |+for _line in Path("FURB129.py").open(): -21 21 | pass -22 22 | -23 23 | FURB129.py:26:18: FURB129 [*] Instead of calling `readlines()`, iterate over file object directly | @@ -154,15 +91,6 @@ FURB129.py:26:18: FURB129 [*] Instead of calling `readlines()`, iterate over fil | = help: Remove `readlines()` -ℹ Unsafe fix -23 23 | -24 24 | def func(): -25 25 | f = Path("FURB129.py").open() -26 |- for _line in f.readlines(): - 26 |+ for _line in f: -27 27 | pass -28 28 | f.close() -29 29 | FURB129.py:32:18: FURB129 [*] Instead of calling `readlines()`, iterate over file object directly | @@ -173,15 +101,6 @@ FURB129.py:32:18: FURB129 [*] Instead of calling `readlines()`, iterate over fil | = help: Remove `readlines()` -ℹ Unsafe fix -29 29 | -30 30 | -31 31 | def func(f: io.BytesIO): -32 |- for _line in f.readlines(): - 32 |+ for _line in f: -33 33 | pass -34 34 | -35 35 | FURB129.py:38:22: FURB129 [*] Instead of calling `readlines()`, iterate over file object directly | @@ -194,15 +113,6 @@ FURB129.py:38:22: FURB129 [*] Instead of calling `readlines()`, iterate over fil | = help: Remove `readlines()` -ℹ Unsafe fix -35 35 | -36 36 | def func(): -37 37 | with (open("FURB129.py") as f, foo as bar): -38 |- for _line in f.readlines(): - 38 |+ for _line in f: -39 39 | pass -40 40 | for _line in bar.readlines(): -41 41 | pass FURB129.py:48:17: FURB129 [*] Instead of calling `readlines()`, iterate over file object directly | @@ -213,15 +123,6 @@ FURB129.py:48:17: FURB129 [*] Instead of calling `readlines()`, iterate over fil | = help: Remove `readlines()` -ℹ Unsafe fix -45 45 | -46 46 | -47 47 | with builtins.open("FURB129.py") as f: -48 |- for line in f.readlines(): - 48 |+ for line in f: -49 49 | pass -50 50 | -51 51 | FURB129.py:56:17: FURB129 [*] Instead of calling `readlines()`, iterate over file object directly | @@ -231,13 +132,3 @@ FURB129.py:56:17: FURB129 [*] Instead of calling `readlines()`, iterate over fil 57 | pass | = help: Remove `readlines()` - -ℹ Unsafe fix -53 53 | -54 54 | -55 55 | with o("FURB129.py") as f: -56 |- for line in f.readlines(): - 56 |+ for line in f: -57 57 | pass -58 58 | -59 59 | diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB131_FURB131.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB131_FURB131.py.snap index fcd3ecd84eb12..0d76db8d28394 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB131_FURB131.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB131_FURB131.py.snap @@ -9,15 +9,6 @@ FURB131.py:11:1: FURB131 [*] Prefer `clear` over deleting a full slice | = help: Replace with `clear()` -ℹ Unsafe fix -8 8 | # these should match -9 9 | -10 10 | # FURB131 -11 |-del nums[:] - 11 |+nums.clear() -12 12 | -13 13 | -14 14 | # FURB131 FURB131.py:15:1: FURB131 [*] Prefer `clear` over deleting a full slice | @@ -27,15 +18,6 @@ FURB131.py:15:1: FURB131 [*] Prefer `clear` over deleting a full slice | = help: Replace with `clear()` -ℹ Unsafe fix -12 12 | -13 13 | -14 14 | # FURB131 -15 |-del names[:] - 15 |+names.clear() -16 16 | -17 17 | -18 18 | # FURB131 FURB131.py:19:1: FURB131 Prefer `clear` over deleting a full slice | @@ -62,15 +44,6 @@ FURB131.py:28:5: FURB131 [*] Prefer `clear` over deleting a full slice | = help: Replace with `clear()` -ℹ Unsafe fix -25 25 | -26 26 | def yes_one(x: list[int]): -27 27 | # FURB131 -28 |- del x[:] - 28 |+ x.clear() -29 29 | -30 30 | -31 31 | def yes_two(x: dict[int, str]): FURB131.py:33:5: FURB131 [*] Prefer `clear` over deleting a full slice | @@ -81,15 +54,6 @@ FURB131.py:33:5: FURB131 [*] Prefer `clear` over deleting a full slice | = help: Replace with `clear()` -ℹ Unsafe fix -30 30 | -31 31 | def yes_two(x: dict[int, str]): -32 32 | # FURB131 -33 |- del x[:] - 33 |+ x.clear() -34 34 | -35 35 | -36 36 | def yes_three(x: List[int]): FURB131.py:38:5: FURB131 [*] Prefer `clear` over deleting a full slice | @@ -100,15 +64,6 @@ FURB131.py:38:5: FURB131 [*] Prefer `clear` over deleting a full slice | = help: Replace with `clear()` -ℹ Unsafe fix -35 35 | -36 36 | def yes_three(x: List[int]): -37 37 | # FURB131 -38 |- del x[:] - 38 |+ x.clear() -39 39 | -40 40 | -41 41 | def yes_four(x: Dict[int, str]): FURB131.py:43:5: FURB131 [*] Prefer `clear` over deleting a full slice | @@ -119,15 +74,6 @@ FURB131.py:43:5: FURB131 [*] Prefer `clear` over deleting a full slice | = help: Replace with `clear()` -ℹ Unsafe fix -40 40 | -41 41 | def yes_four(x: Dict[int, str]): -42 42 | # FURB131 -43 |- del x[:] - 43 |+ x.clear() -44 44 | -45 45 | -46 46 | def yes_five(x: Dict[int, str]): FURB131.py:48:5: FURB131 [*] Prefer `clear` over deleting a full slice | @@ -140,15 +86,6 @@ FURB131.py:48:5: FURB131 [*] Prefer `clear` over deleting a full slice | = help: Replace with `clear()` -ℹ Unsafe fix -45 45 | -46 46 | def yes_five(x: Dict[int, str]): -47 47 | # FURB131 -48 |- del x[:] - 48 |+ x.clear() -49 49 | -50 50 | x = 1 -51 51 | FURB131.py:58:1: FURB131 [*] Prefer `clear` over deleting a full slice | @@ -160,13 +97,3 @@ FURB131.py:58:1: FURB131 [*] Prefer `clear` over deleting a full slice 60 | # these should not | = help: Replace with `clear()` - -ℹ Unsafe fix -55 55 | -56 56 | sneaky = SneakyList() -57 57 | # FURB131 -58 |-del sneaky[:] - 58 |+sneaky.clear() -59 59 | -60 60 | # these should not -61 61 | diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB132_FURB132.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB132_FURB132.py.snap index ac600b20be6ae..843b8b41f6758 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB132_FURB132.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB132_FURB132.py.snap @@ -10,16 +10,6 @@ FURB132.py:12:1: FURB132 [*] Use `s.discard("x")` instead of check and `remove` | = help: Replace with `s.discard("x")` -ℹ Unsafe fix -9 9 | # these should match -10 10 | -11 11 | # FURB132 -12 |-if "x" in s: -13 |- s.remove("x") - 12 |+s.discard("x") -14 13 | -15 14 | -16 15 | # FURB132 FURB132.py:22:1: FURB132 [*] Use `s3.discard("x")` instead of check and `remove` | @@ -30,16 +20,6 @@ FURB132.py:22:1: FURB132 [*] Use `s3.discard("x")` instead of check and `remove` | = help: Replace with `s3.discard("x")` -ℹ Unsafe fix -19 19 | -20 20 | -21 21 | # FURB132 -22 |-if "x" in s3: -23 |- s3.remove("x") - 22 |+s3.discard("x") -24 23 | -25 24 | -26 25 | var = "y" FURB132.py:28:1: FURB132 [*] Use `s.discard(var)` instead of check and `remove` | @@ -51,16 +31,6 @@ FURB132.py:28:1: FURB132 [*] Use `s.discard(var)` instead of check and `remove` | = help: Replace with `s.discard(var)` -ℹ Unsafe fix -25 25 | -26 26 | var = "y" -27 27 | # FURB132 -28 |-if var in s: -29 |- s.remove(var) - 28 |+s.discard(var) -30 29 | -31 30 | -32 31 | if f"{var}:{var}" in s: FURB132.py:32:1: FURB132 [*] Use `s.discard(f"{var}:{var}")` instead of check and `remove` | @@ -69,16 +39,3 @@ FURB132.py:32:1: FURB132 [*] Use `s.discard(f"{var}:{var}")` instead of check an | |____________________________^ FURB132 | = help: Replace with `s.discard(f"{var}:{var}")` - -ℹ Unsafe fix -29 29 | s.remove(var) -30 30 | -31 31 | -32 |-if f"{var}:{var}" in s: -33 |- s.remove(f"{var}:{var}") - 32 |+s.discard(f"{var}:{var}") -34 33 | -35 34 | -36 35 | def identity(x): - - diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB136_FURB136.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB136_FURB136.py.snap index bf698bafbfe3f..6612ab30090ae 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB136_FURB136.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB136_FURB136.py.snap @@ -12,7 +12,6 @@ FURB136.py:4:1: FURB136 [*] Replace `x if x > y else y` with `max(y, x)` | = help: Replace with `max(y, x)` -ℹ Safe fix 1 1 | x = 1 2 2 | y = 2 3 3 | @@ -33,7 +32,6 @@ FURB136.py:6:1: FURB136 [*] Replace `x if x >= y else y` with `max(x, y)` | = help: Replace with `max(x, y)` -ℹ Safe fix 3 3 | 4 4 | x if x > y else y # FURB136 5 5 | @@ -54,7 +52,6 @@ FURB136.py:8:1: FURB136 [*] Replace `x if x < y else y` with `min(y, x)` | = help: Replace with `min(y, x)` -ℹ Safe fix 5 5 | 6 6 | x if x >= y else y # FURB136 7 7 | @@ -75,7 +72,6 @@ FURB136.py:10:1: FURB136 [*] Replace `x if x <= y else y` with `min(x, y)` | = help: Replace with `min(x, y)` -ℹ Safe fix 7 7 | 8 8 | x if x < y else y # FURB136 9 9 | @@ -96,7 +92,6 @@ FURB136.py:12:1: FURB136 [*] Replace `y if x > y else x` with `min(x, y)` | = help: Replace with `min(x, y)` -ℹ Safe fix 9 9 | 10 10 | x if x <= y else y # FURB136 11 11 | @@ -117,7 +112,6 @@ FURB136.py:14:1: FURB136 [*] Replace `y if x >= y else x` with `min(y, x)` | = help: Replace with `min(y, x)` -ℹ Safe fix 11 11 | 12 12 | y if x > y else x # FURB136 13 13 | @@ -138,7 +132,6 @@ FURB136.py:16:1: FURB136 [*] Replace `y if x < y else x` with `max(x, y)` | = help: Replace with `max(x, y)` -ℹ Safe fix 13 13 | 14 14 | y if x >= y else x # FURB136 15 15 | @@ -159,7 +152,6 @@ FURB136.py:18:1: FURB136 [*] Replace `y if x <= y else x` with `max(y, x)` | = help: Replace with `max(y, x)` -ℹ Safe fix 15 15 | 16 16 | y if x < y else x # FURB136 17 17 | @@ -181,7 +173,6 @@ FURB136.py:22:1: FURB136 [*] Replace `if` expression with `max(y, x)` | = help: Replace with `max(y, x)` -ℹ Safe fix 19 19 | 20 20 | x + y if x > y else y # OK 21 21 | @@ -190,5 +181,3 @@ FURB136.py:22:1: FURB136 [*] Replace `if` expression with `max(y, x)` 24 |- > y 25 |-) else y # FURB136 22 |+max(y, x) # FURB136 - - diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB140_FURB140.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB140_FURB140.py.snap index 5fc72a0bc02b2..425158300611f 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB140_FURB140.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB140_FURB140.py.snap @@ -11,7 +11,6 @@ FURB140.py:7:1: FURB140 [*] Use `itertools.starmap` instead of the generator | = help: Replace with `itertools.starmap` -ℹ Safe fix 1 |+from itertools import starmap 1 2 | def zipped(): 2 3 | return zip([1, 2, 3], "ABC") @@ -35,7 +34,6 @@ FURB140.py:10:1: FURB140 [*] Use `itertools.starmap` instead of the generator | = help: Replace with `itertools.starmap` -ℹ Safe fix 1 |+from itertools import starmap 1 2 | def zipped(): 2 3 | return zip([1, 2, 3], "ABC") @@ -58,7 +56,6 @@ FURB140.py:13:1: FURB140 [*] Use `itertools.starmap` instead of the generator | = help: Replace with `itertools.starmap` -ℹ Safe fix 1 |+from itertools import starmap 1 2 | def zipped(): 2 3 | return zip([1, 2, 3], "ABC") @@ -83,7 +80,6 @@ FURB140.py:19:1: FURB140 [*] Use `itertools.starmap` instead of the generator | = help: Replace with `itertools.starmap` -ℹ Safe fix 16 16 | from itertools import starmap as sm 17 17 | 18 18 | # FURB140 @@ -103,7 +99,6 @@ FURB140.py:22:1: FURB140 [*] Use `itertools.starmap` instead of the generator | = help: Replace with `itertools.starmap` -ℹ Safe fix 19 19 | [print(x, y) for x, y in zipped()] 20 20 | 21 21 | # FURB140 @@ -123,7 +118,6 @@ FURB140.py:25:1: FURB140 [*] Use `itertools.starmap` instead of the generator | = help: Replace with `itertools.starmap` -ℹ Safe fix 22 22 | (print(x, y) for x, y in zipped()) 23 23 | 24 24 | # FURB140 @@ -144,7 +138,6 @@ FURB140.py:29:1: FURB140 [*] Use `itertools.starmap` instead of the generator | = help: Replace with `itertools.starmap` -ℹ Safe fix 26 26 | 27 27 | # FURB140 (check it still flags starred arguments). 28 28 | # See https://github.com/astral-sh/ruff/issues/7636 @@ -164,7 +157,6 @@ FURB140.py:30:1: FURB140 [*] Use `itertools.starmap` instead of the generator | = help: Replace with `itertools.starmap` -ℹ Safe fix 27 27 | # FURB140 (check it still flags starred arguments). 28 28 | # See https://github.com/astral-sh/ruff/issues/7636 29 29 | [foo(*t) for t in [(85, 60), (100, 80)]] @@ -185,7 +177,6 @@ FURB140.py:31:1: FURB140 [*] Use `itertools.starmap` instead of the generator | = help: Replace with `itertools.starmap` -ℹ Safe fix 28 28 | # See https://github.com/astral-sh/ruff/issues/7636 29 29 | [foo(*t) for t in [(85, 60), (100, 80)]] 30 30 | (foo(*t) for t in [(85, 60), (100, 80)]) @@ -193,6 +184,4 @@ FURB140.py:31:1: FURB140 [*] Use `itertools.starmap` instead of the generator 31 |+set(sm(foo, [(85, 60), (100, 80)])) 32 32 | 33 33 | # Non-errors. -34 34 | - - +34 34 | diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB142_FURB142.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB142_FURB142.py.snap index cd781a8bbe030..198adfb0b13b0 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB142_FURB142.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB142_FURB142.py.snap @@ -13,7 +13,6 @@ FURB142.py:5:1: FURB142 [*] Use of `set.add()` in a for loop | = help: Replace with `.update()` -ℹ Safe fix 2 2 | 3 3 | s = set() 4 4 | @@ -36,7 +35,6 @@ FURB142.py:8:1: FURB142 [*] Use of `set.add()` in a for loop | = help: Replace with `.update()` -ℹ Safe fix 5 5 | for x in [1, 2, 3]: 6 6 | s.add(x) 7 7 | @@ -59,7 +57,6 @@ FURB142.py:11:1: FURB142 [*] Use of `set.add()` in a for loop | = help: Replace with `.update()` -ℹ Safe fix 8 8 | for x in {1, 2, 3}: 9 9 | s.add(x) 10 10 | @@ -82,7 +79,6 @@ FURB142.py:14:1: FURB142 [*] Use of `set.discard()` in a for loop | = help: Replace with `.difference_update()` -ℹ Safe fix 11 11 | for x in (1, 2, 3): 12 12 | s.add(x) 13 13 | @@ -105,7 +101,6 @@ FURB142.py:17:1: FURB142 [*] Use of `set.add()` in a for loop | = help: Replace with `.update()` -ℹ Safe fix 14 14 | for x in (1, 2, 3): 15 15 | s.discard(x) 16 16 | @@ -128,7 +123,6 @@ FURB142.py:20:1: FURB142 [*] Use of `set.add()` in a for loop | = help: Replace with `.update()` -ℹ Safe fix 17 17 | for x in (1, 2, 3): 18 18 | s.add(x + 1) 19 19 | @@ -151,7 +145,6 @@ FURB142.py:25:1: FURB142 [*] Use of `set.add()` in a for loop | = help: Replace with `.update()` -ℹ Safe fix 22 22 | 23 23 | num = 123 24 24 | @@ -174,7 +167,6 @@ FURB142.py:28:1: FURB142 [*] Use of `set.add()` in a for loop | = help: Replace with `.update()` -ℹ Safe fix 25 25 | for x in (1, 2, 3): 26 26 | s.add(num) 27 27 | @@ -197,7 +189,6 @@ FURB142.py:31:1: FURB142 [*] Use of `set.add()` in a for loop | = help: Replace with `.update()` -ℹ Safe fix 28 28 | for x in (1, 2, 3): 29 29 | s.add((num, x)) 30 30 | diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB145_FURB145.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB145_FURB145.py.snap index 388dfb2488cc0..3c00b0028410e 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB145_FURB145.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB145_FURB145.py.snap @@ -11,7 +11,6 @@ FURB145.py:4:5: FURB145 [*] Prefer `copy` method over slicing | = help: Replace with `copy()` -ℹ Safe fix 1 1 | l = [1, 2, 3, 4, 5] 2 2 | 3 3 | # Errors. @@ -32,7 +31,6 @@ FURB145.py:5:11: FURB145 [*] Prefer `copy` method over slicing | = help: Replace with `copy()` -ℹ Safe fix 2 2 | 3 3 | # Errors. 4 4 | a = l[:] @@ -53,7 +51,6 @@ FURB145.py:6:8: FURB145 [*] Prefer `copy` method over slicing | = help: Replace with `copy()` -ℹ Safe fix 3 3 | # Errors. 4 4 | a = l[:] 5 5 | b, c = 1, l[:] @@ -74,7 +71,6 @@ FURB145.py:7:5: FURB145 [*] Prefer `copy` method over slicing | = help: Replace with `copy()` -ℹ Safe fix 4 4 | a = l[:] 5 5 | b, c = 1, l[:] 6 6 | d, e = l[:], 1 @@ -94,7 +90,6 @@ FURB145.py:8:1: FURB145 [*] Prefer `copy` method over slicing | = help: Replace with `copy()` -ℹ Safe fix 5 5 | b, c = 1, l[:] 6 6 | d, e = l[:], 1 7 7 | m = l[::] @@ -115,7 +110,6 @@ FURB145.py:9:7: FURB145 [*] Prefer `copy` method over slicing | = help: Replace with `copy()` -ℹ Safe fix 6 6 | d, e = l[:], 1 7 7 | m = l[::] 8 8 | l[:] @@ -124,5 +118,3 @@ FURB145.py:9:7: FURB145 [*] Prefer `copy` method over slicing 10 10 | 11 11 | # False negatives. 12 12 | aa = a[:] # Type inference. - - diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB148_FURB148.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB148_FURB148.py.snap index 3cb94bc16bd50..b2146c1cbfc24 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB148_FURB148.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB148_FURB148.py.snap @@ -10,15 +10,6 @@ FURB148.py:14:17: FURB148 [*] `enumerate` value is unused, use `for x in range(l | = help: Replace with `range(len(...))` -ℹ Unsafe fix -11 11 | books_tuple = ("Dune", "Foundation", "Neuromancer") -12 12 | -13 13 | # Errors -14 |-for index, _ in enumerate(books): - 14 |+for index in range(len(books)): -15 15 | print(index) -16 16 | -17 17 | for index, _ in enumerate(books, start=0): FURB148.py:17:17: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead | @@ -30,15 +21,6 @@ FURB148.py:17:17: FURB148 [*] `enumerate` value is unused, use `for x in range(l | = help: Replace with `range(len(...))` -ℹ Unsafe fix -14 14 | for index, _ in enumerate(books): -15 15 | print(index) -16 16 | -17 |-for index, _ in enumerate(books, start=0): - 17 |+for index in range(len(books)): -18 18 | print(index) -19 19 | -20 20 | for index, _ in enumerate(books, 0): FURB148.py:20:17: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead | @@ -50,15 +32,6 @@ FURB148.py:20:17: FURB148 [*] `enumerate` value is unused, use `for x in range(l | = help: Replace with `range(len(...))` -ℹ Unsafe fix -17 17 | for index, _ in enumerate(books, start=0): -18 18 | print(index) -19 19 | -20 |-for index, _ in enumerate(books, 0): - 20 |+for index in range(len(books)): -21 21 | print(index) -22 22 | -23 23 | for index, _ in enumerate(books, start=1): FURB148.py:23:17: FURB148 `enumerate` value is unused, use `for x in range(len(y))` instead | @@ -110,15 +83,6 @@ FURB148.py:35:16: FURB148 [*] `enumerate` index is unused, use `for x in y` inst | = help: Remove `enumerate` -ℹ Unsafe fix -32 32 | for index, _ in enumerate(books, x): -33 33 | print(book) -34 34 | -35 |-for _, book in enumerate(books): - 35 |+for book in books: -36 36 | print(book) -37 37 | -38 38 | for _, book in enumerate(books, start=0): FURB148.py:38:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead | @@ -130,15 +94,6 @@ FURB148.py:38:16: FURB148 [*] `enumerate` index is unused, use `for x in y` inst | = help: Remove `enumerate` -ℹ Unsafe fix -35 35 | for _, book in enumerate(books): -36 36 | print(book) -37 37 | -38 |-for _, book in enumerate(books, start=0): - 38 |+for book in books: -39 39 | print(book) -40 40 | -41 41 | for _, book in enumerate(books, 0): FURB148.py:41:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead | @@ -150,15 +105,6 @@ FURB148.py:41:16: FURB148 [*] `enumerate` index is unused, use `for x in y` inst | = help: Remove `enumerate` -ℹ Unsafe fix -38 38 | for _, book in enumerate(books, start=0): -39 39 | print(book) -40 40 | -41 |-for _, book in enumerate(books, 0): - 41 |+for book in books: -42 42 | print(book) -43 43 | -44 44 | for _, book in enumerate(books, start=1): FURB148.py:44:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead | @@ -170,15 +116,6 @@ FURB148.py:44:16: FURB148 [*] `enumerate` index is unused, use `for x in y` inst | = help: Remove `enumerate` -ℹ Unsafe fix -41 41 | for _, book in enumerate(books, 0): -42 42 | print(book) -43 43 | -44 |-for _, book in enumerate(books, start=1): - 44 |+for book in books: -45 45 | print(book) -46 46 | -47 47 | for _, book in enumerate(books, 1): FURB148.py:47:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead | @@ -190,15 +127,6 @@ FURB148.py:47:16: FURB148 [*] `enumerate` index is unused, use `for x in y` inst | = help: Remove `enumerate` -ℹ Unsafe fix -44 44 | for _, book in enumerate(books, start=1): -45 45 | print(book) -46 46 | -47 |-for _, book in enumerate(books, 1): - 47 |+for book in books: -48 48 | print(book) -49 49 | -50 50 | for _, book in enumerate(books, start=x): FURB148.py:50:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead | @@ -210,15 +138,6 @@ FURB148.py:50:16: FURB148 [*] `enumerate` index is unused, use `for x in y` inst | = help: Remove `enumerate` -ℹ Unsafe fix -47 47 | for _, book in enumerate(books, 1): -48 48 | print(book) -49 49 | -50 |-for _, book in enumerate(books, start=x): - 50 |+for book in books: -51 51 | print(book) -52 52 | -53 53 | for _, book in enumerate(books, x): FURB148.py:53:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead | @@ -230,15 +149,6 @@ FURB148.py:53:16: FURB148 [*] `enumerate` index is unused, use `for x in y` inst | = help: Remove `enumerate` -ℹ Unsafe fix -50 50 | for _, book in enumerate(books, start=x): -51 51 | print(book) -52 52 | -53 |-for _, book in enumerate(books, x): - 53 |+for book in books: -54 54 | print(book) -55 55 | -56 56 | for index, (_, _) in enumerate(books): FURB148.py:56:22: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead | @@ -250,15 +160,6 @@ FURB148.py:56:22: FURB148 [*] `enumerate` value is unused, use `for x in range(l | = help: Replace with `range(len(...))` -ℹ Unsafe fix -53 53 | for _, book in enumerate(books, x): -54 54 | print(book) -55 55 | -56 |-for index, (_, _) in enumerate(books): - 56 |+for index in range(len(books)): -57 57 | print(index) -58 58 | -59 59 | for (_, _), book in enumerate(books): FURB148.py:59:21: FURB148 [*] `enumerate` index is unused, use `for x in y` instead | @@ -270,15 +171,6 @@ FURB148.py:59:21: FURB148 [*] `enumerate` index is unused, use `for x in y` inst | = help: Remove `enumerate` -ℹ Unsafe fix -56 56 | for index, (_, _) in enumerate(books): -57 57 | print(index) -58 58 | -59 |-for (_, _), book in enumerate(books): - 59 |+for book in books: -60 60 | print(book) -61 61 | -62 62 | for(index, _)in enumerate(books): FURB148.py:62:17: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead | @@ -290,15 +182,6 @@ FURB148.py:62:17: FURB148 [*] `enumerate` value is unused, use `for x in range(l | = help: Replace with `range(len(...))` -ℹ Unsafe fix -59 59 | for (_, _), book in enumerate(books): -60 60 | print(book) -61 61 | -62 |-for(index, _)in enumerate(books): - 62 |+for index in range(len(books)): -63 63 | print(index) -64 64 | -65 65 | for(index), _ in enumerate(books): FURB148.py:65:18: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead | @@ -310,15 +193,6 @@ FURB148.py:65:18: FURB148 [*] `enumerate` value is unused, use `for x in range(l | = help: Replace with `range(len(...))` -ℹ Unsafe fix -62 62 | for(index, _)in enumerate(books): -63 63 | print(index) -64 64 | -65 |-for(index), _ in enumerate(books): - 65 |+for index in range(len(books)): -66 66 | print(index) -67 67 | -68 68 | for index, _ in enumerate(books_and_authors): FURB148.py:68:17: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead | @@ -330,15 +204,6 @@ FURB148.py:68:17: FURB148 [*] `enumerate` value is unused, use `for x in range(l | = help: Replace with `range(len(...))` -ℹ Unsafe fix -65 65 | for(index), _ in enumerate(books): -66 66 | print(index) -67 67 | -68 |-for index, _ in enumerate(books_and_authors): - 68 |+for index in range(len(books_and_authors)): -69 69 | print(index) -70 70 | -71 71 | for _, book in enumerate(books_and_authors): FURB148.py:71:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead | @@ -350,15 +215,6 @@ FURB148.py:71:16: FURB148 [*] `enumerate` index is unused, use `for x in y` inst | = help: Remove `enumerate` -ℹ Unsafe fix -68 68 | for index, _ in enumerate(books_and_authors): -69 69 | print(index) -70 70 | -71 |-for _, book in enumerate(books_and_authors): - 71 |+for book in books_and_authors: -72 72 | print(book) -73 73 | -74 74 | for index, _ in enumerate(books_set): FURB148.py:74:17: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead | @@ -370,15 +226,6 @@ FURB148.py:74:17: FURB148 [*] `enumerate` value is unused, use `for x in range(l | = help: Replace with `range(len(...))` -ℹ Unsafe fix -71 71 | for _, book in enumerate(books_and_authors): -72 72 | print(book) -73 73 | -74 |-for index, _ in enumerate(books_set): - 74 |+for index in range(len(books_set)): -75 75 | print(index) -76 76 | -77 77 | for _, book in enumerate(books_set): FURB148.py:77:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead | @@ -390,15 +237,6 @@ FURB148.py:77:16: FURB148 [*] `enumerate` index is unused, use `for x in y` inst | = help: Remove `enumerate` -ℹ Unsafe fix -74 74 | for index, _ in enumerate(books_set): -75 75 | print(index) -76 76 | -77 |-for _, book in enumerate(books_set): - 77 |+for book in books_set: -78 78 | print(book) -79 79 | -80 80 | for index, _ in enumerate(books_tuple): FURB148.py:80:17: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead | @@ -410,15 +248,6 @@ FURB148.py:80:17: FURB148 [*] `enumerate` value is unused, use `for x in range(l | = help: Replace with `range(len(...))` -ℹ Unsafe fix -77 77 | for _, book in enumerate(books_set): -78 78 | print(book) -79 79 | -80 |-for index, _ in enumerate(books_tuple): - 80 |+for index in range(len(books_tuple)): -81 81 | print(index) -82 82 | -83 83 | for _, book in enumerate(books_tuple): FURB148.py:83:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead | @@ -429,15 +258,3 @@ FURB148.py:83:16: FURB148 [*] `enumerate` index is unused, use `for x in y` inst 84 | print(book) | = help: Remove `enumerate` - -ℹ Unsafe fix -80 80 | for index, _ in enumerate(books_tuple): -81 81 | print(index) -82 82 | -83 |-for _, book in enumerate(books_tuple): - 83 |+for book in books_tuple: -84 84 | print(book) -85 85 | -86 86 | # OK - - diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB152_FURB152.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB152_FURB152.py.snap index 9933f51589ab9..f1c76ec8c16a0 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB152_FURB152.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB152_FURB152.py.snap @@ -12,7 +12,6 @@ FURB152.py:3:5: FURB152 [*] Replace `3.14` with `math.pi` | = help: Use `math.pi` -ℹ Safe fix 1 |+import math 1 2 | r = 3.1 # OK 2 3 | @@ -33,7 +32,6 @@ FURB152.py:5:5: FURB152 [*] Replace `6.28` with `math.tau` | = help: Use `math.tau` -ℹ Safe fix 1 |+import math 1 2 | r = 3.1 # OK 2 3 | @@ -56,7 +54,6 @@ FURB152.py:7:5: FURB152 [*] Replace `2.71` with `math.e` | = help: Use `math.e` -ℹ Safe fix 1 |+import math 1 2 | r = 3.1 # OK 2 3 | @@ -81,7 +78,6 @@ FURB152.py:11:5: FURB152 [*] Replace `3.141` with `math.pi` | = help: Use `math.pi` -ℹ Safe fix 1 |+import math 1 2 | r = 3.1 # OK 2 3 | @@ -107,7 +103,6 @@ FURB152.py:13:5: FURB152 [*] Replace `3.142` with `math.pi` | = help: Use `math.pi` -ℹ Safe fix 1 |+import math 1 2 | r = 3.1 # OK 2 3 | @@ -133,7 +128,6 @@ FURB152.py:15:5: FURB152 [*] Replace `3.1415` with `math.pi` | = help: Use `math.pi` -ℹ Safe fix 1 |+import math 1 2 | r = 3.1 # OK 2 3 | @@ -159,7 +153,6 @@ FURB152.py:17:5: FURB152 [*] Replace `3.1416` with `math.pi` | = help: Use `math.pi` -ℹ Safe fix 1 |+import math 1 2 | r = 3.1 # OK 2 3 | @@ -185,7 +178,6 @@ FURB152.py:19:5: FURB152 [*] Replace `3.141592` with `math.pi` | = help: Use `math.pi` -ℹ Safe fix 1 |+import math 1 2 | r = 3.1 # OK 2 3 | @@ -211,7 +203,6 @@ FURB152.py:21:5: FURB152 [*] Replace `3.141593` with `math.pi` | = help: Use `math.pi` -ℹ Safe fix 1 |+import math 1 2 | r = 3.1 # OK 2 3 | @@ -237,7 +228,6 @@ FURB152.py:23:5: FURB152 [*] Replace `3.14159265` with `math.pi` | = help: Use `math.pi` -ℹ Safe fix 1 |+import math 1 2 | r = 3.1 # OK 2 3 | @@ -263,7 +253,6 @@ FURB152.py:25:5: FURB152 [*] Replace `3.141592653589793238462643383279` with `ma | = help: Use `math.pi` -ℹ Safe fix 1 |+import math 1 2 | r = 3.1 # OK 2 3 | @@ -289,7 +278,6 @@ FURB152.py:31:5: FURB152 [*] Replace `2.718` with `math.e` | = help: Use `math.e` -ℹ Safe fix 1 |+import math 1 2 | r = 3.1 # OK 2 3 | @@ -315,7 +303,6 @@ FURB152.py:33:5: FURB152 [*] Replace `2.7182` with `math.e` | = help: Use `math.e` -ℹ Safe fix 1 |+import math 1 2 | r = 3.1 # OK 2 3 | @@ -341,7 +328,6 @@ FURB152.py:35:5: FURB152 [*] Replace `2.7183` with `math.e` | = help: Use `math.e` -ℹ Safe fix 1 |+import math 1 2 | r = 3.1 # OK 2 3 | @@ -365,7 +351,6 @@ FURB152.py:45:5: FURB152 [*] Replace `2.7182000000000001` with `math.e` | = help: Use `math.e` -ℹ Safe fix 1 |+import math 1 2 | r = 3.1 # OK 2 3 | @@ -376,5 +361,3 @@ FURB152.py:45:5: FURB152 [*] Replace `2.7182000000000001` with `math.e` 44 45 | 45 |-e = 2.7182000000000001 # FURB152 46 |+e = math.e # FURB152 - - diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB154_FURB154.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB154_FURB154.py.snap index a935e1ae3c4fe..5f8d208fa3bbf 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB154_FURB154.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB154_FURB154.py.snap @@ -11,7 +11,6 @@ FURB154.py:4:5: FURB154 [*] Use of repeated consecutive `global` | = help: Merge `global` statements -ℹ Safe fix 1 1 | # Errors 2 2 | 3 3 | def f1(): @@ -33,7 +32,6 @@ FURB154.py:9:5: FURB154 [*] Use of repeated consecutive `global` | = help: Merge `global` statements -ℹ Safe fix 6 6 | 7 7 | 8 8 | def f3(): @@ -57,7 +55,6 @@ FURB154.py:15:5: FURB154 [*] Use of repeated consecutive `global` | = help: Merge `global` statements -ℹ Safe fix 12 12 | 13 13 | 14 14 | def f4(): @@ -79,7 +76,6 @@ FURB154.py:18:5: FURB154 [*] Use of repeated consecutive `global` | = help: Merge `global` statements -ℹ Safe fix 15 15 | global x 16 16 | global y 17 17 | pass @@ -102,7 +98,6 @@ FURB154.py:26:9: FURB154 [*] Use of repeated consecutive `nonlocal` | = help: Merge `nonlocal` statements -ℹ Safe fix 23 23 | x = y = z = 1 24 24 | 25 25 | def inner(): @@ -126,7 +121,6 @@ FURB154.py:30:9: FURB154 [*] Use of repeated consecutive `nonlocal` | = help: Merge `nonlocal` statements -ℹ Safe fix 27 27 | nonlocal y 28 28 | 29 29 | def inner2(): @@ -150,7 +144,6 @@ FURB154.py:35:9: FURB154 [*] Use of repeated consecutive `nonlocal` | = help: Merge `nonlocal` statements -ℹ Safe fix 32 32 | nonlocal z 33 33 | 34 34 | def inner3(): @@ -172,7 +165,6 @@ FURB154.py:38:9: FURB154 [*] Use of repeated consecutive `nonlocal` | = help: Merge `nonlocal` statements -ℹ Safe fix 35 35 | nonlocal x 36 36 | nonlocal y 37 37 | pass @@ -195,7 +187,6 @@ FURB154.py:46:9: FURB154 [*] Use of repeated consecutive `global` | = help: Merge `global` statements -ℹ Safe fix 43 43 | w = x = y = z = 1 44 44 | 45 45 | def inner(): @@ -219,7 +210,6 @@ FURB154.py:48:9: FURB154 [*] Use of repeated consecutive `nonlocal` | = help: Merge `nonlocal` statements -ℹ Safe fix 45 45 | def inner(): 46 46 | global w 47 47 | global x @@ -241,7 +231,6 @@ FURB154.py:53:9: FURB154 [*] Use of repeated consecutive `nonlocal` | = help: Merge `nonlocal` statements -ℹ Safe fix 50 50 | 51 51 | def inner2(): 52 52 | global x @@ -263,7 +252,6 @@ FURB154.py:58:5: FURB154 [*] Use of repeated consecutive `global` | = help: Merge `global` statements -ℹ Safe fix 55 55 | 56 56 | 57 57 | def f6(): diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB157_FURB157.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB157_FURB157.py.snap index ef8680e3666d0..908e0c3ace646 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB157_FURB157.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB157_FURB157.py.snap @@ -11,7 +11,6 @@ FURB157.py:5:9: FURB157 [*] Verbose expression in `Decimal` constructor | = help: Replace with `0` -ℹ Safe fix 2 2 | from decimal import Decimal 3 3 | 4 4 | # Errors @@ -32,7 +31,6 @@ FURB157.py:6:9: FURB157 [*] Verbose expression in `Decimal` constructor | = help: Replace with `-42` -ℹ Safe fix 3 3 | 4 4 | # Errors 5 5 | Decimal("0") @@ -53,7 +51,6 @@ FURB157.py:7:9: FURB157 [*] Verbose expression in `Decimal` constructor | = help: Replace with `"Infinity"` -ℹ Safe fix 4 4 | # Errors 5 5 | Decimal("0") 6 6 | Decimal("-42") @@ -74,7 +71,6 @@ FURB157.py:8:9: FURB157 [*] Verbose expression in `Decimal` constructor | = help: Replace with `"-Infinity"` -ℹ Safe fix 5 5 | Decimal("0") 6 6 | Decimal("-42") 7 7 | Decimal(float("Infinity")) @@ -95,7 +91,6 @@ FURB157.py:9:9: FURB157 [*] Verbose expression in `Decimal` constructor | = help: Replace with `"inf"` -ℹ Safe fix 6 6 | Decimal("-42") 7 7 | Decimal(float("Infinity")) 8 8 | Decimal(float("-Infinity")) @@ -116,7 +111,6 @@ FURB157.py:10:9: FURB157 [*] Verbose expression in `Decimal` constructor | = help: Replace with `"-inf"` -ℹ Safe fix 7 7 | Decimal(float("Infinity")) 8 8 | Decimal(float("-Infinity")) 9 9 | Decimal(float("inf")) @@ -136,7 +130,6 @@ FURB157.py:11:9: FURB157 [*] Verbose expression in `Decimal` constructor | = help: Replace with `"nan"` -ℹ Safe fix 8 8 | Decimal(float("-Infinity")) 9 9 | Decimal(float("inf")) 10 10 | Decimal(float("-inf")) @@ -157,7 +150,6 @@ FURB157.py:12:17: FURB157 [*] Verbose expression in `Decimal` constructor | = help: Replace with `0` -ℹ Safe fix 9 9 | Decimal(float("inf")) 10 10 | Decimal(float("-inf")) 11 11 | Decimal(float("nan")) diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB161_FURB161.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB161_FURB161.py.snap index 0085558579ae4..a7d017572258e 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB161_FURB161.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB161_FURB161.py.snap @@ -12,7 +12,6 @@ FURB161.py:6:9: FURB161 [*] Use of `bin(x).count('1')` | = help: Replace with `(x).bit_count()` -ℹ Safe fix 3 3 | def ten() -> int: 4 4 | return 10 5 5 | @@ -32,7 +31,6 @@ FURB161.py:7:9: FURB161 [*] Use of `bin(10).count('1')` | = help: Replace with `(10).bit_count()` -ℹ Safe fix 4 4 | return 10 5 5 | 6 6 | count = bin(x).count("1") # FURB161 @@ -53,7 +51,6 @@ FURB161.py:8:9: FURB161 [*] Use of `bin(0b1010).count('1')` | = help: Replace with `0b1010.bit_count()` -ℹ Safe fix 5 5 | 6 6 | count = bin(x).count("1") # FURB161 7 7 | count = bin(10).count("1") # FURB161 @@ -74,7 +71,6 @@ FURB161.py:9:9: FURB161 [*] Use of `bin(0xA).count('1')` | = help: Replace with `0xA.bit_count()` -ℹ Safe fix 6 6 | count = bin(x).count("1") # FURB161 7 7 | count = bin(10).count("1") # FURB161 8 8 | count = bin(0b1010).count("1") # FURB161 @@ -95,7 +91,6 @@ FURB161.py:10:9: FURB161 [*] Use of `bin(0o12).count('1')` | = help: Replace with `0o12.bit_count()` -ℹ Safe fix 7 7 | count = bin(10).count("1") # FURB161 8 8 | count = bin(0b1010).count("1") # FURB161 9 9 | count = bin(0xA).count("1") # FURB161 @@ -116,7 +111,6 @@ FURB161.py:11:9: FURB161 [*] Use of `bin(0x10 + 0x1000).count('1')` | = help: Replace with `(0x10 + 0x1000).bit_count()` -ℹ Safe fix 8 8 | count = bin(0b1010).count("1") # FURB161 9 9 | count = bin(0xA).count("1") # FURB161 10 10 | count = bin(0o12).count("1") # FURB161 @@ -137,7 +131,6 @@ FURB161.py:12:9: FURB161 [*] Use of `bin(ten()).count('1')` | = help: Replace with `ten().bit_count()` -ℹ Safe fix 9 9 | count = bin(0xA).count("1") # FURB161 10 10 | count = bin(0o12).count("1") # FURB161 11 11 | count = bin(0x10 + 0x1000).count("1") # FURB161 @@ -157,7 +150,6 @@ FURB161.py:13:9: FURB161 [*] Use of `bin(10).count('1')` | = help: Replace with `(10).bit_count()` -ℹ Safe fix 10 10 | count = bin(0o12).count("1") # FURB161 11 11 | count = bin(0x10 + 0x1000).count("1") # FURB161 12 12 | count = bin(ten()).count("1") # FURB161 @@ -178,7 +170,6 @@ FURB161.py:14:9: FURB161 [*] Use of `bin("10" "15").count('1')` | = help: Replace with `("10" "15").bit_count()` -ℹ Safe fix 11 11 | count = bin(0x10 + 0x1000).count("1") # FURB161 12 12 | count = bin(ten()).count("1") # FURB161 13 13 | count = bin((10)).count("1") # FURB161 @@ -187,5 +178,3 @@ FURB161.py:14:9: FURB161 [*] Use of `bin("10" "15").count('1')` 15 15 | 16 16 | count = x.bit_count() # OK 17 17 | count = (10).bit_count() # OK - - diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB163_FURB163.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB163_FURB163.py.snap index c305821cc9a85..561395836fab1 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB163_FURB163.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB163_FURB163.py.snap @@ -11,7 +11,6 @@ FURB163.py:4:1: FURB163 [*] Prefer `math.log2(1)` over `math.log` with a redunda | = help: Replace with `math.log2(1)` -ℹ Safe fix 1 1 | import math 2 2 | 3 3 | # Errors @@ -32,7 +31,6 @@ FURB163.py:5:1: FURB163 [*] Prefer `math.log10(1)` over `math.log` with a redund | = help: Replace with `math.log10(1)` -ℹ Safe fix 2 2 | 3 3 | # Errors 4 4 | math.log(1, 2) @@ -53,7 +51,6 @@ FURB163.py:6:1: FURB163 [*] Prefer `math.log(1)` over `math.log` with a redundan | = help: Replace with `math.log(1)` -ℹ Safe fix 3 3 | # Errors 4 4 | math.log(1, 2) 5 5 | math.log(1, 10) @@ -74,7 +71,6 @@ FURB163.py:8:1: FURB163 [*] Prefer `math.log2(foo)` over `math.log` with a redun | = help: Replace with `math.log2(foo)` -ℹ Safe fix 5 5 | math.log(1, 10) 6 6 | math.log(1, math.e) 7 7 | foo = ... @@ -95,7 +91,6 @@ FURB163.py:9:1: FURB163 [*] Prefer `math.log10(foo)` over `math.log` with a redu | = help: Replace with `math.log10(foo)` -ℹ Safe fix 6 6 | math.log(1, math.e) 7 7 | foo = ... 8 8 | math.log(foo, 2) @@ -116,7 +111,6 @@ FURB163.py:10:1: FURB163 [*] Prefer `math.log(foo)` over `math.log` with a redun | = help: Replace with `math.log(foo)` -ℹ Safe fix 7 7 | foo = ... 8 8 | math.log(foo, 2) 9 9 | math.log(foo, 10) @@ -136,7 +130,6 @@ FURB163.py:11:1: FURB163 [*] Prefer `math.log2(1)` over `math.log` with a redund | = help: Replace with `math.log2(1)` -ℹ Safe fix 8 8 | math.log(foo, 2) 9 9 | math.log(foo, 10) 10 10 | math.log(foo, math.e) @@ -157,7 +150,6 @@ FURB163.py:12:1: FURB163 [*] Prefer `math.log10(1)` over `math.log` with a redun | = help: Replace with `math.log10(1)` -ℹ Safe fix 9 9 | math.log(foo, 10) 10 10 | math.log(foo, math.e) 11 11 | math.log(1, 2.0) diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB164_FURB164.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB164_FURB164.py.snap index 04340e219c219..e95c270aa3765 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB164_FURB164.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB164_FURB164.py.snap @@ -11,7 +11,6 @@ FURB164.py:7:5: FURB164 [*] Verbose method `from_float` in `Fraction` constructi | = help: Replace with `Fraction` constructor -ℹ Safe fix 4 4 | import fractions 5 5 | 6 6 | # Errors @@ -32,7 +31,6 @@ FURB164.py:8:5: FURB164 [*] Verbose method `from_float` in `Fraction` constructi | = help: Replace with `Fraction` constructor -ℹ Safe fix 5 5 | 6 6 | # Errors 7 7 | _ = Fraction.from_float(0.1) @@ -53,7 +51,6 @@ FURB164.py:9:5: FURB164 [*] Verbose method `from_float` in `Fraction` constructi | = help: Replace with `Fraction` constructor -ℹ Safe fix 6 6 | # Errors 7 7 | _ = Fraction.from_float(0.1) 8 8 | _ = Fraction.from_float(-0.5) @@ -74,7 +71,6 @@ FURB164.py:10:5: FURB164 [*] Verbose method `from_float` in `Fraction` construct | = help: Replace with `Fraction` constructor -ℹ Safe fix 7 7 | _ = Fraction.from_float(0.1) 8 8 | _ = Fraction.from_float(-0.5) 9 9 | _ = Fraction.from_float(5.0) @@ -95,7 +91,6 @@ FURB164.py:11:5: FURB164 [*] Verbose method `from_decimal` in `Fraction` constru | = help: Replace with `Fraction` constructor -ℹ Safe fix 8 8 | _ = Fraction.from_float(-0.5) 9 9 | _ = Fraction.from_float(5.0) 10 10 | _ = fractions.Fraction.from_float(4.2) @@ -116,7 +111,6 @@ FURB164.py:12:5: FURB164 [*] Verbose method `from_decimal` in `Fraction` constru | = help: Replace with `Fraction` constructor -ℹ Safe fix 9 9 | _ = Fraction.from_float(5.0) 10 10 | _ = fractions.Fraction.from_float(4.2) 11 11 | _ = Fraction.from_decimal(Decimal("4.2")) @@ -137,7 +131,6 @@ FURB164.py:13:5: FURB164 [*] Verbose method `from_decimal` in `Fraction` constru | = help: Replace with `Fraction` constructor -ℹ Safe fix 10 10 | _ = fractions.Fraction.from_float(4.2) 11 11 | _ = Fraction.from_decimal(Decimal("4.2")) 12 12 | _ = Fraction.from_decimal(Decimal("-4.2")) @@ -158,7 +151,6 @@ FURB164.py:13:27: FURB164 [*] Verbose method `from_float` in `Decimal` construct | = help: Replace with `Decimal` constructor -ℹ Safe fix 10 10 | _ = fractions.Fraction.from_float(4.2) 11 11 | _ = Fraction.from_decimal(Decimal("4.2")) 12 12 | _ = Fraction.from_decimal(Decimal("-4.2")) @@ -179,7 +171,6 @@ FURB164.py:14:5: FURB164 [*] Verbose method `from_float` in `Decimal` constructi | = help: Replace with `Decimal` constructor -ℹ Safe fix 11 11 | _ = Fraction.from_decimal(Decimal("4.2")) 12 12 | _ = Fraction.from_decimal(Decimal("-4.2")) 13 13 | _ = Fraction.from_decimal(Decimal.from_float(4.2)) @@ -200,7 +191,6 @@ FURB164.py:15:5: FURB164 [*] Verbose method `from_float` in `Decimal` constructi | = help: Replace with `Decimal` constructor -ℹ Safe fix 12 12 | _ = Fraction.from_decimal(Decimal("-4.2")) 13 13 | _ = Fraction.from_decimal(Decimal.from_float(4.2)) 14 14 | _ = Decimal.from_float(0.1) @@ -221,7 +211,6 @@ FURB164.py:16:5: FURB164 [*] Verbose method `from_float` in `Decimal` constructi | = help: Replace with `Decimal` constructor -ℹ Safe fix 13 13 | _ = Fraction.from_decimal(Decimal.from_float(4.2)) 14 14 | _ = Decimal.from_float(0.1) 15 15 | _ = Decimal.from_float(-0.5) @@ -242,7 +231,6 @@ FURB164.py:17:5: FURB164 [*] Verbose method `from_float` in `Decimal` constructi | = help: Replace with `Decimal` constructor -ℹ Safe fix 14 14 | _ = Decimal.from_float(0.1) 15 15 | _ = Decimal.from_float(-0.5) 16 16 | _ = Decimal.from_float(5.0) @@ -263,7 +251,6 @@ FURB164.py:18:5: FURB164 [*] Verbose method `from_float` in `Decimal` constructi | = help: Replace with `Decimal` constructor -ℹ Safe fix 15 15 | _ = Decimal.from_float(-0.5) 16 16 | _ = Decimal.from_float(5.0) 17 17 | _ = decimal.Decimal.from_float(4.2) @@ -284,7 +271,6 @@ FURB164.py:19:5: FURB164 [*] Verbose method `from_float` in `Decimal` constructi | = help: Replace with `Decimal` constructor -ℹ Safe fix 16 16 | _ = Decimal.from_float(5.0) 17 17 | _ = decimal.Decimal.from_float(4.2) 18 18 | _ = Decimal.from_float(float("inf")) @@ -305,7 +291,6 @@ FURB164.py:20:5: FURB164 [*] Verbose method `from_float` in `Decimal` constructi | = help: Replace with `Decimal` constructor -ℹ Safe fix 17 17 | _ = decimal.Decimal.from_float(4.2) 18 18 | _ = Decimal.from_float(float("inf")) 19 19 | _ = Decimal.from_float(float("-inf")) @@ -325,7 +310,6 @@ FURB164.py:21:5: FURB164 [*] Verbose method `from_float` in `Decimal` constructi | = help: Replace with `Decimal` constructor -ℹ Safe fix 18 18 | _ = Decimal.from_float(float("inf")) 19 19 | _ = Decimal.from_float(float("-inf")) 20 20 | _ = Decimal.from_float(float("Infinity")) @@ -346,7 +330,6 @@ FURB164.py:22:5: FURB164 [*] Verbose method `from_float` in `Decimal` constructi | = help: Replace with `Decimal` constructor -ℹ Safe fix 19 19 | _ = Decimal.from_float(float("-inf")) 20 20 | _ = Decimal.from_float(float("Infinity")) 21 21 | _ = Decimal.from_float(float("-Infinity")) diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB166_FURB166.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB166_FURB166.py.snap index c78dbdb22cad2..e52a7cc58cdaa 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB166_FURB166.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB166_FURB166.py.snap @@ -12,14 +12,6 @@ FURB166.py:3:5: FURB166 [*] Use of `int` with explicit `base=2` after removing p | = help: Replace with `base=0` -ℹ Unsafe fix -1 1 | # Errors -2 2 | -3 |-_ = int("0b1010"[2:], 2) - 3 |+_ = int("0b1010", 0) -4 4 | _ = int("0o777"[2:], 8) -5 5 | _ = int("0xFFFF"[2:], 16) -6 6 | FURB166.py:4:5: FURB166 [*] Use of `int` with explicit `base=8` after removing prefix | @@ -30,15 +22,6 @@ FURB166.py:4:5: FURB166 [*] Use of `int` with explicit `base=8` after removing p | = help: Replace with `base=0` -ℹ Unsafe fix -1 1 | # Errors -2 2 | -3 3 | _ = int("0b1010"[2:], 2) -4 |-_ = int("0o777"[2:], 8) - 4 |+_ = int("0o777", 0) -5 5 | _ = int("0xFFFF"[2:], 16) -6 6 | -7 7 | b = "0b11" FURB166.py:5:5: FURB166 [*] Use of `int` with explicit `base=16` after removing prefix | @@ -51,15 +34,6 @@ FURB166.py:5:5: FURB166 [*] Use of `int` with explicit `base=16` after removing | = help: Replace with `base=0` -ℹ Unsafe fix -2 2 | -3 3 | _ = int("0b1010"[2:], 2) -4 4 | _ = int("0o777"[2:], 8) -5 |-_ = int("0xFFFF"[2:], 16) - 5 |+_ = int("0xFFFF", 0) -6 6 | -7 7 | b = "0b11" -8 8 | _ = int(b[2:], 2) FURB166.py:8:5: FURB166 [*] Use of `int` with explicit `base=2` after removing prefix | @@ -71,15 +45,6 @@ FURB166.py:8:5: FURB166 [*] Use of `int` with explicit `base=2` after removing p | = help: Replace with `base=0` -ℹ Unsafe fix -5 5 | _ = int("0xFFFF"[2:], 16) -6 6 | -7 7 | b = "0b11" -8 |-_ = int(b[2:], 2) - 8 |+_ = int(b, 0) -9 9 | -10 10 | _ = int("0xFFFF"[2:], base=16) -11 11 | FURB166.py:10:5: FURB166 [*] Use of `int` with explicit `base=16` after removing prefix | @@ -92,15 +57,6 @@ FURB166.py:10:5: FURB166 [*] Use of `int` with explicit `base=16` after removing | = help: Replace with `base=0` -ℹ Unsafe fix -7 7 | b = "0b11" -8 8 | _ = int(b[2:], 2) -9 9 | -10 |-_ = int("0xFFFF"[2:], base=16) - 10 |+_ = int("0xFFFF", base=0) -11 11 | -12 12 | _ = int(b"0xFFFF"[2:], 16) -13 13 | FURB166.py:12:5: FURB166 [*] Use of `int` with explicit `base=16` after removing prefix | @@ -111,15 +67,6 @@ FURB166.py:12:5: FURB166 [*] Use of `int` with explicit `base=16` after removing | = help: Replace with `base=0` -ℹ Unsafe fix -9 9 | -10 10 | _ = int("0xFFFF"[2:], base=16) -11 11 | -12 |-_ = int(b"0xFFFF"[2:], 16) - 12 |+_ = int(b"0xFFFF", 0) -13 13 | -14 14 | -15 15 | def get_str(): FURB166.py:19:5: FURB166 [*] Use of `int` with explicit `base=16` after removing prefix | @@ -129,13 +76,3 @@ FURB166.py:19:5: FURB166 [*] Use of `int` with explicit `base=16` after removing 21 | # OK | = help: Replace with `base=0` - -ℹ Unsafe fix -16 16 | return "0xFFF" -17 17 | -18 18 | -19 |-_ = int(get_str()[2:], 16) - 19 |+_ = int(get_str(), 0) -20 20 | -21 21 | # OK -22 22 | diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB167_FURB167.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB167_FURB167.py.snap index a95fff1e098b8..8340a03ba14d8 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB167_FURB167.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB167_FURB167.py.snap @@ -10,7 +10,6 @@ FURB167.py:13:42: FURB167 [*] Use of regular expression alias `re.I` | = help: Replace with `re.IGNORECASE` -ℹ Safe fix 10 10 | import re 11 11 | 12 12 | # FURB167 @@ -29,7 +28,6 @@ FURB167.py:21:39: FURB167 [*] Use of regular expression alias `re.I` | = help: Replace with `re.IGNORECASE` -ℹ Safe fix 1 |+import re 1 2 | def func(): 2 3 | import re @@ -41,5 +39,3 @@ FURB167.py:21:39: FURB167 [*] Use of regular expression alias `re.I` 21 |- if match("^hello", "hello world", I): 22 |+ if match("^hello", "hello world", re.IGNORECASE): 22 23 | pass - - diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB168_FURB168.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB168_FURB168.py.snap index 88aa3efb4ea4a..add40e9b1fdb4 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB168_FURB168.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB168_FURB168.py.snap @@ -11,7 +11,6 @@ FURB168.py:5:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if a | = help: Replace with `is` operator -ℹ Safe fix 2 2 | 3 3 | # Errors. 4 4 | @@ -31,7 +30,6 @@ FURB168.py:8:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if a | = help: Replace with `is` operator -ℹ Safe fix 5 5 | if isinstance(foo, type(None)): 6 6 | pass 7 7 | @@ -51,7 +49,6 @@ FURB168.py:11:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if | = help: Replace with `is` operator -ℹ Safe fix 8 8 | if isinstance(foo, (type(None))): 9 9 | pass 10 10 | @@ -71,7 +68,6 @@ FURB168.py:14:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if | = help: Replace with `is` operator -ℹ Safe fix 11 11 | if isinstance(foo, (type(None), type(None), type(None))): 12 12 | pass 13 13 | @@ -91,7 +87,6 @@ FURB168.py:17:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if | = help: Replace with `is` operator -ℹ Safe fix 14 14 | if isinstance(foo, None | None): 15 15 | pass 16 16 | @@ -111,7 +106,6 @@ FURB168.py:20:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if | = help: Replace with `is` operator -ℹ Safe fix 17 17 | if isinstance(foo, (None | None)): 18 18 | pass 19 19 | @@ -131,7 +125,6 @@ FURB168.py:23:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if | = help: Replace with `is` operator -ℹ Safe fix 20 20 | if isinstance(foo, None | type(None)): 21 21 | pass 22 22 | @@ -150,7 +143,6 @@ FURB168.py:27:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if | = help: Replace with `is` operator -ℹ Safe fix 24 24 | pass 25 25 | 26 26 | # A bit contrived, but is both technically valid and equivalent to the above. @@ -158,6 +150,4 @@ FURB168.py:27:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if 27 |+if foo is None: 28 28 | pass 29 29 | -30 30 | - - +30 30 | diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB169_FURB169.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB169_FURB169.py.snap index ee9ee14f36ef1..ba378b0d46255 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB169_FURB169.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB169_FURB169.py.snap @@ -12,7 +12,6 @@ FURB169.py:5:1: FURB169 [*] Compare the identities of `foo` and `None` instead o | = help: Replace with `foo is None` -ℹ Safe fix 2 2 | 3 3 | # Error. 4 4 | @@ -33,7 +32,6 @@ FURB169.py:7:1: FURB169 [*] Compare the identities of `foo` and `None` instead o | = help: Replace with `foo is None` -ℹ Safe fix 4 4 | 5 5 | type(foo) is type(None) 6 6 | @@ -54,7 +52,6 @@ FURB169.py:9:1: FURB169 [*] Compare the identities of `None` and `None` instead | = help: Replace with `None is None` -ℹ Safe fix 6 6 | 7 7 | type(None) is type(foo) 8 8 | @@ -75,7 +72,6 @@ FURB169.py:11:1: FURB169 [*] Compare the identities of `foo` and `None` instead | = help: Replace with `foo is not None` -ℹ Safe fix 8 8 | 9 9 | type(None) is type(None) 10 10 | @@ -96,7 +92,6 @@ FURB169.py:13:1: FURB169 [*] Compare the identities of `foo` and `None` instead | = help: Replace with `foo is not None` -ℹ Safe fix 10 10 | 11 11 | type(foo) is not type(None) 12 12 | @@ -117,7 +112,6 @@ FURB169.py:15:1: FURB169 [*] Compare the identities of `None` and `None` instead | = help: Replace with `None is not None` -ℹ Safe fix 12 12 | 13 13 | type(None) is not type(foo) 14 14 | @@ -138,7 +132,6 @@ FURB169.py:17:1: FURB169 [*] Compare the identities of `foo` and `None` instead | = help: Replace with `foo is None` -ℹ Safe fix 14 14 | 15 15 | type(None) is not type(None) 16 16 | @@ -159,7 +152,6 @@ FURB169.py:19:1: FURB169 [*] Compare the identities of `foo` and `None` instead | = help: Replace with `foo is None` -ℹ Safe fix 16 16 | 17 17 | type(foo) == type(None) 18 18 | @@ -180,7 +172,6 @@ FURB169.py:21:1: FURB169 [*] Compare the identities of `None` and `None` instead | = help: Replace with `None is None` -ℹ Safe fix 18 18 | 19 19 | type(None) == type(foo) 20 20 | @@ -201,7 +192,6 @@ FURB169.py:23:1: FURB169 [*] Compare the identities of `foo` and `None` instead | = help: Replace with `foo is not None` -ℹ Safe fix 20 20 | 21 21 | type(None) == type(None) 22 22 | @@ -222,7 +212,6 @@ FURB169.py:25:1: FURB169 [*] Compare the identities of `foo` and `None` instead | = help: Replace with `foo is not None` -ℹ Safe fix 22 22 | 23 23 | type(foo) != type(None) 24 24 | @@ -243,7 +232,6 @@ FURB169.py:27:1: FURB169 [*] Compare the identities of `None` and `None` instead | = help: Replace with `None is not None` -ℹ Safe fix 24 24 | 25 25 | type(None) != type(foo) 26 26 | @@ -251,6 +239,4 @@ FURB169.py:27:1: FURB169 [*] Compare the identities of `None` and `None` instead 27 |+None is not None 28 28 | 29 29 | # Ok. -30 30 | - - +30 30 | diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB171_FURB171.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB171_FURB171.py.snap index 2b29e1e40aa51..c6cbb104b9674 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB171_FURB171.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB171_FURB171.py.snap @@ -11,7 +11,6 @@ FURB171.py:3:4: FURB171 [*] Membership test against single-item container | = help: Convert to equality test -ℹ Safe fix 1 1 | # Errors. 2 2 | 3 |-if 1 in (1,): @@ -30,7 +29,6 @@ FURB171.py:6:4: FURB171 [*] Membership test against single-item container | = help: Convert to equality test -ℹ Safe fix 3 3 | if 1 in (1,): 4 4 | print("Single-element tuple") 5 5 | @@ -50,7 +48,6 @@ FURB171.py:9:4: FURB171 [*] Membership test against single-item container | = help: Convert to equality test -ℹ Safe fix 6 6 | if 1 in [1]: 7 7 | print("Single-element list") 8 8 | @@ -70,7 +67,6 @@ FURB171.py:12:4: FURB171 [*] Membership test against single-item container | = help: Convert to equality test -ℹ Safe fix 9 9 | if 1 in {1}: 10 10 | print("Single-element set") 11 11 | @@ -90,7 +86,6 @@ FURB171.py:15:4: FURB171 [*] Membership test against single-item container | = help: Convert to inequality test -ℹ Safe fix 12 12 | if "a" in "a": 13 13 | print("Single-element string") 14 14 | @@ -110,7 +105,6 @@ FURB171.py:18:8: FURB171 [*] Membership test against single-item container | = help: Convert to equality test -ℹ Safe fix 15 15 | if 1 not in (1,): 16 16 | print("Check `not in` membership test") 17 17 | @@ -119,5 +113,3 @@ FURB171.py:18:8: FURB171 [*] Membership test against single-item container 19 19 | print("Check the negated membership test") 20 20 | 21 21 | # Non-errors. - - diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB180_FURB180.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB180_FURB180.py.snap index 0d683880efd9d..d77cee1198248 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB180_FURB180.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB180_FURB180.py.snap @@ -12,7 +12,6 @@ FURB180.py:7:10: FURB180 [*] Use of `metaclass=abc.ABCMeta` to define abstract b | = help: Replace with `abc.ABC` -ℹ Safe fix 4 4 | 5 5 | # Errors 6 6 | @@ -31,7 +30,6 @@ FURB180.py:12:10: FURB180 [*] Use of `metaclass=abc.ABCMeta` to define abstract | = help: Replace with `abc.ABC` -ℹ Safe fix 9 9 | def foo(self): pass 10 10 | 11 11 | @@ -50,7 +48,6 @@ FURB180.py:26:18: FURB180 [*] Use of `metaclass=abc.ABCMeta` to define abstract | = help: Replace with `abc.ABC` -ℹ Safe fix 23 23 | pass 24 24 | 25 25 | @@ -68,7 +65,6 @@ FURB180.py:31:34: FURB180 [*] Use of `metaclass=abc.ABCMeta` to define abstract | = help: Replace with `abc.ABC` -ℹ Safe fix 28 28 | def foo(self): pass 29 29 | 30 30 | @@ -76,6 +72,4 @@ FURB180.py:31:34: FURB180 [*] Use of `metaclass=abc.ABCMeta` to define abstract 31 |+class A3(B0, abc.ABC, before_metaclass=1): 32 32 | pass 33 33 | -34 34 | - - +34 34 | diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB181_FURB181.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB181_FURB181.py.snap index cca7645c90adf..ae1c884dc5171 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB181_FURB181.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB181_FURB181.py.snap @@ -12,15 +12,6 @@ FURB181.py:19:1: FURB181 [*] Use of hashlib's `.digest().hex()` | = help: Replace with `.hexdigest()` -ℹ Unsafe fix -16 16 | -17 17 | # these will match -18 18 | -19 |-blake2b().digest().hex() - 19 |+blake2b().hexdigest() -20 20 | blake2s().digest().hex() -21 21 | md5().digest().hex() -22 22 | sha1().digest().hex() FURB181.py:20:1: FURB181 [*] Use of hashlib's `.digest().hex()` | @@ -32,15 +23,6 @@ FURB181.py:20:1: FURB181 [*] Use of hashlib's `.digest().hex()` | = help: Replace with `.hexdigest()` -ℹ Unsafe fix -17 17 | # these will match -18 18 | -19 19 | blake2b().digest().hex() -20 |-blake2s().digest().hex() - 20 |+blake2s().hexdigest() -21 21 | md5().digest().hex() -22 22 | sha1().digest().hex() -23 23 | sha224().digest().hex() FURB181.py:21:1: FURB181 [*] Use of hashlib's `.digest().hex()` | @@ -53,15 +35,6 @@ FURB181.py:21:1: FURB181 [*] Use of hashlib's `.digest().hex()` | = help: Replace with `.hexdigest()` -ℹ Unsafe fix -18 18 | -19 19 | blake2b().digest().hex() -20 20 | blake2s().digest().hex() -21 |-md5().digest().hex() - 21 |+md5().hexdigest() -22 22 | sha1().digest().hex() -23 23 | sha224().digest().hex() -24 24 | sha256().digest().hex() FURB181.py:22:1: FURB181 [*] Use of hashlib's `.digest().hex()` | @@ -74,15 +47,6 @@ FURB181.py:22:1: FURB181 [*] Use of hashlib's `.digest().hex()` | = help: Replace with `.hexdigest()` -ℹ Unsafe fix -19 19 | blake2b().digest().hex() -20 20 | blake2s().digest().hex() -21 21 | md5().digest().hex() -22 |-sha1().digest().hex() - 22 |+sha1().hexdigest() -23 23 | sha224().digest().hex() -24 24 | sha256().digest().hex() -25 25 | sha384().digest().hex() FURB181.py:23:1: FURB181 [*] Use of hashlib's `.digest().hex()` | @@ -95,15 +59,6 @@ FURB181.py:23:1: FURB181 [*] Use of hashlib's `.digest().hex()` | = help: Replace with `.hexdigest()` -ℹ Unsafe fix -20 20 | blake2s().digest().hex() -21 21 | md5().digest().hex() -22 22 | sha1().digest().hex() -23 |-sha224().digest().hex() - 23 |+sha224().hexdigest() -24 24 | sha256().digest().hex() -25 25 | sha384().digest().hex() -26 26 | sha3_224().digest().hex() FURB181.py:24:1: FURB181 [*] Use of hashlib's `.digest().hex()` | @@ -116,15 +71,6 @@ FURB181.py:24:1: FURB181 [*] Use of hashlib's `.digest().hex()` | = help: Replace with `.hexdigest()` -ℹ Unsafe fix -21 21 | md5().digest().hex() -22 22 | sha1().digest().hex() -23 23 | sha224().digest().hex() -24 |-sha256().digest().hex() - 24 |+sha256().hexdigest() -25 25 | sha384().digest().hex() -26 26 | sha3_224().digest().hex() -27 27 | sha3_256().digest().hex() FURB181.py:25:1: FURB181 [*] Use of hashlib's `.digest().hex()` | @@ -137,15 +83,6 @@ FURB181.py:25:1: FURB181 [*] Use of hashlib's `.digest().hex()` | = help: Replace with `.hexdigest()` -ℹ Unsafe fix -22 22 | sha1().digest().hex() -23 23 | sha224().digest().hex() -24 24 | sha256().digest().hex() -25 |-sha384().digest().hex() - 25 |+sha384().hexdigest() -26 26 | sha3_224().digest().hex() -27 27 | sha3_256().digest().hex() -28 28 | sha3_384().digest().hex() FURB181.py:26:1: FURB181 [*] Use of hashlib's `.digest().hex()` | @@ -158,15 +95,6 @@ FURB181.py:26:1: FURB181 [*] Use of hashlib's `.digest().hex()` | = help: Replace with `.hexdigest()` -ℹ Unsafe fix -23 23 | sha224().digest().hex() -24 24 | sha256().digest().hex() -25 25 | sha384().digest().hex() -26 |-sha3_224().digest().hex() - 26 |+sha3_224().hexdigest() -27 27 | sha3_256().digest().hex() -28 28 | sha3_384().digest().hex() -29 29 | sha3_512().digest().hex() FURB181.py:27:1: FURB181 [*] Use of hashlib's `.digest().hex()` | @@ -179,15 +107,6 @@ FURB181.py:27:1: FURB181 [*] Use of hashlib's `.digest().hex()` | = help: Replace with `.hexdigest()` -ℹ Unsafe fix -24 24 | sha256().digest().hex() -25 25 | sha384().digest().hex() -26 26 | sha3_224().digest().hex() -27 |-sha3_256().digest().hex() - 27 |+sha3_256().hexdigest() -28 28 | sha3_384().digest().hex() -29 29 | sha3_512().digest().hex() -30 30 | sha512().digest().hex() FURB181.py:28:1: FURB181 [*] Use of hashlib's `.digest().hex()` | @@ -200,15 +119,6 @@ FURB181.py:28:1: FURB181 [*] Use of hashlib's `.digest().hex()` | = help: Replace with `.hexdigest()` -ℹ Unsafe fix -25 25 | sha384().digest().hex() -26 26 | sha3_224().digest().hex() -27 27 | sha3_256().digest().hex() -28 |-sha3_384().digest().hex() - 28 |+sha3_384().hexdigest() -29 29 | sha3_512().digest().hex() -30 30 | sha512().digest().hex() -31 31 | shake_128().digest(10).hex() FURB181.py:29:1: FURB181 [*] Use of hashlib's `.digest().hex()` | @@ -221,15 +131,6 @@ FURB181.py:29:1: FURB181 [*] Use of hashlib's `.digest().hex()` | = help: Replace with `.hexdigest()` -ℹ Unsafe fix -26 26 | sha3_224().digest().hex() -27 27 | sha3_256().digest().hex() -28 28 | sha3_384().digest().hex() -29 |-sha3_512().digest().hex() - 29 |+sha3_512().hexdigest() -30 30 | sha512().digest().hex() -31 31 | shake_128().digest(10).hex() -32 32 | shake_256().digest(10).hex() FURB181.py:30:1: FURB181 [*] Use of hashlib's `.digest().hex()` | @@ -242,15 +143,6 @@ FURB181.py:30:1: FURB181 [*] Use of hashlib's `.digest().hex()` | = help: Replace with `.hexdigest()` -ℹ Unsafe fix -27 27 | sha3_256().digest().hex() -28 28 | sha3_384().digest().hex() -29 29 | sha3_512().digest().hex() -30 |-sha512().digest().hex() - 30 |+sha512().hexdigest() -31 31 | shake_128().digest(10).hex() -32 32 | shake_256().digest(10).hex() -33 33 | FURB181.py:31:1: FURB181 Use of hashlib's `.digest().hex()` | @@ -284,15 +176,6 @@ FURB181.py:34:1: FURB181 [*] Use of hashlib's `.digest().hex()` | = help: Replace with `.hexdigest()` -ℹ Unsafe fix -31 31 | shake_128().digest(10).hex() -32 32 | shake_256().digest(10).hex() -33 33 | -34 |-hashlib.sha256().digest().hex() - 34 |+hashlib.sha256().hexdigest() -35 35 | -36 36 | sha256(b"text").digest().hex() -37 37 | FURB181.py:36:1: FURB181 [*] Use of hashlib's `.digest().hex()` | @@ -305,15 +188,6 @@ FURB181.py:36:1: FURB181 [*] Use of hashlib's `.digest().hex()` | = help: Replace with `.hexdigest()` -ℹ Unsafe fix -33 33 | -34 34 | hashlib.sha256().digest().hex() -35 35 | -36 |-sha256(b"text").digest().hex() - 36 |+sha256(b"text").hexdigest() -37 37 | -38 38 | hash_algo().digest().hex() -39 39 | FURB181.py:38:1: FURB181 [*] Use of hashlib's `.digest().hex()` | @@ -325,15 +199,3 @@ FURB181.py:38:1: FURB181 [*] Use of hashlib's `.digest().hex()` 40 | # not yet supported | = help: Replace with `.hexdigest()` - -ℹ Unsafe fix -35 35 | -36 36 | sha256(b"text").digest().hex() -37 37 | -38 |-hash_algo().digest().hex() - 38 |+hash_algo().hexdigest() -39 39 | -40 40 | # not yet supported -41 41 | h = sha256() - - diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB187_FURB187.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB187_FURB187.py.snap index e4d08fd9eefbc..42ae0f3b79c5d 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB187_FURB187.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB187_FURB187.py.snap @@ -10,15 +10,6 @@ FURB187.py:6:5: FURB187 [*] Use of assignment of `reversed` on list `l` | = help: Replace with `l.reverse()` -ℹ Unsafe fix -3 3 | -4 4 | def a(): -5 5 | l = [] -6 |- l = reversed(l) - 6 |+ l.reverse() -7 7 | -8 8 | -9 9 | def b(): FURB187.py:11:5: FURB187 [*] Use of assignment of `reversed` on list `l` | @@ -29,15 +20,6 @@ FURB187.py:11:5: FURB187 [*] Use of assignment of `reversed` on list `l` | = help: Replace with `l.reverse()` -ℹ Unsafe fix -8 8 | -9 9 | def b(): -10 10 | l = [] -11 |- l = list(reversed(l)) - 11 |+ l.reverse() -12 12 | -13 13 | -14 14 | def c(): FURB187.py:16:5: FURB187 [*] Use of assignment of `reversed` on list `l` | @@ -47,13 +29,3 @@ FURB187.py:16:5: FURB187 [*] Use of assignment of `reversed` on list `l` | ^^^^^^^^^^^ FURB187 | = help: Replace with `l.reverse()` - -ℹ Unsafe fix -13 13 | -14 14 | def c(): -15 15 | l = [] -16 |- l = l[::-1] - 16 |+ l.reverse() -17 17 | -18 18 | -19 19 | # False negative diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB192_FURB192.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB192_FURB192.py.snap index 2d962a82b9581..35c64f4df8f63 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB192_FURB192.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB192_FURB192.py.snap @@ -12,7 +12,6 @@ FURB192.py:3:1: FURB192 [*] Prefer `min` over `sorted()` to compute the minimum | = help: Replace with `min` -ℹ Safe fix 1 1 | # Errors 2 2 | 3 |-sorted(l)[0] @@ -32,7 +31,6 @@ FURB192.py:5:1: FURB192 [*] Prefer `max` over `sorted()` to compute the maximum | = help: Replace with `max` -ℹ Safe fix 2 2 | 3 3 | sorted(l)[0] 4 4 | @@ -53,7 +51,6 @@ FURB192.py:7:1: FURB192 [*] Prefer `max` over `sorted()` to compute the maximum | = help: Replace with `max` -ℹ Safe fix 4 4 | 5 5 | sorted(l)[-1] 6 6 | @@ -74,7 +71,6 @@ FURB192.py:9:1: FURB192 [*] Prefer `min` over `sorted()` to compute the minimum | = help: Replace with `min` -ℹ Safe fix 6 6 | 7 7 | sorted(l, reverse=False)[-1] 8 8 | @@ -95,7 +91,6 @@ FURB192.py:11:1: FURB192 [*] Prefer `min` over `sorted()` to compute the minimum | = help: Replace with `min` -ℹ Safe fix 8 8 | 9 9 | sorted(l, key=lambda x: x)[0] 10 10 | @@ -116,7 +111,6 @@ FURB192.py:13:1: FURB192 [*] Prefer `min` over `sorted()` to compute the minimum | = help: Replace with `min` -ℹ Safe fix 10 10 | 11 11 | sorted(l, key=key_fn)[0] 12 12 | @@ -137,15 +131,6 @@ FURB192.py:17:1: FURB192 [*] Prefer `min` over `sorted()` to compute the minimum | = help: Replace with `min` -ℹ Unsafe fix -14 14 | -15 15 | # Unsafe -16 16 | -17 |-sorted(l, key=key_fn, reverse=True)[-1] - 17 |+min(l, key=key_fn) -18 18 | -19 19 | sorted(l, reverse=True)[0] -20 20 | FURB192.py:19:1: FURB192 [*] Prefer `max` over `sorted()` to compute the maximum value in a sequence | @@ -158,15 +143,6 @@ FURB192.py:19:1: FURB192 [*] Prefer `max` over `sorted()` to compute the maximum | = help: Replace with `max` -ℹ Unsafe fix -16 16 | -17 17 | sorted(l, key=key_fn, reverse=True)[-1] -18 18 | -19 |-sorted(l, reverse=True)[0] - 19 |+max(l) -20 20 | -21 21 | sorted(l, reverse=True)[-1] -22 22 | FURB192.py:21:1: FURB192 [*] Prefer `min` over `sorted()` to compute the minimum value in a sequence | @@ -178,13 +154,3 @@ FURB192.py:21:1: FURB192 [*] Prefer `min` over `sorted()` to compute the minimum 23 | # Non-errors | = help: Replace with `min` - -ℹ Unsafe fix -18 18 | -19 19 | sorted(l, reverse=True)[0] -20 20 | -21 |-sorted(l, reverse=True)[-1] - 21 |+min(l) -22 22 | -23 23 | # Non-errors -24 24 | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__PY39_RUF013_RUF013_0.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__PY39_RUF013_RUF013_0.py.snap index 096eceb46b23a..c70c99d43794b 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__PY39_RUF013_RUF013_0.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__PY39_RUF013_RUF013_0.py.snap @@ -9,15 +9,6 @@ RUF013_0.py:20:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `Optional[T]` -ℹ Unsafe fix -17 17 | pass -18 18 | -19 19 | -20 |-def f(arg: int = None): # RUF013 - 20 |+def f(arg: Optional[int] = None): # RUF013 -21 21 | pass -22 22 | -23 23 | RUF013_0.py:24:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -27,15 +18,6 @@ RUF013_0.py:24:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `Optional[T]` -ℹ Unsafe fix -21 21 | pass -22 22 | -23 23 | -24 |-def f(arg: str = None): # RUF013 - 24 |+def f(arg: Optional[str] = None): # RUF013 -25 25 | pass -26 26 | -27 27 | RUF013_0.py:28:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -45,15 +27,6 @@ RUF013_0.py:28:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `Optional[T]` -ℹ Unsafe fix -25 25 | pass -26 26 | -27 27 | -28 |-def f(arg: Tuple[str] = None): # RUF013 - 28 |+def f(arg: Optional[Tuple[str]] = None): # RUF013 -29 29 | pass -30 30 | -31 31 | RUF013_0.py:58:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -63,15 +36,6 @@ RUF013_0.py:58:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `Optional[T]` -ℹ Unsafe fix -55 55 | pass -56 56 | -57 57 | -58 |-def f(arg: Union = None): # RUF013 - 58 |+def f(arg: Optional[Union] = None): # RUF013 -59 59 | pass -60 60 | -61 61 | RUF013_0.py:62:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -81,15 +45,6 @@ RUF013_0.py:62:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `Optional[T]` -ℹ Unsafe fix -59 59 | pass -60 60 | -61 61 | -62 |-def f(arg: Union[int] = None): # RUF013 - 62 |+def f(arg: Optional[Union[int]] = None): # RUF013 -63 63 | pass -64 64 | -65 65 | RUF013_0.py:66:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -99,15 +54,6 @@ RUF013_0.py:66:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `Optional[T]` -ℹ Unsafe fix -63 63 | pass -64 64 | -65 65 | -66 |-def f(arg: Union[int, str] = None): # RUF013 - 66 |+def f(arg: Optional[Union[int, str]] = None): # RUF013 -67 67 | pass -68 68 | -69 69 | RUF013_0.py:85:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -117,15 +63,6 @@ RUF013_0.py:85:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `Optional[T]` -ℹ Unsafe fix -82 82 | pass -83 83 | -84 84 | -85 |-def f(arg: int | float = None): # RUF013 - 85 |+def f(arg: Optional[int | float] = None): # RUF013 -86 86 | pass -87 87 | -88 88 | RUF013_0.py:89:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -135,15 +72,6 @@ RUF013_0.py:89:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `Optional[T]` -ℹ Unsafe fix -86 86 | pass -87 87 | -88 88 | -89 |-def f(arg: int | float | str | bytes = None): # RUF013 - 89 |+def f(arg: Optional[int | float | str | bytes] = None): # RUF013 -90 90 | pass -91 91 | -92 92 | RUF013_0.py:108:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -153,15 +81,6 @@ RUF013_0.py:108:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `Optional[T]` -ℹ Unsafe fix -105 105 | pass -106 106 | -107 107 | -108 |-def f(arg: Literal[1] = None): # RUF013 - 108 |+def f(arg: Optional[Literal[1]] = None): # RUF013 -109 109 | pass -110 110 | -111 111 | RUF013_0.py:112:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -171,15 +90,6 @@ RUF013_0.py:112:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `Optional[T]` -ℹ Unsafe fix -109 109 | pass -110 110 | -111 111 | -112 |-def f(arg: Literal[1, "foo"] = None): # RUF013 - 112 |+def f(arg: Optional[Literal[1, "foo"]] = None): # RUF013 -113 113 | pass -114 114 | -115 115 | RUF013_0.py:131:22: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -189,15 +99,6 @@ RUF013_0.py:131:22: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `Optional[T]` -ℹ Unsafe fix -128 128 | pass -129 129 | -130 130 | -131 |-def f(arg: Annotated[int, ...] = None): # RUF013 - 131 |+def f(arg: Annotated[Optional[int], ...] = None): # RUF013 -132 132 | pass -133 133 | -134 134 | RUF013_0.py:135:32: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -207,15 +108,6 @@ RUF013_0.py:135:32: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `Optional[T]` -ℹ Unsafe fix -132 132 | pass -133 133 | -134 134 | -135 |-def f(arg: Annotated[Annotated[int | str, ...], ...] = None): # RUF013 - 135 |+def f(arg: Annotated[Annotated[Optional[int | str], ...], ...] = None): # RUF013 -136 136 | pass -137 137 | -138 138 | RUF013_0.py:151:11: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -227,15 +119,6 @@ RUF013_0.py:151:11: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `Optional[T]` -ℹ Unsafe fix -148 148 | -149 149 | -150 150 | def f( -151 |- arg1: int = None, # RUF013 - 151 |+ arg1: Optional[int] = None, # RUF013 -152 152 | arg2: Union[int, float] = None, # RUF013 -153 153 | arg3: Literal[1, 2, 3] = None, # RUF013 -154 154 | ): RUF013_0.py:152:11: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -248,15 +131,6 @@ RUF013_0.py:152:11: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `Optional[T]` -ℹ Unsafe fix -149 149 | -150 150 | def f( -151 151 | arg1: int = None, # RUF013 -152 |- arg2: Union[int, float] = None, # RUF013 - 152 |+ arg2: Optional[Union[int, float]] = None, # RUF013 -153 153 | arg3: Literal[1, 2, 3] = None, # RUF013 -154 154 | ): -155 155 | pass RUF013_0.py:153:11: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -269,15 +143,6 @@ RUF013_0.py:153:11: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `Optional[T]` -ℹ Unsafe fix -150 150 | def f( -151 151 | arg1: int = None, # RUF013 -152 152 | arg2: Union[int, float] = None, # RUF013 -153 |- arg3: Literal[1, 2, 3] = None, # RUF013 - 153 |+ arg3: Optional[Literal[1, 2, 3]] = None, # RUF013 -154 154 | ): -155 155 | pass -156 156 | RUF013_0.py:181:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -287,15 +152,6 @@ RUF013_0.py:181:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `Optional[T]` -ℹ Unsafe fix -178 178 | pass -179 179 | -180 180 | -181 |-def f(arg: Union[Annotated[int, ...], Union[str, bytes]] = None): # RUF013 - 181 |+def f(arg: Optional[Union[Annotated[int, ...], Union[str, bytes]]] = None): # RUF013 -182 182 | pass -183 183 | -184 184 | RUF013_0.py:188:13: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -305,15 +161,6 @@ RUF013_0.py:188:13: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `Optional[T]` -ℹ Unsafe fix -185 185 | # Quoted -186 186 | -187 187 | -188 |-def f(arg: "int" = None): # RUF013 - 188 |+def f(arg: "Optional[int]" = None): # RUF013 -189 189 | pass -190 190 | -191 191 | RUF013_0.py:192:13: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -323,15 +170,6 @@ RUF013_0.py:192:13: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `Optional[T]` -ℹ Unsafe fix -189 189 | pass -190 190 | -191 191 | -192 |-def f(arg: "str" = None): # RUF013 - 192 |+def f(arg: "Optional[str]" = None): # RUF013 -193 193 | pass -194 194 | -195 195 | RUF013_0.py:196:12: RUF013 PEP 484 prohibits implicit `Optional` | @@ -348,13 +186,3 @@ RUF013_0.py:204:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 205 | pass | = help: Convert to `Optional[T]` - -ℹ Unsafe fix -201 201 | pass -202 202 | -203 203 | -204 |-def f(arg: Union["int", "str"] = None): # RUF013 - 204 |+def f(arg: Optional[Union["int", "str"]] = None): # RUF013 -205 205 | pass -206 206 | -207 207 | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__PY39_RUF013_RUF013_1.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__PY39_RUF013_RUF013_1.py.snap index b15b7e14094f6..af26e32988c22 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__PY39_RUF013_RUF013_1.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__PY39_RUF013_RUF013_1.py.snap @@ -8,12 +8,3 @@ RUF013_1.py:4:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 5 | pass | = help: Convert to `Optional[T]` - -ℹ Unsafe fix -1 1 | # No `typing.Optional` import - 2 |+from typing import Optional -2 3 | -3 4 | -4 |-def f(arg: int = None): # RUF013 - 5 |+def f(arg: Optional[int] = None): # RUF013 -5 6 | pass diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF005_RUF005.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF005_RUF005.py.snap index 8e9c466eb6f66..fadc9c4ffec1a 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF005_RUF005.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF005_RUF005.py.snap @@ -52,15 +52,6 @@ RUF005.py:39:7: RUF005 [*] Consider `[1, 2, 3, *foo]` instead of concatenation | = help: Replace with `[1, 2, 3, *foo]` -ℹ Unsafe fix -36 36 | yay = Fun().yay -37 37 | -38 38 | foo = [4, 5, 6] -39 |-bar = [1, 2, 3] + foo - 39 |+bar = [1, 2, 3, *foo] -40 40 | zoob = tuple(bar) -41 41 | quux = (7, 8, 9) + zoob -42 42 | spam = quux + (10, 11, 12) RUF005.py:41:8: RUF005 [*] Consider `(7, 8, 9, *zoob)` instead of concatenation | @@ -73,15 +64,6 @@ RUF005.py:41:8: RUF005 [*] Consider `(7, 8, 9, *zoob)` instead of concatenation | = help: Replace with `(7, 8, 9, *zoob)` -ℹ Unsafe fix -38 38 | foo = [4, 5, 6] -39 39 | bar = [1, 2, 3] + foo -40 40 | zoob = tuple(bar) -41 |-quux = (7, 8, 9) + zoob - 41 |+quux = (7, 8, 9, *zoob) -42 42 | spam = quux + (10, 11, 12) -43 43 | spom = list(spam) -44 44 | eggs = spom + [13, 14, 15] RUF005.py:42:8: RUF005 [*] Consider `(*quux, 10, 11, 12)` instead of concatenation | @@ -94,15 +76,6 @@ RUF005.py:42:8: RUF005 [*] Consider `(*quux, 10, 11, 12)` instead of concatenati | = help: Replace with `(*quux, 10, 11, 12)` -ℹ Unsafe fix -39 39 | bar = [1, 2, 3] + foo -40 40 | zoob = tuple(bar) -41 41 | quux = (7, 8, 9) + zoob -42 |-spam = quux + (10, 11, 12) - 42 |+spam = (*quux, 10, 11, 12) -43 43 | spom = list(spam) -44 44 | eggs = spom + [13, 14, 15] -45 45 | elatement = ("we all say",) + yay() RUF005.py:44:8: RUF005 [*] Consider `[*spom, 13, 14, 15]` instead of concatenation | @@ -115,15 +88,6 @@ RUF005.py:44:8: RUF005 [*] Consider `[*spom, 13, 14, 15]` instead of concatenati | = help: Replace with `[*spom, 13, 14, 15]` -ℹ Unsafe fix -41 41 | quux = (7, 8, 9) + zoob -42 42 | spam = quux + (10, 11, 12) -43 43 | spom = list(spam) -44 |-eggs = spom + [13, 14, 15] - 44 |+eggs = [*spom, 13, 14, 15] -45 45 | elatement = ("we all say",) + yay() -46 46 | excitement = ("we all think",) + Fun().yay() -47 47 | astonishment = ("we all feel",) + Fun.words RUF005.py:45:13: RUF005 [*] Consider `("we all say", *yay())` instead of concatenation | @@ -136,15 +100,6 @@ RUF005.py:45:13: RUF005 [*] Consider `("we all say", *yay())` instead of concate | = help: Replace with `("we all say", *yay())` -ℹ Unsafe fix -42 42 | spam = quux + (10, 11, 12) -43 43 | spom = list(spam) -44 44 | eggs = spom + [13, 14, 15] -45 |-elatement = ("we all say",) + yay() - 45 |+elatement = ("we all say", *yay()) -46 46 | excitement = ("we all think",) + Fun().yay() -47 47 | astonishment = ("we all feel",) + Fun.words -48 48 | RUF005.py:46:14: RUF005 [*] Consider `("we all think", *Fun().yay())` instead of concatenation | @@ -156,15 +111,6 @@ RUF005.py:46:14: RUF005 [*] Consider `("we all think", *Fun().yay())` instead of | = help: Replace with `("we all think", *Fun().yay())` -ℹ Unsafe fix -43 43 | spom = list(spam) -44 44 | eggs = spom + [13, 14, 15] -45 45 | elatement = ("we all say",) + yay() -46 |-excitement = ("we all think",) + Fun().yay() - 46 |+excitement = ("we all think", *Fun().yay()) -47 47 | astonishment = ("we all feel",) + Fun.words -48 48 | -49 49 | chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) RUF005.py:47:16: RUF005 [*] Consider `("we all feel", *Fun.words)` instead of concatenation | @@ -177,15 +123,6 @@ RUF005.py:47:16: RUF005 [*] Consider `("we all feel", *Fun.words)` instead of co | = help: Replace with `("we all feel", *Fun.words)` -ℹ Unsafe fix -44 44 | eggs = spom + [13, 14, 15] -45 45 | elatement = ("we all say",) + yay() -46 46 | excitement = ("we all think",) + Fun().yay() -47 |-astonishment = ("we all feel",) + Fun.words - 47 |+astonishment = ("we all feel", *Fun.words) -48 48 | -49 49 | chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) -50 50 | RUF005.py:49:9: RUF005 [*] Consider iterable unpacking instead of concatenation | @@ -198,15 +135,6 @@ RUF005.py:49:9: RUF005 [*] Consider iterable unpacking instead of concatenation | = help: Replace with iterable unpacking -ℹ Unsafe fix -46 46 | excitement = ("we all think",) + Fun().yay() -47 47 | astonishment = ("we all feel",) + Fun.words -48 48 | -49 |-chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) - 49 |+chain = ["a", "b", "c", *eggs, *list(("yes", "no", "pants") + zoob)] -50 50 | -51 51 | baz = () + zoob -52 52 | RUF005.py:49:39: RUF005 [*] Consider `("yes", "no", "pants", *zoob)` instead of concatenation | @@ -219,15 +147,6 @@ RUF005.py:49:39: RUF005 [*] Consider `("yes", "no", "pants", *zoob)` instead of | = help: Replace with `("yes", "no", "pants", *zoob)` -ℹ Unsafe fix -46 46 | excitement = ("we all think",) + Fun().yay() -47 47 | astonishment = ("we all feel",) + Fun.words -48 48 | -49 |-chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) - 49 |+chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants", *zoob)) -50 50 | -51 51 | baz = () + zoob -52 52 | RUF005.py:51:7: RUF005 [*] Consider `(*zoob,)` instead of concatenation | @@ -240,15 +159,6 @@ RUF005.py:51:7: RUF005 [*] Consider `(*zoob,)` instead of concatenation | = help: Replace with `(*zoob,)` -ℹ Unsafe fix -48 48 | -49 49 | chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) -50 50 | -51 |-baz = () + zoob - 51 |+baz = (*zoob,) -52 52 | -53 53 | [] + foo + [ -54 54 | ] RUF005.py:53:1: RUF005 [*] Consider `[*foo]` instead of concatenation | @@ -262,16 +172,6 @@ RUF005.py:53:1: RUF005 [*] Consider `[*foo]` instead of concatenation | = help: Replace with `[*foo]` -ℹ Unsafe fix -50 50 | -51 51 | baz = () + zoob -52 52 | -53 |-[] + foo + [ -54 |-] - 53 |+[*foo] -55 54 | -56 55 | pylint_call = [sys.executable, "-m", "pylint"] + args + [path] -57 56 | pylint_call_tuple = (sys.executable, "-m", "pylint") + args + (path, path2) RUF005.py:56:15: RUF005 [*] Consider `[sys.executable, "-m", "pylint", *args, path]` instead of concatenation | @@ -284,15 +184,6 @@ RUF005.py:56:15: RUF005 [*] Consider `[sys.executable, "-m", "pylint", *args, pa | = help: Replace with `[sys.executable, "-m", "pylint", *args, path]` -ℹ Unsafe fix -53 53 | [] + foo + [ -54 54 | ] -55 55 | -56 |-pylint_call = [sys.executable, "-m", "pylint"] + args + [path] - 56 |+pylint_call = [sys.executable, "-m", "pylint", *args, path] -57 57 | pylint_call_tuple = (sys.executable, "-m", "pylint") + args + (path, path2) -58 58 | b = a + [2, 3] + [4] -59 59 | RUF005.py:57:21: RUF005 [*] Consider iterable unpacking instead of concatenation | @@ -303,15 +194,6 @@ RUF005.py:57:21: RUF005 [*] Consider iterable unpacking instead of concatenation | = help: Replace with iterable unpacking -ℹ Unsafe fix -54 54 | ] -55 55 | -56 56 | pylint_call = [sys.executable, "-m", "pylint"] + args + [path] -57 |-pylint_call_tuple = (sys.executable, "-m", "pylint") + args + (path, path2) - 57 |+pylint_call_tuple = (sys.executable, "-m", "pylint", *args, path, path2) -58 58 | b = a + [2, 3] + [4] -59 59 | -60 60 | # Uses the non-preferred quote style, which should be retained. RUF005.py:58:5: RUF005 [*] Consider `[*a, 2, 3, 4]` instead of concatenation | @@ -324,15 +206,6 @@ RUF005.py:58:5: RUF005 [*] Consider `[*a, 2, 3, 4]` instead of concatenation | = help: Replace with `[*a, 2, 3, 4]` -ℹ Unsafe fix -55 55 | -56 56 | pylint_call = [sys.executable, "-m", "pylint"] + args + [path] -57 57 | pylint_call_tuple = (sys.executable, "-m", "pylint") + args + (path, path2) -58 |-b = a + [2, 3] + [4] - 58 |+b = [*a, 2, 3, 4] -59 59 | -60 60 | # Uses the non-preferred quote style, which should be retained. -61 61 | f"{a() + ['b']}" RUF005.py:61:4: RUF005 [*] Consider `[*a(), 'b']` instead of concatenation | @@ -343,15 +216,3 @@ RUF005.py:61:4: RUF005 [*] Consider `[*a(), 'b']` instead of concatenation 63 | ### | = help: Replace with `[*a(), 'b']` - -ℹ Unsafe fix -58 58 | b = a + [2, 3] + [4] -59 59 | -60 60 | # Uses the non-preferred quote style, which should be retained. -61 |-f"{a() + ['b']}" - 61 |+f"{[*a(), 'b']}" -62 62 | -63 63 | ### -64 64 | # Non-errors. - - diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF010_RUF010.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF010_RUF010.py.snap index fe2e4e3c743be..34e5db65729ac 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF010_RUF010.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF010_RUF010.py.snap @@ -10,7 +10,6 @@ RUF010.py:9:4: RUF010 [*] Use explicit conversion flag | = help: Replace with conversion flag -ℹ Safe fix 6 6 | pass 7 7 | 8 8 | @@ -29,7 +28,6 @@ RUF010.py:9:16: RUF010 [*] Use explicit conversion flag | = help: Replace with conversion flag -ℹ Safe fix 6 6 | pass 7 7 | 8 8 | @@ -48,7 +46,6 @@ RUF010.py:9:29: RUF010 [*] Use explicit conversion flag | = help: Replace with conversion flag -ℹ Safe fix 6 6 | pass 7 7 | 8 8 | @@ -69,7 +66,6 @@ RUF010.py:11:4: RUF010 [*] Use explicit conversion flag | = help: Replace with conversion flag -ℹ Safe fix 8 8 | 9 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 10 10 | @@ -90,7 +86,6 @@ RUF010.py:11:19: RUF010 [*] Use explicit conversion flag | = help: Replace with conversion flag -ℹ Safe fix 8 8 | 9 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 10 10 | @@ -111,7 +106,6 @@ RUF010.py:11:35: RUF010 [*] Use explicit conversion flag | = help: Replace with conversion flag -ℹ Safe fix 8 8 | 9 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 10 10 | @@ -132,7 +126,6 @@ RUF010.py:13:5: RUF010 [*] Use explicit conversion flag | = help: Replace with conversion flag -ℹ Safe fix 10 10 | 11 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 12 12 | @@ -153,7 +146,6 @@ RUF010.py:13:19: RUF010 [*] Use explicit conversion flag | = help: Replace with conversion flag -ℹ Safe fix 10 10 | 11 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 12 12 | @@ -174,7 +166,6 @@ RUF010.py:13:34: RUF010 [*] Use explicit conversion flag | = help: Replace with conversion flag -ℹ Safe fix 10 10 | 11 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 12 12 | @@ -195,7 +186,6 @@ RUF010.py:15:14: RUF010 [*] Use explicit conversion flag | = help: Replace with conversion flag -ℹ Safe fix 12 12 | 13 13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 14 14 | @@ -216,7 +206,6 @@ RUF010.py:15:29: RUF010 [*] Use explicit conversion flag | = help: Replace with conversion flag -ℹ Safe fix 12 12 | 13 13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 14 14 | @@ -236,7 +225,6 @@ RUF010.py:35:20: RUF010 [*] Use explicit conversion flag | = help: Replace with conversion flag -ℹ Safe fix 32 32 | ( 33 33 | f"Member of tuple mismatches type at index {i}. Expected {of_shape_i}. Got " 34 34 | " intermediary content " @@ -244,6 +232,4 @@ RUF010.py:35:20: RUF010 [*] Use explicit conversion flag 35 |+ f" that flows {obj!r} of type {type(obj)}.{additional_message}" # RUF010 36 36 | ) 37 37 | -38 38 | - - +38 38 | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_0.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_0.py.snap index 50bcc3df25e9f..823f372ef4d53 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_0.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_0.py.snap @@ -9,15 +9,6 @@ RUF013_0.py:20:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `T | None` -ℹ Unsafe fix -17 17 | pass -18 18 | -19 19 | -20 |-def f(arg: int = None): # RUF013 - 20 |+def f(arg: int | None = None): # RUF013 -21 21 | pass -22 22 | -23 23 | RUF013_0.py:24:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -27,15 +18,6 @@ RUF013_0.py:24:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `T | None` -ℹ Unsafe fix -21 21 | pass -22 22 | -23 23 | -24 |-def f(arg: str = None): # RUF013 - 24 |+def f(arg: str | None = None): # RUF013 -25 25 | pass -26 26 | -27 27 | RUF013_0.py:28:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -45,15 +27,6 @@ RUF013_0.py:28:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `T | None` -ℹ Unsafe fix -25 25 | pass -26 26 | -27 27 | -28 |-def f(arg: Tuple[str] = None): # RUF013 - 28 |+def f(arg: Tuple[str] | None = None): # RUF013 -29 29 | pass -30 30 | -31 31 | RUF013_0.py:58:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -63,15 +36,6 @@ RUF013_0.py:58:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `T | None` -ℹ Unsafe fix -55 55 | pass -56 56 | -57 57 | -58 |-def f(arg: Union = None): # RUF013 - 58 |+def f(arg: Union | None = None): # RUF013 -59 59 | pass -60 60 | -61 61 | RUF013_0.py:62:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -81,15 +45,6 @@ RUF013_0.py:62:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `T | None` -ℹ Unsafe fix -59 59 | pass -60 60 | -61 61 | -62 |-def f(arg: Union[int] = None): # RUF013 - 62 |+def f(arg: Union[int] | None = None): # RUF013 -63 63 | pass -64 64 | -65 65 | RUF013_0.py:66:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -99,15 +54,6 @@ RUF013_0.py:66:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `T | None` -ℹ Unsafe fix -63 63 | pass -64 64 | -65 65 | -66 |-def f(arg: Union[int, str] = None): # RUF013 - 66 |+def f(arg: Union[int, str] | None = None): # RUF013 -67 67 | pass -68 68 | -69 69 | RUF013_0.py:85:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -117,15 +63,6 @@ RUF013_0.py:85:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `T | None` -ℹ Unsafe fix -82 82 | pass -83 83 | -84 84 | -85 |-def f(arg: int | float = None): # RUF013 - 85 |+def f(arg: int | float | None = None): # RUF013 -86 86 | pass -87 87 | -88 88 | RUF013_0.py:89:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -135,15 +72,6 @@ RUF013_0.py:89:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `T | None` -ℹ Unsafe fix -86 86 | pass -87 87 | -88 88 | -89 |-def f(arg: int | float | str | bytes = None): # RUF013 - 89 |+def f(arg: int | float | str | bytes | None = None): # RUF013 -90 90 | pass -91 91 | -92 92 | RUF013_0.py:108:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -153,15 +81,6 @@ RUF013_0.py:108:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `T | None` -ℹ Unsafe fix -105 105 | pass -106 106 | -107 107 | -108 |-def f(arg: Literal[1] = None): # RUF013 - 108 |+def f(arg: Literal[1] | None = None): # RUF013 -109 109 | pass -110 110 | -111 111 | RUF013_0.py:112:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -171,15 +90,6 @@ RUF013_0.py:112:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `T | None` -ℹ Unsafe fix -109 109 | pass -110 110 | -111 111 | -112 |-def f(arg: Literal[1, "foo"] = None): # RUF013 - 112 |+def f(arg: Literal[1, "foo"] | None = None): # RUF013 -113 113 | pass -114 114 | -115 115 | RUF013_0.py:131:22: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -189,15 +99,6 @@ RUF013_0.py:131:22: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `T | None` -ℹ Unsafe fix -128 128 | pass -129 129 | -130 130 | -131 |-def f(arg: Annotated[int, ...] = None): # RUF013 - 131 |+def f(arg: Annotated[int | None, ...] = None): # RUF013 -132 132 | pass -133 133 | -134 134 | RUF013_0.py:135:32: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -207,15 +108,6 @@ RUF013_0.py:135:32: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `T | None` -ℹ Unsafe fix -132 132 | pass -133 133 | -134 134 | -135 |-def f(arg: Annotated[Annotated[int | str, ...], ...] = None): # RUF013 - 135 |+def f(arg: Annotated[Annotated[int | str | None, ...], ...] = None): # RUF013 -136 136 | pass -137 137 | -138 138 | RUF013_0.py:151:11: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -227,15 +119,6 @@ RUF013_0.py:151:11: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `T | None` -ℹ Unsafe fix -148 148 | -149 149 | -150 150 | def f( -151 |- arg1: int = None, # RUF013 - 151 |+ arg1: int | None = None, # RUF013 -152 152 | arg2: Union[int, float] = None, # RUF013 -153 153 | arg3: Literal[1, 2, 3] = None, # RUF013 -154 154 | ): RUF013_0.py:152:11: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -248,15 +131,6 @@ RUF013_0.py:152:11: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `T | None` -ℹ Unsafe fix -149 149 | -150 150 | def f( -151 151 | arg1: int = None, # RUF013 -152 |- arg2: Union[int, float] = None, # RUF013 - 152 |+ arg2: Union[int, float] | None = None, # RUF013 -153 153 | arg3: Literal[1, 2, 3] = None, # RUF013 -154 154 | ): -155 155 | pass RUF013_0.py:153:11: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -269,15 +143,6 @@ RUF013_0.py:153:11: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `T | None` -ℹ Unsafe fix -150 150 | def f( -151 151 | arg1: int = None, # RUF013 -152 152 | arg2: Union[int, float] = None, # RUF013 -153 |- arg3: Literal[1, 2, 3] = None, # RUF013 - 153 |+ arg3: Literal[1, 2, 3] | None = None, # RUF013 -154 154 | ): -155 155 | pass -156 156 | RUF013_0.py:181:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -287,15 +152,6 @@ RUF013_0.py:181:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `T | None` -ℹ Unsafe fix -178 178 | pass -179 179 | -180 180 | -181 |-def f(arg: Union[Annotated[int, ...], Union[str, bytes]] = None): # RUF013 - 181 |+def f(arg: Union[Annotated[int, ...], Union[str, bytes]] | None = None): # RUF013 -182 182 | pass -183 183 | -184 184 | RUF013_0.py:188:13: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -305,15 +161,6 @@ RUF013_0.py:188:13: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `T | None` -ℹ Unsafe fix -185 185 | # Quoted -186 186 | -187 187 | -188 |-def f(arg: "int" = None): # RUF013 - 188 |+def f(arg: "int | None" = None): # RUF013 -189 189 | pass -190 190 | -191 191 | RUF013_0.py:192:13: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -323,15 +170,6 @@ RUF013_0.py:192:13: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `T | None` -ℹ Unsafe fix -189 189 | pass -190 190 | -191 191 | -192 |-def f(arg: "str" = None): # RUF013 - 192 |+def f(arg: "str | None" = None): # RUF013 -193 193 | pass -194 194 | -195 195 | RUF013_0.py:196:12: RUF013 PEP 484 prohibits implicit `Optional` | @@ -348,13 +186,3 @@ RUF013_0.py:204:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 205 | pass | = help: Convert to `T | None` - -ℹ Unsafe fix -201 201 | pass -202 202 | -203 203 | -204 |-def f(arg: Union["int", "str"] = None): # RUF013 - 204 |+def f(arg: Union["int", "str"] | None = None): # RUF013 -205 205 | pass -206 206 | -207 207 | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_1.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_1.py.snap index f2bf264ff57d4..bd0fbd7a8f7d5 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_1.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_1.py.snap @@ -8,11 +8,3 @@ RUF013_1.py:4:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 5 | pass | = help: Convert to `T | None` - -ℹ Unsafe fix -1 1 | # No `typing.Optional` import -2 2 | -3 3 | -4 |-def f(arg: int = None): # RUF013 - 4 |+def f(arg: int | None = None): # RUF013 -5 5 | pass diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_3.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_3.py.snap index f8172df9aafe2..84152b634c8d0 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_3.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_3.py.snap @@ -9,15 +9,6 @@ RUF013_3.py:4:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `T | None` -ℹ Unsafe fix -1 1 | import typing -2 2 | -3 3 | -4 |-def f(arg: typing.List[str] = None): # RUF013 - 4 |+def f(arg: typing.List[str] | None = None): # RUF013 -5 5 | pass -6 6 | -7 7 | RUF013_3.py:22:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -27,15 +18,6 @@ RUF013_3.py:22:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | = help: Convert to `T | None` -ℹ Unsafe fix -19 19 | pass -20 20 | -21 21 | -22 |-def f(arg: typing.Union[int, str] = None): # RUF013 - 22 |+def f(arg: typing.Union[int, str] | None = None): # RUF013 -23 23 | pass -24 24 | -25 25 | RUF013_3.py:29:12: RUF013 [*] PEP 484 prohibits implicit `Optional` | @@ -44,11 +26,3 @@ RUF013_3.py:29:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 30 | pass | = help: Convert to `T | None` - -ℹ Unsafe fix -26 26 | # Literal -27 27 | -28 28 | -29 |-def f(arg: typing.Literal[1, "foo", True] = None): # RUF013 - 29 |+def f(arg: typing.Literal[1, "foo", True] | None = None): # RUF013 -30 30 | pass diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF015_RUF015.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF015_RUF015.py.snap index 7500f39c81f82..4626847725db7 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF015_RUF015.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF015_RUF015.py.snap @@ -11,15 +11,6 @@ RUF015.py:4:1: RUF015 [*] Prefer `next(iter(x))` over single element slice | = help: Replace with `next(iter(x))` -ℹ Unsafe fix -1 1 | x = range(10) -2 2 | -3 3 | # RUF015 -4 |-list(x)[0] - 4 |+next(iter(x)) -5 5 | tuple(x)[0] -6 6 | list(i for i in x)[0] -7 7 | [i for i in x][0] RUF015.py:5:1: RUF015 [*] Prefer `next(iter(x))` over single element slice | @@ -32,15 +23,6 @@ RUF015.py:5:1: RUF015 [*] Prefer `next(iter(x))` over single element slice | = help: Replace with `next(iter(x))` -ℹ Unsafe fix -2 2 | -3 3 | # RUF015 -4 4 | list(x)[0] -5 |-tuple(x)[0] - 5 |+next(iter(x)) -6 6 | list(i for i in x)[0] -7 7 | [i for i in x][0] -8 8 | RUF015.py:6:1: RUF015 [*] Prefer `next(iter(x))` over single element slice | @@ -52,15 +34,6 @@ RUF015.py:6:1: RUF015 [*] Prefer `next(iter(x))` over single element slice | = help: Replace with `next(iter(x))` -ℹ Unsafe fix -3 3 | # RUF015 -4 4 | list(x)[0] -5 5 | tuple(x)[0] -6 |-list(i for i in x)[0] - 6 |+next(iter(x)) -7 7 | [i for i in x][0] -8 8 | -9 9 | # OK (not indexing (solely) the first element) RUF015.py:7:1: RUF015 [*] Prefer `next(iter(x))` over single element slice | @@ -73,15 +46,6 @@ RUF015.py:7:1: RUF015 [*] Prefer `next(iter(x))` over single element slice | = help: Replace with `next(iter(x))` -ℹ Unsafe fix -4 4 | list(x)[0] -5 5 | tuple(x)[0] -6 6 | list(i for i in x)[0] -7 |-[i for i in x][0] - 7 |+next(iter(x)) -8 8 | -9 9 | # OK (not indexing (solely) the first element) -10 10 | list(x) RUF015.py:29:1: RUF015 [*] Prefer `next(i + 1 for i in x)` over single element slice | @@ -93,15 +57,6 @@ RUF015.py:29:1: RUF015 [*] Prefer `next(i + 1 for i in x)` over single element s | = help: Replace with `next(i + 1 for i in x)` -ℹ Unsafe fix -26 26 | [i for i in x][::] -27 27 | -28 28 | # RUF015 (doesn't mirror the underlying list) -29 |-[i + 1 for i in x][0] - 29 |+next(i + 1 for i in x) -30 30 | [i for i in x if i > 5][0] -31 31 | [(i, i + 1) for i in x][0] -32 32 | RUF015.py:30:1: RUF015 [*] Prefer `next(i for i in x if i > 5)` over single element slice | @@ -113,15 +68,6 @@ RUF015.py:30:1: RUF015 [*] Prefer `next(i for i in x if i > 5)` over single elem | = help: Replace with `next(i for i in x if i > 5)` -ℹ Unsafe fix -27 27 | -28 28 | # RUF015 (doesn't mirror the underlying list) -29 29 | [i + 1 for i in x][0] -30 |-[i for i in x if i > 5][0] - 30 |+next(i for i in x if i > 5) -31 31 | [(i, i + 1) for i in x][0] -32 32 | -33 33 | # RUF015 (multiple generators) RUF015.py:31:1: RUF015 [*] Prefer `next((i, i + 1) for i in x)` over single element slice | @@ -134,15 +80,6 @@ RUF015.py:31:1: RUF015 [*] Prefer `next((i, i + 1) for i in x)` over single elem | = help: Replace with `next((i, i + 1) for i in x)` -ℹ Unsafe fix -28 28 | # RUF015 (doesn't mirror the underlying list) -29 29 | [i + 1 for i in x][0] -30 30 | [i for i in x if i > 5][0] -31 |-[(i, i + 1) for i in x][0] - 31 |+next((i, i + 1) for i in x) -32 32 | -33 33 | # RUF015 (multiple generators) -34 34 | y = range(10) RUF015.py:35:1: RUF015 [*] Prefer `next(i + j for i in x for j in y)` over single element slice | @@ -155,15 +92,6 @@ RUF015.py:35:1: RUF015 [*] Prefer `next(i + j for i in x for j in y)` over singl | = help: Replace with `next(i + j for i in x for j in y)` -ℹ Unsafe fix -32 32 | -33 33 | # RUF015 (multiple generators) -34 34 | y = range(10) -35 |-[i + j for i in x for j in y][0] - 35 |+next(i + j for i in x for j in y) -36 36 | -37 37 | # RUF015 -38 38 | list(range(10))[0] RUF015.py:38:1: RUF015 [*] Prefer `next(iter(range(10)))` over single element slice | @@ -175,15 +103,6 @@ RUF015.py:38:1: RUF015 [*] Prefer `next(iter(range(10)))` over single element sl | = help: Replace with `next(iter(range(10)))` -ℹ Unsafe fix -35 35 | [i + j for i in x for j in y][0] -36 36 | -37 37 | # RUF015 -38 |-list(range(10))[0] - 38 |+next(iter(range(10))) -39 39 | list(x.y)[0] -40 40 | list(x["y"])[0] -41 41 | [*range(10)][0] RUF015.py:39:1: RUF015 [*] Prefer `next(iter(x.y))` over single element slice | @@ -196,15 +115,6 @@ RUF015.py:39:1: RUF015 [*] Prefer `next(iter(x.y))` over single element slice | = help: Replace with `next(iter(x.y))` -ℹ Unsafe fix -36 36 | -37 37 | # RUF015 -38 38 | list(range(10))[0] -39 |-list(x.y)[0] - 39 |+next(iter(x.y)) -40 40 | list(x["y"])[0] -41 41 | [*range(10)][0] -42 42 | [*x["y"]][0] RUF015.py:40:1: RUF015 [*] Prefer `next(iter(x["y"]))` over single element slice | @@ -217,15 +127,6 @@ RUF015.py:40:1: RUF015 [*] Prefer `next(iter(x["y"]))` over single element slice | = help: Replace with `next(iter(x["y"]))` -ℹ Unsafe fix -37 37 | # RUF015 -38 38 | list(range(10))[0] -39 39 | list(x.y)[0] -40 |-list(x["y"])[0] - 40 |+next(iter(x["y"])) -41 41 | [*range(10)][0] -42 42 | [*x["y"]][0] -43 43 | [*x.y][0] RUF015.py:41:1: RUF015 [*] Prefer `next(iter(range(10)))` over single element slice | @@ -238,15 +139,6 @@ RUF015.py:41:1: RUF015 [*] Prefer `next(iter(range(10)))` over single element sl | = help: Replace with `next(iter(range(10)))` -ℹ Unsafe fix -38 38 | list(range(10))[0] -39 39 | list(x.y)[0] -40 40 | list(x["y"])[0] -41 |-[*range(10)][0] - 41 |+next(iter(range(10))) -42 42 | [*x["y"]][0] -43 43 | [*x.y][0] -44 44 | [* x.y][0] RUF015.py:42:1: RUF015 [*] Prefer `next(iter(x["y"]))` over single element slice | @@ -259,15 +151,6 @@ RUF015.py:42:1: RUF015 [*] Prefer `next(iter(x["y"]))` over single element slice | = help: Replace with `next(iter(x["y"]))` -ℹ Unsafe fix -39 39 | list(x.y)[0] -40 40 | list(x["y"])[0] -41 41 | [*range(10)][0] -42 |-[*x["y"]][0] - 42 |+next(iter(x["y"])) -43 43 | [*x.y][0] -44 44 | [* x.y][0] -45 45 | [ RUF015.py:43:1: RUF015 [*] Prefer `next(iter(x.y))` over single element slice | @@ -280,15 +163,6 @@ RUF015.py:43:1: RUF015 [*] Prefer `next(iter(x.y))` over single element slice | = help: Replace with `next(iter(x.y))` -ℹ Unsafe fix -40 40 | list(x["y"])[0] -41 41 | [*range(10)][0] -42 42 | [*x["y"]][0] -43 |-[*x.y][0] - 43 |+next(iter(x.y)) -44 44 | [* x.y][0] -45 45 | [ -46 46 | *x.y RUF015.py:44:1: RUF015 [*] Prefer `next(iter(x.y))` over single element slice | @@ -301,15 +175,6 @@ RUF015.py:44:1: RUF015 [*] Prefer `next(iter(x.y))` over single element slice | = help: Replace with `next(iter(x.y))` -ℹ Unsafe fix -41 41 | [*range(10)][0] -42 42 | [*x["y"]][0] -43 43 | [*x.y][0] -44 |-[* x.y][0] - 44 |+next(iter(x.y)) -45 45 | [ -46 46 | *x.y -47 47 | ][0] RUF015.py:45:1: RUF015 [*] Prefer `next(iter(x.y))` over single element slice | @@ -324,17 +189,6 @@ RUF015.py:45:1: RUF015 [*] Prefer `next(iter(x.y))` over single element slice | = help: Replace with `next(iter(x.y))` -ℹ Unsafe fix -42 42 | [*x["y"]][0] -43 43 | [*x.y][0] -44 44 | [* x.y][0] -45 |-[ -46 |- *x.y -47 |-][0] - 45 |+next(iter(x.y)) -48 46 | -49 47 | # RUF015 (multi-line) -50 48 | revision_heads_map_ast = [ RUF015.py:50:26: RUF015 [*] Prefer `next(...)` over single element slice | @@ -351,20 +205,6 @@ RUF015.py:50:26: RUF015 [*] Prefer `next(...)` over single element slice | = help: Replace with `next(...)` -ℹ Unsafe fix -47 47 | ][0] -48 48 | -49 49 | # RUF015 (multi-line) -50 |-revision_heads_map_ast = [ - 50 |+revision_heads_map_ast = next( -51 51 | a -52 52 | for a in revision_heads_map_ast_obj.body -53 53 | if isinstance(a, ast.Assign) and a.targets[0].id == "REVISION_HEADS_MAP" -54 |-][0] - 54 |+) -55 55 | -56 56 | # RUF015 (zip) -57 57 | list(zip(x, y))[0] RUF015.py:57:1: RUF015 [*] Prefer `next(zip(x, y))` over single element slice | @@ -375,15 +215,6 @@ RUF015.py:57:1: RUF015 [*] Prefer `next(zip(x, y))` over single element slice | = help: Replace with `next(zip(x, y))` -ℹ Unsafe fix -54 54 | ][0] -55 55 | -56 56 | # RUF015 (zip) -57 |-list(zip(x, y))[0] - 57 |+next(zip(x, y)) -58 58 | [*zip(x, y)][0] -59 59 | -60 60 | # RUF015 (pop) RUF015.py:58:1: RUF015 [*] Prefer `next(zip(x, y))` over single element slice | @@ -396,15 +227,6 @@ RUF015.py:58:1: RUF015 [*] Prefer `next(zip(x, y))` over single element slice | = help: Replace with `next(zip(x, y))` -ℹ Unsafe fix -55 55 | -56 56 | # RUF015 (zip) -57 57 | list(zip(x, y))[0] -58 |-[*zip(x, y)][0] - 58 |+next(zip(x, y)) -59 59 | -60 60 | # RUF015 (pop) -61 61 | list(x).pop(0) RUF015.py:61:1: RUF015 [*] Prefer `next(iter(x))` over single element slice | @@ -416,15 +238,6 @@ RUF015.py:61:1: RUF015 [*] Prefer `next(iter(x))` over single element slice | = help: Replace with `next(iter(x))` -ℹ Unsafe fix -58 58 | [*zip(x, y)][0] -59 59 | -60 60 | # RUF015 (pop) -61 |-list(x).pop(0) - 61 |+next(iter(x)) -62 62 | [i for i in x].pop(0) -63 63 | list(i for i in x).pop(0) -64 64 | RUF015.py:62:1: RUF015 [*] Prefer `next(iter(x))` over single element slice | @@ -436,15 +249,6 @@ RUF015.py:62:1: RUF015 [*] Prefer `next(iter(x))` over single element slice | = help: Replace with `next(iter(x))` -ℹ Unsafe fix -59 59 | -60 60 | # RUF015 (pop) -61 61 | list(x).pop(0) -62 |-[i for i in x].pop(0) - 62 |+next(iter(x)) -63 63 | list(i for i in x).pop(0) -64 64 | -65 65 | # OK RUF015.py:63:1: RUF015 [*] Prefer `next(iter(x))` over single element slice | @@ -457,15 +261,6 @@ RUF015.py:63:1: RUF015 [*] Prefer `next(iter(x))` over single element slice | = help: Replace with `next(iter(x))` -ℹ Unsafe fix -60 60 | # RUF015 (pop) -61 61 | list(x).pop(0) -62 62 | [i for i in x].pop(0) -63 |-list(i for i in x).pop(0) - 63 |+next(iter(x)) -64 64 | -65 65 | # OK -66 66 | list(x).pop(1) RUF015.py:73:5: RUF015 [*] Prefer `next(iter(zip(x, y)))` over single element slice | @@ -475,10 +270,3 @@ RUF015.py:73:5: RUF015 [*] Prefer `next(iter(zip(x, y)))` over single element sl | ^^^^^^^^^^^^^^^^^^ RUF015 | = help: Replace with `next(iter(zip(x, y)))` - -ℹ Unsafe fix -70 70 | -71 71 | def test(): -72 72 | zip = list # Overwrite the builtin zip -73 |- list(zip(x, y))[0] - 73 |+ next(iter(zip(x, y))) diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF017_RUF017_0.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF017_RUF017_0.py.snap index aad3c2fed9103..85233ec1b215b 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF017_RUF017_0.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF017_RUF017_0.py.snap @@ -11,18 +11,6 @@ RUF017_0.py:5:1: RUF017 [*] Avoid quadratic list summation | = help: Replace with `functools.reduce` -ℹ Unsafe fix - 1 |+import functools - 2 |+import operator -1 3 | x = [1, 2, 3] -2 4 | y = [4, 5, 6] -3 5 | -4 6 | # RUF017 -5 |-sum([x, y], start=[]) - 7 |+functools.reduce(operator.iadd, [x, y], []) -6 8 | sum([x, y], []) -7 9 | sum([[1, 2, 3], [4, 5, 6]], start=[]) -8 10 | sum([[1, 2, 3], [4, 5, 6]], []) RUF017_0.py:6:1: RUF017 [*] Avoid quadratic list summation | @@ -35,19 +23,6 @@ RUF017_0.py:6:1: RUF017 [*] Avoid quadratic list summation | = help: Replace with `functools.reduce` -ℹ Unsafe fix - 1 |+import functools - 2 |+import operator -1 3 | x = [1, 2, 3] -2 4 | y = [4, 5, 6] -3 5 | -4 6 | # RUF017 -5 7 | sum([x, y], start=[]) -6 |-sum([x, y], []) - 8 |+functools.reduce(operator.iadd, [x, y], []) -7 9 | sum([[1, 2, 3], [4, 5, 6]], start=[]) -8 10 | sum([[1, 2, 3], [4, 5, 6]], []) -9 11 | sum([[1, 2, 3], [4, 5, 6]], RUF017_0.py:7:1: RUF017 [*] Avoid quadratic list summation | @@ -60,20 +35,6 @@ RUF017_0.py:7:1: RUF017 [*] Avoid quadratic list summation | = help: Replace with `functools.reduce` -ℹ Unsafe fix - 1 |+import functools - 2 |+import operator -1 3 | x = [1, 2, 3] -2 4 | y = [4, 5, 6] -3 5 | -4 6 | # RUF017 -5 7 | sum([x, y], start=[]) -6 8 | sum([x, y], []) -7 |-sum([[1, 2, 3], [4, 5, 6]], start=[]) - 9 |+functools.reduce(operator.iadd, [[1, 2, 3], [4, 5, 6]], []) -8 10 | sum([[1, 2, 3], [4, 5, 6]], []) -9 11 | sum([[1, 2, 3], [4, 5, 6]], -10 12 | []) RUF017_0.py:8:1: RUF017 [*] Avoid quadratic list summation | @@ -86,21 +47,6 @@ RUF017_0.py:8:1: RUF017 [*] Avoid quadratic list summation | = help: Replace with `functools.reduce` -ℹ Unsafe fix - 1 |+import functools - 2 |+import operator -1 3 | x = [1, 2, 3] -2 4 | y = [4, 5, 6] -3 5 | --------------------------------------------------------------------------------- -5 7 | sum([x, y], start=[]) -6 8 | sum([x, y], []) -7 9 | sum([[1, 2, 3], [4, 5, 6]], start=[]) -8 |-sum([[1, 2, 3], [4, 5, 6]], []) - 10 |+functools.reduce(operator.iadd, [[1, 2, 3], [4, 5, 6]], []) -9 11 | sum([[1, 2, 3], [4, 5, 6]], -10 12 | []) -11 13 | RUF017_0.py:9:1: RUF017 [*] Avoid quadratic list summation | @@ -114,22 +60,6 @@ RUF017_0.py:9:1: RUF017 [*] Avoid quadratic list summation | = help: Replace with `functools.reduce` -ℹ Unsafe fix - 1 |+import functools - 2 |+import operator -1 3 | x = [1, 2, 3] -2 4 | y = [4, 5, 6] -3 5 | --------------------------------------------------------------------------------- -6 8 | sum([x, y], []) -7 9 | sum([[1, 2, 3], [4, 5, 6]], start=[]) -8 10 | sum([[1, 2, 3], [4, 5, 6]], []) -9 |-sum([[1, 2, 3], [4, 5, 6]], -10 |- []) - 11 |+functools.reduce(operator.iadd, [[1, 2, 3], [4, 5, 6]], []) -11 12 | -12 13 | # OK -13 14 | sum([x, y]) RUF017_0.py:21:5: RUF017 [*] Avoid quadratic list summation | @@ -140,15 +70,6 @@ RUF017_0.py:21:5: RUF017 [*] Avoid quadratic list summation | = help: Replace with `functools.reduce` -ℹ Unsafe fix -18 18 | def func(): -19 19 | import functools, operator -20 20 | -21 |- sum([x, y], []) - 21 |+ functools.reduce(operator.iadd, [x, y], []) -22 22 | -23 23 | -24 24 | # Regression test for: https://github.com/astral-sh/ruff/issues/7718 RUF017_0.py:26:5: RUF017 [*] Avoid quadratic list summation | @@ -158,18 +79,3 @@ RUF017_0.py:26:5: RUF017 [*] Avoid quadratic list summation | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF017 | = help: Replace with `functools.reduce` - -ℹ Unsafe fix - 1 |+import functools - 2 |+import operator -1 3 | x = [1, 2, 3] -2 4 | y = [4, 5, 6] -3 5 | --------------------------------------------------------------------------------- -23 25 | -24 26 | # Regression test for: https://github.com/astral-sh/ruff/issues/7718 -25 27 | def func(): -26 |- sum((factor.dims for factor in bases), []) - 28 |+ functools.reduce(operator.iadd, (factor.dims for factor in bases), []) - - diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF017_RUF017_1.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF017_RUF017_1.py.snap index ff3b145e56799..7541973fda0e1 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF017_RUF017_1.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF017_RUF017_1.py.snap @@ -7,11 +7,3 @@ RUF017_1.py:1:1: RUF017 [*] Avoid quadratic list summation | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF017 | = help: Replace with `functools.reduce` - -ℹ Unsafe fix -1 |-sum((factor.dims for factor in bases), []) - 1 |+import functools - 2 |+import operator - 3 |+functools.reduce(operator.iadd, (factor.dims for factor in bases), []) - - diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF019_RUF019.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF019_RUF019.py.snap index f536eb250ac13..85a131d0d4636 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF019_RUF019.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF019_RUF019.py.snap @@ -11,7 +11,6 @@ RUF019.py:3:4: RUF019 [*] Unnecessary key check before dictionary access | = help: Replace with `dict.get` -ℹ Safe fix 1 1 | d = {} 2 2 | # RUF019 3 |-if "k" in d and d["k"]: @@ -29,7 +28,6 @@ RUF019.py:7:4: RUF019 [*] Unnecessary key check before dictionary access | = help: Replace with `dict.get` -ℹ Safe fix 4 4 | pass 5 5 | 6 6 | k = "k" @@ -49,7 +47,6 @@ RUF019.py:10:4: RUF019 [*] Unnecessary key check before dictionary access | = help: Replace with `dict.get` -ℹ Safe fix 7 7 | if k in d and d[k]: 8 8 | pass 9 9 | @@ -69,7 +66,6 @@ RUF019.py:13:4: RUF019 [*] Unnecessary key check before dictionary access | = help: Replace with `dict.get` -ℹ Safe fix 10 10 | if (k) in d and d[k]: 11 11 | pass 12 12 | @@ -90,7 +86,6 @@ RUF019.py:16:6: RUF019 [*] Unnecessary key check before dictionary access | = help: Replace with `dict.get` -ℹ Safe fix 13 13 | if k in d and d[(k)]: 14 14 | pass 15 15 | @@ -111,7 +106,6 @@ RUF019.py:18:6: RUF019 [*] Unnecessary key check before dictionary access | = help: Replace with `dict.get` -ℹ Safe fix 15 15 | 16 16 | not ("key" in dct and dct["key"]) 17 17 | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF020_RUF020.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF020_RUF020.py.snap index 64fd30b4ed4d2..0d0097be2c1fc 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF020_RUF020.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF020_RUF020.py.snap @@ -12,7 +12,6 @@ RUF020.py:3:7: RUF020 [*] `Union[Never, T]` is equivalent to `T` | = help: Remove `Never` -ℹ Safe fix 1 1 | from typing import Never, NoReturn, Union 2 2 | 3 |-Union[Never, int] @@ -31,7 +30,6 @@ RUF020.py:4:7: RUF020 [*] `Union[NoReturn, T]` is equivalent to `T` | = help: Remove `NoReturn` -ℹ Safe fix 1 1 | from typing import Never, NoReturn, Union 2 2 | 3 3 | Union[Never, int] @@ -52,7 +50,6 @@ RUF020.py:5:1: RUF020 [*] `Never | T` is equivalent to `T` | = help: Remove `Never` -ℹ Safe fix 2 2 | 3 3 | Union[Never, int] 4 4 | Union[NoReturn, int] @@ -73,7 +70,6 @@ RUF020.py:6:1: RUF020 [*] `NoReturn | T` is equivalent to `T` | = help: Remove `NoReturn` -ℹ Safe fix 3 3 | Union[Never, int] 4 4 | Union[NoReturn, int] 5 5 | Never | int @@ -92,7 +88,6 @@ RUF020.py:7:13: RUF020 [*] `Union[Never, T]` is equivalent to `T` | = help: Remove `Never` -ℹ Safe fix 4 4 | Union[NoReturn, int] 5 5 | Never | int 6 6 | NoReturn | int @@ -110,7 +105,6 @@ RUF020.py:7:32: RUF020 [*] `Union[NoReturn, T]` is equivalent to `T` | = help: Remove `NoReturn` -ℹ Safe fix 4 4 | Union[NoReturn, int] 5 5 | Never | int 6 6 | NoReturn | int @@ -127,11 +121,8 @@ RUF020.py:8:7: RUF020 [*] `Union[NoReturn, T]` is equivalent to `T` | = help: Remove `NoReturn` -ℹ Safe fix 5 5 | Never | int 6 6 | NoReturn | int 7 7 | Union[Union[Never, int], Union[NoReturn, int]] 8 |-Union[NoReturn, int, float] 8 |+Union[int, float] - - diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF021_RUF021.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF021_RUF021.py.snap index 0660b0b97f85a..83a3b2335cdbb 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF021_RUF021.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF021_RUF021.py.snap @@ -10,7 +10,6 @@ RUF021.py:12:10: RUF021 [*] Parenthesize `a and b` expressions when chaining `an | = help: Parenthesize the `and` subexpression -ℹ Safe fix 9 9 | # as part of a chain. 10 10 | 11 11 | a, b, c = 1, 0, 2 @@ -31,7 +30,6 @@ RUF021.py:13:10: RUF021 [*] Parenthesize `a and b` expressions when chaining `an | = help: Parenthesize the `and` subexpression -ℹ Safe fix 10 10 | 11 11 | a, b, c = 1, 0, 2 12 12 | x = a or b and c # RUF021: => `a or (b and c)` @@ -51,7 +49,6 @@ RUF021.py:16:5: RUF021 [*] Parenthesize `a and b` expressions when chaining `and | = help: Parenthesize the `and` subexpression -ℹ Safe fix 13 13 | x = a or b and c # looooooooooooooooooooooooooooooong comment but it won't prevent an autofix 14 14 | 15 15 | a, b, c = 0, 1, 2 @@ -70,7 +67,6 @@ RUF021.py:19:14: RUF021 [*] Parenthesize `a and b` expressions when chaining `an | = help: Parenthesize the `and` subexpression -ℹ Safe fix 16 16 | y = a and b or c # RUF021: => `(a and b) or c` 17 17 | 18 18 | a, b, c, d = 1, 2, 0, 3 @@ -90,7 +86,6 @@ RUF021.py:26:11: RUF021 [*] Parenthesize `a and b` expressions when chaining `an | = help: Parenthesize the `and` subexpression -ℹ Safe fix 23 23 | 24 24 | if bool(): 25 25 | pass @@ -109,7 +104,6 @@ RUF021.py:30:7: RUF021 [*] Parenthesize `a and b` expressions when chaining `and | = help: Parenthesize the `and` subexpression -ℹ Safe fix 27 27 | pass 28 28 | 29 29 | a, b, c, d = 0, 1, 0, 2 @@ -128,7 +122,6 @@ RUF021.py:30:18: RUF021 [*] Parenthesize `a and b` expressions when chaining `an | = help: Parenthesize the `and` subexpression -ℹ Safe fix 27 27 | pass 28 28 | 29 29 | a, b, c, d = 0, 1, 0, 2 @@ -149,7 +142,6 @@ RUF021.py:35:44: RUF021 [*] Parenthesize `a and b` expressions when chaining `an | = help: Parenthesize the `and` subexpression -ℹ Safe fix 32 32 | 33 33 | b, c, d, e = 2, 3, 0, 4 34 34 | # RUF021: => `a or b or c or (d and e)`: @@ -169,7 +161,6 @@ RUF021.py:38:8: RUF021 [*] Parenthesize `a and b` expressions when chaining `and | = help: Parenthesize the `and` subexpression -ℹ Safe fix 35 35 | z = [a for a in range(5) if a or b or c or d and e] 36 36 | 37 37 | a, b, c, d = 0, 1, 3, 0 @@ -190,7 +181,6 @@ RUF021.py:40:4: RUF021 [*] Parenthesize `a and b` expressions when chaining `and | = help: Parenthesize the `and` subexpression -ℹ Safe fix 37 37 | a, b, c, d = 0, 1, 3, 0 38 38 | assert not a and b or c or d # RUF021: => `(not a and b) or c or d` 39 39 | @@ -213,7 +203,6 @@ RUF021.py:46:8: RUF021 [*] Parenthesize `a and b` expressions when chaining `and | = help: Parenthesize the `and` subexpression -ℹ Safe fix 43 43 | 44 44 | if ( 45 45 | some_reasonably_long_condition @@ -241,7 +230,6 @@ RUF021.py:48:8: RUF021 [*] Parenthesize `a and b` expressions when chaining `and | = help: Parenthesize the `and` subexpression -ℹ Safe fix 45 45 | some_reasonably_long_condition 46 46 | or some_other_reasonably_long_condition 47 47 | and some_third_reasonably_long_condition diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF022_RUF022.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF022_RUF022.py.snap index c886b91ccf04d..2feae9013c4e9 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF022_RUF022.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF022_RUF022.py.snap @@ -12,7 +12,6 @@ RUF022.py:5:11: RUF022 [*] `__all__` is not sorted | = help: Apply an isort-style sorting to `__all__` -ℹ Safe fix 2 2 | # Single-line __all__ definitions (nice 'n' easy!) 3 3 | ################################################## 4 4 | @@ -31,7 +30,6 @@ RUF022.py:6:12: RUF022 [*] `__all__` is not sorted | = help: Apply an isort-style sorting to `__all__` -ℹ Safe fix 3 3 | ################################################## 4 4 | 5 5 | __all__ = ["d", "c", "b", "a"] # a comment that is untouched @@ -52,7 +50,6 @@ RUF022.py:7:11: RUF022 [*] `__all__` is not sorted | = help: Apply an isort-style sorting to `__all__` -ℹ Safe fix 4 4 | 5 5 | __all__ = ["d", "c", "b", "a"] # a comment that is untouched 6 6 | __all__ += ["foo", "bar", "antipasti"] @@ -73,7 +70,6 @@ RUF022.py:11:17: RUF022 [*] `__all__` is not sorted | = help: Apply an isort-style sorting to `__all__` -ℹ Safe fix 8 8 | 9 9 | # Quoting style is retained, 10 10 | # but unnecessary parens are not @@ -94,7 +90,6 @@ RUF022.py:14:18: RUF022 [*] `__all__` is not sorted | = help: Apply an isort-style sorting to `__all__` -ℹ Safe fix 11 11 | __all__: list = ['b', "c", ((('a')))] 12 12 | # Trailing commas are also not retained in single-line `__all__` definitions 13 13 | # (but they are in multiline `__all__` definitions) @@ -114,7 +109,6 @@ RUF022.py:17:16: RUF022 [*] `__all__` is not sorted | = help: Apply an isort-style sorting to `__all__` -ℹ Safe fix 14 14 | __all__: tuple = ("b", "c", "a",) 15 15 | 16 16 | if bool(): @@ -135,7 +129,6 @@ RUF022.py:19:16: RUF022 [*] `__all__` is not sorted | = help: Apply an isort-style sorting to `__all__` -ℹ Safe fix 16 16 | if bool(): 17 17 | __all__ += ("x", "m", "a", "s") 18 18 | else: @@ -156,7 +149,6 @@ RUF022.py:21:22: RUF022 [*] `__all__` is not sorted | = help: Apply an isort-style sorting to `__all__` -ℹ Safe fix 18 18 | else: 19 19 | __all__ += "foo3", "foo2", "foo1" # NB: an implicit tuple (without parens) 20 20 | @@ -177,7 +169,6 @@ RUF022.py:23:11: RUF022 [*] `__all__` is not sorted | = help: Apply an isort-style sorting to `__all__` -ℹ Safe fix 20 20 | 21 21 | __all__: list[str] = ["the", "three", "little", "pigs"] 22 22 | @@ -197,7 +188,6 @@ RUF022.py:24:16: RUF022 [*] `__all__` is not sorted | = help: Apply an isort-style sorting to `__all__` -ℹ Safe fix 21 21 | __all__: list[str] = ["the", "three", "little", "pigs"] 22 22 | 23 23 | __all__ = ("parenthesized_item"), "in", ("an_unparenthesized_tuple") @@ -217,7 +207,6 @@ RUF022.py:25:16: RUF022 [*] `__all__` is not sorted | = help: Apply an isort-style sorting to `__all__` -ℹ Safe fix 22 22 | 23 23 | __all__ = ("parenthesized_item"), "in", ("an_unparenthesized_tuple") 24 24 | __all__.extend(["foo", "bar"]) @@ -238,7 +227,6 @@ RUF022.py:26:19: RUF022 [*] `__all__` is not sorted | = help: Apply an isort-style sorting to `__all__` -ℹ Safe fix 23 23 | __all__ = ("parenthesized_item"), "in", ("an_unparenthesized_tuple") 24 24 | __all__.extend(["foo", "bar"]) 25 25 | __all__.extend(("foo", "bar")) @@ -266,7 +254,6 @@ RUF022.py:32:11: RUF022 [*] `__all__` is not sorted | = help: Apply an isort-style sorting to `__all__` -ℹ Safe fix 30 30 | #################################### 31 31 | 32 32 | __all__ = ( @@ -301,7 +288,6 @@ RUF022.py:40:11: RUF022 [*] `__all__` is not sorted | = help: Apply an isort-style sorting to `__all__` -ℹ Safe fix 38 38 | ) 39 39 | 40 40 | __all__ = [ @@ -360,7 +346,6 @@ RUF022.py:54:11: RUF022 [*] `__all__` is not sorted | = help: Apply an isort-style sorting to `__all__` -ℹ Safe fix 54 54 | __all__ = [ 55 55 | "APRIL", 56 56 | "AUGUST", @@ -422,7 +407,6 @@ RUF022.py:91:11: RUF022 [*] `__all__` is not sorted | = help: Apply an isort-style sorting to `__all__` -ℹ Safe fix 88 88 | ########################################## 89 89 | 90 90 | # comment0 @@ -463,7 +447,6 @@ RUF022.py:101:11: RUF022 [*] `__all__` is not sorted | = help: Apply an isort-style sorting to `__all__` -ℹ Safe fix 99 99 | # comment7 100 100 | 101 101 | __all__ = [ # comment0 @@ -503,7 +486,6 @@ RUF022.py:110:11: RUF022 [*] `__all__` is not sorted | = help: Apply an isort-style sorting to `__all__` -ℹ Safe fix 107 107 | # comment6 108 108 | ] # comment7 109 109 | @@ -590,7 +572,6 @@ RUF022.py:125:28: RUF022 [*] `__all__` is not sorted | = help: Apply an isort-style sorting to `__all__` -ℹ Safe fix 123 123 | "register_error", "lookup_error"] 124 124 | 125 125 | __all__: tuple[str, ...] = ( # a comment about the opening paren @@ -624,7 +605,6 @@ RUF022.py:138:11: RUF022 [*] `__all__` is not sorted | = help: Apply an isort-style sorting to `__all__` -ℹ Safe fix 136 136 | # Also, this doesn't end with a trailing comma, 137 137 | # so the autofix shouldn't introduce one: 138 138 | __all__ = ( @@ -657,7 +637,6 @@ RUF022.py:145:16: RUF022 [*] `__all__` is not sorted | = help: Apply an isort-style sorting to `__all__` -ℹ Safe fix 143 143 | ) 144 144 | 145 145 | __all__.extend(( # comment0 @@ -689,7 +668,6 @@ RUF022.py:155:5: RUF022 [*] `__all__` is not sorted | = help: Apply an isort-style sorting to `__all__` -ℹ Safe fix 153 153 | __all__.extend( # comment0 154 154 | # comment1 155 155 | ( # comment2 @@ -722,7 +700,6 @@ RUF022.py:164:16: RUF022 [*] `__all__` is not sorted | = help: Apply an isort-style sorting to `__all__` -ℹ Safe fix 162 162 | ) # comment2 163 163 | 164 164 | __all__.extend([ # comment0 @@ -754,7 +731,6 @@ RUF022.py:174:5: RUF022 [*] `__all__` is not sorted | = help: Apply an isort-style sorting to `__all__` -ℹ Safe fix 172 172 | __all__.extend( # comment0 173 173 | # comment1 174 174 | [ # comment2 @@ -784,7 +760,6 @@ RUF022.py:183:11: RUF022 [*] `__all__` is not sorted | = help: Apply an isort-style sorting to `__all__` -ℹ Safe fix 180 180 | ] # comment4 181 181 | ) # comment2 182 182 | @@ -815,7 +790,6 @@ RUF022.py:188:11: RUF022 [*] `__all__` is not sorted | = help: Apply an isort-style sorting to `__all__` -ℹ Safe fix 185 185 | "LabeledScale", "OptionMenu", 186 186 | ] 187 187 | @@ -849,7 +823,6 @@ RUF022.py:192:11: RUF022 [*] `__all__` is not sorted | = help: Apply an isort-style sorting to `__all__` -ℹ Safe fix 190 190 | ] 191 191 | 192 192 | __all__ = [ @@ -921,7 +894,6 @@ RUF022.py:225:11: RUF022 [*] `__all__` is not sorted | = help: Apply an isort-style sorting to `__all__` -ℹ Safe fix 223 223 | ############################################################ 224 224 | 225 225 | __all__ = ( @@ -947,7 +919,6 @@ RUF022.py:229:11: RUF022 [*] `__all__` is not sorted | = help: Apply an isort-style sorting to `__all__` -ℹ Safe fix 227 227 | "dumps",) 228 228 | 229 229 | __all__ = [ @@ -979,7 +950,6 @@ RUF022.py:233:11: RUF022 [*] `__all__` is not sorted | = help: Apply an isort-style sorting to `__all__` -ℹ Safe fix 230 230 | "loads", 231 231 | "dumps" , ] 232 232 | @@ -1013,7 +983,6 @@ RUF022.py:243:11: RUF022 [*] `__all__` is not sorted | = help: Apply an isort-style sorting to `__all__` -ℹ Safe fix 241 241 | ] 242 242 | 243 243 | __all__ = ( @@ -1055,7 +1024,6 @@ RUF022.py:253:11: RUF022 [*] `__all__` is not sorted | = help: Apply an isort-style sorting to `__all__` -ℹ Safe fix 251 251 | ) 252 252 | 253 253 | __all__ = ( # comment about the opening paren @@ -1076,5 +1044,3 @@ RUF022.py:253:11: RUF022 [*] `__all__` is not sorted 263 263 | # strange multiline comment comment 2a 264 264 | # strange multiline comment 2b 265 265 | , - - diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF023_RUF023.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF023_RUF023.py.snap index 2ec896e3081c3..38d30d89f7bd3 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF023_RUF023.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF023_RUF023.py.snap @@ -10,7 +10,6 @@ RUF023.py:6:17: RUF023 [*] `Klass.__slots__` is not sorted | = help: Apply a natural sort to `Klass.__slots__` -ℹ Safe fix 3 3 | ######################### 4 4 | 5 5 | class Klass: @@ -31,7 +30,6 @@ RUF023.py:7:17: RUF023 [*] `Klass.__slots__` is not sorted | = help: Apply a natural sort to `Klass.__slots__` -ℹ Safe fix 4 4 | 5 5 | class Klass: 6 6 | __slots__ = ["d", "c", "b", "a"] # a comment that is untouched @@ -52,7 +50,6 @@ RUF023.py:11:22: RUF023 [*] `Klass.__slots__` is not sorted | = help: Apply a natural sort to `Klass.__slots__` -ℹ Safe fix 8 8 | 9 9 | # Quoting style is retained, 10 10 | # but unnecessary parens are not @@ -73,7 +70,6 @@ RUF023.py:14:24: RUF023 [*] `Klass.__slots__` is not sorted | = help: Apply a natural sort to `Klass.__slots__` -ℹ Safe fix 11 11 | __slots__: set = {'b', "c", ((('a')))} 12 12 | # Trailing commas are also not retained for single-line definitions 13 13 | # (but they are in multiline definitions) @@ -94,7 +90,6 @@ RUF023.py:18:21: RUF023 [*] `Klass2.__slots__` is not sorted | = help: Apply a natural sort to `Klass2.__slots__` -ℹ Safe fix 15 15 | 16 16 | class Klass2: 17 17 | if bool(): @@ -115,7 +110,6 @@ RUF023.py:20:21: RUF023 [*] `Klass2.__slots__` is not sorted | = help: Apply a natural sort to `Klass2.__slots__` -ℹ Safe fix 17 17 | if bool(): 18 18 | __slots__ = {"x": "docs for x", "m": "docs for m", "a": "docs for a"} 19 19 | else: @@ -136,7 +130,6 @@ RUF023.py:22:28: RUF023 [*] `Klass2.__slots__` is not sorted | = help: Apply a natural sort to `Klass2.__slots__` -ℹ Safe fix 19 19 | else: 20 20 | __slots__ = "foo3", "foo2", "foo1" # NB: an implicit tuple (without parens) 21 21 | @@ -156,7 +149,6 @@ RUF023.py:23:17: RUF023 [*] `Klass2.__slots__` is not sorted | = help: Apply a natural sort to `Klass2.__slots__` -ℹ Safe fix 20 20 | __slots__ = "foo3", "foo2", "foo1" # NB: an implicit tuple (without parens) 21 21 | 22 22 | __slots__: list[str] = ["the", "three", "little", "pigs"] @@ -177,7 +169,6 @@ RUF023.py:26:17: RUF023 [*] `Klass2.__slots__` is not sorted | = help: Apply a natural sort to `Klass2.__slots__` -ℹ Safe fix 23 23 | __slots__ = ("parenthesized_item"), "in", ("an_unparenthesized_tuple") 24 24 | # we use natural sort, 25 25 | # not alphabetical sort or "isort-style" sort @@ -204,7 +195,6 @@ RUF023.py:33:17: RUF023 [*] `Klass3.__slots__` is not sorted | = help: Apply a natural sort to `Klass3.__slots__` -ℹ Safe fix 31 31 | 32 32 | class Klass3: 33 33 | __slots__ = ( @@ -239,7 +229,6 @@ RUF023.py:40:17: RUF023 [*] `Klass3.__slots__` is not sorted | = help: Apply a natural sort to `Klass3.__slots__` -ℹ Safe fix 38 38 | "a0" 39 39 | ) 40 40 | __slots__ = [ @@ -274,7 +263,6 @@ RUF023.py:54:17: RUF023 [*] `Klass4.__slots__` is not sorted | = help: Apply a natural sort to `Klass4.__slots__` -ℹ Safe fix 51 51 | 52 52 | class Klass4: 53 53 | # comment0 @@ -315,7 +303,6 @@ RUF023.py:64:17: RUF023 [*] `Klass4.__slots__` is not sorted | = help: Apply a natural sort to `Klass4.__slots__` -ℹ Safe fix 62 62 | # comment7 63 63 | 64 64 | __slots__ = [ # comment0 @@ -376,7 +363,6 @@ RUF023.py:75:17: RUF023 [*] `PurePath.__slots__` is not sorted | = help: Apply a natural sort to `PurePath.__slots__` -ℹ Safe fix 73 73 | # from cpython/Lib/pathlib/__init__.py 74 74 | class PurePath: 75 75 | __slots__ = ( @@ -459,7 +445,6 @@ RUF023.py:113:17: RUF023 [*] `ArgumentDescriptor.__slots__` is not sorted | = help: Apply a natural sort to `ArgumentDescriptor.__slots__` -ℹ Safe fix 111 111 | # From cpython/Lib/pickletools.py 112 112 | class ArgumentDescriptor(object): 113 113 | __slots__ = ( @@ -555,7 +540,6 @@ RUF023.py:162:17: RUF023 [*] `BezierBuilder.__slots__` is not sorted | = help: Apply a natural sort to `BezierBuilder.__slots__` -ℹ Safe fix 159 159 | ############################################################ 160 160 | 161 161 | class BezierBuilder: @@ -582,7 +566,6 @@ RUF023.py:166:17: RUF023 [*] `BezierBuilder2.__slots__` is not sorted | = help: Apply a natural sort to `BezierBuilder2.__slots__` -ℹ Safe fix 163 163 | 'canvas',) 164 164 | 165 165 | class BezierBuilder2: @@ -615,7 +598,6 @@ RUF023.py:170:17: RUF023 [*] `BezierBuilder3.__slots__` is not sorted | = help: Apply a natural sort to `BezierBuilder3.__slots__` -ℹ Safe fix 167 167 | 'canvas' , } 168 168 | 169 169 | class BezierBuilder3: @@ -648,7 +630,6 @@ RUF023.py:181:17: RUF023 [*] `BezierBuilder4.__slots__` is not sorted | = help: Apply a natural sort to `BezierBuilder4.__slots__` -ℹ Safe fix 179 179 | 180 180 | class BezierBuilder4: 181 181 | __slots__ = ( @@ -677,7 +658,6 @@ RUF023.py:191:17: RUF023 [*] `BezierBuilder4.__slots__` is not sorted | = help: Apply a natural sort to `BezierBuilder4.__slots__` -ℹ Safe fix 188 188 | , 189 189 | ) 190 190 | @@ -693,5 +673,3 @@ RUF023.py:191:17: RUF023 [*] `BezierBuilder4.__slots__` is not sorted 194 197 | 195 198 | ################################### 196 199 | # These should all not get flagged: - - diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF024_RUF024.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF024_RUF024.py.snap index f083f1920fa04..50906996f45b6 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF024_RUF024.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF024_RUF024.py.snap @@ -11,15 +11,6 @@ RUF024.py:9:1: RUF024 [*] Do not pass mutable objects as values to `dict.fromkey | = help: Replace with comprehension -ℹ Unsafe fix -6 6 | ] -7 7 | -8 8 | # Errors. -9 |-dict.fromkeys(pierogi_fillings, []) - 9 |+{key: [] for key in pierogi_fillings} -10 10 | dict.fromkeys(pierogi_fillings, list()) -11 11 | dict.fromkeys(pierogi_fillings, {}) -12 12 | dict.fromkeys(pierogi_fillings, set()) RUF024.py:10:1: RUF024 [*] Do not pass mutable objects as values to `dict.fromkeys` | @@ -32,15 +23,6 @@ RUF024.py:10:1: RUF024 [*] Do not pass mutable objects as values to `dict.fromke | = help: Replace with comprehension -ℹ Unsafe fix -7 7 | -8 8 | # Errors. -9 9 | dict.fromkeys(pierogi_fillings, []) -10 |-dict.fromkeys(pierogi_fillings, list()) - 10 |+{key: list() for key in pierogi_fillings} -11 11 | dict.fromkeys(pierogi_fillings, {}) -12 12 | dict.fromkeys(pierogi_fillings, set()) -13 13 | dict.fromkeys(pierogi_fillings, {"pre": "populated!"}) RUF024.py:11:1: RUF024 [*] Do not pass mutable objects as values to `dict.fromkeys` | @@ -53,15 +35,6 @@ RUF024.py:11:1: RUF024 [*] Do not pass mutable objects as values to `dict.fromke | = help: Replace with comprehension -ℹ Unsafe fix -8 8 | # Errors. -9 9 | dict.fromkeys(pierogi_fillings, []) -10 10 | dict.fromkeys(pierogi_fillings, list()) -11 |-dict.fromkeys(pierogi_fillings, {}) - 11 |+{key: {} for key in pierogi_fillings} -12 12 | dict.fromkeys(pierogi_fillings, set()) -13 13 | dict.fromkeys(pierogi_fillings, {"pre": "populated!"}) -14 14 | dict.fromkeys(pierogi_fillings, dict()) RUF024.py:12:1: RUF024 [*] Do not pass mutable objects as values to `dict.fromkeys` | @@ -74,15 +47,6 @@ RUF024.py:12:1: RUF024 [*] Do not pass mutable objects as values to `dict.fromke | = help: Replace with comprehension -ℹ Unsafe fix -9 9 | dict.fromkeys(pierogi_fillings, []) -10 10 | dict.fromkeys(pierogi_fillings, list()) -11 11 | dict.fromkeys(pierogi_fillings, {}) -12 |-dict.fromkeys(pierogi_fillings, set()) - 12 |+{key: set() for key in pierogi_fillings} -13 13 | dict.fromkeys(pierogi_fillings, {"pre": "populated!"}) -14 14 | dict.fromkeys(pierogi_fillings, dict()) -15 15 | import builtins RUF024.py:13:1: RUF024 [*] Do not pass mutable objects as values to `dict.fromkeys` | @@ -95,15 +59,6 @@ RUF024.py:13:1: RUF024 [*] Do not pass mutable objects as values to `dict.fromke | = help: Replace with comprehension -ℹ Unsafe fix -10 10 | dict.fromkeys(pierogi_fillings, list()) -11 11 | dict.fromkeys(pierogi_fillings, {}) -12 12 | dict.fromkeys(pierogi_fillings, set()) -13 |-dict.fromkeys(pierogi_fillings, {"pre": "populated!"}) - 13 |+{key: {"pre": "populated!"} for key in pierogi_fillings} -14 14 | dict.fromkeys(pierogi_fillings, dict()) -15 15 | import builtins -16 16 | builtins.dict.fromkeys(pierogi_fillings, dict()) RUF024.py:14:1: RUF024 [*] Do not pass mutable objects as values to `dict.fromkeys` | @@ -116,15 +71,6 @@ RUF024.py:14:1: RUF024 [*] Do not pass mutable objects as values to `dict.fromke | = help: Replace with comprehension -ℹ Unsafe fix -11 11 | dict.fromkeys(pierogi_fillings, {}) -12 12 | dict.fromkeys(pierogi_fillings, set()) -13 13 | dict.fromkeys(pierogi_fillings, {"pre": "populated!"}) -14 |-dict.fromkeys(pierogi_fillings, dict()) - 14 |+{key: dict() for key in pierogi_fillings} -15 15 | import builtins -16 16 | builtins.dict.fromkeys(pierogi_fillings, dict()) -17 17 | RUF024.py:16:1: RUF024 [*] Do not pass mutable objects as values to `dict.fromkeys` | @@ -136,13 +82,3 @@ RUF024.py:16:1: RUF024 [*] Do not pass mutable objects as values to `dict.fromke 18 | # Okay. | = help: Replace with comprehension - -ℹ Unsafe fix -13 13 | dict.fromkeys(pierogi_fillings, {"pre": "populated!"}) -14 14 | dict.fromkeys(pierogi_fillings, dict()) -15 15 | import builtins -16 |-builtins.dict.fromkeys(pierogi_fillings, dict()) - 16 |+{key: dict() for key in pierogi_fillings} -17 17 | -18 18 | # Okay. -19 19 | dict.fromkeys(pierogi_fillings) diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF025_RUF025.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF025_RUF025.py.snap index 519fb1b801390..e5afeabab9954 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF025_RUF025.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF025_RUF025.py.snap @@ -10,7 +10,6 @@ RUF025.py:6:5: RUF025 [*] Unnecessary dict comprehension for iterable; use `dict | = help: Replace with `dict.fromkeys(iterable, value)`) -ℹ Safe fix 3 3 | 4 4 | def func(): 5 5 | numbers = [1, 2, 3] @@ -29,7 +28,6 @@ RUF025.py:10:23: RUF025 [*] Unnecessary dict comprehension for iterable; use `di | = help: Replace with `dict.fromkeys(iterable)`) -ℹ Safe fix 7 7 | 8 8 | 9 9 | def func(): @@ -47,7 +45,6 @@ RUF025.py:15:5: RUF025 [*] Unnecessary dict comprehension for iterable; use `dic | = help: Replace with `dict.fromkeys(iterable)`) -ℹ Safe fix 12 12 | 13 13 | 14 14 | def func(): @@ -66,7 +63,6 @@ RUF025.py:26:7: RUF025 [*] Unnecessary dict comprehension for iterable; use `dic | = help: Replace with `dict.fromkeys(iterable)`) -ℹ Safe fix 23 23 | def f(data): 24 24 | return data 25 25 | @@ -84,7 +80,6 @@ RUF025.py:30:5: RUF025 [*] Unnecessary dict comprehension for iterable; use `dic | = help: Replace with `dict.fromkeys(iterable)`) -ℹ Safe fix 27 27 | 28 28 | 29 29 | def func(): @@ -102,7 +97,6 @@ RUF025.py:34:5: RUF025 [*] Unnecessary dict comprehension for iterable; use `dic | = help: Replace with `dict.fromkeys(iterable)`) -ℹ Safe fix 31 31 | 32 32 | 33 33 | def func(): @@ -120,7 +114,6 @@ RUF025.py:38:5: RUF025 [*] Unnecessary dict comprehension for iterable; use `dic | = help: Replace with `dict.fromkeys(iterable)`) -ℹ Safe fix 35 35 | 36 36 | 37 37 | def func(): @@ -138,7 +131,6 @@ RUF025.py:42:5: RUF025 [*] Unnecessary dict comprehension for iterable; use `dic | = help: Replace with `dict.fromkeys(iterable)`) -ℹ Safe fix 39 39 | 40 40 | 41 41 | def func(): @@ -156,7 +148,6 @@ RUF025.py:46:5: RUF025 [*] Unnecessary dict comprehension for iterable; use `dic | = help: Replace with `dict.fromkeys(iterable)`) -ℹ Safe fix 43 43 | 44 44 | 45 45 | def func(): @@ -174,7 +165,6 @@ RUF025.py:54:5: RUF025 [*] Unnecessary dict comprehension for iterable; use `dic | = help: Replace with `dict.fromkeys(iterable)`) -ℹ Safe fix 51 51 | return 1 52 52 | 53 53 | a = f() @@ -193,7 +183,6 @@ RUF025.py:59:6: RUF025 [*] Unnecessary dict comprehension for iterable; use `dic | = help: Replace with `dict.fromkeys(iterable)`) -ℹ Safe fix 56 56 | 57 57 | def func(): 58 58 | values = ["a", "b", "c"] @@ -202,5 +191,3 @@ RUF025.py:59:6: RUF025 [*] Unnecessary dict comprehension for iterable; use `dic 60 60 | 61 61 | 62 62 | # Non-violation cases: RUF025 - - diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF026_RUF026.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF026_RUF026.py.snap index 100ff9db321ba..4fccb0fd63920 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF026_RUF026.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF026_RUF026.py.snap @@ -9,15 +9,6 @@ RUF026.py:11:5: RUF026 [*] `default_factory` is a positional-only argument to `d | = help: Replace with `defaultdict(default_factory=int)` -ℹ Unsafe fix -8 8 | -9 9 | -10 10 | def func(): -11 |- defaultdict(default_factory=int) # RUF026 - 11 |+ defaultdict(int) # RUF026 -12 12 | -13 13 | -14 14 | def func(): RUF026.py:15:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` | @@ -27,15 +18,6 @@ RUF026.py:15:5: RUF026 [*] `default_factory` is a positional-only argument to `d | = help: Replace with `defaultdict(default_factory=float)` -ℹ Unsafe fix -12 12 | -13 13 | -14 14 | def func(): -15 |- defaultdict(default_factory=float) # RUF026 - 15 |+ defaultdict(float) # RUF026 -16 16 | -17 17 | -18 18 | def func(): RUF026.py:19:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` | @@ -45,15 +27,6 @@ RUF026.py:19:5: RUF026 [*] `default_factory` is a positional-only argument to `d | = help: Replace with `defaultdict(default_factory=dict)` -ℹ Unsafe fix -16 16 | -17 17 | -18 18 | def func(): -19 |- defaultdict(default_factory=dict) # RUF026 - 19 |+ defaultdict(dict) # RUF026 -20 20 | -21 21 | -22 22 | def func(): RUF026.py:23:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` | @@ -63,15 +36,6 @@ RUF026.py:23:5: RUF026 [*] `default_factory` is a positional-only argument to `d | = help: Replace with `defaultdict(default_factory=list)` -ℹ Unsafe fix -20 20 | -21 21 | -22 22 | def func(): -23 |- defaultdict(default_factory=list) # RUF026 - 23 |+ defaultdict(list) # RUF026 -24 24 | -25 25 | -26 26 | def func(): RUF026.py:27:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` | @@ -81,15 +45,6 @@ RUF026.py:27:5: RUF026 [*] `default_factory` is a positional-only argument to `d | = help: Replace with `defaultdict(default_factory=tuple)` -ℹ Unsafe fix -24 24 | -25 25 | -26 26 | def func(): -27 |- defaultdict(default_factory=tuple) # RUF026 - 27 |+ defaultdict(tuple) # RUF026 -28 28 | -29 29 | -30 30 | def func(): RUF026.py:34:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` | @@ -100,15 +55,6 @@ RUF026.py:34:5: RUF026 [*] `default_factory` is a positional-only argument to `d | = help: Replace with `defaultdict(default_factory=foo)` -ℹ Unsafe fix -31 31 | def foo(): -32 32 | pass -33 33 | -34 |- defaultdict(default_factory=foo) # RUF026 - 34 |+ defaultdict(foo) # RUF026 -35 35 | -36 36 | -37 37 | def func(): RUF026.py:38:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` | @@ -118,15 +64,6 @@ RUF026.py:38:5: RUF026 [*] `default_factory` is a positional-only argument to `d | = help: Replace with `defaultdict(default_factory=lambda: 1)` -ℹ Unsafe fix -35 35 | -36 36 | -37 37 | def func(): -38 |- defaultdict(default_factory=lambda: 1) # RUF026 - 38 |+ defaultdict(lambda: 1) # RUF026 -39 39 | -40 40 | -41 41 | def func(): RUF026.py:44:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` | @@ -137,15 +74,6 @@ RUF026.py:44:5: RUF026 [*] `default_factory` is a positional-only argument to `d | = help: Replace with `defaultdict(default_factory=deque)` -ℹ Unsafe fix -41 41 | def func(): -42 42 | from collections import deque -43 43 | -44 |- defaultdict(default_factory=deque) # RUF026 - 44 |+ defaultdict(deque) # RUF026 -45 45 | -46 46 | -47 47 | def func(): RUF026.py:52:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` | @@ -156,15 +84,6 @@ RUF026.py:52:5: RUF026 [*] `default_factory` is a positional-only argument to `d | = help: Replace with `defaultdict(default_factory=MyCallable())` -ℹ Unsafe fix -49 49 | def __call__(self): -50 50 | pass -51 51 | -52 |- defaultdict(default_factory=MyCallable()) # RUF026 - 52 |+ defaultdict(MyCallable()) # RUF026 -53 53 | -54 54 | -55 55 | def func(): RUF026.py:56:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` | @@ -174,15 +93,6 @@ RUF026.py:56:5: RUF026 [*] `default_factory` is a positional-only argument to `d | = help: Replace with `defaultdict(default_factory=tuple)` -ℹ Unsafe fix -53 53 | -54 54 | -55 55 | def func(): -56 |- defaultdict(default_factory=tuple, member=1) # RUF026 - 56 |+ defaultdict(tuple, member=1) # RUF026 -57 57 | -58 58 | -59 59 | def func(): RUF026.py:60:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` | @@ -192,15 +102,6 @@ RUF026.py:60:5: RUF026 [*] `default_factory` is a positional-only argument to `d | = help: Replace with `defaultdict(default_factory=tuple)` -ℹ Unsafe fix -57 57 | -58 58 | -59 59 | def func(): -60 |- defaultdict(member=1, default_factory=tuple) # RUF026 - 60 |+ defaultdict(tuple, member=1) # RUF026 -61 61 | -62 62 | -63 63 | def func(): RUF026.py:64:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` | @@ -210,15 +111,6 @@ RUF026.py:64:5: RUF026 [*] `default_factory` is a positional-only argument to `d | = help: Replace with `defaultdict(default_factory=tuple)` -ℹ Unsafe fix -61 61 | -62 62 | -63 63 | def func(): -64 |- defaultdict(member=1, default_factory=tuple,) # RUF026 - 64 |+ defaultdict(tuple, member=1,) # RUF026 -65 65 | -66 66 | -67 67 | def func(): RUF026.py:68:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` | @@ -232,16 +124,6 @@ RUF026.py:68:5: RUF026 [*] `default_factory` is a positional-only argument to `d | = help: Replace with `defaultdict(default_factory=tuple)` -ℹ Unsafe fix -66 66 | -67 67 | def func(): -68 68 | defaultdict( -69 |- member=1, -70 |- default_factory=tuple, - 69 |+ tuple, member=1, -71 70 | ) # RUF026 -72 71 | -73 72 | RUF026.py:75:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` | @@ -254,16 +136,3 @@ RUF026.py:75:5: RUF026 [*] `default_factory` is a positional-only argument to `d | |_____^ RUF026 | = help: Replace with `defaultdict(default_factory=tuple)` - -ℹ Unsafe fix -73 73 | -74 74 | def func(): -75 75 | defaultdict( -76 |- default_factory=tuple, -77 |- member=1, - 76 |+ tuple, member=1, -78 77 | ) # RUF026 -79 78 | -80 79 | - - diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF027_RUF027_0.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF027_RUF027_0.py.snap index ca858cdcda640..9ae0f58893423 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF027_RUF027_0.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF027_RUF027_0.py.snap @@ -10,15 +10,6 @@ RUF027_0.py:5:7: RUF027 [*] Possible f-string without an `f` prefix | = help: Add `f` prefix -ℹ Unsafe fix -2 2 | -3 3 | "always ignore this: {val}" -4 4 | -5 |-print("but don't ignore this: {val}") # RUF027 - 5 |+print(f"but don't ignore this: {val}") # RUF027 -6 6 | -7 7 | -8 8 | def simple_cases(): RUF027_0.py:10:9: RUF027 [*] Possible f-string without an `f` prefix | @@ -30,15 +21,6 @@ RUF027_0.py:10:9: RUF027 [*] Possible f-string without an `f` prefix | = help: Add `f` prefix -ℹ Unsafe fix -7 7 | -8 8 | def simple_cases(): -9 9 | a = 4 -10 |- b = "{a}" # RUF027 - 10 |+ b = f"{a}" # RUF027 -11 11 | c = "{a} {b} f'{val}' " # RUF027 -12 12 | -13 13 | RUF027_0.py:11:9: RUF027 [*] Possible f-string without an `f` prefix | @@ -49,15 +31,6 @@ RUF027_0.py:11:9: RUF027 [*] Possible f-string without an `f` prefix | = help: Add `f` prefix -ℹ Unsafe fix -8 8 | def simple_cases(): -9 9 | a = 4 -10 10 | b = "{a}" # RUF027 -11 |- c = "{a} {b} f'{val}' " # RUF027 - 11 |+ c = f"{a} {b} f'{val}' " # RUF027 -12 12 | -13 13 | -14 14 | def escaped_string(): RUF027_0.py:21:9: RUF027 [*] Possible f-string without an `f` prefix | @@ -69,15 +42,6 @@ RUF027_0.py:21:9: RUF027 [*] Possible f-string without an `f` prefix | = help: Add `f` prefix -ℹ Unsafe fix -18 18 | -19 19 | def raw_string(): -20 20 | a = 4 -21 |- b = r"raw string with formatting: {a}" # RUF027 - 21 |+ b = fr"raw string with formatting: {a}" # RUF027 -22 22 | c = r"raw string with \backslashes\ and \"escaped quotes\": {a}" # RUF027 -23 23 | -24 24 | RUF027_0.py:22:9: RUF027 [*] Possible f-string without an `f` prefix | @@ -88,15 +52,6 @@ RUF027_0.py:22:9: RUF027 [*] Possible f-string without an `f` prefix | = help: Add `f` prefix -ℹ Unsafe fix -19 19 | def raw_string(): -20 20 | a = 4 -21 21 | b = r"raw string with formatting: {a}" # RUF027 -22 |- c = r"raw string with \backslashes\ and \"escaped quotes\": {a}" # RUF027 - 22 |+ c = fr"raw string with \backslashes\ and \"escaped quotes\": {a}" # RUF027 -23 23 | -24 24 | -25 25 | def print_name(name: str): RUF027_0.py:27:11: RUF027 [*] Possible f-string without an `f` prefix | @@ -108,15 +63,6 @@ RUF027_0.py:27:11: RUF027 [*] Possible f-string without an `f` prefix | = help: Add `f` prefix -ℹ Unsafe fix -24 24 | -25 25 | def print_name(name: str): -26 26 | a = 4 -27 |- print("Hello, {name}!") # RUF027 - 27 |+ print(f"Hello, {name}!") # RUF027 -28 28 | print("The test value we're using today is {a}") # RUF027 -29 29 | -30 30 | RUF027_0.py:28:11: RUF027 [*] Possible f-string without an `f` prefix | @@ -127,15 +73,6 @@ RUF027_0.py:28:11: RUF027 [*] Possible f-string without an `f` prefix | = help: Add `f` prefix -ℹ Unsafe fix -25 25 | def print_name(name: str): -26 26 | a = 4 -27 27 | print("Hello, {name}!") # RUF027 -28 |- print("The test value we're using today is {a}") # RUF027 - 28 |+ print(f"The test value we're using today is {a}") # RUF027 -29 29 | -30 30 | -31 31 | def nested_funcs(): RUF027_0.py:33:33: RUF027 [*] Possible f-string without an `f` prefix | @@ -146,15 +83,6 @@ RUF027_0.py:33:33: RUF027 [*] Possible f-string without an `f` prefix | = help: Add `f` prefix -ℹ Unsafe fix -30 30 | -31 31 | def nested_funcs(): -32 32 | a = 4 -33 |- print(do_nothing(do_nothing("{a}"))) # RUF027 - 33 |+ print(do_nothing(do_nothing(f"{a}"))) # RUF027 -34 34 | -35 35 | -36 36 | def tripled_quoted(): RUF027_0.py:39:19: RUF027 [*] Possible f-string without an `f` prefix | @@ -167,15 +95,6 @@ RUF027_0.py:39:19: RUF027 [*] Possible f-string without an `f` prefix | = help: Add `f` prefix -ℹ Unsafe fix -36 36 | def tripled_quoted(): -37 37 | a = 4 -38 38 | c = a -39 |- single_line = """ {a} """ # RUF027 - 39 |+ single_line = f""" {a} """ # RUF027 -40 40 | # RUF027 -41 41 | multi_line = a = """b { # comment -42 42 | c} d RUF027_0.py:41:22: RUF027 [*] Possible f-string without an `f` prefix | @@ -189,15 +108,6 @@ RUF027_0.py:41:22: RUF027 [*] Possible f-string without an `f` prefix | = help: Add `f` prefix -ℹ Unsafe fix -38 38 | c = a -39 39 | single_line = """ {a} """ # RUF027 -40 40 | # RUF027 -41 |- multi_line = a = """b { # comment - 41 |+ multi_line = a = f"""b { # comment -42 42 | c} d -43 43 | """ -44 44 | RUF027_0.py:49:9: RUF027 [*] Possible f-string without an `f` prefix | @@ -211,15 +121,6 @@ RUF027_0.py:49:9: RUF027 [*] Possible f-string without an `f` prefix | = help: Add `f` prefix -ℹ Unsafe fix -46 46 | def single_quoted_multi_line(): -47 47 | a = 4 -48 48 | # RUF027 -49 |- b = " {\ - 49 |+ b = f" {\ -50 50 | a} \ -51 51 | " -52 52 | RUF027_0.py:56:9: RUF027 [*] Possible f-string without an `f` prefix | @@ -231,15 +132,6 @@ RUF027_0.py:56:9: RUF027 [*] Possible f-string without an `f` prefix | = help: Add `f` prefix -ℹ Unsafe fix -53 53 | -54 54 | def implicit_concat(): -55 55 | a = 4 -56 |- b = "{a}" "+" "{b}" r" \\ " # RUF027 for the first part only - 56 |+ b = f"{a}" "+" "{b}" r" \\ " # RUF027 for the first part only -57 57 | print(f"{a}" "{a}" f"{b}") # RUF027 -58 58 | -59 59 | RUF027_0.py:57:18: RUF027 [*] Possible f-string without an `f` prefix | @@ -250,15 +142,6 @@ RUF027_0.py:57:18: RUF027 [*] Possible f-string without an `f` prefix | = help: Add `f` prefix -ℹ Unsafe fix -54 54 | def implicit_concat(): -55 55 | a = 4 -56 56 | b = "{a}" "+" "{b}" r" \\ " # RUF027 for the first part only -57 |- print(f"{a}" "{a}" f"{b}") # RUF027 - 57 |+ print(f"{a}" f"{a}" f"{b}") # RUF027 -58 58 | -59 59 | -60 60 | def escaped_chars(): RUF027_0.py:62:9: RUF027 [*] Possible f-string without an `f` prefix | @@ -269,15 +152,6 @@ RUF027_0.py:62:9: RUF027 [*] Possible f-string without an `f` prefix | = help: Add `f` prefix -ℹ Unsafe fix -59 59 | -60 60 | def escaped_chars(): -61 61 | a = 4 -62 |- b = "\"not escaped:\" '{a}' \"escaped:\": '{{c}}'" # RUF027 - 62 |+ b = f"\"not escaped:\" '{a}' \"escaped:\": '{{c}}'" # RUF027 -63 63 | -64 64 | -65 65 | def method_calls(): RUF027_0.py:70:18: RUF027 [*] Possible f-string without an `f` prefix | @@ -290,15 +164,6 @@ RUF027_0.py:70:18: RUF027 [*] Possible f-string without an `f` prefix | = help: Add `f` prefix -ℹ Unsafe fix -67 67 | value.method = print_name -68 68 | first = "Wendy" -69 69 | last = "Appleseed" -70 |- value.method("{first} {last}") # RUF027 - 70 |+ value.method(f"{first} {last}") # RUF027 -71 71 | -72 72 | def format_specifiers(): -73 73 | a = 4 RUF027_0.py:74:9: RUF027 [*] Possible f-string without an `f` prefix | @@ -308,12 +173,3 @@ RUF027_0.py:74:9: RUF027 [*] Possible f-string without an `f` prefix | ^^^^^^^^^^^^^^ RUF027 | = help: Add `f` prefix - -ℹ Unsafe fix -71 71 | -72 72 | def format_specifiers(): -73 73 | a = 4 -74 |- b = "{a:b} {a:^5}" - 74 |+ b = f"{a:b} {a:^5}" - - diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF028_RUF028.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF028_RUF028.py.snap index a2846ab41fa89..b69379885a2e3 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF028_RUF028.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF028_RUF028.py.snap @@ -12,13 +12,6 @@ RUF028.py:3:9: RUF028 [*] This suppression comment is invalid because it cannot | = help: Remove this comment -ℹ Unsafe fix -1 1 | def fmt_off_between_lists(): -2 2 | test_list = [ -3 |- # fmt: off -4 3 | 1, -5 4 | 2, -6 5 | 3, RUF028.py:12:5: RUF028 [*] This suppression comment is invalid because it cannot be on its own line | @@ -30,14 +23,6 @@ RUF028.py:12:5: RUF028 [*] This suppression comment is invalid because it cannot | = help: Remove this comment -ℹ Unsafe fix -9 9 | -10 10 | # note: the second `fmt: skip`` should be OK -11 11 | def fmt_skip_on_own_line(): -12 |- # fmt: skip -13 12 | pass # fmt: skip -14 13 | -15 14 | RUF028.py:17:1: RUF028 [*] This suppression comment is invalid because it cannot be after a decorator | @@ -49,14 +34,6 @@ RUF028.py:17:1: RUF028 [*] This suppression comment is invalid because it cannot | = help: Remove this comment -ℹ Unsafe fix -14 14 | -15 15 | -16 16 | @fmt_skip_on_own_line -17 |-# fmt: off -18 17 | @fmt_off_between_lists -19 18 | def fmt_off_between_decorators(): -20 19 | pass RUF028.py:24:1: RUF028 [*] This suppression comment is invalid because it cannot be after a decorator | @@ -68,14 +45,6 @@ RUF028.py:24:1: RUF028 [*] This suppression comment is invalid because it cannot | = help: Remove this comment -ℹ Unsafe fix -21 21 | -22 22 | -23 23 | @fmt_off_between_decorators -24 |-# fmt: off -25 24 | class FmtOffBetweenClassDecorators: -26 25 | ... -27 26 | RUF028.py:33:5: RUF028 [*] This suppression comment is invalid because it cannot be directly above an alternate body | @@ -88,14 +57,6 @@ RUF028.py:33:5: RUF028 [*] This suppression comment is invalid because it cannot | = help: Remove this comment -ℹ Unsafe fix -30 30 | x = [1, 2, 3] -31 31 | for val in x: -32 32 | print(x) -33 |- # fmt: off -34 33 | else: -35 34 | print("done") -36 35 | while False: RUF028.py:39:5: RUF028 [*] This suppression comment is invalid because it cannot be directly above an alternate body | @@ -108,14 +69,6 @@ RUF028.py:39:5: RUF028 [*] This suppression comment is invalid because it cannot | = help: Remove this comment -ℹ Unsafe fix -36 36 | while False: -37 37 | print("while") -38 38 | # fmt: off -39 |- # fmt: off -40 39 | else: -41 40 | print("done") -42 41 | if len(x) > 3: RUF028.py:45:5: RUF028 [*] This suppression comment is invalid because it cannot be directly above an alternate body | @@ -128,14 +81,6 @@ RUF028.py:45:5: RUF028 [*] This suppression comment is invalid because it cannot | = help: Remove this comment -ℹ Unsafe fix -42 42 | if len(x) > 3: -43 43 | print("huh?") -44 44 | # fmt: on -45 |- # fmt: off -46 45 | else: -47 46 | print("expected") -48 47 | RUF028.py:52:5: RUF028 [*] This suppression comment is invalid because it cannot be after a decorator | @@ -148,14 +93,6 @@ RUF028.py:52:5: RUF028 [*] This suppression comment is invalid because it cannot | = help: Remove this comment -ℹ Unsafe fix -49 49 | -50 50 | class Test: -51 51 | @classmethod -52 |- # fmt: off -53 52 | def cls_method_a( -54 53 | # fmt: off -55 54 | cls, RUF028.py:54:9: RUF028 [*] This suppression comment is invalid because it cannot be in an expression, pattern, argument list, or other non-statement | @@ -168,14 +105,6 @@ RUF028.py:54:9: RUF028 [*] This suppression comment is invalid because it cannot | = help: Remove this comment -ℹ Unsafe fix -51 51 | @classmethod -52 52 | # fmt: off -53 53 | def cls_method_a( -54 |- # fmt: off -55 54 | cls, -56 55 | ) -> None: # noqa: test # fmt: skip -57 56 | pass RUF028.py:62:13: RUF028 [*] This suppression comment is invalid because it cannot be at the end of a line | @@ -187,15 +116,6 @@ RUF028.py:62:13: RUF028 [*] This suppression comment is invalid because it canno | = help: Remove this comment -ℹ Unsafe fix -59 59 | -60 60 | def fmt_on_trailing(): -61 61 | # fmt: off -62 |- val = 5 # fmt: on - 62 |+ val = 5 -63 63 | pass # fmt: on -64 64 | -65 65 | RUF028.py:63:10: RUF028 [*] This suppression comment is invalid because it cannot be at the end of a line | @@ -205,13 +125,3 @@ RUF028.py:63:10: RUF028 [*] This suppression comment is invalid because it canno | ^^^^^^^^^ RUF028 | = help: Remove this comment - -ℹ Unsafe fix -60 60 | def fmt_on_trailing(): -61 61 | # fmt: off -62 62 | val = 5 # fmt: on -63 |- pass # fmt: on - 63 |+ pass -64 64 | -65 65 | -66 66 | # all of these should be fine diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF030_RUF030.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF030_RUF030.py.snap index aeea27858e988..50235dd1e4be5 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF030_RUF030.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF030_RUF030.py.snap @@ -12,15 +12,6 @@ RUF030.py:6:14: RUF030 [*] `print()` expression in `assert` statement is likely | = help: Remove `print` -ℹ Unsafe fix -3 3 | # Standard Case -4 4 | # Expects: -5 5 | # - single StringLiteral -6 |-assert True, print("This print is not intentional.") - 6 |+assert True, "This print is not intentional." -7 7 | -8 8 | # Concatenated string literals -9 9 | # Expects: RUF030.py:11:14: RUF030 [*] `print()` expression in `assert` statement is likely unintentional | @@ -33,15 +24,6 @@ RUF030.py:11:14: RUF030 [*] `print()` expression in `assert` statement is likely | = help: Remove `print` -ℹ Unsafe fix -8 8 | # Concatenated string literals -9 9 | # Expects: -10 10 | # - single StringLiteral -11 |-assert True, print("This print" " is not intentional.") - 11 |+assert True, "This print is not intentional." -12 12 | -13 13 | # Positional arguments, string literals -14 14 | # Expects: RUF030.py:16:14: RUF030 [*] `print()` expression in `assert` statement is likely unintentional | @@ -54,15 +36,6 @@ RUF030.py:16:14: RUF030 [*] `print()` expression in `assert` statement is likely | = help: Remove `print` -ℹ Unsafe fix -13 13 | # Positional arguments, string literals -14 14 | # Expects: -15 15 | # - single StringLiteral concatenated with " " -16 |-assert True, print("This print", "is not intentional") - 16 |+assert True, "This print is not intentional" -17 17 | -18 18 | # Concatenated string literals combined with Positional arguments -19 19 | # Expects: RUF030.py:21:14: RUF030 [*] `print()` expression in `assert` statement is likely unintentional | @@ -75,15 +48,6 @@ RUF030.py:21:14: RUF030 [*] `print()` expression in `assert` statement is likely | = help: Remove `print` -ℹ Unsafe fix -18 18 | # Concatenated string literals combined with Positional arguments -19 19 | # Expects: -20 20 | # - single stringliteral concatenated with " " only between `print` and `is` -21 |-assert True, print("This " "print", "is not intentional.") - 21 |+assert True, "This print is not intentional." -22 22 | -23 23 | # Positional arguments, string literals with a variable -24 24 | # Expects: RUF030.py:26:14: RUF030 [*] `print()` expression in `assert` statement is likely unintentional | @@ -96,15 +60,6 @@ RUF030.py:26:14: RUF030 [*] `print()` expression in `assert` statement is likely | = help: Remove `print` -ℹ Unsafe fix -23 23 | # Positional arguments, string literals with a variable -24 24 | # Expects: -25 25 | # - single FString concatenated with " " -26 |-assert True, print("This", print.__name__, "is not intentional.") - 26 |+assert True, f"This {print.__name__} is not intentional." -27 27 | -28 28 | # Mixed brackets string literals -29 29 | # Expects: RUF030.py:31:14: RUF030 [*] `print()` expression in `assert` statement is likely unintentional | @@ -117,15 +72,6 @@ RUF030.py:31:14: RUF030 [*] `print()` expression in `assert` statement is likely | = help: Remove `print` -ℹ Unsafe fix -28 28 | # Mixed brackets string literals -29 29 | # Expects: -30 30 | # - single StringLiteral concatenated with " " -31 |-assert True, print("This print", 'is not intentional', """and should be removed""") - 31 |+assert True, "This print is not intentional and should be removed" -32 32 | -33 33 | # Mixed brackets with other brackets inside -34 34 | # Expects: RUF030.py:36:14: RUF030 [*] `print()` expression in `assert` statement is likely unintentional | @@ -138,15 +84,6 @@ RUF030.py:36:14: RUF030 [*] `print()` expression in `assert` statement is likely | = help: Remove `print` -ℹ Unsafe fix -33 33 | # Mixed brackets with other brackets inside -34 34 | # Expects: -35 35 | # - single StringLiteral concatenated with " " and escaped brackets -36 |-assert True, print("This print", 'is not "intentional"', """and "should" be 'removed'""") - 36 |+assert True, "This print is not \"intentional\" and \"should\" be 'removed'" -37 37 | -38 38 | # Positional arguments, string literals with a separator -39 39 | # Expects: RUF030.py:41:14: RUF030 [*] `print()` expression in `assert` statement is likely unintentional | @@ -159,15 +96,6 @@ RUF030.py:41:14: RUF030 [*] `print()` expression in `assert` statement is likely | = help: Remove `print` -ℹ Unsafe fix -38 38 | # Positional arguments, string literals with a separator -39 39 | # Expects: -40 40 | # - single StringLiteral concatenated with "|" -41 |-assert True, print("This print", "is not intentional", sep="|") - 41 |+assert True, "This print|is not intentional" -42 42 | -43 43 | # Positional arguments, string literals with None as separator -44 44 | # Expects: RUF030.py:46:14: RUF030 [*] `print()` expression in `assert` statement is likely unintentional | @@ -180,15 +108,6 @@ RUF030.py:46:14: RUF030 [*] `print()` expression in `assert` statement is likely | = help: Remove `print` -ℹ Unsafe fix -43 43 | # Positional arguments, string literals with None as separator -44 44 | # Expects: -45 45 | # - single StringLiteral concatenated with " " -46 |-assert True, print("This print", "is not intentional", sep=None) - 46 |+assert True, "This print is not intentional" -47 47 | -48 48 | # Positional arguments, string literals with variable as separator, needs f-string -49 49 | # Expects: RUF030.py:51:14: RUF030 [*] `print()` expression in `assert` statement is likely unintentional | @@ -201,15 +120,6 @@ RUF030.py:51:14: RUF030 [*] `print()` expression in `assert` statement is likely | = help: Remove `print` -ℹ Unsafe fix -48 48 | # Positional arguments, string literals with variable as separator, needs f-string -49 49 | # Expects: -50 50 | # - single FString concatenated with "{U00A0}" -51 |-assert True, print("This print", "is not intentional", sep=U00A0) - 51 |+assert True, f"This print{U00A0}is not intentional" -52 52 | -53 53 | # Unnecessary f-string -54 54 | # Expects: RUF030.py:56:14: RUF030 [*] `print()` expression in `assert` statement is likely unintentional | @@ -222,15 +132,6 @@ RUF030.py:56:14: RUF030 [*] `print()` expression in `assert` statement is likely | = help: Remove `print` -ℹ Unsafe fix -53 53 | # Unnecessary f-string -54 54 | # Expects: -55 55 | # - single StringLiteral -56 |-assert True, print(f"This f-string is just a literal.") - 56 |+assert True, "This f-string is just a literal." -57 57 | -58 58 | # Positional arguments, string literals and f-strings -59 59 | # Expects: RUF030.py:61:14: RUF030 [*] `print()` expression in `assert` statement is likely unintentional | @@ -243,15 +144,6 @@ RUF030.py:61:14: RUF030 [*] `print()` expression in `assert` statement is likely | = help: Remove `print` -ℹ Unsafe fix -58 58 | # Positional arguments, string literals and f-strings -59 59 | # Expects: -60 60 | # - single FString concatenated with " " -61 |-assert True, print("This print", f"is not {'intentional':s}") - 61 |+assert True, f"This print is not {'intentional':s}" -62 62 | -63 63 | # Positional arguments, string literals and f-strings with a separator -64 64 | # Expects: RUF030.py:66:14: RUF030 [*] `print()` expression in `assert` statement is likely unintentional | @@ -264,15 +156,6 @@ RUF030.py:66:14: RUF030 [*] `print()` expression in `assert` statement is likely | = help: Remove `print` -ℹ Unsafe fix -63 63 | # Positional arguments, string literals and f-strings with a separator -64 64 | # Expects: -65 65 | # - single FString concatenated with "|" -66 |-assert True, print("This print", f"is not {'intentional':s}", sep="|") - 66 |+assert True, f"This print|is not {'intentional':s}" -67 67 | -68 68 | # A single f-string -69 69 | # Expects: RUF030.py:71:14: RUF030 [*] `print()` expression in `assert` statement is likely unintentional | @@ -285,15 +168,6 @@ RUF030.py:71:14: RUF030 [*] `print()` expression in `assert` statement is likely | = help: Remove `print` -ℹ Unsafe fix -68 68 | # A single f-string -69 69 | # Expects: -70 70 | # - single FString -71 |-assert True, print(f"This print is not {'intentional':s}") - 71 |+assert True, f"This print is not {'intentional':s}" -72 72 | -73 73 | # A single f-string with a redundant separator -74 74 | # Expects: RUF030.py:76:14: RUF030 [*] `print()` expression in `assert` statement is likely unintentional | @@ -306,15 +180,6 @@ RUF030.py:76:14: RUF030 [*] `print()` expression in `assert` statement is likely | = help: Remove `print` -ℹ Unsafe fix -73 73 | # A single f-string with a redundant separator -74 74 | # Expects: -75 75 | # - single FString -76 |-assert True, print(f"This print is not {'intentional':s}", sep="|") - 76 |+assert True, f"This print is not {'intentional':s}" -77 77 | -78 78 | # Complex f-string with variable as separator -79 79 | # Expects: RUF030.py:83:14: RUF030 [*] `print()` expression in `assert` statement is likely unintentional | @@ -327,15 +192,6 @@ RUF030.py:83:14: RUF030 [*] `print()` expression in `assert` statement is likely | = help: Remove `print` -ℹ Unsafe fix -80 80 | # - single FString concatenated with "{U00A0}", all placeholders preserved -81 81 | condition = "True is True" -82 82 | maintainer = "John Doe" -83 |-assert True, print("Unreachable due to", condition, f", ask {maintainer} for advice", sep=U00A0) - 83 |+assert True, f"Unreachable due to{U00A0}{condition}{U00A0}, ask {maintainer} for advice" -84 84 | -85 85 | # Empty print -86 86 | # Expects: RUF030.py:88:14: RUF030 [*] `print()` expression in `assert` statement is likely unintentional | @@ -348,15 +204,6 @@ RUF030.py:88:14: RUF030 [*] `print()` expression in `assert` statement is likely | = help: Remove `print` -ℹ Unsafe fix -85 85 | # Empty print -86 86 | # Expects: -87 87 | # - `msg` entirely removed from assertion -88 |-assert True, print() - 88 |+assert True -89 89 | -90 90 | # Empty print with separator -91 91 | # Expects: RUF030.py:93:14: RUF030 [*] `print()` expression in `assert` statement is likely unintentional | @@ -369,15 +216,6 @@ RUF030.py:93:14: RUF030 [*] `print()` expression in `assert` statement is likely | = help: Remove `print` -ℹ Unsafe fix -90 90 | # Empty print with separator -91 91 | # Expects: -92 92 | # - `msg` entirely removed from assertion -93 |-assert True, print(sep=" ") - 93 |+assert True -94 94 | -95 95 | # Custom print function that actually returns a string -96 96 | # Expects: RUF030.py:108:14: RUF030 [*] `print()` expression in `assert` statement is likely unintentional | @@ -387,10 +225,3 @@ RUF030.py:108:14: RUF030 [*] `print()` expression in `assert` statement is likel | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 | = help: Remove `print` - -ℹ Unsafe fix -105 105 | # Use of `builtins.print` -106 106 | # Expects: -107 107 | # - single StringLiteral -108 |-assert True, builtins.print("This print should be removed.") - 108 |+assert True, "This print should be removed." diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF101_RUF101.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF101_RUF101.py.snap index c7a92cb49eff8..9c8fb490386cb 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF101_RUF101.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF101_RUF101.py.snap @@ -10,7 +10,6 @@ RUF101.py:1:15: RUF101 [*] `RUF940` is a redirect to `RUF950` | = help: Replace with `RUF950` -ℹ Safe fix 1 |-x = 2 # noqa: RUF940 2 1 | x = 2 # noqa: RUF950 2 |+x = 2 # noqa: RUF950 @@ -29,7 +28,6 @@ RUF101.py:3:15: RUF101 [*] `RUF940` is a redirect to `RUF950` | = help: Replace with `RUF950` -ℹ Safe fix 1 1 | x = 2 # noqa: RUF940 2 2 | x = 2 # noqa: RUF950 3 |-x = 2 # noqa: RUF940, RUF950 @@ -49,7 +47,6 @@ RUF101.py:4:23: RUF101 [*] `RUF940` is a redirect to `RUF950` | = help: Replace with `RUF950` -ℹ Safe fix 1 1 | x = 2 # noqa: RUF940 2 2 | x = 2 # noqa: RUF950 3 3 | x = 2 # noqa: RUF940, RUF950 @@ -68,7 +65,6 @@ RUF101.py:5:15: RUF101 [*] `RUF940` is a redirect to `RUF950` | = help: Replace with `RUF950` -ℹ Safe fix 2 2 | x = 2 # noqa: RUF950 3 3 | x = 2 # noqa: RUF940, RUF950 4 4 | x = 2 # noqa: RUF950, RUF940, RUF950, RUF950, RUF950 @@ -86,7 +82,6 @@ RUF101.py:5:31: RUF101 [*] `RUF940` is a redirect to `RUF950` | = help: Replace with `RUF950` -ℹ Safe fix 2 2 | x = 2 # noqa: RUF950 3 3 | x = 2 # noqa: RUF940, RUF950 4 4 | x = 2 # noqa: RUF950, RUF940, RUF950, RUF950, RUF950 @@ -103,7 +98,6 @@ RUF101.py:6:15: RUF101 [*] `RUF940` is a redirect to `RUF950` | = help: Replace with `RUF950` -ℹ Safe fix 3 3 | x = 2 # noqa: RUF940, RUF950 4 4 | x = 2 # noqa: RUF950, RUF940, RUF950, RUF950, RUF950 5 5 | x = 2 # noqa: RUF940, RUF950, RUF940 @@ -119,7 +113,6 @@ RUF101.py:6:31: RUF101 [*] `RUF940` is a redirect to `RUF950` | = help: Replace with `RUF950` -ℹ Safe fix 3 3 | x = 2 # noqa: RUF940, RUF950 4 4 | x = 2 # noqa: RUF950, RUF940, RUF950, RUF950, RUF950 5 5 | x = 2 # noqa: RUF940, RUF950, RUF940 diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__noqa.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__noqa.snap index 6736a8f1c5020..039a8b141db95 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__noqa.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__noqa.snap @@ -9,12 +9,3 @@ noqa.py:23:5: F841 [*] Local variable `I` is assigned to but never used | ^ F841 | = help: Remove assignment to unused variable `I` - -ℹ Unsafe fix -20 20 | -21 21 | def f(): -22 22 | # Only `E741` should be ignored by the `noqa`. -23 |- I = 1 # noqa: E741.F841 - 23 |+ pass # noqa: E741.F841 - - diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_0.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_0.snap index 4832895a7074b..346b60f479057 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_0.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_0.snap @@ -10,7 +10,6 @@ RUF100_0.py:9:12: RUF100 [*] Unused blanket `noqa` directive | = help: Remove unused `noqa` directive -ℹ Safe fix 6 6 | b = 2 # noqa: F841 7 7 | 8 8 | # Invalid @@ -30,7 +29,6 @@ RUF100_0.py:13:12: RUF100 [*] Unused `noqa` directive (unused: `E501`) | = help: Remove unused `noqa` directive -ℹ Safe fix 10 10 | print(c) 11 11 | 12 12 | # Invalid @@ -50,7 +48,6 @@ RUF100_0.py:16:12: RUF100 [*] Unused `noqa` directive (unused: `F841`, `E501`) | = help: Remove unused `noqa` directive -ℹ Safe fix 13 13 | d = 1 # noqa: E501 14 14 | 15 15 | # Invalid @@ -70,7 +67,6 @@ RUF100_0.py:19:12: RUF100 [*] Unused `noqa` directive (unused: `F841`, `W191`; n | = help: Remove unused `noqa` directive -ℹ Safe fix 16 16 | d = 1 # noqa: F841, E501 17 17 | 18 18 | # Invalid (and unimplemented or not enabled) @@ -90,7 +86,6 @@ RUF100_0.py:22:12: RUF100 [*] Unused `noqa` directive (unused: `F841`) | = help: Remove unused `noqa` directive -ℹ Safe fix 19 19 | d = 1 # noqa: F841, W191, F821 20 20 | 21 21 | # Invalid (but external) @@ -110,7 +105,6 @@ RUF100_0.py:25:12: RUF100 [*] Unused `noqa` directive (unknown: `V500`) | = help: Remove unused `noqa` directive -ℹ Safe fix 22 22 | d = 1 # noqa: F841, V101 23 23 | 24 24 | # Invalid (but external) @@ -131,7 +125,6 @@ RUF100_0.py:29:12: RUF100 [*] Unused `noqa` directive (unused: `E501`) | = help: Remove unused `noqa` directive -ℹ Safe fix 26 26 | 27 27 | # fmt: off 28 28 | # Invalid - no space before # @@ -150,14 +143,6 @@ RUF100_0.py:32:5: F841 [*] Local variable `d` is assigned to but never used | = help: Remove assignment to unused variable `d` -ℹ Unsafe fix -29 29 | d = 1 # noqa: E501 -30 30 | -31 31 | # Invalid - many spaces before # -32 |- d = 1 # noqa: E501 -33 32 | # fmt: on -34 33 | -35 34 | RUF100_0.py:32:12: RUF100 [*] Unused `noqa` directive (unused: `E501`) | @@ -168,7 +153,6 @@ RUF100_0.py:32:12: RUF100 [*] Unused `noqa` directive (unused: `E501`) | = help: Remove unused `noqa` directive -ℹ Safe fix 29 29 | d = 1 # noqa: E501 30 30 | 31 31 | # Invalid - many spaces before # @@ -188,7 +172,6 @@ RUF100_0.py:58:6: RUF100 [*] Unused `noqa` directive (unused: `F841`) | = help: Remove unused `noqa` directive -ℹ Safe fix 55 55 | https://github.com/PyCQA/pycodestyle/pull/258/files#diff-841c622497a8033d10152bfdfb15b20b92437ecdea21a260944ea86b77b51533 56 56 | 57 57 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. @@ -208,7 +191,6 @@ RUF100_0.py:66:6: RUF100 [*] Unused `noqa` directive (unused: `E501`) | = help: Remove unused `noqa` directive -ℹ Safe fix 63 63 | https://github.com/PyCQA/pycodestyle/pull/258/files#diff-841c622497a8033d10152bfdfb15b20b92437ecdea21a260944ea86b77b51533 64 64 | 65 65 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor. @@ -228,7 +210,6 @@ RUF100_0.py:74:6: RUF100 [*] Unused blanket `noqa` directive | = help: Remove unused `noqa` directive -ℹ Safe fix 71 71 | https://github.com/PyCQA/pycodestyle/pull/258/files#diff-841c622497a8033d10152bfdfb15b20b92437ecdea21a260944ea86b77b51533 72 72 | 73 73 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor. @@ -248,7 +229,6 @@ RUF100_0.py:88:8: F401 [*] `shelve` imported but unused | = help: Remove unused import: `shelve` -ℹ Safe fix 85 85 | 86 86 | import collections # noqa 87 87 | import os # noqa: F401, RUF100 @@ -274,7 +254,6 @@ RUF100_0.py:93:92: RUF100 [*] Unused `noqa` directive (unused: `F401`) | = help: Remove unused `noqa` directive -ℹ Safe fix 90 90 | 91 91 | print(sys.path) 92 92 | @@ -294,7 +273,6 @@ RUF100_0.py:107:12: RUF100 [*] Unused `noqa` directive (unknown: `E50`) | = help: Remove unused `noqa` directive -ℹ Safe fix 104 104 | 105 105 | def f(): 106 106 | # Invalid - nonexistent error code with multibyte character @@ -313,14 +291,6 @@ RUF100_0.py:108:5: F841 [*] Local variable `e` is assigned to but never used | = help: Remove assignment to unused variable `e` -ℹ Unsafe fix -105 105 | def f(): -106 106 | # Invalid - nonexistent error code with multibyte character -107 107 | d = 1 # …noqa: F841, E50 -108 |- e = 1 # …noqa: E50 -109 108 | -110 109 | -111 110 | def f(): RUF100_0.py:108:12: RUF100 [*] Unused `noqa` directive (unknown: `E50`) | @@ -331,7 +301,6 @@ RUF100_0.py:108:12: RUF100 [*] Unused `noqa` directive (unknown: `E50`) | = help: Remove unused `noqa` directive -ℹ Safe fix 105 105 | def f(): 106 106 | # Invalid - nonexistent error code with multibyte character 107 107 | d = 1 # …noqa: F841, E50 @@ -352,7 +321,6 @@ RUF100_0.py:118:12: RUF100 [*] Unused `noqa` directive (duplicated: `F841`; unkn | = help: Remove unused `noqa` directive -ℹ Safe fix 115 115 | 116 116 | # Check duplicate code detection 117 117 | def f(): @@ -373,7 +341,6 @@ RUF100_0.py:120:19: RUF100 [*] Unused `noqa` directive (duplicated: `SIM300`, `S | = help: Remove unused `noqa` directive -ℹ Safe fix 117 117 | def f(): 118 118 | x = 2 # noqa: F841, F841, X200 119 119 | @@ -394,7 +361,6 @@ RUF100_0.py:122:12: RUF100 [*] Unused `noqa` directive (duplicated: `F841`, `F84 | = help: Remove unused `noqa` directive -ℹ Safe fix 119 119 | 120 120 | y = 2 == bar # noqa: SIM300, F841, SIM300, SIM300 121 121 | @@ -415,7 +381,6 @@ RUF100_0.py:129:20: RUF100 [*] Unused `noqa` directive (duplicated: `S307`, `S30 | = help: Remove unused `noqa` directive -ℹ Safe fix 126 126 | 127 127 | # Allow code redirects 128 128 | x = eval(command) # noqa: PGH001, S307 @@ -434,7 +399,6 @@ RUF100_0.py:130:20: RUF100 [*] Unused `noqa` directive (duplicated: `PGH001`) | = help: Remove unused `noqa` directive -ℹ Safe fix 127 127 | # Allow code redirects 128 128 | x = eval(command) # noqa: PGH001, S307 129 129 | x = eval(command) # noqa: S307, PGH001, S307, S307, S307 @@ -451,7 +415,6 @@ RUF100_0.py:131:20: RUF100 [*] Unused `noqa` directive (duplicated: `PGH001`, `S | = help: Remove unused `noqa` directive -ℹ Safe fix 128 128 | x = eval(command) # noqa: PGH001, S307 129 129 | x = eval(command) # noqa: S307, PGH001, S307, S307, S307 130 130 | x = eval(command) # noqa: PGH001, S307, PGH001 diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_0_prefix.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_0_prefix.snap index 10d49089c3dc9..7786f1f2c2036 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_0_prefix.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_0_prefix.snap @@ -10,7 +10,6 @@ RUF100_0.py:9:12: RUF100 [*] Unused blanket `noqa` directive | = help: Remove unused `noqa` directive -ℹ Safe fix 6 6 | b = 2 # noqa: F841 7 7 | 8 8 | # Invalid @@ -30,7 +29,6 @@ RUF100_0.py:13:12: RUF100 [*] Unused `noqa` directive (unused: `E501`) | = help: Remove unused `noqa` directive -ℹ Safe fix 10 10 | print(c) 11 11 | 12 12 | # Invalid @@ -50,7 +48,6 @@ RUF100_0.py:16:12: RUF100 [*] Unused `noqa` directive (unused: `F841`, `E501`) | = help: Remove unused `noqa` directive -ℹ Safe fix 13 13 | d = 1 # noqa: E501 14 14 | 15 15 | # Invalid @@ -70,7 +67,6 @@ RUF100_0.py:19:12: RUF100 [*] Unused `noqa` directive (unused: `F841`, `W191`; n | = help: Remove unused `noqa` directive -ℹ Safe fix 16 16 | d = 1 # noqa: F841, E501 17 17 | 18 18 | # Invalid (and unimplemented or not enabled) @@ -90,7 +86,6 @@ RUF100_0.py:22:12: RUF100 [*] Unused `noqa` directive (unused: `F841`) | = help: Remove unused `noqa` directive -ℹ Safe fix 19 19 | d = 1 # noqa: F841, W191, F821 20 20 | 21 21 | # Invalid (but external) @@ -111,7 +106,6 @@ RUF100_0.py:29:12: RUF100 [*] Unused `noqa` directive (unused: `E501`) | = help: Remove unused `noqa` directive -ℹ Safe fix 26 26 | 27 27 | # fmt: off 28 28 | # Invalid - no space before # @@ -130,14 +124,6 @@ RUF100_0.py:32:5: F841 [*] Local variable `d` is assigned to but never used | = help: Remove assignment to unused variable `d` -ℹ Unsafe fix -29 29 | d = 1 # noqa: E501 -30 30 | -31 31 | # Invalid - many spaces before # -32 |- d = 1 # noqa: E501 -33 32 | # fmt: on -34 33 | -35 34 | RUF100_0.py:32:12: RUF100 [*] Unused `noqa` directive (unused: `E501`) | @@ -148,7 +134,6 @@ RUF100_0.py:32:12: RUF100 [*] Unused `noqa` directive (unused: `E501`) | = help: Remove unused `noqa` directive -ℹ Safe fix 29 29 | d = 1 # noqa: E501 30 30 | 31 31 | # Invalid - many spaces before # @@ -168,7 +153,6 @@ RUF100_0.py:58:6: RUF100 [*] Unused `noqa` directive (unused: `F841`) | = help: Remove unused `noqa` directive -ℹ Safe fix 55 55 | https://github.com/PyCQA/pycodestyle/pull/258/files#diff-841c622497a8033d10152bfdfb15b20b92437ecdea21a260944ea86b77b51533 56 56 | 57 57 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. @@ -188,7 +172,6 @@ RUF100_0.py:66:6: RUF100 [*] Unused `noqa` directive (unused: `E501`) | = help: Remove unused `noqa` directive -ℹ Safe fix 63 63 | https://github.com/PyCQA/pycodestyle/pull/258/files#diff-841c622497a8033d10152bfdfb15b20b92437ecdea21a260944ea86b77b51533 64 64 | 65 65 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor. @@ -208,7 +191,6 @@ RUF100_0.py:74:6: RUF100 [*] Unused blanket `noqa` directive | = help: Remove unused `noqa` directive -ℹ Safe fix 71 71 | https://github.com/PyCQA/pycodestyle/pull/258/files#diff-841c622497a8033d10152bfdfb15b20b92437ecdea21a260944ea86b77b51533 72 72 | 73 73 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor. @@ -228,7 +210,6 @@ RUF100_0.py:88:8: F401 [*] `shelve` imported but unused | = help: Remove unused import: `shelve` -ℹ Safe fix 85 85 | 86 86 | import collections # noqa 87 87 | import os # noqa: F401, RUF100 @@ -254,7 +235,6 @@ RUF100_0.py:93:92: RUF100 [*] Unused `noqa` directive (unused: `F401`) | = help: Remove unused `noqa` directive -ℹ Safe fix 90 90 | 91 91 | print(sys.path) 92 92 | @@ -274,7 +254,6 @@ RUF100_0.py:107:12: RUF100 [*] Unused `noqa` directive (unknown: `E50`) | = help: Remove unused `noqa` directive -ℹ Safe fix 104 104 | 105 105 | def f(): 106 106 | # Invalid - nonexistent error code with multibyte character @@ -293,14 +272,6 @@ RUF100_0.py:108:5: F841 [*] Local variable `e` is assigned to but never used | = help: Remove assignment to unused variable `e` -ℹ Unsafe fix -105 105 | def f(): -106 106 | # Invalid - nonexistent error code with multibyte character -107 107 | d = 1 # …noqa: F841, E50 -108 |- e = 1 # …noqa: E50 -109 108 | -110 109 | -111 110 | def f(): RUF100_0.py:108:12: RUF100 [*] Unused `noqa` directive (unknown: `E50`) | @@ -311,7 +282,6 @@ RUF100_0.py:108:12: RUF100 [*] Unused `noqa` directive (unknown: `E50`) | = help: Remove unused `noqa` directive -ℹ Safe fix 105 105 | def f(): 106 106 | # Invalid - nonexistent error code with multibyte character 107 107 | d = 1 # …noqa: F841, E50 @@ -332,7 +302,6 @@ RUF100_0.py:118:12: RUF100 [*] Unused `noqa` directive (duplicated: `F841`; unkn | = help: Remove unused `noqa` directive -ℹ Safe fix 115 115 | 116 116 | # Check duplicate code detection 117 117 | def f(): @@ -353,7 +322,6 @@ RUF100_0.py:120:19: RUF100 [*] Unused `noqa` directive (duplicated: `SIM300`, `S | = help: Remove unused `noqa` directive -ℹ Safe fix 117 117 | def f(): 118 118 | x = 2 # noqa: F841, F841, X200 119 119 | @@ -374,7 +342,6 @@ RUF100_0.py:122:12: RUF100 [*] Unused `noqa` directive (duplicated: `F841`, `F84 | = help: Remove unused `noqa` directive -ℹ Safe fix 119 119 | 120 120 | y = 2 == bar # noqa: SIM300, F841, SIM300, SIM300 121 121 | @@ -395,7 +362,6 @@ RUF100_0.py:129:20: RUF100 [*] Unused `noqa` directive (duplicated: `S307`, `S30 | = help: Remove unused `noqa` directive -ℹ Safe fix 126 126 | 127 127 | # Allow code redirects 128 128 | x = eval(command) # noqa: PGH001, S307 @@ -414,7 +380,6 @@ RUF100_0.py:130:20: RUF100 [*] Unused `noqa` directive (duplicated: `PGH001`) | = help: Remove unused `noqa` directive -ℹ Safe fix 127 127 | # Allow code redirects 128 128 | x = eval(command) # noqa: PGH001, S307 129 129 | x = eval(command) # noqa: S307, PGH001, S307, S307, S307 @@ -431,7 +396,6 @@ RUF100_0.py:131:20: RUF100 [*] Unused `noqa` directive (duplicated: `PGH001`, `S | = help: Remove unused `noqa` directive -ℹ Safe fix 128 128 | x = eval(command) # noqa: PGH001, S307 129 129 | x = eval(command) # noqa: S307, PGH001, S307, S307, S307 130 130 | x = eval(command) # noqa: PGH001, S307, PGH001 diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_1.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_1.snap index bd0aaf365a2cf..8db7d6809e6d9 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_1.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_1.snap @@ -11,7 +11,6 @@ RUF100_1.py:37:9: F401 [*] `typing.Union` imported but unused | = help: Remove unused import: `typing.Union` -ℹ Safe fix 34 34 | # This should ignore the first error. 35 35 | from typing import ( 36 36 | Mapping, # noqa: F401 @@ -32,7 +31,6 @@ RUF100_1.py:52:20: RUF100 [*] Unused `noqa` directive (unused: `F401`) | = help: Remove unused `noqa` directive -ℹ Safe fix 49 49 | def f(): 50 50 | # This should ignore the error, but the inner noqa should be marked as unused. 51 51 | from typing import ( # noqa: F401 @@ -52,7 +50,6 @@ RUF100_1.py:59:20: RUF100 [*] Unused `noqa` directive (unused: `F401`) | = help: Remove unused `noqa` directive -ℹ Safe fix 56 56 | def f(): 57 57 | # This should ignore the error, but the inner noqa should be marked as unused. 58 58 | from typing import ( # noqa @@ -72,7 +69,6 @@ RUF100_1.py:66:16: RUF100 [*] Unused `noqa` directive (non-enabled: `F501`) | = help: Remove unused `noqa` directive -ℹ Safe fix 63 63 | def f(): 64 64 | # This should ignore the error, but mark F501 as unused. 65 65 | from typing import ( # noqa: F401 @@ -93,7 +89,6 @@ RUF100_1.py:72:27: RUF100 [*] Unused `noqa` directive (non-enabled: `F501`) | = help: Remove unused `noqa` directive -ℹ Safe fix 69 69 | 70 70 | def f(): 71 71 | # This should ignore the error, but mark F501 as unused. @@ -112,7 +107,6 @@ RUF100_1.py:89:24: F401 [*] `typing.Awaitable` imported but unused | = help: Remove unused import -ℹ Safe fix 86 86 | 87 87 | def f(): 88 88 | # This should mark F501 as unused. @@ -128,7 +122,6 @@ RUF100_1.py:89:35: F401 [*] `typing.AwaitableGenerator` imported but unused | = help: Remove unused import -ℹ Safe fix 86 86 | 87 87 | def f(): 88 88 | # This should mark F501 as unused. @@ -144,11 +137,8 @@ RUF100_1.py:89:55: RUF100 [*] Unused `noqa` directive (non-enabled: `F501`) | = help: Remove unused `noqa` directive -ℹ Safe fix 86 86 | 87 87 | def f(): 88 88 | # This should mark F501 as unused. 89 |- from typing import Awaitable, AwaitableGenerator # noqa: F501 89 |+ from typing import Awaitable, AwaitableGenerator - - diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_2.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_2.snap index 4eef8cdef37e6..64901a6e7f130 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_2.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_2.snap @@ -8,8 +8,5 @@ RUF100_2.py:1:19: RUF100 [*] Unused `noqa` directive (unused: `F401`) | = help: Remove unused `noqa` directive -ℹ Safe fix 1 |-import itertools # noqa: F401 1 |+import itertools - - diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_3.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_3.snap index 5f38b489e2ab9..22576cd018884 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_3.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_3.snap @@ -10,7 +10,6 @@ RUF100_3.py:1:1: RUF100 [*] Unused blanket `noqa` directive | = help: Remove unused `noqa` directive -ℹ Safe fix 1 |-# noqa 2 1 | # noqa # comment 3 2 | print() # noqa @@ -26,7 +25,6 @@ RUF100_3.py:2:1: RUF100 [*] Unused blanket `noqa` directive | = help: Remove unused `noqa` directive -ℹ Safe fix 1 1 | # noqa 2 |-# noqa # comment 2 |+# comment @@ -45,7 +43,6 @@ RUF100_3.py:3:10: RUF100 [*] Unused blanket `noqa` directive | = help: Remove unused `noqa` directive -ℹ Safe fix 1 1 | # noqa 2 2 | # noqa # comment 3 |-print() # noqa @@ -65,7 +62,6 @@ RUF100_3.py:4:10: RUF100 [*] Unused blanket `noqa` directive | = help: Remove unused `noqa` directive -ℹ Safe fix 1 1 | # noqa 2 2 | # noqa # comment 3 3 | print() # noqa @@ -86,7 +82,6 @@ RUF100_3.py:5:10: RUF100 [*] Unused blanket `noqa` directive | = help: Remove unused `noqa` directive -ℹ Safe fix 2 2 | # noqa # comment 3 3 | print() # noqa 4 4 | print() # noqa # comment @@ -107,7 +102,6 @@ RUF100_3.py:6:10: RUF100 [*] Unused blanket `noqa` directive | = help: Remove unused `noqa` directive -ℹ Safe fix 3 3 | print() # noqa 4 4 | print() # noqa # comment 5 5 | print() # noqa # comment @@ -128,7 +122,6 @@ RUF100_3.py:7:10: RUF100 [*] Unused blanket `noqa` directive | = help: Remove unused `noqa` directive -ℹ Safe fix 4 4 | print() # noqa # comment 5 5 | print() # noqa # comment 6 6 | print() # noqa comment @@ -149,7 +142,6 @@ RUF100_3.py:14:1: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) | = help: Remove unused `noqa` directive -ℹ Safe fix 11 11 | print(a) # noqa comment 12 12 | print(a) # noqa comment 13 13 | @@ -168,7 +160,6 @@ RUF100_3.py:15:1: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) | = help: Remove unused `noqa` directive -ℹ Safe fix 12 12 | print(a) # noqa comment 13 13 | 14 14 | # noqa: E501, F821 @@ -189,7 +180,6 @@ RUF100_3.py:16:10: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) | = help: Remove unused `noqa` directive -ℹ Safe fix 13 13 | 14 14 | # noqa: E501, F821 15 15 | # noqa: E501, F821 # comment @@ -210,7 +200,6 @@ RUF100_3.py:17:10: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) | = help: Remove unused `noqa` directive -ℹ Safe fix 14 14 | # noqa: E501, F821 15 15 | # noqa: E501, F821 # comment 16 16 | print() # noqa: E501, F821 @@ -231,7 +220,6 @@ RUF100_3.py:18:10: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) | = help: Remove unused `noqa` directive -ℹ Safe fix 15 15 | # noqa: E501, F821 # comment 16 16 | print() # noqa: E501, F821 17 17 | print() # noqa: E501, F821 # comment @@ -252,7 +240,6 @@ RUF100_3.py:19:10: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) | = help: Remove unused `noqa` directive -ℹ Safe fix 16 16 | print() # noqa: E501, F821 17 17 | print() # noqa: E501, F821 # comment 18 18 | print() # noqa: E501, F821 # comment @@ -273,7 +260,6 @@ RUF100_3.py:20:10: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) | = help: Remove unused `noqa` directive -ℹ Safe fix 17 17 | print() # noqa: E501, F821 # comment 18 18 | print() # noqa: E501, F821 # comment 19 19 | print() # noqa: E501, F821 comment @@ -294,7 +280,6 @@ RUF100_3.py:21:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) | = help: Remove unused `noqa` directive -ℹ Safe fix 18 18 | print() # noqa: E501, F821 # comment 19 19 | print() # noqa: E501, F821 comment 20 20 | print() # noqa: E501, F821 comment @@ -315,7 +300,6 @@ RUF100_3.py:22:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) | = help: Remove unused `noqa` directive -ℹ Safe fix 19 19 | print() # noqa: E501, F821 comment 20 20 | print() # noqa: E501, F821 comment 21 21 | print(a) # noqa: E501, F821 @@ -336,7 +320,6 @@ RUF100_3.py:23:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) | = help: Remove unused `noqa` directive -ℹ Safe fix 20 20 | print() # noqa: E501, F821 comment 21 21 | print(a) # noqa: E501, F821 22 22 | print(a) # noqa: E501, F821 # comment @@ -356,7 +339,6 @@ RUF100_3.py:24:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) | = help: Remove unused `noqa` directive -ℹ Safe fix 21 21 | print(a) # noqa: E501, F821 22 22 | print(a) # noqa: E501, F821 # comment 23 23 | print(a) # noqa: E501, F821 # comment @@ -377,7 +359,6 @@ RUF100_3.py:25:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) | = help: Remove unused `noqa` directive -ℹ Safe fix 22 22 | print(a) # noqa: E501, F821 # comment 23 23 | print(a) # noqa: E501, F821 # comment 24 24 | print(a) # noqa: E501, F821 comment @@ -406,7 +387,6 @@ RUF100_3.py:27:39: RUF100 [*] Unused `noqa` directive (unused: `E501`) | = help: Remove unused `noqa` directive -ℹ Safe fix 24 24 | print(a) # noqa: E501, F821 comment 25 25 | print(a) # noqa: E501, F821 comment 26 26 | @@ -422,11 +402,8 @@ RUF100_3.py:28:39: RUF100 [*] Unused `noqa` directive (unused: `E501`) | = help: Remove unused `noqa` directive -ℹ Safe fix 25 25 | print(a) # noqa: E501, F821 comment 26 26 | 27 27 | print(a) # comment with unicode µ # noqa: E501 28 |-print(a) # comment with unicode µ # noqa: E501, F821 28 |+print(a) # comment with unicode µ # noqa: F821 - - diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_5.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_5.snap index a58ef10cb160d..0dd8b2d38f1fd 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_5.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_5.snap @@ -11,14 +11,6 @@ RUF100_5.py:7:5: ERA001 Found commented-out code | = help: Remove commented-out code -ℹ Display-only fix -4 4 | dictionary = { -5 5 | # "key1": 123, # noqa: ERA001 -6 6 | # "key2": 456, # noqa -7 |- # "key3": 789, -8 7 | } -9 8 | -10 9 | RUF100_5.py:11:1: ERA001 Found commented-out code | @@ -27,11 +19,6 @@ RUF100_5.py:11:1: ERA001 Found commented-out code | = help: Remove commented-out code -ℹ Display-only fix -8 8 | } -9 9 | -10 10 | -11 |-#import os # noqa: E501 RUF100_5.py:11:13: RUF100 [*] Unused `noqa` directive (unused: `E501`) | @@ -40,11 +27,8 @@ RUF100_5.py:11:13: RUF100 [*] Unused `noqa` directive (unused: `E501`) | = help: Remove unused `noqa` directive -ℹ Safe fix 8 8 | } 9 9 | 10 10 | 11 |-#import os # noqa: E501 11 |+#import os - - diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_codes.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_codes.snap index 32744177506e0..8bf9a552cd7e3 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_codes.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_codes.snap @@ -8,12 +8,3 @@ ruff_noqa_codes.py:8:5: F841 [*] Local variable `x` is assigned to but never use | ^ F841 | = help: Remove assignment to unused variable `x` - -ℹ Unsafe fix -5 5 | -6 6 | -7 7 | def f(): -8 |- x = 1 - 8 |+ pass - - diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_invalid.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_invalid.snap index 7161b11be3c2b..7816f5818a4f4 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_invalid.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_invalid.snap @@ -8,7 +8,6 @@ ruff_noqa_invalid.py:1:8: F401 [*] `os` imported but unused | = help: Remove unused import: `os` -ℹ Safe fix 1 |-import os # ruff: noqa: F401 2 1 | 3 2 | @@ -21,12 +20,3 @@ ruff_noqa_invalid.py:5:5: F841 [*] Local variable `x` is assigned to but never u | ^ F841 | = help: Remove assignment to unused variable `x` - -ℹ Unsafe fix -2 2 | -3 3 | -4 4 | def f(): -5 |- x = 1 - 5 |+ pass - - diff --git a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__error-instead-of-exception_TRY400.py.snap b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__error-instead-of-exception_TRY400.py.snap index 1cc91d6730fee..ddb9e28ae00ec 100644 --- a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__error-instead-of-exception_TRY400.py.snap +++ b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__error-instead-of-exception_TRY400.py.snap @@ -12,7 +12,6 @@ TRY400.py:13:9: TRY400 [*] Use `logging.exception` instead of `logging.error` | = help: Replace with `exception` -ℹ Safe fix 10 10 | try: 11 11 | a = 1 12 12 | except Exception: @@ -30,7 +29,6 @@ TRY400.py:16:13: TRY400 [*] Use `logging.exception` instead of `logging.error` | = help: Replace with `exception` -ℹ Safe fix 13 13 | logging.error("Context message here") 14 14 | 15 15 | if True: @@ -51,15 +49,6 @@ TRY400.py:27:9: TRY400 [*] Use `logging.exception` instead of `logging.error` | = help: Replace with `exception` -ℹ Unsafe fix -24 24 | try: -25 25 | a = 1 -26 26 | except Exception: -27 |- logger.error("Context message here") - 27 |+ logger.exception("Context message here") -28 28 | -29 29 | if True: -30 30 | logger.error("Context message here") TRY400.py:30:13: TRY400 [*] Use `logging.exception` instead of `logging.error` | @@ -69,15 +58,6 @@ TRY400.py:30:13: TRY400 [*] Use `logging.exception` instead of `logging.error` | = help: Replace with `exception` -ℹ Unsafe fix -27 27 | logger.error("Context message here") -28 28 | -29 29 | if True: -30 |- logger.error("Context message here") - 30 |+ logger.exception("Context message here") -31 31 | -32 32 | -33 33 | def bad(): TRY400.py:37:9: TRY400 [*] Use `logging.exception` instead of `logging.error` | @@ -90,15 +70,6 @@ TRY400.py:37:9: TRY400 [*] Use `logging.exception` instead of `logging.error` | = help: Replace with `exception` -ℹ Unsafe fix -34 34 | try: -35 35 | a = 1 -36 36 | except Exception: -37 |- log.error("Context message here") - 37 |+ log.exception("Context message here") -38 38 | -39 39 | if True: -40 40 | log.error("Context message here") TRY400.py:40:13: TRY400 [*] Use `logging.exception` instead of `logging.error` | @@ -108,15 +79,6 @@ TRY400.py:40:13: TRY400 [*] Use `logging.exception` instead of `logging.error` | = help: Replace with `exception` -ℹ Unsafe fix -37 37 | log.error("Context message here") -38 38 | -39 39 | if True: -40 |- log.error("Context message here") - 40 |+ log.exception("Context message here") -41 41 | -42 42 | -43 43 | def bad(): TRY400.py:47:9: TRY400 [*] Use `logging.exception` instead of `logging.error` | @@ -129,15 +91,6 @@ TRY400.py:47:9: TRY400 [*] Use `logging.exception` instead of `logging.error` | = help: Replace with `exception` -ℹ Unsafe fix -44 44 | try: -45 45 | a = 1 -46 46 | except Exception: -47 |- self.logger.error("Context message here") - 47 |+ self.logger.exception("Context message here") -48 48 | -49 49 | if True: -50 50 | self.logger.error("Context message here") TRY400.py:50:13: TRY400 [*] Use `logging.exception` instead of `logging.error` | @@ -147,15 +100,6 @@ TRY400.py:50:13: TRY400 [*] Use `logging.exception` instead of `logging.error` | = help: Replace with `exception` -ℹ Unsafe fix -47 47 | self.logger.error("Context message here") -48 48 | -49 49 | if True: -50 |- self.logger.error("Context message here") - 50 |+ self.logger.exception("Context message here") -51 51 | -52 52 | -53 53 | def good(): TRY400.py:100:9: TRY400 [*] Use `logging.exception` instead of `logging.error` | @@ -168,7 +112,6 @@ TRY400.py:100:9: TRY400 [*] Use `logging.exception` instead of `logging.error` | = help: Replace with `exception` -ℹ Safe fix 97 97 | try: 98 98 | a = 1 99 99 | except Exception: @@ -186,7 +129,6 @@ TRY400.py:103:13: TRY400 [*] Use `logging.exception` instead of `logging.error` | = help: Replace with `exception` -ℹ Safe fix 100 100 | error("Context message here") 101 101 | 102 102 | if True: @@ -205,7 +147,6 @@ TRY400.py:143:13: TRY400 [*] Use `logging.exception` instead of `logging.error` | = help: Replace with `exception` -ℹ Safe fix 140 140 | try: 141 141 | b = 2 142 142 | except Exception: diff --git a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__verbose-raise_TRY201.py.snap b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__verbose-raise_TRY201.py.snap index 558c2c91ac299..4284bf8fa1e73 100644 --- a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__verbose-raise_TRY201.py.snap +++ b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__verbose-raise_TRY201.py.snap @@ -10,15 +10,6 @@ TRY201.py:20:15: TRY201 [*] Use `raise` without specifying exception name | = help: Remove exception name -ℹ Unsafe fix -17 17 | process() -18 18 | except MyException as e: -19 19 | logger.exception("process failed") -20 |- raise e - 20 |+ raise -21 21 | -22 22 | -23 23 | def good(): TRY201.py:63:19: TRY201 [*] Use `raise` without specifying exception name | @@ -29,15 +20,6 @@ TRY201.py:63:19: TRY201 [*] Use `raise` without specifying exception name | = help: Remove exception name -ℹ Unsafe fix -60 60 | except MyException as e: -61 61 | logger.exception("process failed") -62 62 | if True: -63 |- raise e - 63 |+ raise -64 64 | -65 65 | -66 66 | def bad_that_needs_recursion_2(): TRY201.py:74:23: TRY201 [*] Use `raise` without specifying exception name | @@ -46,12 +28,3 @@ TRY201.py:74:23: TRY201 [*] Use `raise` without specifying exception name | ^ TRY201 | = help: Remove exception name - -ℹ Unsafe fix -71 71 | if True: -72 72 | -73 73 | def foo(): -74 |- raise e - 74 |+ raise - - diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__import_sorting.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__import_sorting.snap index b0cc03fe750e1..f2ab2dc4234cf 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__import_sorting.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__import_sorting.snap @@ -13,7 +13,6 @@ isort.ipynb:cell 1:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 |+import math 2 |+import random 1 3 | from pathlib import Path @@ -34,7 +33,6 @@ isort.ipynb:cell 2:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 1 1 | from pathlib import Path 2 2 | import random 3 3 | import math @@ -58,7 +56,6 @@ isort.ipynb:cell 3:1:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 6 6 | # Newline should be added here 7 7 | def foo(): 8 8 | pass @@ -78,12 +75,9 @@ isort.ipynb:cell 3:7:1: I001 [*] Import block is un-sorted or un-formatted | = help: Organize imports -ℹ Safe fix 12 12 | %matplotlib \ 13 13 | --inline 14 14 | 15 |+import abc 15 16 | import math 16 |-import abc - - diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__ipy_escape_command.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__ipy_escape_command.snap index 8c1a547e85966..0f7e59e81acf5 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__ipy_escape_command.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__ipy_escape_command.snap @@ -12,7 +12,6 @@ ipy_escape_command.ipynb:cell 1:5:8: F401 [*] `os` imported but unused | = help: Remove unused import: `os` -ℹ Safe fix 2 2 | 3 3 | %matplotlib inline 4 4 | @@ -29,10 +28,7 @@ ipy_escape_command.ipynb:cell 2:2:8: F401 [*] `sys` imported but unused | = help: Remove unused import: `sys` -ℹ Safe fix 6 6 | 7 7 | _ = math.pi 8 8 | %%timeit 9 |-import sys - - diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__unused_variable.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__unused_variable.snap index a610a9bb123c2..3c7ebc60e70a4 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__unused_variable.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__unused_variable.snap @@ -10,13 +10,6 @@ unused_variable.ipynb:cell 1:2:5: F841 [*] Local variable `foo1` is assigned to | = help: Remove assignment to unused variable `foo1` -ℹ Unsafe fix -1 1 | def f(): -2 |- foo1 = %matplotlib --list - 2 |+ %matplotlib --list -3 3 | foo2: list[str] = %matplotlib --list -4 4 | def f(): -5 5 | bar1 = !pwd unused_variable.ipynb:cell 1:3:5: F841 [*] Local variable `foo2` is assigned to but never used | @@ -27,14 +20,6 @@ unused_variable.ipynb:cell 1:3:5: F841 [*] Local variable `foo2` is assigned to | = help: Remove assignment to unused variable `foo2` -ℹ Unsafe fix -1 1 | def f(): -2 2 | foo1 = %matplotlib --list -3 |- foo2: list[str] = %matplotlib --list - 3 |+ %matplotlib --list -4 4 | def f(): -5 5 | bar1 = !pwd -6 6 | bar2: str = !pwd unused_variable.ipynb:cell 2:2:5: F841 [*] Local variable `bar1` is assigned to but never used | @@ -45,13 +30,6 @@ unused_variable.ipynb:cell 2:2:5: F841 [*] Local variable `bar1` is assigned to | = help: Remove assignment to unused variable `bar1` -ℹ Unsafe fix -2 2 | foo1 = %matplotlib --list -3 3 | foo2: list[str] = %matplotlib --list -4 4 | def f(): -5 |- bar1 = !pwd - 5 |+ !pwd -6 6 | bar2: str = !pwd unused_variable.ipynb:cell 2:3:5: F841 [*] Local variable `bar2` is assigned to but never used | @@ -61,12 +39,3 @@ unused_variable.ipynb:cell 2:3:5: F841 [*] Local variable `bar2` is assigned to | ^^^^ F841 | = help: Remove assignment to unused variable `bar2` - -ℹ Unsafe fix -3 3 | foo2: list[str] = %matplotlib --list -4 4 | def f(): -5 5 | bar1 = !pwd -6 |- bar2: str = !pwd - 6 |+ !pwd - -