Skip to content

Commit 7ad5241

Browse files
authored
Merge pull request #50 from radoering/no-colon-after-codes
Remove colon after codes in order to comply with "--format=%(code)s"
2 parents 35a1a1d + fa6eef6 commit 7ad5241

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,22 +118,22 @@ class B(Model):
118118
Will 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

125125
and 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

132132
or
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**

flake8_type_checking/codes.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from __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"

tests/test_errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

133133
def test_import_is_local():

tests/test_should_warn.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff 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

8888
def 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
]

0 commit comments

Comments
 (0)