diff --git a/CHANGELOG.md b/CHANGELOG.md index d151564c2..88d88e5c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ We used to have incremental versioning before `0.1.0`. - Adds `flake8-logging-format` dependency - Adds `flake8-type-annotations` dependency +- Adds `flake8-breaking-line` dependency - Removes `flake8-super-call` dependency - Adds `PartialFloatViolation` - Adds `MagicNumberViolation` diff --git a/docs/_pages/errors/index.rst b/docs/_pages/errors/index.rst index 784dfc7fb..4a1207442 100644 --- a/docs/_pages/errors/index.rst +++ b/docs/_pages/errors/index.rst @@ -22,6 +22,7 @@ flake8-eradicate `E800 `_ flake8 `F400 - F901 `_ flake8-logging-format `G001 - G202 `_ flake8-isort `I001 - I005 `_ +flake8-broken-line `N400 `_ pep8-naming `N800 - N820 `_ flake8-string-format `P101 - P302 `_ flake8-quotes `Q000 `_ diff --git a/pyproject.lock b/pyproject.lock index 3865c0495..935ef8f26 100644 --- a/pyproject.lock +++ b/pyproject.lock @@ -165,6 +165,18 @@ bandit = "*" flake8 = "*" flake8-polyfill = "*" +[[package]] +category = "main" +description = "Flake8 plugin to forbid backslashes for line breaks" +name = "flake8-broken-line" +optional = false +platform = "*" +python-versions = ">=3.6,<4.0" +version = "0.1.0" + +[package.dependencies] +flake8 = ">=3.5,<4.0" + [[package]] category = "main" description = "A plugin for flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and pycodestyle." @@ -912,7 +924,7 @@ python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4" version = "1.23" [metadata] -content-hash = "7affe331e0a571d216d882f94af864d29c94542ddbe5337032a6f1c7eb661b9a" +content-hash = "7636ccf296172b92b28a5af8ad03d5425e2f4bd88d951e25196a439e45008174" platform = "*" python-versions = "^3.6 || ^3.7" @@ -932,6 +944,7 @@ docutils = ["02aec4bd92ab067f6ff27a38a38a41173bf01bed8f89157768c1573f53e474a6", eradicate = ["f9af01c544ccd8f71bc2f7f3fa39dc363d842cfcb9c730a83676a59026ab5f24"] flake8 = ["7253265f7abd8b313e3892944044a365e3f4ac3fcdcfb4298f55ee9ddf188ba0", "c7841163e2b576d435799169b78703ad6ac1bbb0f199994fc05f700b2a90ea37"] flake8-bandit = ["a66c7b42af9530d5e988851ccee02958a51a85d46f1f4609ecc3546948f809b8", "f7c3421fd9aebc63689c0693511e16dcad678fd4a0ce624b78ca91ae713eacdc"] +flake8-broken-line = ["3eb823f48b4ec67735ebbe8e282319826c8e8be7dfc185c9e259228084c21de2", "84147d38a1562d011a8de0bb1de299a715f7dea1a7332bd6946db04a1e4c3ddd"] flake8-bugbear = ["07b6e769d7f4e168d590f7088eae40f6ddd9fa4952bed31602def65842682c83", "0ccf56975f4db1d69dc1cf3598c99d768ebf95d0cad27d76087954aa399b515a"] flake8-builtins = ["8d806360767947c0035feada4ddef3ede32f0a586ef457e62d811b8456ad9a51", "cd7b1b7fec4905386a3643b59f9ca8e305768da14a49a7efb31fe9364f33cd04"] flake8-coding = ["549c2b22c08711feda11795fb49f147a626305b602c547837bab405e7981f844", "f2ee7c3c8ae47f2d278111a2090655bcf170789c24ccfea519d93be2ede7571c"] diff --git a/pyproject.toml b/pyproject.toml index e660c547c..9d575a239 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,6 +59,7 @@ flake8-eradicate = "^0.1" flake8-bandit = "^1.0" flake8-logging-format = "^0.5" flake8-type-annotations = "^0.1" +flake8-broken-line = "^0.1" pep8-naming = "^0.7" [tool.poetry.dev-dependencies] diff --git a/tests/fixtures/external_plugins.py b/tests/fixtures/external_plugins.py index a4c3918a7..0dee91fea 100644 --- a/tests/fixtures/external_plugins.py +++ b/tests/fixtures/external_plugins.py @@ -27,3 +27,7 @@ def camelCase(): ... def function_name(plugin: str ='flake8') ->str: return plugin + + +multiline_string = 'some\ +string' diff --git a/tests/test_plugins.py b/tests/test_plugins.py index 73cd0c3c8..c343e77c3 100644 --- a/tests/test_plugins.py +++ b/tests/test_plugins.py @@ -35,6 +35,7 @@ def test_noqa_fixture_disabled(absolute_path): assert output.count('F401') > 0 # flake8 assert output.count('G001') > 0 # flake8-logging-format assert output.count('I001') > 0 # flake8-isort + assert output.count('N400') > 0 # flake8-broken-line assert output.count('N802') > 0 # pep8-naming assert output.count('P101') > 0 # flake8-string-format assert output.count('Q000') > 0 # flake8-quotes diff --git a/wemake_python_styleguide/visitors/tokenize/wrong_comments.py b/wemake_python_styleguide/visitors/tokenize/wrong_comments.py index c671912d6..a27597350 100644 --- a/wemake_python_styleguide/visitors/tokenize/wrong_comments.py +++ b/wemake_python_styleguide/visitors/tokenize/wrong_comments.py @@ -16,7 +16,6 @@ import re import tokenize -from typing.re import Match, Pattern from wemake_python_styleguide.errors.tokens import ( WrongDocCommentViolation, @@ -28,15 +27,15 @@ class WrongCommentVisitor(BaseTokenVisitor): """Checks comment tokens.""" - noqa_check: Pattern = re.compile(r'^noqa:?($|[A-Z\d\,\s]+)') - type_check: Pattern = re.compile(r'^type:\s?([\w\d\[\]\'\"\.]+)$') + noqa_check = re.compile(r'^noqa:?($|[A-Z\d\,\s]+)') + type_check = re.compile(r'^type:\s?([\w\d\[\]\'\"\.]+)$') def _get_comment_text(self, token: tokenize.TokenInfo) -> str: return token.string[1:].strip() def _check_noqa(self, token: tokenize.TokenInfo) -> None: comment_text = self._get_comment_text(token) - match: Match = self.noqa_check.match(comment_text) + match = self.noqa_check.match(comment_text) if not match: return @@ -48,7 +47,7 @@ def _check_noqa(self, token: tokenize.TokenInfo) -> None: def _check_typed_ast(self, token: tokenize.TokenInfo) -> None: comment_text = self._get_comment_text(token) - match: Match = self.type_check.match(comment_text) + match = self.type_check.match(comment_text) if not match: return