summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <cpopa@cloudbasesolutions.com>2014-11-17 18:46:43 +0200
committerClaudiu Popa <cpopa@cloudbasesolutions.com>2014-11-17 18:46:43 +0200
commita1ece4ffc6ed23e685089664a51d97fe1160070f (patch)
treeb8b52528e75727bbbaee59680ff3d7ff4875d38c
parent9f7bf56e2f2a6f34e8d2623f8f7703106453e440 (diff)
downloadpylint-a1ece4ffc6ed23e685089664a51d97fe1160070f.tar.gz
Add hex, oct, nonzero and cmp to the list of methods removed in Python 3.
-rw-r--r--ChangeLog3
-rw-r--r--checkers/python3.py24
-rw-r--r--test/unittest_checker_python3.py12
3 files changed, 38 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index daa995b..a877b66 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -129,7 +129,8 @@ ChangeLog for Pylint
raw_input, reduce, StandardError, unicode, reload and xrange.
* Warn for magic methods which are not used in any way in Python 3:
- __coerce__, __delslice__, __getslice__, and __setslice__.
+ __coerce__, __delslice__, __getslice__, __setslice__, __cmp__,
+ __oct__, __nonzero__ and __hex__.
* Don't emit 'assigning-non-slot' when the assignment is for a property.
Closes issue #359.
diff --git a/checkers/python3.py b/checkers/python3.py
index 5c66f76..e428a60 100644
--- a/checkers/python3.py
+++ b/checkers/python3.py
@@ -217,6 +217,26 @@ class Python3Checker(checkers.BaseChecker):
'(missing from Python 3). You can use instead imp.reload '
'or importlib.reload.',
{'maxversion': (3, 0)}),
+ 'W1627': ('__oct__ method defined',
+ 'oct-method',
+ 'Used when a __oct__ method is defined '
+ '(method is not used by Python 3)',
+ {'maxversion': (3, 0)}),
+ 'W1628': ('__hex__ method defined',
+ 'hex-method',
+ 'Used when a __hex__ method is defined '
+ '(method is not used by Python 3)',
+ {'maxversion': (3, 0)}),
+ 'W1629': ('__nonzero__ method defined',
+ 'nonzero-method',
+ 'Used when a __nonzero__ method is defined '
+ '(method is not used by Python 3)',
+ {'maxversion': (3, 0)}),
+ 'W1630': ('__cmp__ method defined',
+ 'cmp-method',
+ 'Used when a __cmp__ method is defined '
+ '(method is not used by Python 3)',
+ {'maxversion': (3, 0)}),
}
_missing_builtins = frozenset([
@@ -241,6 +261,10 @@ class Python3Checker(checkers.BaseChecker):
'__delslice__',
'__getslice__',
'__setslice__',
+ '__oct__',
+ '__hex__',
+ '__nonzero__',
+ '__cmp__',
])
def __init__(self, *args, **kwargs):
diff --git a/test/unittest_checker_python3.py b/test/unittest_checker_python3.py
index dc22d3a..b57fc96 100644
--- a/test/unittest_checker_python3.py
+++ b/test/unittest_checker_python3.py
@@ -80,6 +80,18 @@ class Python3CheckerTest(testutils.CheckerTestCase):
def test_coerce_method(self):
self._test_defined_method('coerce', 'coerce-method')
+ def test_oct_method(self):
+ self._test_defined_method('oct', 'oct-method')
+
+ def test_hex_method(self):
+ self._test_defined_method('hex', 'hex-method')
+
+ def test_nonzero_method(self):
+ self._test_defined_method('nonzero', 'nonzero-method')
+
+ def test_cmp_method(self):
+ self._test_defined_method('cmp', 'cmp-method')
+
@python2_only
def test_print_statement(self):
node = test_utils.extract_node('print "Hello, World!" #@')