Repository: wemake-services/wemake-python-styleguide

Issue:
Make sure `WrongMagicCommentViolation` also catches `noqa WPS100` comments
There are wrong comments that are widely used by newcomers: `# noqa WPS100`
But, it is simply wrong. 

We need to be sure that `WrongMagicCommentViolation` catches that.
Make sure `WrongMagicCommentViolation` also catches `noqa WPS100` comments
There are wrong comments that are widely used by newcomers: `# noqa WPS100`
But, it is simply wrong. 

We need to be sure that `WrongMagicCommentViolation` catches that.


Discussion:
Am I understanding that it currently there's a check for `# noqa` comments, but it doesn't catch comments that state `# noqa WPS200` (and possibly other additions? 

If not could you elaborate a bit, I think i'd be interested in taking this one, I just want to be sure I understand the issue first. Thank you, @sobolevn!
@AvianAnalyst yes, you are right. We catch several types of incorrect `noqa` options. But not `# noqa WPSXXX`. We need to fix it.

You can have a look at https://github.com/wemake-services/wemake-python-styleguide/blob/master/wemake_python_styleguide/visitors/tokenize/comments.py 
And the docs on how to contribute: https://wemake-python-stylegui.de/en/latest/pages/api/index.html
Thanks for the response! 

I started trying to setup a dev environment, and I have the repo forked and cloned but I'm running into issues with poetry. 

I'm on ubuntu 19.04, with python 3.7. I installed poetry using `sudo -H pip3 install poetry`, started a shell with `poetry shell` and then ran `poetry install`, but i get a 
```
[FileNotFoundError]                   
[Errno 2] No such file or directory: 'pip': 'pip'  
```

I found a bug on poetry's github about this issue: https://github.com/sdispater/poetry/issues/712 and that lead to https://github.com/sdispater/poetry/pull/861 but before I grabbed that fork of poetry, I wanted to check to see if anyone here has had a similar issue/recommendations on something else to try?
You can try this solution: 

```bash
poetry config settings.virtualenvs.in-project true
poetry install
source .venv/bin/activate
```
After `poetry config settings.virtualenvs.in-project true` i get the same error as before.
@AvianAnalyst can you please try to uninstall and clean everything? And them install `poetry` via `curl` as we do in `.travis.yml`
@AvianAnalyst hey, how's it going? Do you need any help?
Hey, can I take this one?
Sure! Thanks a lot!
Ok, before I add the code, I just wanted to make sure I understand what this really means. You want `# noqa: WPS100` comments to raise `WrongMagicCommentViolation` the same way `# noqa` without the prefixes do. However, other `# noqa: XXX` comments will still be ignored by the violation. Am I getting this right?
Yes, that's correct.
Am I understanding that it currently there's a check for `# noqa` comments, but it doesn't catch comments that state `# noqa WPS200` (and possibly other additions? 

If not could you elaborate a bit, I think i'd be interested in taking this one, I just want to be sure I understand the issue first. Thank you, @sobolevn!
@AvianAnalyst yes, you are right. We catch several types of incorrect `noqa` options. But not `# noqa WPSXXX`. We need to fix it.

You can have a look at https://github.com/wemake-services/wemake-python-styleguide/blob/master/wemake_python_styleguide/visitors/tokenize/comments.py 
And the docs on how to contribute: https://wemake-python-stylegui.de/en/latest/pages/api/index.html
Thanks for the response! 

I started trying to setup a dev environment, and I have the repo forked and cloned but I'm running into issues with poetry. 

I'm on ubuntu 19.04, with python 3.7. I installed poetry using `sudo -H pip3 install poetry`, started a shell with `poetry shell` and then ran `poetry install`, but i get a 
```
[FileNotFoundError]                   
[Errno 2] No such file or directory: 'pip': 'pip'  
```

I found a bug on poetry's github about this issue: https://github.com/sdispater/poetry/issues/712 and that lead to https://github.com/sdispater/poetry/pull/861 but before I grabbed that fork of poetry, I wanted to check to see if anyone here has had a similar issue/recommendations on something else to try?
You can try this solution: 

```bash
poetry config settings.virtualenvs.in-project true
poetry install
source .venv/bin/activate
```
After `poetry config settings.virtualenvs.in-project true` i get the same error as before.
@AvianAnalyst can you please try to uninstall and clean everything? And them install `poetry` via `curl` as we do in `.travis.yml`
@AvianAnalyst hey, how's it going? Do you need any help?
Hey, can I take this one?
Sure! Thanks a lot!
Ok, before I add the code, I just wanted to make sure I understand what this really means. You want `# noqa: WPS100` comments to raise `WrongMagicCommentViolation` the same way `# noqa` without the prefixes do. However, other `# noqa: XXX` comments will still be ignored by the violation. Am I getting this right?
Yes, that's correct.

Resolving patch:
diff --git a/wemake_python_styleguide/visitors/tokenize/comments.py b/wemake_python_styleguide/visitors/tokenize/comments.py
--- a/wemake_python_styleguide/visitors/tokenize/comments.py
+++ b/wemake_python_styleguide/visitors/tokenize/comments.py
@@ -44,7 +44,7 @@ class WrongCommentVisitor(BaseTokenVisitor):
     """Checks comment tokens."""
 
     _no_cover: ClassVar[Pattern] = re.compile(r'^pragma:\s+no\s+cover')
-    _noqa_check: ClassVar[Pattern] = re.compile(r'^noqa:?($|[A-Z\d\,\s]+)')
+    _noqa_check: ClassVar[Pattern] = re.compile(r'^(noqa:?)($|[A-Z\d\,\s]+)')
     _type_check: ClassVar[Pattern] = re.compile(
         r'^type:\s?([\w\d\[\]\'\"\.]+)$',
     )
@@ -77,8 +77,10 @@ def _check_noqa(self, token: tokenize.TokenInfo) -> None:
             return
 
         self._noqa_count += 1
-        excludes = match.groups()[0].strip()
-        if not excludes:
+        excludes = match.groups()[1].strip()
+        prefix = match.groups()[0].strip()
+
+        if not excludes or prefix[-1] != ':':
             # We cannot pass the actual line here,
             # since it will be ignored due to `# noqa` comment:
             self.add_violation(WrongMagicCommentViolation(text=comment_text))


Test patch:
diff --git a/tests/test_visitors/test_tokenize/test_comments/test_noqa_comment.py b/tests/test_visitors/test_tokenize/test_comments/test_noqa_comment.py
--- a/tests/test_visitors/test_tokenize/test_comments/test_noqa_comment.py
+++ b/tests/test_visitors/test_tokenize/test_comments/test_noqa_comment.py
@@ -38,6 +38,7 @@ def test_correct_comments(
 
 
 @pytest.mark.parametrize('code', [
+    'x = 10_00 # noqa WPS002',
     'x = 10_00  # noqa',
     'x = 10_00  #   noqa   ',
     'x = 10_00 #noqa',