From 7d0fd7e4ec1b7265c4ba36436071b1ebb17ddcc6 Mon Sep 17 00:00:00 2001 From: 5j9 <5j9@users.noreply.github.com> Date: Tue, 10 Mar 2020 12:38:34 +0330 Subject: [PATCH] check annotated variable declarations PEP 526, syntax for variable annotations, has been introduced in Python 3.6. https://www.python.org/dev/peps/pep-0526/ fixes #138 --- src/pep8ext_naming.py | 2 ++ testsuite/N8xx_py36.py | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 testsuite/N8xx_py36.py diff --git a/src/pep8ext_naming.py b/src/pep8ext_naming.py index ee3a3ed..e81ccdf 100644 --- a/src/pep8ext_naming.py +++ b/src/pep8ext_naming.py @@ -436,6 +436,8 @@ def visit_namedexpr(self, node, parents, ignore): for error in self._find_errors(node.target, parents, ignore): yield error + visit_annassign = visit_namedexpr + def visit_with(self, node, parents, ignore): if PY2: for error in self._find_errors( diff --git a/testsuite/N8xx_py36.py b/testsuite/N8xx_py36.py new file mode 100644 index 0000000..cc9008b --- /dev/null +++ b/testsuite/N8xx_py36.py @@ -0,0 +1,16 @@ +# python_version >= '3.6' +#: Okay +var1: int = 1 +var2: int +def some(): + variable: int = 1 +class Test(object): + variable: int = 1 +#: N816:1:1 +mixedCase: int = 1 +#: N806:2:5 +def some(): + mixedCase: int = 1 +#: N815:2:5 +class Test(object): + mixedCase: int = 1