@@ -87,6 +87,9 @@ class GoogleStyleGuideChecker(checkers.BaseChecker):
8787 'lambda-func' ,
8888 "For common operations like multiplication, use the functions from the operator module"
8989 "instead of lambda functions. For example, prefer operator.mul to lambda x, y: x * y." ),
90+ 'C6015' : ('No blank line after a class definition' ,
91+ 'blank-line-after-class-required' ,
92+ 'Missing a blank line after a class definition' ),
9093 }
9194
9295 options = (
@@ -173,6 +176,9 @@ def visit_raise(self, node): # type: (astroid.Raise) -> None
173176 def visit_if (self , node ):
174177 self .__use_cond_expr (node ) # type: (astroid.If) -> None
175178
179+ def visit_classdef (self , node ): # type: (astroid.ClassDef) -> None
180+ self .__class_def_check (node )
181+
176182 @staticmethod
177183 def __get_module_names (node ): # type: (astroid.ImportFrom) -> typing.Generator[str, None, None]
178184 for name in node .names :
@@ -322,3 +328,17 @@ def __lambda_func(self, node): # type: (astroid.Lambda) -> None
322328 lambda_fun = "lambda " + left + ', ' + right + ": " + " " .join ([left , node .ops [0 ][0 ], right ])
323329 op_fun = "operator." + operator
324330 self .add_message ('lambda-func' , node = node , args = {'op' : op_fun , 'lambda_fun' : lambda_fun })
331+
332+ def __class_def_check (self , node ): # type: (astroid.ClassDef) -> None
333+ """Enforce a blank line after a class definition line."""
334+ prev_line = node .lineno
335+
336+ for element in node .body :
337+ curr_line = element .lineno
338+ blank_lines = curr_line - prev_line - 1
339+ if isinstance (element , astroid .FunctionDef ) and blank_lines < 1 :
340+ self .add_message ('blank-line-after-class-required' , node = node )
341+ break
342+ elif isinstance (element , astroid .FunctionDef ):
343+ break
344+ prev_line = curr_line
0 commit comments