diff --git a/crates/ruff_linter/resources/test/fixtures/flake8_type_checking/quote.py b/crates/ruff_linter/resources/test/fixtures/flake8_type_checking/quote.py index 54de2738fb870..1f14d2d61204d 100644 --- a/crates/ruff_linter/resources/test/fixtures/flake8_type_checking/quote.py +++ b/crates/ruff_linter/resources/test/fixtures/flake8_type_checking/quote.py @@ -104,3 +104,9 @@ def f(): def foo(self, user: AbstractBaseUser["int"], view: "type[CondorBaseViewSet]"): pass + def foo(self, user: AbstractBaseUser['int']): + pass + + def foo(self, user: AbstractBaseUser['int', "str"]): + pass + diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/helpers.rs b/crates/ruff_linter/src/rules/flake8_type_checking/helpers.rs index 12b24cddb8a6d..b90f023041805 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/helpers.rs +++ b/crates/ruff_linter/src/rules/flake8_type_checking/helpers.rs @@ -266,10 +266,7 @@ pub(crate) fn quote_annotation( let annotation = generator.expr(expr); let annotation_new = if annotation.contains(quote.as_char()) { - annotation.replace( - quote.as_char(), - "e.opposite().as_char().to_string(), - ) + annotation.replace(quote.as_char(), "e.opposite().as_char().to_string()) } else { annotation }; 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 d34a4c92b4359..23b8b478a718b 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 @@ -469,4 +469,12 @@ quote.py:102:44: TCH002 [*] Move third-party import `django.contrib.auth.models. 104 |- def foo(self, user: AbstractBaseUser["int"], view: "type[CondorBaseViewSet]"): 107 |+ def foo(self, user: "AbstractBaseUser['int']", view: "type[CondorBaseViewSet]"): 105 108 | pass -106 109 | +106 109 | +107 |- def foo(self, user: AbstractBaseUser['int']): + 110 |+ def foo(self, user: "AbstractBaseUser['int']"): +108 111 | pass +109 112 | +110 |- def foo(self, user: AbstractBaseUser['int', "str"]): + 113 |+ def foo(self, user: "AbstractBaseUser['int', 'str']"): +111 114 | pass +112 115 |