diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2019-09-17 10:17:42 +0200 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2019-09-17 10:32:00 +0200 |
commit | 0a90b4a0b369d75a3e2aee9a4ad57ce264bc18a0 (patch) | |
tree | 977fb4e44d83c7e86ed2642ffae2c553f69c5566 | |
parent | 344f6859e9d584309f57d142259fad77a17d11ee (diff) | |
download | pylint-git-0a90b4a0b369d75a3e2aee9a4ad57ce264bc18a0.tar.gz |
Removed Python 2 specific checks
Certain checks such as relative-import, invalid-encoded-data and missing-super-argument
were removed as they no longer make sense on Python 3.
59 files changed, 24 insertions, 692 deletions
@@ -12,6 +12,9 @@ Release date: TBA This check warns when modules are imported from places other than a module toplevel, e.g. inside a function or a class. +* Removed Python 2 specific checks such as ``relative-import``, + ``invalid-encoded-data``, ``missing-super-argument``. + * Support forward references for ``function-redefined`` check. Close #2540 diff --git a/pylint/checkers/imports.py b/pylint/checkers/imports.py index 49973194a..ea0267181 100644 --- a/pylint/checkers/imports.py +++ b/pylint/checkers/imports.py @@ -224,12 +224,6 @@ MSGS = { "deprecated-module", "Used a module marked as deprecated is imported.", ), - "W0403": ( - "Relative import %r, should be %r", - "relative-import", - "Used when an import relative to the package directory is detected.", - {"maxversion": (3, 0)}, - ), "W0404": ( "Reimport %r (imported line %s)", "reimported", @@ -508,7 +502,6 @@ class ImportsChecker(BaseChecker): if imported_module is None: continue - self._check_relative_import(modnode, node, imported_module, name) self._add_imported_module(node, imported_module.name) @check_messages(*MSGS) @@ -533,8 +526,6 @@ class ImportsChecker(BaseChecker): if imported_module is None: return modnode = node.root() - self._check_relative_import(modnode, node, imported_module, basename) - for name, _ in node.names: if name != "*": self._add_imported_module(node, "%s.%s" % (imported_module.name, name)) @@ -803,30 +794,6 @@ class ImportsChecker(BaseChecker): dotted_modname = _get_import_name(importnode, modname) self.add_message("import-error", args=repr(dotted_modname), node=importnode) - def _check_relative_import( - self, modnode, importnode, importedmodnode, importedasname - ): - """check relative import. node is either an Import or From node, modname - the imported module name. - """ - if not self.linter.is_message_enabled("relative-import"): - return None - if importedmodnode.file is None: - return False # built-in module - if modnode is importedmodnode: - return False # module importing itself - if modnode.absolute_import_activated() or getattr(importnode, "level", None): - return False - if importedmodnode.name != importedasname: - # this must be a relative import... - self.add_message( - "relative-import", - args=(importedasname, importedmodnode.name), - node=importnode, - ) - return None - return None - def _add_imported_module(self, node, importedmodname): """notify an imported module, used to analyze dependencies""" module_file = node.root().file diff --git a/pylint/checkers/misc.py b/pylint/checkers/misc.py index 12dc90815..dcf7a3e15 100644 --- a/pylint/checkers/misc.py +++ b/pylint/checkers/misc.py @@ -78,14 +78,7 @@ class EncodingChecker(BaseChecker): "%s", "fixme", "Used when a warning note as FIXME or XXX is detected.", - ), - "W0512": ( - 'Cannot decode using encoding "%s", unexpected byte at position %d', - "invalid-encoded-data", - "Used when a source line cannot be decoded using the specified " - "source file encoding.", - {"maxversion": (3, 0)}, - ), + ) } options = ( @@ -112,10 +105,8 @@ class EncodingChecker(BaseChecker): def _check_encoding(self, lineno, line, file_encoding): try: return line.decode(file_encoding) - except UnicodeDecodeError as ex: - self.add_message( - "invalid-encoded-data", line=lineno, args=(file_encoding, ex.args[2]) - ) + except UnicodeDecodeError: + pass except LookupError: if line.startswith("#") and "coding" in line and file_encoding in line: self.add_message( diff --git a/pylint/checkers/newstyle.py b/pylint/checkers/newstyle.py index 19d4578c3..46f4e4e60 100644 --- a/pylint/checkers/newstyle.py +++ b/pylint/checkers/newstyle.py @@ -25,13 +25,7 @@ MSGS = { "bad-super-call", "Used when another argument than the current class is given as " "first argument of the super builtin.", - ), - "E1004": ( - "Missing argument to super()", - "missing-super-argument", - "Used when the super builtin didn't receive an argument.", - {"maxversion": (3, 0)}, - ), + ) } @@ -52,7 +46,7 @@ class NewStyleConflictChecker(BaseChecker): # configuration options options = () - @check_messages("bad-super-call", "missing-super-argument") + @check_messages("bad-super-call") def visit_functiondef(self, node): """check use of super""" # ignore actual functions or method within a new style class diff --git a/pylint/checkers/variables.py b/pylint/checkers/variables.py index e55d32ad1..70acb9ff6 100644 --- a/pylint/checkers/variables.py +++ b/pylint/checkers/variables.py @@ -1296,13 +1296,6 @@ class VariablesChecker(BaseChecker): return False return stmt.modname in self.config.redefining_builtins_modules - @utils.check_messages("redefine-in-handler") - def visit_excepthandler(self, node): - for name in utils.get_all_elements(node.name): - clobbering, args = utils.clobber_in_except(name) - if clobbering: - self.add_message("redefine-in-handler", args=args, node=name) - def visit_assignname(self, node): if isinstance(node.assign_type(), astroid.AugAssign): self.visit_name(node) diff --git a/tests/functional/a/abstract_class_instantiated_py2.py b/tests/functional/a/abstract_class_instantiated_py2.py deleted file mode 100644 index ba34d2641..000000000 --- a/tests/functional/a/abstract_class_instantiated_py2.py +++ /dev/null @@ -1,82 +0,0 @@ -"""Check that instantiating a class with -`abc.ABCMeta` as metaclass fails if it defines -abstract methods. -""" - -# pylint: disable=too-few-public-methods, missing-docstring, useless-object-inheritance -# pylint: disable=no-absolute-import, metaclass-assignment -# pylint: disable=abstract-method, import-error, wildcard-import - -import abc -from abc import ABCMeta -from lala import Bala - - -class GoodClass(object): - __metaclass__ = abc.ABCMeta - -class SecondGoodClass(object): - __metaclass__ = abc.ABCMeta - - def test(self): - """ do nothing. """ - -class ThirdGoodClass(object): - __metaclass__ = abc.ABCMeta - - def test(self): - raise NotImplementedError() - -class FourthGoodClass(object): - __metaclass__ = ABCMeta - -class BadClass(object): - __metaclass__ = abc.ABCMeta - - @abc.abstractmethod - def test(self): - """ do nothing. """ - -class SecondBadClass(object): - __metaclass__ = abc.ABCMeta - - @property - @abc.abstractmethod - def test(self): - """ do nothing. """ - -class ThirdBadClass(object): - __metaclass__ = ABCMeta - - @abc.abstractmethod - def test(self): - pass - -class FourthBadClass(ThirdBadClass): - pass - - -class SomeMetaclass(object): - __metaclass__ = ABCMeta - - @abc.abstractmethod - def prop(self): - pass - -class FifthGoodClass(SomeMetaclass): - """Don't consider this abstract if some attributes are - there, but can't be inferred. - """ - prop = Bala # missing - - -def main(): - """ do nothing """ - GoodClass() - SecondGoodClass() - ThirdGoodClass() - FourthGoodClass() - BadClass() # [abstract-class-instantiated] - SecondBadClass() # [abstract-class-instantiated] - ThirdBadClass() # [abstract-class-instantiated] - FourthBadClass() # [abstract-class-instantiated] diff --git a/tests/functional/a/abstract_class_instantiated_py2.rc b/tests/functional/a/abstract_class_instantiated_py2.rc deleted file mode 100644 index b11e16d54..000000000 --- a/tests/functional/a/abstract_class_instantiated_py2.rc +++ /dev/null @@ -1,2 +0,0 @@ -[testoptions] -max_pyver=3.0
\ No newline at end of file diff --git a/tests/functional/a/abstract_class_instantiated_py2.txt b/tests/functional/a/abstract_class_instantiated_py2.txt deleted file mode 100644 index 1e4a72d09..000000000 --- a/tests/functional/a/abstract_class_instantiated_py2.txt +++ /dev/null @@ -1,4 +0,0 @@ -abstract-class-instantiated:79:main:Abstract class 'BadClass' with abstract methods instantiated
-abstract-class-instantiated:80:main:Abstract class 'SecondBadClass' with abstract methods instantiated
-abstract-class-instantiated:81:main:Abstract class 'ThirdBadClass' with abstract methods instantiated
-abstract-class-instantiated:82:main:Abstract class 'FourthBadClass' with abstract methods instantiated
diff --git a/tests/functional/a/abstract_method_py2.py b/tests/functional/a/abstract_method_py2.py deleted file mode 100644 index 54fd1f952..000000000 --- a/tests/functional/a/abstract_method_py2.py +++ /dev/null @@ -1,90 +0,0 @@ -"""Test abstract-method warning.""" -from __future__ import print_function - -# pylint: disable=missing-docstring, no-init, no-self-use -# pylint: disable=too-few-public-methods, useless-object-inheritance -import abc - -class Abstract(object): - def aaaa(self): - """should be overridden in concrete class""" - raise NotImplementedError() - - def bbbb(self): - """should be overridden in concrete class""" - raise NotImplementedError() - - -class AbstractB(Abstract): - """Abstract class. - - this class is checking that it does not output an error msg for - unimplemeted methods in abstract classes - """ - def cccc(self): - """should be overridden in concrete class""" - raise NotImplementedError() - -class Concrete(Abstract): # [abstract-method] - """Concrete class""" - - def aaaa(self): - """overidden form Abstract""" - - -class Structure(object): - __metaclass__ = abc.ABCMeta - - @abc.abstractmethod - def __iter__(self): - pass - @abc.abstractmethod - def __len__(self): - pass - @abc.abstractmethod - def __contains__(self, _): - pass - @abc.abstractmethod - def __hash__(self): - pass - - -# +1: [abstract-method, abstract-method, abstract-method] -class Container(Structure): - def __contains__(self, _): - pass - - -# +1: [abstract-method, abstract-method, abstract-method] -class Sizable(Structure): - def __len__(self): - pass - - -# +1: [abstract-method, abstract-method, abstract-method] -class Hashable(Structure): - __hash__ = 42 - - -# +1: [abstract-method, abstract-method, abstract-method] -class Iterator(Structure): - def keys(self): - return iter([1, 2, 3]) - - __iter__ = keys - - -class AbstractSizable(Structure): - @abc.abstractmethod - def length(self): - pass - __len__ = length - - -class GoodComplexMRO(Container, Iterator, Sizable, Hashable): - pass - - -# +1: [abstract-method, abstract-method, abstract-method] -class BadComplexMro(Container, Iterator, AbstractSizable): - pass diff --git a/tests/functional/a/abstract_method_py2.rc b/tests/functional/a/abstract_method_py2.rc deleted file mode 100644 index b11e16d54..000000000 --- a/tests/functional/a/abstract_method_py2.rc +++ /dev/null @@ -1,2 +0,0 @@ -[testoptions] -max_pyver=3.0
\ No newline at end of file diff --git a/tests/functional/a/abstract_method_py2.txt b/tests/functional/a/abstract_method_py2.txt deleted file mode 100644 index 3f9d207e6..000000000 --- a/tests/functional/a/abstract_method_py2.txt +++ /dev/null @@ -1,16 +0,0 @@ -abstract-method:28:Concrete:"Method 'bbbb' is abstract in class 'Abstract' but is not overridden"
-abstract-method:53:Container:"Method '__hash__' is abstract in class 'Structure' but is not overridden"
-abstract-method:53:Container:"Method '__iter__' is abstract in class 'Structure' but is not overridden"
-abstract-method:53:Container:"Method '__len__' is abstract in class 'Structure' but is not overridden"
-abstract-method:59:Sizable:"Method '__contains__' is abstract in class 'Structure' but is not overridden"
-abstract-method:59:Sizable:"Method '__hash__' is abstract in class 'Structure' but is not overridden"
-abstract-method:59:Sizable:"Method '__iter__' is abstract in class 'Structure' but is not overridden"
-abstract-method:65:Hashable:"Method '__contains__' is abstract in class 'Structure' but is not overridden"
-abstract-method:65:Hashable:"Method '__iter__' is abstract in class 'Structure' but is not overridden"
-abstract-method:65:Hashable:"Method '__len__' is abstract in class 'Structure' but is not overridden"
-abstract-method:70:Iterator:"Method '__contains__' is abstract in class 'Structure' but is not overridden"
-abstract-method:70:Iterator:"Method '__hash__' is abstract in class 'Structure' but is not overridden"
-abstract-method:70:Iterator:"Method '__len__' is abstract in class 'Structure' but is not overridden"
-abstract-method:89:BadComplexMro:"Method '__hash__' is abstract in class 'Structure' but is not overridden"
-abstract-method:89:BadComplexMro:"Method '__len__' is abstract in class 'AbstractSizable' but is not overridden"
-abstract-method:89:BadComplexMro:"Method 'length' is abstract in class 'AbstractSizable' but is not overridden"
diff --git a/tests/functional/a/anomalous_unicode_escape_py2.py b/tests/functional/a/anomalous_unicode_escape_py2.py deleted file mode 100644 index 8f304fa47..000000000 --- a/tests/functional/a/anomalous_unicode_escape_py2.py +++ /dev/null @@ -1,20 +0,0 @@ -# pylint:disable=W0105, W0511 -"""Test for backslash escapes in byte vs unicode strings""" - -# Would be valid in Unicode, but probably not what you want otherwise -BAD_UNICODE = b'\u0042' # [anomalous-unicode-escape-in-string] -BAD_LONG_UNICODE = b'\U00000042' # [anomalous-unicode-escape-in-string] -# +1:[anomalous-unicode-escape-in-string] -BAD_NAMED_UNICODE = b'\N{GREEK SMALL LETTER ALPHA}' - -GOOD_UNICODE = u'\u0042' -GOOD_LONG_UNICODE = u'\U00000042' -GOOD_NAMED_UNICODE = u'\N{GREEK SMALL LETTER ALPHA}' - - -# Valid raw strings -RAW_BACKSLASHES = r'raw' -RAW_UNICODE = ur"\u0062\n" - -# In a comment you can have whatever you want: \ \\ \n \m -# even things that look like bad strings: "C:\Program Files" diff --git a/tests/functional/a/anomalous_unicode_escape_py2.rc b/tests/functional/a/anomalous_unicode_escape_py2.rc deleted file mode 100644 index a2328edb7..000000000 --- a/tests/functional/a/anomalous_unicode_escape_py2.rc +++ /dev/null @@ -1,2 +0,0 @@ -[testoptions]
-max_pyver=3.0
\ No newline at end of file diff --git a/tests/functional/a/anomalous_unicode_escape_py2.txt b/tests/functional/a/anomalous_unicode_escape_py2.txt deleted file mode 100644 index c242cb98f..000000000 --- a/tests/functional/a/anomalous_unicode_escape_py2.txt +++ /dev/null @@ -1,3 +0,0 @@ -anomalous-unicode-escape-in-string:5::"Anomalous Unicode escape in byte string: '\u'. String constant might be missing an r or u prefix." -anomalous-unicode-escape-in-string:6::"Anomalous Unicode escape in byte string: '\U'. String constant might be missing an r or u prefix." -anomalous-unicode-escape-in-string:8::"Anomalous Unicode escape in byte string: '\N'. String constant might be missing an r or u prefix." diff --git a/tests/functional/b/bad_open_mode.py b/tests/functional/b/bad_open_mode.py deleted file mode 100644 index 6b749de03..000000000 --- a/tests/functional/b/bad_open_mode.py +++ /dev/null @@ -1,37 +0,0 @@ -"""Warnings for using open() with an invalid mode string.""" - -open('foo.bar', 'w', 2) -open('foo.bar', 'rw') # [bad-open-mode] -open(name='foo.bar', buffering=10, mode='rw') # [bad-open-mode] -open(mode='rw', name='foo.bar') # [bad-open-mode] -open('foo.bar', 'U+') -open('foo.bar', 'rb+') -open('foo.bar', 'Uw') # [bad-open-mode] -open('foo.bar', 2) # [bad-open-mode] -open('foo.bar', buffering=2) -WRITE_MODE = 'w' -open('foo.bar', 'U' + WRITE_MODE + 'z') # [bad-open-mode] -open('foo.bar', 'br') # [bad-open-mode] -open('foo.bar', 'wU') # [bad-open-mode] -open('foo.bar', 'r+b') -open('foo.bar', 'r+') -open('foo.bar', 'w+') -open('foo.bar', 'xb') # [bad-open-mode] -open('foo.bar', 'rx') # [bad-open-mode] -open('foo.bar', 'Ur') -open('foo.bar', 'rU') -open('foo.bar', 'rUb') -open('foo.bar', 'rUb+') -open('foo.bar', 'rU+b') -open('foo.bar', 'r+Ub') -open('foo.bar', '+rUb') # [bad-open-mode] -open('foo.bar', 'ab+') -open('foo.bar', 'a+b') -open('foo.bar', 'aU') # [bad-open-mode] -open('foo.bar', 'U+b') -open('foo.bar', '+Ub') -open('foo.bar', 'b+U') -open('foo.bar', 'Urb+') -open('foo.bar', 'Ur+b') -open('foo.bar', 'Ubr') # [bad-open-mode] -open('foo.bar', 'Ut') # [bad-open-mode] diff --git a/tests/functional/b/bad_open_mode.rc b/tests/functional/b/bad_open_mode.rc deleted file mode 100644 index b9ab97702..000000000 --- a/tests/functional/b/bad_open_mode.rc +++ /dev/null @@ -1,2 +0,0 @@ -[testoptions]
-max_pyver=3.0
diff --git a/tests/functional/b/bad_open_mode.txt b/tests/functional/b/bad_open_mode.txt deleted file mode 100644 index b0222863e..000000000 --- a/tests/functional/b/bad_open_mode.txt +++ /dev/null @@ -1,14 +0,0 @@ -bad-open-mode:4::"""rw"" is not a valid mode for open." -bad-open-mode:5::"""rw"" is not a valid mode for open." -bad-open-mode:6::"""rw"" is not a valid mode for open." -bad-open-mode:9::"""Uw"" is not a valid mode for open." -bad-open-mode:10::"""2"" is not a valid mode for open." -bad-open-mode:13::"""Uwz"" is not a valid mode for open." -bad-open-mode:14::"""br"" is not a valid mode for open." -bad-open-mode:15::"""wU"" is not a valid mode for open." -bad-open-mode:19::"""xb"" is not a valid mode for open." -bad-open-mode:20::"""rx"" is not a valid mode for open." -bad-open-mode:27::"""+rUb"" is not a valid mode for open." -bad-open-mode:30::"""aU"" is not a valid mode for open." -bad-open-mode:36::"""Ubr"" is not a valid mode for open." -bad-open-mode:37::"""Ut"" is not a valid mode for open." diff --git a/tests/functional/c/class_members_py27.py b/tests/functional/c/class_members_py27.py deleted file mode 100644 index 584faa5e8..000000000 --- a/tests/functional/c/class_members_py27.py +++ /dev/null @@ -1,70 +0,0 @@ -""" Various tests for class members access. """
-# pylint: disable=R0903,print-statement,no-absolute-import, metaclass-assignment,import-error,no-init,missing-docstring, wrong-import-order,wrong-import-position, useless-object-inheritance
-from missing import Missing
-class MyClass(object):
- """class docstring"""
-
- def __init__(self):
- """init"""
- self.correct = 1
-
- def test(self):
- """test"""
- self.correct += 2
- self.incorrect += 2 # [no-member]
- del self.havenot # [no-member]
- self.nonexistent1.truc() # [no-member]
- self.nonexistent2[1] = 'hehe' # [no-member]
-
-class XYZMixin(object):
- """access to undefined members should be ignored in mixin classes by
- default
- """
- def __init__(self):
- print self.nonexistent
-
-
-class NewClass(object):
- """use object.__setattr__"""
- def __init__(self):
- self.__setattr__('toto', 'tutu')
-
-from abc import ABCMeta
-
-class TestMetaclass(object):
- """ Test attribute access for metaclasses. """
- __metaclass__ = ABCMeta
-
-class Metaclass(type):
- """ metaclass """
- @classmethod
- def test(cls):
- """ classmethod """
-
-class UsingMetaclass(object):
- """ empty """
- __metaclass__ = Metaclass
-
-TestMetaclass.register(int)
-UsingMetaclass.test()
-TestMetaclass().register(int) # [no-member]
-UsingMetaclass().test() # [no-member]
-
-
-class NoKnownBases(Missing):
- """Don't emit no-member if we don't know the bases of a class."""
-
-NoKnownBases().lalala()
-
-
-class MetaClass(object):
- """Look some methods in the implicit metaclass."""
-
- @classmethod
- def whatever(cls):
- return cls.mro() + cls.missing() # [no-member]
-
-from collections import namedtuple
-
-Tuple = namedtuple("Tuple", "field other")
-Tuple.field.__doc__ = "A doc for the field."
diff --git a/tests/functional/c/class_members_py27.rc b/tests/functional/c/class_members_py27.rc deleted file mode 100644 index 80170b777..000000000 --- a/tests/functional/c/class_members_py27.rc +++ /dev/null @@ -1,3 +0,0 @@ -[testoptions] -min_pyver=2.7
-max_pyver=3.0
\ No newline at end of file diff --git a/tests/functional/c/class_members_py27.txt b/tests/functional/c/class_members_py27.txt deleted file mode 100644 index 3a3be0ede..000000000 --- a/tests/functional/c/class_members_py27.txt +++ /dev/null @@ -1,7 +0,0 @@ -no-member:14:MyClass.test:Instance of 'MyClass' has no 'incorrect' member:INFERENCE -no-member:15:MyClass.test:Instance of 'MyClass' has no 'havenot' member:INFERENCE -no-member:16:MyClass.test:Instance of 'MyClass' has no 'nonexistent1' member:INFERENCE -no-member:17:MyClass.test:Instance of 'MyClass' has no 'nonexistent2' member:INFERENCE -no-member:50::Instance of 'TestMetaclass' has no 'register' member:INFERENCE -no-member:51::Instance of 'UsingMetaclass' has no 'test' member:INFERENCE -no-member:65:MetaClass.whatever:Class 'MetaClass' has no 'missing' member:INFERENCE diff --git a/tests/functional/d/dangerous_default_value.py b/tests/functional/d/dangerous_default_value.py deleted file mode 100644 index 58a22f443..000000000 --- a/tests/functional/d/dangerous_default_value.py +++ /dev/null @@ -1,79 +0,0 @@ -# pylint: disable=missing-docstring - - -HEHE = {} - -def function1(value=[]): # [dangerous-default-value] - """docstring""" - return value - -def function2(value=HEHE): # [dangerous-default-value] - """docstring""" - return value - -def function3(value): - """docstring""" - return value - -def function4(value=set()): # [dangerous-default-value] - """set is mutable and dangerous.""" - return value - -def function5(value=frozenset()): - """frozenset is immutable and safe.""" - return value - -GLOBAL_SET = set() - -def function6(value=GLOBAL_SET): # [dangerous-default-value] - """set is mutable and dangerous.""" - return value - -def function7(value=dict()): # [dangerous-default-value] - """dict is mutable and dangerous.""" - return value - -def function8(value=list()): # [dangerous-default-value] - """list is mutable and dangerous.""" - return value - -def function9(value=[1, 2, 3, 4]): # [dangerous-default-value] - """list with items should not output item values in error message""" - return value - -def function10(value={'a': 1, 'b': 2}): # [dangerous-default-value] - """dictionaries with items should not output item values in error message""" - return value - -def function11(value=list([1, 2, 3])): # [dangerous-default-value] - """list with items should not output item values in error message""" - return value - -def function12(value=dict([('a', 1), ('b', 2)])): # [dangerous-default-value] - """dictionaries with items should not output item values in error message""" - return value - -OINK = { - 'a': 1, - 'b': 2 -} - -def function13(value=OINK): # [dangerous-default-value] - """dictionaries with items should not output item values in error message""" - return value - -def function14(value=dict([(1, 2), (1, 2, 3)])): # [dangerous-default-value] - """a dictionary which will not be inferred to a syntax AST, but to an - astroid.Instance. - """ - return value - -INVALID_DICT = dict([(1, 2), (1, 2, 3)]) - -def function15(value=INVALID_DICT): # [dangerous-default-value] - """The same situation as function14.""" - return value - -def function16(value={1}): # [dangerous-default-value] - """set literal as default value""" - return value diff --git a/tests/functional/d/dangerous_default_value.rc b/tests/functional/d/dangerous_default_value.rc deleted file mode 100644 index a2328edb7..000000000 --- a/tests/functional/d/dangerous_default_value.rc +++ /dev/null @@ -1,2 +0,0 @@ -[testoptions]
-max_pyver=3.0
\ No newline at end of file diff --git a/tests/functional/d/dangerous_default_value.txt b/tests/functional/d/dangerous_default_value.txt deleted file mode 100644 index 92180e90f..000000000 --- a/tests/functional/d/dangerous_default_value.txt +++ /dev/null @@ -1,14 +0,0 @@ -dangerous-default-value:6:function1:Dangerous default value [] as argument -dangerous-default-value:10:function2:Dangerous default value HEHE (__builtin__.dict) as argument -dangerous-default-value:18:function4:Dangerous default value set() (__builtin__.set) as argument -dangerous-default-value:28:function6:Dangerous default value GLOBAL_SET (__builtin__.set) as argument -dangerous-default-value:32:function7:Dangerous default value dict() (__builtin__.dict) as argument -dangerous-default-value:36:function8:Dangerous default value list() (__builtin__.list) as argument -dangerous-default-value:40:function9:Dangerous default value [] as argument -dangerous-default-value:44:function10:Dangerous default value {} as argument -dangerous-default-value:48:function11:Dangerous default value list() (__builtin__.list) as argument -dangerous-default-value:52:function12:Dangerous default value dict() (__builtin__.dict) as argument -dangerous-default-value:61:function13:Dangerous default value OINK (__builtin__.dict) as argument -dangerous-default-value:65:function14:Dangerous default value dict() (__builtin__.dict) as argument -dangerous-default-value:73:function15:Dangerous default value INVALID_DICT (__builtin__.dict) as argument -dangerous-default-value:77:function16:Dangerous default value set() as argument diff --git a/tests/functional/d/deprecated_lambda.py b/tests/functional/d/deprecated_lambda.py deleted file mode 100644 index 92a2e84ab..000000000 --- a/tests/functional/d/deprecated_lambda.py +++ /dev/null @@ -1,23 +0,0 @@ -# pylint: disable=missing-docstring,invalid-name,no-absolute-import - -import functools - -# Don't do this, use a comprehension instead. -assert map(lambda x: x*2, [1, 2, 3]) == [2, 4, 6] # [deprecated-lambda] - -assert filter(lambda x: x != 1, [1, 2, 3]) == [2, 3] # [deprecated-lambda] - -# It's still ok to use map and filter with anything but an inline lambda. -double = lambda x: x * 2 -assert map(double, [1, 2, 3]) == [2, 4, 6] - -# It's also ok to pass lambdas to other functions. -assert functools.reduce(lambda x, y: x * y, [1, 2, 3, 4]) == 24 - -# Or to an undefined function or one with varargs -def f(*a): - return len(a) - -f(lambda x, y: x + y, [1, 2, 3]) - -undefined_function(lambda: 2) # pylint: disable=undefined-variable diff --git a/tests/functional/d/deprecated_lambda.rc b/tests/functional/d/deprecated_lambda.rc deleted file mode 100644 index a65023393..000000000 --- a/tests/functional/d/deprecated_lambda.rc +++ /dev/null @@ -1,2 +0,0 @@ -[testoptions] -max_pyver=3.0 diff --git a/tests/functional/d/deprecated_lambda.txt b/tests/functional/d/deprecated_lambda.txt deleted file mode 100644 index 78cd9fbfb..000000000 --- a/tests/functional/d/deprecated_lambda.txt +++ /dev/null @@ -1,2 +0,0 @@ -deprecated-lambda:6::map/filter on lambda could be replaced by comprehension -deprecated-lambda:8::map/filter on lambda could be replaced by comprehension diff --git a/tests/functional/d/deprecated_methods_py2.py b/tests/functional/d/deprecated_methods_py2.py deleted file mode 100644 index ceba1e4f9..000000000 --- a/tests/functional/d/deprecated_methods_py2.py +++ /dev/null @@ -1,9 +0,0 @@ -""" Functional test for deprecated methods in Python 2 """ -# pylint: disable=no-member -import os -import xml.etree.ElementTree - -os.popen2('') # [deprecated-method] -os.popen3('') # [deprecated-method] -os.popen4('') # [deprecated-method] -xml.etree.ElementTree.Element('elem').getchildren() # [deprecated-method] diff --git a/tests/functional/d/deprecated_methods_py2.rc b/tests/functional/d/deprecated_methods_py2.rc deleted file mode 100644 index a65023393..000000000 --- a/tests/functional/d/deprecated_methods_py2.rc +++ /dev/null @@ -1,2 +0,0 @@ -[testoptions] -max_pyver=3.0 diff --git a/tests/functional/d/deprecated_methods_py2.txt b/tests/functional/d/deprecated_methods_py2.txt deleted file mode 100644 index e1038185c..000000000 --- a/tests/functional/d/deprecated_methods_py2.txt +++ /dev/null @@ -1,4 +0,0 @@ -deprecated-method:6::Using deprecated method popen2() -deprecated-method:7::Using deprecated method popen3() -deprecated-method:8::Using deprecated method popen4() -deprecated-method:9::Using deprecated method getchildren() diff --git a/tests/functional/d/deprecated_module_py2.py b/tests/functional/d/deprecated_module_py2.py deleted file mode 100644 index b0d186540..000000000 --- a/tests/functional/d/deprecated_module_py2.py +++ /dev/null @@ -1,8 +0,0 @@ -"""Test deprecated modules.""" -# pylint: disable=unused-import,no-name-in-module,import-error,ungrouped-imports - -import Bastion # [deprecated-module] -import rexec # [deprecated-module] - -from Bastion import bastion_module # [deprecated-module] -from rexec import rexec_module # [deprecated-module] diff --git a/tests/functional/d/deprecated_module_py2.rc b/tests/functional/d/deprecated_module_py2.rc deleted file mode 100644 index a65023393..000000000 --- a/tests/functional/d/deprecated_module_py2.rc +++ /dev/null @@ -1,2 +0,0 @@ -[testoptions] -max_pyver=3.0 diff --git a/tests/functional/d/deprecated_module_py2.txt b/tests/functional/d/deprecated_module_py2.txt deleted file mode 100644 index 54f555505..000000000 --- a/tests/functional/d/deprecated_module_py2.txt +++ /dev/null @@ -1,4 +0,0 @@ -deprecated-module:4::Uses of a deprecated module 'Bastion' -deprecated-module:5::Uses of a deprecated module 'rexec' -deprecated-module:7::Uses of a deprecated module 'Bastion' -deprecated-module:8::Uses of a deprecated module 'rexec' diff --git a/tests/functional/d/disable_ungrouped_imports.py b/tests/functional/d/disable_ungrouped_imports.py index 836c76d1a..48c06c01c 100644 --- a/tests/functional/d/disable_ungrouped_imports.py +++ b/tests/functional/d/disable_ungrouped_imports.py @@ -1,6 +1,6 @@ """Checks that disabling 'ungrouped-imports' on an import prevents subsequent imports from being considered ungrouped in respect to it.""" -# pylint: disable=unused-import,relative-import,wrong-import-position,wrong-import-order,using-constant-test +# pylint: disable=unused-import,wrong-import-position,wrong-import-order,using-constant-test # pylint: disable=import-error from os.path import basename import logging.config # pylint: disable=ungrouped-imports diff --git a/tests/functional/i/invalid_encoded_data.py b/tests/functional/i/invalid_encoded_data.py deleted file mode 100644 index 743031cef..000000000 --- a/tests/functional/i/invalid_encoded_data.py +++ /dev/null @@ -1,5 +0,0 @@ -# coding: utf-8 -"""Test data file with encoding errors.""" - - -STR = 'Суествительное' # [invalid-encoded-data] diff --git a/tests/functional/i/invalid_encoded_data.rc b/tests/functional/i/invalid_encoded_data.rc deleted file mode 100644 index a65023393..000000000 --- a/tests/functional/i/invalid_encoded_data.rc +++ /dev/null @@ -1,2 +0,0 @@ -[testoptions] -max_pyver=3.0 diff --git a/tests/functional/i/invalid_encoded_data.txt b/tests/functional/i/invalid_encoded_data.txt deleted file mode 100644 index c6e69dc1f..000000000 --- a/tests/functional/i/invalid_encoded_data.txt +++ /dev/null @@ -1 +0,0 @@ -invalid-encoded-data:5::"Cannot decode using encoding ""utf-8"", unexpected byte at position 11" diff --git a/tests/functional/i/invalid_encoding_py27.py b/tests/functional/i/invalid_encoding_py27.py deleted file mode 100644 index fb6b2de16..000000000 --- a/tests/functional/i/invalid_encoding_py27.py +++ /dev/null @@ -1,3 +0,0 @@ -"""Test data file with wrong encoding and if coding is not first line.""" -# coding: utd-8 # [syntax-error] -STR = 'some text' diff --git a/tests/functional/i/invalid_encoding_py27.rc b/tests/functional/i/invalid_encoding_py27.rc deleted file mode 100644 index eca2dd95a..000000000 --- a/tests/functional/i/invalid_encoding_py27.rc +++ /dev/null @@ -1,3 +0,0 @@ -[testoptions] -min_pyver=2.7.10 -max_pyver=3.0 diff --git a/tests/functional/i/invalid_encoding_py27.txt b/tests/functional/i/invalid_encoding_py27.txt deleted file mode 100644 index 856a1a1db..000000000 --- a/tests/functional/i/invalid_encoding_py27.txt +++ /dev/null @@ -1 +0,0 @@ -syntax-error:2::Cannot decode using encoding "utd-8", bad encoding diff --git a/tests/functional/l/line_too_long.py b/tests/functional/l/line_too_long.py index e2affd609..60310b5a0 100644 --- a/tests/functional/l/line_too_long.py +++ b/tests/functional/l/line_too_long.py @@ -1,4 +1,4 @@ -# pylint: disable=invalid-encoded-data, fixme, unnecessary-pass
+# pylint: disable=fixme, unnecessary-pass
# +1: [line-too-long]
#####################################################################################################
# +1: [line-too-long]
diff --git a/tests/functional/r/redefine_in_handler.py b/tests/functional/r/redefine_in_handler.py deleted file mode 100644 index 9f56cfbea..000000000 --- a/tests/functional/r/redefine_in_handler.py +++ /dev/null @@ -1,68 +0,0 @@ -"""Test for W0623, overwriting names in exception handlers.""" -# pylint: disable=broad-except,bare-except,print-statement,no-absolute-import,duplicate-except -# pylint: disable=invalid-name, unused-variable -import exceptions - -__revision__ = '' - -class MyError(Exception): - """Special exception class.""" - pass - - -def some_function(): - """A function.""" - exc = None - - try: - {}["a"] - except KeyError, exceptions.RuntimeError: # [redefine-in-handler] - pass - except KeyError, OSError: # [redefine-in-handler] - pass - except KeyError, MyError: # [redefine-in-handler] - pass - except KeyError, exc: # this is fine - print exc - except KeyError, exc1: # this is fine - print exc1 - except KeyError, FOO: # C0103 - print FOO - - try: - pass - except KeyError, exc1: # this is fine - print exc1 - -class MyOtherError(Exception): - """Special exception class.""" - pass - - -exc3 = None - -try: - pass -except KeyError, exceptions.RuntimeError: # [redefine-in-handler] - pass -except KeyError, exceptions.RuntimeError.args: # [redefine-in-handler] - pass -except KeyError, OSError: # [redefine-in-handler] - pass -except KeyError, MyOtherError: # [redefine-in-handler] - pass -except KeyError, exc3: # this is fine - print exc3 -except KeyError, exc4: # this is fine - print exc4 -except KeyError, OOPS: # C0103 - print OOPS - -try: - pass -except KeyError, exc4: # this is fine - print exc4 -except IOError, exc5: # this is fine - print exc5 -except MyOtherError, exc5: # this is fine - print exc5 diff --git a/tests/functional/r/redefine_in_handler.rc b/tests/functional/r/redefine_in_handler.rc deleted file mode 100644 index a65023393..000000000 --- a/tests/functional/r/redefine_in_handler.rc +++ /dev/null @@ -1,2 +0,0 @@ -[testoptions] -max_pyver=3.0 diff --git a/tests/functional/r/redefine_in_handler.txt b/tests/functional/r/redefine_in_handler.txt deleted file mode 100644 index 48674a19b..000000000 --- a/tests/functional/r/redefine_in_handler.txt +++ /dev/null @@ -1,7 +0,0 @@ -redefine-in-handler:19:some_function:Redefining name 'RuntimeError' from object 'exceptions' in exception handler -redefine-in-handler:21:some_function:Redefining name 'OSError' from builtins in exception handler -redefine-in-handler:23:some_function:Redefining name 'MyError' from outer scope (line 8) in exception handler -redefine-in-handler:46::Redefining name 'RuntimeError' from object 'exceptions' in exception handler -redefine-in-handler:48::Redefining name 'args' from object 'exceptions.RuntimeError' in exception handler -redefine-in-handler:50::Redefining name 'OSError' from builtins in exception handler -redefine-in-handler:52::Redefining name 'MyOtherError' from outer scope (line 37) in exception handler diff --git a/tests/functional/u/ungrouped_imports.py b/tests/functional/u/ungrouped_imports.py index 2fcf18afc..d21c14839 100644 --- a/tests/functional/u/ungrouped_imports.py +++ b/tests/functional/u/ungrouped_imports.py @@ -1,5 +1,5 @@ """Checks import order rule""" -# pylint: disable=unused-import,relative-import,wrong-import-position,wrong-import-order,using-constant-test +# pylint: disable=unused-import,wrong-import-position,wrong-import-order,using-constant-test # pylint: disable=import-error import six import logging.config diff --git a/tests/functional/w/wrong_import_order.py b/tests/functional/w/wrong_import_order.py index c2791d14a..ed0615b0c 100644 --- a/tests/functional/w/wrong_import_order.py +++ b/tests/functional/w/wrong_import_order.py @@ -1,5 +1,5 @@ """Checks import order rule""" -# pylint: disable=unused-import,relative-import,ungrouped-imports,import-error,no-name-in-module,relative-beyond-top-level +# pylint: disable=unused-import,ungrouped-imports,import-error,no-name-in-module,relative-beyond-top-level from __future__ import absolute_import try: from six.moves import configparser diff --git a/tests/functional/w/wrong_import_order2.py b/tests/functional/w/wrong_import_order2.py index 4f9a100b8..7157512dd 100644 --- a/tests/functional/w/wrong_import_order2.py +++ b/tests/functional/w/wrong_import_order2.py @@ -1,5 +1,5 @@ """Checks import order rule in a right case""" -# pylint: disable=unused-import,relative-import,ungrouped-imports,import-error,no-name-in-module +# pylint: disable=unused-import,ungrouped-imports,import-error,no-name-in-module # Standard imports diff --git a/tests/functional/w/wrong_import_position.py b/tests/functional/w/wrong_import_position.py index 1a9331949..c06f9da1f 100644 --- a/tests/functional/w/wrong_import_position.py +++ b/tests/functional/w/wrong_import_position.py @@ -1,5 +1,5 @@ """Checks import order rule""" -# pylint: disable=unused-import,relative-import,ungrouped-imports,wrong-import-order +# pylint: disable=unused-import,ungrouped-imports,wrong-import-order # pylint: disable=import-error, too-few-public-methods, missing-docstring,using-constant-test, useless-object-inheritance import os.path diff --git a/tests/functional/w/wrong_import_position2.py b/tests/functional/w/wrong_import_position2.py index 65ad9e656..d7441b465 100644 --- a/tests/functional/w/wrong_import_position2.py +++ b/tests/functional/w/wrong_import_position2.py @@ -1,5 +1,5 @@ """Checks import order rule with nested non_import sentence""" -# pylint: disable=unused-import,relative-import,ungrouped-imports,import-error,no-name-in-module,relative-beyond-top-level +# pylint: disable=unused-import,ungrouped-imports,import-error,no-name-in-module,relative-beyond-top-level try: from sys import argv except ImportError: diff --git a/tests/functional/w/wrong_import_position3.py b/tests/functional/w/wrong_import_position3.py index d2cf68529..a1808a8fd 100644 --- a/tests/functional/w/wrong_import_position3.py +++ b/tests/functional/w/wrong_import_position3.py @@ -1,3 +1,3 @@ """Checks import position rule""" -# pylint: disable=unused-import,relative-import,ungrouped-imports,import-error,no-name-in-module,relative-beyond-top-level +# pylint: disable=unused-import,ungrouped-imports,import-error,no-name-in-module,relative-beyond-top-level import os diff --git a/tests/functional/w/wrong_import_position4.py b/tests/functional/w/wrong_import_position4.py index c728241b7..96f39ce8d 100644 --- a/tests/functional/w/wrong_import_position4.py +++ b/tests/functional/w/wrong_import_position4.py @@ -1,5 +1,5 @@ """Checks import position rule""" -# pylint: disable=unused-import,relative-import,ungrouped-imports,import-error,no-name-in-module,relative-beyond-top-level,unused-variable,import-outside-toplevel +# pylint: disable=unused-import,ungrouped-imports,import-error,no-name-in-module,relative-beyond-top-level,unused-variable,import-outside-toplevel def method1(): """Method 1""" import x diff --git a/tests/functional/w/wrong_import_position5.py b/tests/functional/w/wrong_import_position5.py index b96a8a0e4..ff9c28cd7 100644 --- a/tests/functional/w/wrong_import_position5.py +++ b/tests/functional/w/wrong_import_position5.py @@ -1,4 +1,4 @@ r"""Checks import position rule""" -# pylint: disable=unused-import,relative-import,ungrouped-imports,import-error,no-name-in-module,relative-beyond-top-level +# pylint: disable=unused-import,ungrouped-imports,import-error,no-name-in-module,relative-beyond-top-level import os diff --git a/tests/functional/w/wrong_import_position6.py b/tests/functional/w/wrong_import_position6.py index 694c109d1..e719d2cb9 100644 --- a/tests/functional/w/wrong_import_position6.py +++ b/tests/functional/w/wrong_import_position6.py @@ -1,5 +1,5 @@ """Checks import position rule""" -# pylint: disable=unused-import,relative-import,ungrouped-imports,import-error,no-name-in-module,relative-beyond-top-level,undefined-variable +# pylint: disable=unused-import,ungrouped-imports,import-error,no-name-in-module,relative-beyond-top-level,undefined-variable import y diff --git a/tests/functional/w/wrong_import_position7.py b/tests/functional/w/wrong_import_position7.py index bb5095603..58a79b84b 100644 --- a/tests/functional/w/wrong_import_position7.py +++ b/tests/functional/w/wrong_import_position7.py @@ -1,5 +1,5 @@ """Checks import position rule""" -# pylint: disable=unused-import,relative-import,ungrouped-imports,import-error,no-name-in-module,relative-beyond-top-level +# pylint: disable=unused-import,ungrouped-imports,import-error,no-name-in-module,relative-beyond-top-level try: import x except ImportError: diff --git a/tests/functional/w/wrong_import_position8.py b/tests/functional/w/wrong_import_position8.py index cd1028a1b..531d9ca5f 100644 --- a/tests/functional/w/wrong_import_position8.py +++ b/tests/functional/w/wrong_import_position8.py @@ -1,4 +1,4 @@ """Checks import position rule""" -# pylint: disable=unused-import,relative-import,ungrouped-imports,import-error,no-name-in-module,relative-beyond-top-level,undefined-variable +# pylint: disable=unused-import,ungrouped-imports,import-error,no-name-in-module,relative-beyond-top-level,undefined-variable if x: import os diff --git a/tests/functional/w/wrong_import_position9.py b/tests/functional/w/wrong_import_position9.py index a08880b8a..232c453cc 100644 --- a/tests/functional/w/wrong_import_position9.py +++ b/tests/functional/w/wrong_import_position9.py @@ -1,5 +1,5 @@ """Checks import position rule""" -# pylint: disable=unused-import,relative-import,ungrouped-imports,import-error,no-name-in-module,relative-beyond-top-level +# pylint: disable=unused-import,ungrouped-imports,import-error,no-name-in-module,relative-beyond-top-level import y try: import x diff --git a/tests/input/func_w0233.py b/tests/input/func_w0233.py index eb5d97226..feb30c567 100644 --- a/tests/input/func_w0233.py +++ b/tests/input/func_w0233.py @@ -1,4 +1,4 @@ -# pylint: disable=R0903,W0212,W0403,W0406,no-absolute-import,wrong-import-order, useless-object-inheritance +# pylint: disable=R0903,W0212,W0406,no-absolute-import,wrong-import-order, useless-object-inheritance """test for call to __init__ from a non ancestor class """ diff --git a/tests/input/func_w0623_py30.py b/tests/input/func_w0623_py30.py deleted file mode 100644 index 7eb27a923..000000000 --- a/tests/input/func_w0623_py30.py +++ /dev/null @@ -1,17 +0,0 @@ -"""Test for W0623, overwriting names in exception handlers.""" -# pylint: disable=unnecessary-pass - -__revision__ = '' - -class MyError(Exception): - """Special exception class.""" - pass - - -def some_function(): - """A function.""" - - try: - {}["a"] - except KeyError as some_function: # W0623 - pass diff --git a/tests/messages/func_w0623_py30.txt b/tests/messages/func_w0623_py30.txt deleted file mode 100644 index e5cc0f57e..000000000 --- a/tests/messages/func_w0623_py30.txt +++ /dev/null @@ -1,2 +0,0 @@ -W: 16:some_function: Redefining name 'some_function' from outer scope (line 11) in exception handler -W: 16:some_function: Unused variable 'some_function' diff --git a/tests/regrtest_data/package/__init__.py b/tests/regrtest_data/package/__init__.py index bf6b73cda..10cc40f6c 100644 --- a/tests/regrtest_data/package/__init__.py +++ b/tests/regrtest_data/package/__init__.py @@ -1,4 +1,4 @@ -# pylint: disable=R0903,W0403 +# pylint: disable=R0903 """package's __init__ file""" |