diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2018-05-10 07:28:17 -0400 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2018-05-10 07:35:04 -0400 |
commit | 75391673981ce261000c81c15bf10ab47488708f (patch) | |
tree | 09355fd8ef363694fcd25ed90021d4f6780e6913 | |
parent | 5915041a113508a0f72232a8234b4a55808f6dd4 (diff) | |
download | pylint-git-75391673981ce261000c81c15bf10ab47488708f.tar.gz |
The Python 3 porting checker can run with Python 3 as well
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | doc/faq.rst | 1 | ||||
-rw-r--r-- | pylint/checkers/python3.py | 228 | ||||
-rw-r--r-- | pylint/test/unittest_checker_python3.py | 50 |
4 files changed, 89 insertions, 194 deletions
@@ -5,8 +5,12 @@ Pylint's ChangeLog What's New in Pylint 1.9.0? =========================== + Release date: + + * The Python 3 porting mode can now run with Python 3 as well. + * docparams extension allows abstract methods to document what overriding implementations should return, and to raise NotImplementedError without documenting it. diff --git a/doc/faq.rst b/doc/faq.rst index e99328ad3..f6ea23695 100644 --- a/doc/faq.rst +++ b/doc/faq.rst @@ -120,6 +120,7 @@ For example:: Much probably. Read :ref:`ide-integration` + 4. Message Control ================== diff --git a/pylint/checkers/python3.py b/pylint/checkers/python3.py index 630926dbd..7734af745 100644 --- a/pylint/checkers/python3.py +++ b/pylint/checkers/python3.py @@ -21,14 +21,11 @@ """Check Python 2 code for Python 2/3 source-compatible issues.""" from __future__ import absolute_import, print_function +from collections import namedtuple import re import sys import tokenize -from collections import namedtuple - -import six - import astroid from astroid import bases @@ -79,7 +76,7 @@ def _is_builtin(node): _ACCEPTS_ITERATOR = {'iter', 'list', 'tuple', 'sorted', 'set', 'sum', 'any', - 'all', 'enumerate', 'dict', 'filter'} + 'all', 'enumerate', 'dict', 'filter', 'reversed'} DICT_METHODS = {'items', 'keys', 'values'} @@ -96,7 +93,7 @@ def _in_iterating_context(node): return True # Need to make sure the use of the node is in the iterator part of the # comprehension. - elif isinstance(parent, astroid.Comprehension): + if isinstance(parent, astroid.Comprehension): if parent.iter == node: return True # Various built-ins can take in an iterable or list and lead to the same @@ -119,7 +116,7 @@ def _in_iterating_context(node): def _is_conditional_import(node): - """Checks if a import node is in the context of a conditional. + """Checks if an import node is in the context of a conditional. """ parent = node.parent return isinstance(parent, (astroid.TryExcept, astroid.ExceptHandler, @@ -141,34 +138,30 @@ class Python3Checker(checkers.BaseChecker): 'E1601': ('print statement used', 'print-statement', 'Used when a print statement is used ' - '(`print` is a function in Python 3)', - {'maxversion': (3, 0)}), + '(`print` is a function in Python 3)'), 'E1602': ('Parameter unpacking specified', 'parameter-unpacking', 'Used when parameter unpacking is specified for a function' - "(Python 3 doesn't allow it)", - {'maxversion': (3, 0)}), + "(Python 3 doesn't allow it)"), 'E1603': ('Implicit unpacking of exceptions is not supported ' 'in Python 3', 'unpacking-in-except', 'Python3 will not allow implicit unpacking of ' 'exceptions in except clauses. ' 'See http://www.python.org/dev/peps/pep-3110/', - {'maxversion': (3, 0), - 'old_names': [('W0712', 'unpacking-in-except')]}), - 'E1604': ('Use raise ErrorClass(args) instead of raise ErrorClass, args.', + {'old_names': [('W0712', 'unpacking-in-except')]}), + 'E1604': ('Use raise ErrorClass(args) instead of ' + 'raise ErrorClass, args.', 'old-raise-syntax', - "Used when the alternate raise syntax 'raise foo, bar' is used " - "instead of 'raise foo(bar)'. If you need to also raise with a traceback, " - "consider using six.reraise instead.", - {'maxversion': (3, 0), - 'old_names': [('W0121', 'old-raise-syntax')]}), + "Used when the alternate raise syntax " + "'raise foo, bar' is used " + "instead of 'raise foo(bar)'.", + {'old_names': [('W0121', 'old-raise-syntax')]}), 'E1605': ('Use of the `` operator', 'backtick', 'Used when the deprecated "``" (backtick) operator is used ' 'instead of the str() function.', {'scope': WarningScope.NODE, - 'maxversion': (3, 0), 'old_names': [('W0333', 'backtick')]}), 'E1609': ('Import * only allowed at module level', 'import-star-module-level', @@ -178,296 +171,239 @@ class Python3Checker(checkers.BaseChecker): 'W1601': ('apply built-in referenced', 'apply-builtin', 'Used when the apply built-in function is referenced ' - '(missing from Python 3)', - {'maxversion': (3, 0)}), + '(missing from Python 3)'), 'W1602': ('basestring built-in referenced', 'basestring-builtin', 'Used when the basestring built-in function is referenced ' - '(missing from Python 3)', - {'maxversion': (3, 0)}), + '(missing from Python 3)'), 'W1603': ('buffer built-in referenced', 'buffer-builtin', 'Used when the buffer built-in function is referenced ' - '(missing from Python 3)', - {'maxversion': (3, 0)}), + '(missing from Python 3)'), 'W1604': ('cmp built-in referenced', 'cmp-builtin', 'Used when the cmp built-in function is referenced ' - '(missing from Python 3)', - {'maxversion': (3, 0)}), + '(missing from Python 3)'), 'W1605': ('coerce built-in referenced', 'coerce-builtin', 'Used when the coerce built-in function is referenced ' - '(missing from Python 3)', - {'maxversion': (3, 0)}), + '(missing from Python 3)'), 'W1606': ('execfile built-in referenced', 'execfile-builtin', 'Used when the execfile built-in function is referenced ' - '(missing from Python 3)', - {'maxversion': (3, 0)}), + '(missing from Python 3)'), 'W1607': ('file built-in referenced', 'file-builtin', 'Used when the file built-in function is referenced ' - '(missing from Python 3)', - {'maxversion': (3, 0)}), + '(missing from Python 3)'), 'W1608': ('long built-in referenced', 'long-builtin', 'Used when the long built-in function is referenced ' - '(missing from Python 3)', - {'maxversion': (3, 0)}), + '(missing from Python 3)'), 'W1609': ('raw_input built-in referenced', 'raw_input-builtin', 'Used when the raw_input built-in function is referenced ' - '(missing from Python 3)', - {'maxversion': (3, 0)}), + '(missing from Python 3)'), 'W1610': ('reduce built-in referenced', 'reduce-builtin', 'Used when the reduce built-in function is referenced ' - '(missing from Python 3)', - {'maxversion': (3, 0)}), + '(missing from Python 3)'), 'W1611': ('StandardError built-in referenced', 'standarderror-builtin', 'Used when the StandardError built-in function is referenced ' - '(missing from Python 3)', - {'maxversion': (3, 0)}), + '(missing from Python 3)'), 'W1612': ('unicode built-in referenced', 'unicode-builtin', 'Used when the unicode built-in function is referenced ' - '(missing from Python 3)', - {'maxversion': (3, 0)}), + '(missing from Python 3)'), 'W1613': ('xrange built-in referenced', 'xrange-builtin', 'Used when the xrange built-in function is referenced ' - '(missing from Python 3)', - {'maxversion': (3, 0)}), + '(missing from Python 3)'), 'W1614': ('__coerce__ method defined', 'coerce-method', 'Used when a __coerce__ method is defined ' - '(method is not used by Python 3)', - {'maxversion': (3, 0)}), + '(method is not used by Python 3)'), 'W1615': ('__delslice__ method defined', 'delslice-method', 'Used when a __delslice__ method is defined ' - '(method is not used by Python 3)', - {'maxversion': (3, 0)}), + '(method is not used by Python 3)'), 'W1616': ('__getslice__ method defined', 'getslice-method', 'Used when a __getslice__ method is defined ' - '(method is not used by Python 3)', - {'maxversion': (3, 0)}), + '(method is not used by Python 3)'), 'W1617': ('__setslice__ method defined', 'setslice-method', 'Used when a __setslice__ method is defined ' - '(method is not used by Python 3)', - {'maxversion': (3, 0)}), + '(method is not used by Python 3)'), 'W1618': ('import missing `from __future__ import absolute_import`', 'no-absolute-import', 'Used when an import is not accompanied by ' '``from __future__ import absolute_import`` ' - '(default behaviour in Python 3)', - {'maxversion': (3, 0)}), + '(default behaviour in Python 3)'), 'W1619': ('division w/o __future__ statement', 'old-division', 'Used for non-floor division w/o a float literal or ' '``from __future__ import division`` ' - '(Python 3 returns a float for int division unconditionally)', - {'maxversion': (3, 0)}), + '(Python 3 returns a float for int division unconditionally)'), 'W1620': ('Calling a dict.iter*() method', 'dict-iter-method', 'Used for calls to dict.iterkeys(), itervalues() or iteritems() ' - '(Python 3 lacks these methods)', - {'maxversion': (3, 0)}), + '(Python 3 lacks these methods)'), 'W1621': ('Calling a dict.view*() method', 'dict-view-method', 'Used for calls to dict.viewkeys(), viewvalues() or viewitems() ' - '(Python 3 lacks these methods)', - {'maxversion': (3, 0)}), + '(Python 3 lacks these methods)'), 'W1622': ('Called a next() method on an object', 'next-method-called', "Used when an object's next() method is called " - '(Python 3 uses the next() built-in function)', - {'maxversion': (3, 0)}), + '(Python 3 uses the next() built-in function)'), 'W1623': ("Assigning to a class's __metaclass__ attribute", 'metaclass-assignment', "Used when a metaclass is specified by assigning to __metaclass__ " - '(Python 3 specifies the metaclass as a class statement argument)', - {'maxversion': (3, 0)}), + '(Python 3 specifies the metaclass as a class statement argument)'), 'W1624': ('Indexing exceptions will not work on Python 3', 'indexing-exception', 'Indexing exceptions will not work on Python 3. Use ' '`exception.args[index]` instead.', - {'maxversion': (3, 0), - 'old_names': [('W0713', 'indexing-exception')]}), + {'old_names': [('W0713', 'indexing-exception')]}), 'W1625': ('Raising a string exception', 'raising-string', 'Used when a string exception is raised. This will not ' 'work on Python 3.', - {'maxversion': (3, 0), - 'old_names': [('W0701', 'raising-string')]}), + {'old_names': [('W0701', 'raising-string')]}), 'W1626': ('reload built-in referenced', 'reload-builtin', 'Used when the reload built-in function is referenced ' '(missing from Python 3). You can use instead imp.reload ' - 'or importlib.reload.', - {'maxversion': (3, 0)}), + 'or importlib.reload.'), 'W1627': ('__oct__ method defined', 'oct-method', - 'Used when a __oct__ method is defined ' - '(method is not used by Python 3)', - {'maxversion': (3, 0)}), + 'Used when an __oct__ method is defined ' + '(method is not used by Python 3)'), 'W1628': ('__hex__ method defined', 'hex-method', 'Used when a __hex__ method is defined ' - '(method is not used by Python 3)', - {'maxversion': (3, 0)}), + '(method is not used by Python 3)'), 'W1629': ('__nonzero__ method defined', 'nonzero-method', 'Used when a __nonzero__ method is defined ' - '(method is not used by Python 3)', - {'maxversion': (3, 0)}), + '(method is not used by Python 3)'), 'W1630': ('__cmp__ method defined', 'cmp-method', 'Used when a __cmp__ method is defined ' - '(method is not used by Python 3)', - {'maxversion': (3, 0)}), + '(method is not used by Python 3)'), # 'W1631': replaced by W1636 'W1632': ('input built-in referenced', 'input-builtin', 'Used when the input built-in is referenced ' - '(backwards-incompatible semantics in Python 3)', - {'maxversion': (3, 0)}), + '(backwards-incompatible semantics in Python 3)'), 'W1633': ('round built-in referenced', 'round-builtin', 'Used when the round built-in is referenced ' - '(backwards-incompatible semantics in Python 3)', - {'maxversion': (3, 0)}), + '(backwards-incompatible semantics in Python 3)'), 'W1634': ('intern built-in referenced', 'intern-builtin', 'Used when the intern built-in is referenced ' - '(Moved to sys.intern in Python 3)', - {'maxversion': (3, 0)}), + '(Moved to sys.intern in Python 3)'), 'W1635': ('unichr built-in referenced', 'unichr-builtin', 'Used when the unichr built-in is referenced ' - '(Use chr in Python 3)', - {'maxversion': (3, 0)}), + '(Use chr in Python 3)'), 'W1636': ('map built-in referenced when not iterating', 'map-builtin-not-iterating', 'Used when the map built-in is referenced in a non-iterating ' 'context (returns an iterator in Python 3)', - {'maxversion': (3, 0), - 'old_names': [('W1631', 'implicit-map-evaluation')]}), + {'old_names': [('W1631', 'implicit-map-evaluation')]}), 'W1637': ('zip built-in referenced when not iterating', 'zip-builtin-not-iterating', 'Used when the zip built-in is referenced in a non-iterating ' - 'context (returns an iterator in Python 3)', - {'maxversion': (3, 0)}), + 'context (returns an iterator in Python 3)'), 'W1638': ('range built-in referenced when not iterating', 'range-builtin-not-iterating', 'Used when the range built-in is referenced in a non-iterating ' - 'context (returns an iterator in Python 3)', - {'maxversion': (3, 0)}), + 'context (returns an iterator in Python 3)'), 'W1639': ('filter built-in referenced when not iterating', 'filter-builtin-not-iterating', 'Used when the filter built-in is referenced in a non-iterating ' - 'context (returns an iterator in Python 3)', - {'maxversion': (3, 0)}), + 'context (returns an iterator in Python 3)'), 'W1640': ('Using the cmp argument for list.sort / sorted', 'using-cmp-argument', 'Using the cmp argument for list.sort or the sorted ' 'builtin should be avoided, since it was removed in ' 'Python 3. Using either `key` or `functools.cmp_to_key` ' - 'should be preferred.', - {'maxversion': (3, 0)}), + 'should be preferred.'), 'W1641': ('Implementing __eq__ without also implementing __hash__', 'eq-without-hash', 'Used when a class implements __eq__ but not __hash__. In Python 2, objects ' 'get object.__hash__ as the default implementation, in Python 3 objects get ' - 'None as their default __hash__ implementation if they also implement __eq__.', - {'maxversion': (3, 0)}), + 'None as their default __hash__ implementation if they also implement __eq__.'), 'W1642': ('__div__ method defined', 'div-method', 'Used when a __div__ method is defined. Using `__truediv__` and setting' '__div__ = __truediv__ should be preferred.' - '(method is not used by Python 3)', - {'maxversion': (3, 0)}), + '(method is not used by Python 3)'), 'W1643': ('__idiv__ method defined', 'idiv-method', - 'Used when a __idiv__ method is defined. Using `__itruediv__` and setting' + 'Used when an __idiv__ method is defined. Using `__itruediv__` and setting' '__idiv__ = __itruediv__ should be preferred.' - '(method is not used by Python 3)', - {'maxversion': (3, 0)}), + '(method is not used by Python 3)'), 'W1644': ('__rdiv__ method defined', 'rdiv-method', 'Used when a __rdiv__ method is defined. Using `__rtruediv__` and setting' '__rdiv__ = __rtruediv__ should be preferred.' - '(method is not used by Python 3)', - {'maxversion': (3, 0)}), + '(method is not used by Python 3)'), 'W1645': ('Exception.message removed in Python 3', 'exception-message-attribute', 'Used when the message attribute is accessed on an Exception. Use ' - 'str(exception) instead.', - {'maxversion': (3, 0)}), + 'str(exception) instead.'), 'W1646': ('non-text encoding used in str.decode', 'invalid-str-codec', 'Used when using str.encode or str.decode with a non-text encoding. Use ' - 'codecs module to handle arbitrary codecs.', - {'maxversion': (3, 0)}), + 'codecs module to handle arbitrary codecs.'), 'W1647': ('sys.maxint removed in Python 3', 'sys-max-int', - 'Used when accessing sys.maxint. Use sys.maxsize instead.', - {'maxversion': (3, 0)}), + 'Used when accessing sys.maxint. Use sys.maxsize instead.'), 'W1648': ('Module moved in Python 3', 'bad-python3-import', - 'Used when importing a module that no longer exists in Python 3.', - {'maxversion': (3, 0)}), + 'Used when importing a module that no longer exists in Python 3.'), 'W1649': ('Accessing a deprecated function on the string module', 'deprecated-string-function', - 'Used when accessing a string function that has been deprecated in Python 3.', - {'maxversion': (3, 0)}), + 'Used when accessing a string function that has been deprecated in Python 3.'), 'W1650': ('Using str.translate with deprecated deletechars parameters', 'deprecated-str-translate-call', - 'Used when using the deprecated deletechars parameters from str.translate. Use' - 're.sub to remove the desired characters ', - {'maxversion': (3, 0)}), + 'Used when using the deprecated deletechars parameters from str.translate. Use ' + 're.sub to remove the desired characters '), 'W1651': ('Accessing a deprecated function on the itertools module', 'deprecated-itertools-function', - 'Used when accessing a function on itertools that has been removed in Python 3.', - {'maxversion': (3, 0)}), + 'Used when accessing a function on itertools that has been removed in Python 3.'), 'W1652': ('Accessing a deprecated fields on the types module', 'deprecated-types-field', - 'Used when accessing a field on types that has been removed in Python 3.', - {'maxversion': (3, 0)}), + 'Used when accessing a field on types that has been removed in Python 3.'), 'W1653': ('next method defined', 'next-method-defined', 'Used when a next method is defined that would be an iterator in Python 2 but ' - 'is treated as a normal function in Python 3.', - {'maxversion': (3, 0)}), + 'is treated as a normal function in Python 3.',), 'W1654': ('dict.items referenced when not iterating', 'dict-items-not-iterating', 'Used when dict.items is referenced in a non-iterating ' - 'context (returns an iterator in Python 3)', - {'maxversion': (3, 0)}), + 'context (returns an iterator in Python 3)',), 'W1655': ('dict.keys referenced when not iterating', 'dict-keys-not-iterating', 'Used when dict.keys is referenced in a non-iterating ' - 'context (returns an iterator in Python 3)', - {'maxversion': (3, 0)}), + 'context (returns an iterator in Python 3)',), 'W1656': ('dict.values referenced when not iterating', 'dict-values-not-iterating', 'Used when dict.values is referenced in a non-iterating ' - 'context (returns an iterator in Python 3)', - {'maxversion': (3, 0)}), + 'context (returns an iterator in Python 3)',), 'W1657': ('Accessing a removed attribute on the operator module', 'deprecated-operator-function', 'Used when accessing a field on operator module that has been ' - 'removed in Python 3.', - {'maxversion': (3, 0)}), + 'removed in Python 3.',), 'W1658': ('Accessing a removed attribute on the urllib module', 'deprecated-urllib-function', 'Used when accessing a field on urllib module that has been ' - 'removed or moved in Python 3.', - {'maxversion': (3, 0)}), + 'removed or moved in Python 3.',), } _bad_builtins = frozenset([ @@ -650,7 +586,7 @@ class Python3Checker(checkers.BaseChecker): elif node.name == 'next': # If there is a method named `next` declared, if it is invokable # with zero arguments then it implements the Iterator protocol. - # This means if the method is a instance method or a + # This means if the method is an instance method or a # classmethod 1 argument should cause a failure, if it is a # staticmethod 0 arguments should cause a failure. failing_arg_count = 1 @@ -679,7 +615,7 @@ class Python3Checker(checkers.BaseChecker): self.add_message('print-statement', node=node, always_warn=True) def _warn_if_deprecated(self, node, module, attributes, report_on_modules=True): - for message, module_map in six.iteritems(self._bad_python3_module_map): + for message, module_map in self._bad_python3_module_map.items(): if module in module_map and module not in self._modules_warned_about: if isinstance(module_map, frozenset): if report_on_modules: @@ -922,7 +858,8 @@ class Python3Checker(checkers.BaseChecker): strings or old-raise-syntax. """ if (node.exc is not None and - node.inst is not None): + node.inst is not None and + node.tback is None): self.add_message('old-raise-syntax', node=node) # Ignore empty raise. @@ -931,12 +868,11 @@ class Python3Checker(checkers.BaseChecker): expr = node.exc if self._check_raise_value(node, expr): return - else: - try: - value = next(astroid.unpack_infer(expr)) - except astroid.InferenceError: - return - self._check_raise_value(node, value) + try: + value = next(astroid.unpack_infer(expr)) + except astroid.InferenceError: + return + self._check_raise_value(node, value) def _check_raise_value(self, node, expr): if isinstance(expr, astroid.Const): diff --git a/pylint/test/unittest_checker_python3.py b/pylint/test/unittest_checker_python3.py index 1538743ad..374500f3e 100644 --- a/pylint/test/unittest_checker_python3.py +++ b/pylint/test/unittest_checker_python3.py @@ -180,7 +180,6 @@ class TestPython3Checker(testutils.CheckerTestCase): 'enumerate', 'dict'): self.as_argument_to_callable_constructor_test(fxn, func) - @python2_only def test_dict_subclasses_methods_in_iterating_context(self): iterating, not_iterating = astroid.extract_node(''' from __future__ import absolute_import @@ -197,7 +196,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertAddsMessages(message): self.checker.visit_call(not_iterating.value) - @python2_only def test_dict_methods_in_iterating_context(self): iterating_code = [ 'for x in {}: pass', @@ -229,19 +227,15 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertAddsMessages(message): self.checker.visit_call(node) - @python2_only def test_map_in_iterating_context(self): self.iterating_context_tests('map') - @python2_only def test_zip_in_iterating_context(self): self.iterating_context_tests('zip') - @python2_only def test_range_in_iterating_context(self): self.iterating_context_tests('range') - @python2_only def test_filter_in_iterating_context(self): self.iterating_context_tests('filter') @@ -496,10 +490,10 @@ class TestPython3Checker(testutils.CheckerTestCase): node = astroid.extract_node('raise Exception, "test", tb') message = testutils.Message('old-raise-syntax', node=node) + with self.assertAddsMessages(message): self.checker.visit_raise(node) - @python2_only def test_exception_message_attribute(self): node = astroid.extract_node(""" try: @@ -511,7 +505,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertAddsMessages(message): self.checker.visit_attribute(node) - @python2_only def test_normal_message_attribute(self): node = astroid.extract_node(""" e.message #@ @@ -519,33 +512,28 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertNoMessages(): self.checker.visit_attribute(node) - @python2_only def test_invalid_codec(self): node = astroid.extract_node('foobar.encode("hex") #@') message = testutils.Message('invalid-str-codec', node=node) with self.assertAddsMessages(message): self.checker.visit_call(node) - @python2_only def test_valid_codec(self): node = astroid.extract_node('foobar.encode("ascii", "ignore") #@') with self.assertNoMessages(): self.checker.visit_call(node) - @python2_only def test_visit_call_with_kwarg(self): node = astroid.extract_node('foobar.raz(encoding="hex") #@') with self.assertNoMessages(): self.checker.visit_call(node) - @python2_only def test_invalid_open_codec(self): node = astroid.extract_node('open(foobar, encoding="hex") #@') message = testutils.Message('invalid-str-codec', node=node) with self.assertAddsMessages(message): self.checker.visit_call(node) - @python2_only def test_valid_open_codec(self): node = astroid.extract_node('open(foobar, encoding="palmos") #@') with self.assertNoMessages(): @@ -582,7 +570,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertAddsMessages(message): self.checker.visit_call(node) - @python2_only def test_sys_maxint(self): node = astroid.extract_node(''' import sys @@ -592,7 +579,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertAddsMessages(message): self.checker.visit_attribute(node) - @python2_only def test_itertools_izip(self): node = astroid.extract_node(''' from itertools import izip #@ @@ -602,8 +588,7 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertAddsMessages(absolute_import_message, message): self.checker.visit_importfrom(node) - @python2_only - def test_deprecated_types_fiels(self): + def test_deprecated_types_fields(self): node = astroid.extract_node(''' from types import StringType #@ ''') @@ -612,7 +597,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertAddsMessages(absolute_import_message, message): self.checker.visit_importfrom(node) - @python2_only def test_sys_maxint_imort_from(self): node = astroid.extract_node(''' from sys import maxint #@ @@ -622,7 +606,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertAddsMessages(absolute_import_message, message): self.checker.visit_importfrom(node) - @python2_only def test_object_maxint(self): node = astroid.extract_node(''' sys = object() @@ -631,7 +614,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertNoMessages(): self.checker.visit_attribute(node) - @python2_only def test_bad_import(self): node = astroid.extract_node(''' import urllib2, sys #@ @@ -654,7 +636,6 @@ class TestPython3Checker(testutils.CheckerTestCase): self.checker.visit_importfrom(node) self.checker._future_absolute_import = False - @python2_only def test_bad_import_conditional(self): node = astroid.extract_node(''' import six @@ -665,7 +646,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertAddsMessages(absolute_import_message): self.checker.visit_import(node) - @python2_only def test_bad_import_try_except_handler(self): node = astroid.extract_node(''' try: @@ -677,7 +657,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertAddsMessages(absolute_import_message): self.checker.visit_import(node) - @python2_only def test_bad_import_try(self): node = astroid.extract_node(''' try: @@ -691,7 +670,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertAddsMessages(absolute_import_message): self.checker.visit_import(node) - @python2_only def test_bad_import_try_finally(self): node = astroid.extract_node(''' try: @@ -704,7 +682,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertAddsMessages(absolute_import_message, message): self.checker.visit_import(node) - @python2_only def test_bad_import_from(self): node = astroid.extract_node(''' from cStringIO import StringIO #@ @@ -714,7 +691,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertAddsMessages(absolute_import_message, message): self.checker.visit_importfrom(node) - @python2_only def test_bad_string_attribute(self): node = astroid.extract_node(''' import string @@ -724,7 +700,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertAddsMessages(message): self.checker.visit_attribute(node) - @python2_only def test_bad_operator_attribute(self): node = astroid.extract_node(''' import operator @@ -734,7 +709,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertAddsMessages(message): self.checker.visit_attribute(node) - @python2_only def test_bad_urllib_attribute(self): nodes = astroid.extract_node(''' import urllib @@ -749,7 +723,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertAddsMessages(message): self.checker.visit_attribute(node) - @python2_only def test_ok_string_attribute(self): node = astroid.extract_node(''' import string @@ -758,7 +731,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertNoMessages(): self.checker.visit_attribute(node) - @python2_only def test_bad_string_call(self): node = astroid.extract_node(''' import string @@ -768,7 +740,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertAddsMessages(message): self.checker.visit_call(node) - @python2_only def test_ok_shadowed_call(self): node = astroid.extract_node(''' import six.moves.configparser @@ -777,7 +748,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertNoMessages(): self.checker.visit_call(node) - @python2_only def test_ok_string_call(self): node = astroid.extract_node(''' import string @@ -786,7 +756,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertNoMessages(): self.checker.visit_call(node) - @python2_only def test_bad_string_import_from(self): node = astroid.extract_node(''' from string import atoi #@ @@ -796,7 +765,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertAddsMessages(absolute_import_message, message): self.checker.visit_importfrom(node) - @python2_only def test_ok_string_import_from(self): node = astroid.extract_node(''' from string import digits #@ @@ -805,7 +773,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertAddsMessages(absolute_import_message): self.checker.visit_importfrom(node) - @python2_only def test_bad_str_translate_call_string_literal(self): node = astroid.extract_node(''' foobar.translate(None, 'abc123') #@ @@ -815,7 +782,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertAddsMessages(message): self.checker.visit_call(node) - @python2_only def test_bad_str_translate_call_variable(self): node = astroid.extract_node(''' def raz(foobar): @@ -826,7 +792,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertAddsMessages(message): self.checker.visit_call(node) - @python2_only def test_bad_str_translate_call_infer_str(self): node = astroid.extract_node(''' foobar = "hello world" @@ -837,7 +802,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertAddsMessages(message): self.checker.visit_call(node) - @python2_only def test_ok_str_translate_call_integer(self): node = astroid.extract_node(''' foobar.translate(None, 33) #@ @@ -845,7 +809,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertNoMessages(): self.checker.visit_call(node) - @python2_only def test_ok_str_translate_call_keyword(self): node = astroid.extract_node(''' foobar.translate(None, 'foobar', raz=33) #@ @@ -853,7 +816,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertNoMessages(): self.checker.visit_call(node) - @python2_only def test_ok_str_translate_call_not_str(self): node = astroid.extract_node(''' foobar = {} @@ -888,7 +850,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertNoMessages(): self.walk(module) - @python2_only def test_versioninfo_conditional(self): code = ''' from __future__ import absolute_import @@ -901,7 +862,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertNoMessages(): self.walk(module) - @python2_only def test_versioninfo_tuple_conditional(self): code = ''' from __future__ import absolute_import @@ -914,7 +874,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertNoMessages(): self.walk(module) - @python2_only def test_six_ifexp_conditional(self): code = ''' from __future__ import absolute_import @@ -926,7 +885,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertNoMessages(): self.walk(module) - @python2_only def test_next_defined(self): node = astroid.extract_node(""" class Foo(object): @@ -936,7 +894,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertAddsMessages(message): self.checker.visit_functiondef(node) - @python2_only def test_next_defined_too_many_args(self): node = astroid.extract_node(""" class Foo(object): @@ -945,7 +902,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertNoMessages(): self.checker.visit_functiondef(node) - @python2_only def test_next_defined_static_method_too_many_args(self): node = astroid.extract_node(""" class Foo(object): @@ -955,7 +911,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertNoMessages(): self.checker.visit_functiondef(node) - @python2_only def test_next_defined_static_method(self): node = astroid.extract_node(""" class Foo(object): @@ -966,7 +921,6 @@ class TestPython3Checker(testutils.CheckerTestCase): with self.assertAddsMessages(message): self.checker.visit_functiondef(node) - @python2_only def test_next_defined_class_method(self): node = astroid.extract_node(""" class Foo(object): |