Skip to content

Commit

Permalink
check annotated variable declarations
Browse files Browse the repository at this point in the history
PEP 526, syntax for variable annotations, has been introduced in
Python 3.6.[1]

[1]: https://www.python.org/dev/peps/pep-0526/

fixes #138
  • Loading branch information
5j9 committed Mar 10, 2020
1 parent 8ed423d commit b72104c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/pep8ext_naming.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
18 changes: 18 additions & 0 deletions testsuite/N816_py36.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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

0 comments on commit b72104c

Please sign in to comment.