summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2019-02-04 13:24:34 +0100
committerClaudiu Popa <pcmanticore@gmail.com>2019-02-04 13:44:07 +0100
commitc2af5c760307edaf50cc519d189b620ba41f12db (patch)
treea45f85dfb31b877513496709cbca4fc1db052ddf
parent72fd895f636f7d0c62569c39dd74227ed28c8c8b (diff)
downloadpylint-git-c2af5c760307edaf50cc519d189b620ba41f12db.tar.gz
Support ``Ellipsis`` as a synonym for ``pass`` statements.
Close #2718
-rw-r--r--ChangeLog4
-rw-r--r--pylint/checkers/base.py14
-rw-r--r--pylint/test/functional/statement_without_effect.py10
3 files changed, 23 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 2b8e64441..d25187c88 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 478de8bf5..05de23ef8 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 @@ class BasicChecker(_BasicChecker):
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 eb87aca9d..c8394b45e 100644
--- a/pylint/test/functional/statement_without_effect.py
+++ b/pylint/test/functional/statement_without_effect.py
@@ -63,3 +63,13 @@ class ClassLevelAttributeTest(object):
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"""
+ ...