Skip to content

Commit

Permalink
Add checker for classnames
Browse files Browse the repository at this point in the history
  • Loading branch information
stephan-hof committed Aug 12, 2012
1 parent 4c10428 commit 91a53a4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pep8.py
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,18 @@ def visit_node(self, node):
meth(node)


class ClassNameASTCheck(BaseAstCheck):
"""
Almost without exception, class names use the CapWords convention.
Classes for internal use have a leading underscore in addition.
"""
CLASS_NAME_RGX = re.compile('[_A-Z][a-zA-Z0-9]*$')
text = "E800 class names should use CapWords convention"

def visit_classdef(self, node):
if not self.CLASS_NAME_RGX.match(node.name):
self.error_at_node(node, self.text)

##############################################################################
# Helper functions
Expand Down
8 changes: 8 additions & 0 deletions testsuite/E80.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#: E800
class notok(object):
pass
#: E800
class Good(object):
class notok(object):
pass
pass

0 comments on commit 91a53a4

Please sign in to comment.