diff --git a/ChangeLog b/ChangeLog index 2b8e644418..d25187c88b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,10 @@ What's New in Pylint 2.3.0? Release date: TBA +* Support ``Ellipsis`` as a synonym for ``pass`` statements. + + Close #2718 + * ``fixme`` gets triggered only on comments. Close #2321 diff --git a/pylint/checkers/base.py b/pylint/checkers/base.py index 478de8bf54..05de23ef88 100644 --- a/pylint/checkers/base.py +++ b/pylint/checkers/base.py @@ -369,12 +369,12 @@ def report_by_type_stats(sect, stats, old_stats): if total != 0: try: documented = total - stats["undocumented_" + node_type] - percent = (documented * 100.) / total + percent = (documented * 100.0) / total nice_stats[node_type]["percent_documented"] = "%.2f" % percent except KeyError: nice_stats[node_type]["percent_documented"] = "NC" try: - percent = (stats["badname_" + node_type] * 100.) / total + percent = (stats["badname_" + node_type] * 100.0) / total nice_stats[node_type]["percent_badname"] = "%.2f" % percent except KeyError: nice_stats[node_type]["percent_badname"] = "NC" @@ -1089,13 +1089,17 @@ def visit_expr(self, node): return self.add_message("pointless-string-statement", node=node) return - # ignore if this is : + + # Ignore if this is : # * a direct function call # * the unique child of a try/except body - # * a yield (which are wrapped by a discard node in _ast XXX) + # * a yieldd statement + # * an ellipsis (which can be used on Python 3 instead of pass) # warn W0106 if we have any underlying function call (we can't predict # side effects), else pointless-statement - if isinstance(expr, (astroid.Yield, astroid.Await, astroid.Call)) or ( + if isinstance( + expr, (astroid.Yield, astroid.Await, astroid.Ellipsis, astroid.Call) + ) or ( isinstance(node.parent, astroid.TryExcept) and node.parent.body == [node] ): return diff --git a/pylint/test/functional/statement_without_effect.py b/pylint/test/functional/statement_without_effect.py index eb87aca9dd..c8394b45ec 100644 --- a/pylint/test/functional/statement_without_effect.py +++ b/pylint/test/functional/statement_without_effect.py @@ -63,3 +63,13 @@ def test(self): self.val = 42 # +1:[pointless-string-statement] """ this is an invalid attribute docstring. """ + + +def ellipsis(): + """Test that an Ellipsis as a body does not trigger the error""" + ... + + +class EllipsisBody: + """Test that an Ellipsis as a body does not trigger the error""" + ...