---
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
---
TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block
 --> quote3.py:4:44
  |
2 |     from typing import Literal, Union
3 |
4 |     from django.contrib.auth.models import AbstractBaseUser
  |                                            ^^^^^^^^^^^^^^^^
5 |
6 |     def test_union_literal_mixed_quotes(user: AbstractBaseUser[Union[Literal['active', "inactive"], str]]):
  |
help: Move into type-checking block
  |
1 + from typing import TYPE_CHECKING
2 +
3 + if TYPE_CHECKING:
4 +     from django.contrib.auth.models import AbstractBaseUser
5 | def f():
6 |     from typing import Literal, Union
7 |
  -     from django.contrib.auth.models import AbstractBaseUser
8 |
  |
note: This is an unsafe fix and may change runtime behavior

TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block
  --> quote3.py:13:44
   |
11 |     from typing import Callable, Literal
12 |
13 |     from django.contrib.auth.models import AbstractBaseUser
   |                                            ^^^^^^^^^^^^^^^^
14 |
15 |     def test_callable_literal_mixed_quotes(callable_fn: AbstractBaseUser[Callable[["int", Literal['admin', "user"]], 'bool']]):
   |
help: Move into type-checking block
   |
1  + from typing import TYPE_CHECKING
2  +
3  + if TYPE_CHECKING:
4  +     from django.contrib.auth.models import AbstractBaseUser
5  | def f():
--------------------------------------------------------------------------------
16 |
   -     from django.contrib.auth.models import AbstractBaseUser
17 |
   |
note: This is an unsafe fix and may change runtime behavior

TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block
  --> quote3.py:22:44
   |
20 |     from typing import Annotated, Callable, Literal
21 |
22 |     from django.contrib.auth.models import AbstractBaseUser
   |                                            ^^^^^^^^^^^^^^^^
23 |
24 |     def test_callable_annotated_literal(callable_fn: AbstractBaseUser[Callable[[int, Annotated[str, Literal['active', "inactive"]]], b…
   |
help: Move into type-checking block
   |
1  + from typing import TYPE_CHECKING
2  +
3  + if TYPE_CHECKING:
4  +     from django.contrib.auth.models import AbstractBaseUser
5  | def f():
--------------------------------------------------------------------------------
25 |
   -     from django.contrib.auth.models import AbstractBaseUser
26 |
   |
note: This is an unsafe fix and may change runtime behavior

TC002 [*] Move third-party import `django.contrib.auth.models` into a type-checking block
  --> quote3.py:31:37
   |
29 |     from typing import literal
30 |
31 |     from django.contrib.auth import models
   |                                     ^^^^^^
32 |
33 |     def test_attribute(arg: models.AbstractBaseUser["int"]):
   |
help: Move into type-checking block
   |
1  + from typing import TYPE_CHECKING
2  +
3  + if TYPE_CHECKING:
4  +     from django.contrib.auth import models
5  | def f():
--------------------------------------------------------------------------------
34 |
   -     from django.contrib.auth import models
35 |
   |
note: This is an unsafe fix and may change runtime behavior

TC002 [*] Move third-party import `django.contrib.auth.models` into a type-checking block
  --> quote3.py:40:37
   |
38 |     from typing import Literal
39 |
40 |     from django.contrib.auth import models
   |                                     ^^^^^^
41 |
42 |     def test_attribute_typing_literal(arg: models.AbstractBaseUser[Literal["admin"]]):
   |
help: Move into type-checking block
   |
1  + from typing import TYPE_CHECKING
2  +
3  + if TYPE_CHECKING:
4  +     from django.contrib.auth import models
5  | def f():
--------------------------------------------------------------------------------
43 |
   -     from django.contrib.auth import models
44 |
   |
note: This is an unsafe fix and may change runtime behavior

TC002 [*] Move third-party import `third_party.Type` into a type-checking block
  --> quote3.py:59:29
   |
57 | def f():
58 |     from typing import Literal
59 |     from third_party import Type
   |                             ^^^^
60 |
61 |     def test_string_contains_opposite_quote(self, type1: Type[Literal["'"]], type2: Type[Literal["\'"]]):
   |
help: Move into type-checking block
   |
1  + from typing import TYPE_CHECKING
2  +
3  + if TYPE_CHECKING:
4  +     from third_party import Type
5  | def f():
--------------------------------------------------------------------------------
62 |     from typing import Literal
   -     from third_party import Type
63 |
   |
note: This is an unsafe fix and may change runtime behavior

TC002 [*] Move third-party import `third_party.Type` into a type-checking block
  --> quote3.py:67:29
   |
65 | def f():
66 |     from typing import Literal
67 |     from third_party import Type
   |                             ^^^^
68 |
69 |     def test_quote_contains_backslash(self, type1: Type[Literal["\n"]], type2: Type[Literal["\""]]):
   |
help: Move into type-checking block
   |
1  + from typing import TYPE_CHECKING
2  +
3  + if TYPE_CHECKING:
4  +     from third_party import Type
5  | def f():
--------------------------------------------------------------------------------
70 |     from typing import Literal
   -     from third_party import Type
71 |
   |
note: This is an unsafe fix and may change runtime behavior
