Repository: snok/flake8-type-checking (language: python)

Issue:
Colon after code causes issue
Due to the fact that several tools are involved in this problem, I am not 100% sure that the problem is here, but at least I think so. 😉

I'll try to describe the complete use case:

We don't like that imports from typing are forced into a type checking block so they need to be quoted (see https://github.com/python-poetry/poetry/issues/4776#issuecomment-971331270). (Maybe, something to discuss in another issue. 😉)

Thus, we add `# noqa: TC002` to such imports. So far, so good.

However, [yesqa](https://github.com/asottile/yesqa) keeps removing these `noqa` comments. At first, I thought this to be an issue of `yesqa`.
So, I debugged it. And it turns out that `yesqa` is calling `flake8 --format=%(code)s <myfile>`.

For example, if you run this on a file with the following content

```
from typing import List


def f(a: List[int]):
    myDict = {1 + 1 : 2}
    print(myDict)
    print(a)
```

you get

```
TC002:
E203
```

If you print the full message, you can see that the builtin messages do not have a colon. Of course, `yesqa` could strip the colon but I think that `%(code)s` should only return the code (without a colon). I did not dig deeper from this point. Maybe, it would be best to remove the colon? I'll attach a corresponding PR in a moment.


Discussion / hints:

Fix patch:
diff --git a/README.md b/README.md
index 8fed30c..2049a53 100644
--- a/README.md
+++ b/README.md
@@ -118,22 +118,22 @@ class B(Model):
 Will result in these errors
 
 ```shell
->> a.py: TC002: Move third-party import 'models.b.B' into a type-checking block
->> b.py: TC002: Move third-party import 'models.a.A' into a type-checking block
+>> a.py: TC002 Move third-party import 'models.b.B' into a type-checking block
+>> b.py: TC002 Move third-party import 'models.a.A' into a type-checking block
 ```
 
 and consequently trigger these errors if imports are purely moved into type-checking block, without proper forward reference handling
 
 ```shell
->> a.py: TC100: Add 'from __future__ import annotations' import
->> b.py: TC100: Add 'from __future__ import annotations' import
+>> a.py: TC100 Add 'from __future__ import annotations' import
+>> b.py: TC100 Add 'from __future__ import annotations' import
 ```
 
 or
 
 ```shell
->> a.py: TC200: Annotation 'B' needs to be made into a string literal
->> b.py: TC200: Annotation 'A' needs to be made into a string literal
+>> a.py: TC200 Annotation 'B' needs to be made into a string literal
+>> b.py: TC200 Annotation 'A' needs to be made into a string literal
 ```
 
 **Good code**
diff --git a/flake8_type_checking/codes.py b/flake8_type_checking/codes.py
index 96e4f3f..b64fda0 100644
--- a/flake8_type_checking/codes.py
+++ b/flake8_type_checking/codes.py
@@ -1,11 +1,11 @@
 from __future__ import annotations
 
-TC001 = "TC001: Move import '{module}' into a type-checking block"
-TC002 = "TC002: Move third-party import '{module}' into a type-checking block"
-TC003 = 'TC003: Found multiple type checking blocks'
-TC004 = "TC004: Move import '{module}' out of type-checking block. Import is used for more than type hinting."
-TC005 = 'TC005: Found empty type-checking block'
-TC100 = "TC100: Add 'from __future__ import annotations' import"
-TC101 = "TC101: Annotation '{annotation}' does not need to be a string literal"
-TC200 = "TC200: Annotation '{annotation}' needs to be made into a string literal"
-TC201 = "TC201: Annotation '{annotation}' does not need to be a string literal"
+TC001 = "TC001 Move import '{module}' into a type-checking block"
+TC002 = "TC002 Move third-party import '{module}' into a type-checking block"
+TC003 = 'TC003 Found multiple type checking blocks'
+TC004 = "TC004 Move import '{module}' out of type-checking block. Import is used for more than type hinting."
+TC005 = 'TC005 Found empty type-checking block'
+TC100 = "TC100 Add 'from __future__ import annotations' import"
+TC101 = "TC101 Annotation '{annotation}' does not need to be a string literal"
+TC200 = "TC200 Annotation '{annotation}' needs to be made into a string literal"
+TC201 = "TC201 Annotation '{annotation}' does not need to be a string"


Test patch:
diff --git a/tests/test_errors.py b/tests/test_errors.py
index 260ecd4..2e2c7cd 100644
--- a/tests/test_errors.py
+++ b/tests/test_errors.py
@@ -127,7 +127,7 @@ def test_conditional_import(self):
         var: x
         """
         )
-        assert _get_error(example) == {"7:4 TC002: Move third-party import 'x' into a type-checking block"}
+        assert _get_error(example) == {"7:4 TC002 Move third-party import 'x' into a type-checking block"}
 
 
 def test_import_is_local():
diff --git a/tests/test_should_warn.py b/tests/test_should_warn.py
index 7f8ccad..acb37c5 100644
--- a/tests/test_should_warn.py
+++ b/tests/test_should_warn.py
@@ -33,7 +33,7 @@ def test_tc_is_enabled_with_config(flake8dir):
     )
     result = flake8dir.run_flake8()
     assert result.out_lines == [
-        f".{os.sep}example.py:1:1: TC002: Move third-party import 'typing.Union' into a type-checking block"
+        f".{os.sep}example.py:1:1: TC002 Move third-party import 'typing.Union' into a type-checking block"
     ]
 
 
@@ -82,7 +82,7 @@ def test_tc1_works_when_opted_in(flake8dir):
     '''
     )
     result = flake8dir.run_flake8()
-    assert result.out_lines == [f".{os.sep}example.py:1:1: TC100: Add 'from __future__ import annotations' import"]
+    assert result.out_lines == [f".{os.sep}example.py:1:1: TC100 Add 'from __future__ import annotations' import"]
 
 
 def test_tc2_works_when_opted_in(flake8dir):
@@ -106,5 +106,5 @@ def test_tc2_works_when_opted_in(flake8dir):
     )
     result = flake8dir.run_flake8()
     assert result.out_lines == [
-        f".{os.sep}example.py:6:4: TC200: Annotation 'Union' needs to be made into a string literal"
+        f".{os.sep}example.py:6:4: TC200 Annotation 'Union' needs to be made into a string literal"
     ]