cloudinit: remove global disable of pylint W0107 and fix errors#489
Conversation
|
|
||
| def flush(self): | ||
| """Ensure ReportingHandler has published all events""" | ||
| pass |
There was a problem hiding this comment.
i understand how the abstract methods don't need pass, but i'm surprised regular methods don't need it either
There was a problem hiding this comment.
The docstring is part of the body of the method; the pass is extraneous. Given these two definitions:
def before():
"""docstring"""
pass
def after():
"""docstring"""we can use Python's ast module to examine them (though note that as the parser operates on strings, before and after here are actually strings containing the above definitions):
>>> ast.dump(ast.parse(before))
"Module(body=[FunctionDef(name='flush', args=arguments(posonlyargs=[], args=[], vararg=None, kwonlyargs=[], kw_defaults=[], kwarg=None, defaults=[]), body=[Expr(value=Constant(value='docstring', kind=None)), Pass()], decorator_list=[], returns=None, type_comment=None)], type_ignores=[])"
>>> ast.dump(ast.parse(after))
"Module(body=[FunctionDef(name='after', args=arguments(posonlyargs=[], args=[], vararg=None, kwonlyargs=[], kw_defaults=[], kwarg=None, defaults=[]), body=[Expr(value=Constant(value='docstring', kind=None))], decorator_list=[], returns=None, type_comment=None)], type_ignores=[])"The key differences here are the body of the FunctionDef. For before, it's two statements: [Expr(value=Constant(value='docstring', kind=None)), Pass()], whereas for after it is just a single one: [Expr(value=Constant(value='docstring', kind=None))]
There was a problem hiding this comment.
(Also, plugging the definitions into https://vpyast.appspot.com/ will give you a nice graphical indicator of this.)
This includes removing a test class which contained no tests but wasn't detected as empty because of an errant pass statement.
This includes removing a test class which contained no tests but wasn't
detected as empty because of an errant pass statement.
(Also update the comment in .pylintrc to match what we actually filter.)