---
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
snapshot_kind: text
---
strict.py:54:25: TC002 [*] Move third-party import `pkg.bar.A` into a type-checking block
   |
52 |     # In un-strict mode, this _should_ raise an error, since `pkg.bar` isn't used at runtime
53 |     import pkg
54 |     from pkg.bar import A
   |                         ^ TC002
55 | 
56 |     def test(value: A):
   |
   = 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: TC002 [*] Move third-party import `pkg` into a type-checking block
   |
89 |     # Note that `pkg` is a prefix of `pkgfoo` which are both different modules. This is
90 |     # testing the implementation.
91 |     import pkg
   |            ^^^ TC002
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):
