File tree Expand file tree Collapse file tree 4 files changed +19
-19
lines changed
Expand file tree Collapse file tree 4 files changed +19
-19
lines changed Original file line number Diff line number Diff line change @@ -118,22 +118,22 @@ class B(Model):
118118Will result in these errors
119119
120120``` shell
121- >> a.py: TC002: Move third-party import ' models.b.B' into a type-checking block
122- >> b.py: TC002: Move third-party import ' models.a.A' into a type-checking block
121+ >> a.py: TC002 Move third-party import ' models.b.B' into a type-checking block
122+ >> b.py: TC002 Move third-party import ' models.a.A' into a type-checking block
123123```
124124
125125and consequently trigger these errors if imports are purely moved into type-checking block, without proper forward reference handling
126126
127127``` shell
128- >> a.py: TC100: Add ' from __future__ import annotations' import
129- >> b.py: TC100: Add ' from __future__ import annotations' import
128+ >> a.py: TC100 Add ' from __future__ import annotations' import
129+ >> b.py: TC100 Add ' from __future__ import annotations' import
130130```
131131
132132or
133133
134134``` shell
135- >> a.py: TC200: Annotation ' B' needs to be made into a string literal
136- >> b.py: TC200: Annotation ' A' needs to be made into a string literal
135+ >> a.py: TC200 Annotation ' B' needs to be made into a string literal
136+ >> b.py: TC200 Annotation ' A' needs to be made into a string literal
137137```
138138
139139** Good code**
Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3- TC001 = "TC001: Move import '{module}' into a type-checking block"
4- TC002 = "TC002: Move third-party import '{module}' into a type-checking block"
5- TC003 = 'TC003: Found multiple type checking blocks'
6- TC004 = "TC004: Move import '{module}' out of type-checking block. Import is used for more than type hinting."
7- TC005 = 'TC005: Found empty type-checking block'
8- TC100 = "TC100: Add 'from __future__ import annotations' import"
9- TC101 = "TC101: Annotation '{annotation}' does not need to be a string literal"
10- TC200 = "TC200: Annotation '{annotation}' needs to be made into a string literal"
11- TC201 = "TC201: Annotation '{annotation}' does not need to be a string literal "
3+ TC001 = "TC001 Move import '{module}' into a type-checking block"
4+ TC002 = "TC002 Move third-party import '{module}' into a type-checking block"
5+ TC003 = 'TC003 Found multiple type checking blocks'
6+ TC004 = "TC004 Move import '{module}' out of type-checking block. Import is used for more than type hinting."
7+ TC005 = 'TC005 Found empty type-checking block'
8+ TC100 = "TC100 Add 'from __future__ import annotations' import"
9+ TC101 = "TC101 Annotation '{annotation}' does not need to be a string literal"
10+ TC200 = "TC200 Annotation '{annotation}' needs to be made into a string literal"
11+ TC201 = "TC201 Annotation '{annotation}' does not need to be a string"
Original file line number Diff line number Diff line change @@ -127,7 +127,7 @@ def test_conditional_import(self):
127127 var: x
128128 """
129129 )
130- assert _get_error (example ) == {"7:4 TC002: Move third-party import 'x' into a type-checking block" }
130+ assert _get_error (example ) == {"7:4 TC002 Move third-party import 'x' into a type-checking block" }
131131
132132
133133def test_import_is_local ():
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ def test_tc_is_enabled_with_config(flake8dir):
3333 )
3434 result = flake8dir .run_flake8 ()
3535 assert result .out_lines == [
36- f".{ os .sep } example.py:1:1: TC002: Move third-party import 'typing.Union' into a type-checking block"
36+ f".{ os .sep } example.py:1:1: TC002 Move third-party import 'typing.Union' into a type-checking block"
3737 ]
3838
3939
@@ -82,7 +82,7 @@ def test_tc1_works_when_opted_in(flake8dir):
8282 '''
8383 )
8484 result = flake8dir .run_flake8 ()
85- assert result .out_lines == [f".{ os .sep } example.py:1:1: TC100: Add 'from __future__ import annotations' import" ]
85+ assert result .out_lines == [f".{ os .sep } example.py:1:1: TC100 Add 'from __future__ import annotations' import" ]
8686
8787
8888def test_tc2_works_when_opted_in (flake8dir ):
@@ -106,5 +106,5 @@ def test_tc2_works_when_opted_in(flake8dir):
106106 )
107107 result = flake8dir .run_flake8 ()
108108 assert result .out_lines == [
109- f".{ os .sep } example.py:6:4: TC200: Annotation 'Union' needs to be made into a string literal"
109+ f".{ os .sep } example.py:6:4: TC200 Annotation 'Union' needs to be made into a string literal"
110110 ]
You can’t perform that action at this time.
0 commit comments