From f84bf0220812a987595f719acad0be6e8cf0f982 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Sun, 7 Mar 2021 22:20:00 +0100 Subject: Migrate all func_noerror_* to new functional tests --- ..._noerror___init___return_from_inner_function.py | 12 --- ...oerror_access_attr_before_def_false_positive.py | 98 ---------------------- tests/input/func_noerror_base_init_vars.py | 35 -------- tests/input/func_noerror_builtin_module_test.py | 11 --- tests/input/func_noerror_class_attributes.py | 18 ---- ...unc_noerror_classes_meth_could_be_a_function.py | 33 -------- ...func_noerror_classes_protected_member_access.py | 26 ------ tests/input/func_noerror_decorator_scope.py | 19 ----- ...func_noerror_e1101_9588_base_attr_aug_assign.py | 38 --------- .../func_noerror_external_classmethod_crash.py | 21 ----- tests/input/func_noerror_inner_classes.py | 33 -------- .../input/func_noerror_lambda_use_before_assign.py | 8 -- tests/input/func_noerror_mcs_attr_access.py | 20 ----- tests/input/func_noerror_no_warning_docstring.py | 42 ---------- .../func_noerror_object_as_class_attribute.py | 18 ---- tests/input/func_noerror_overloaded_operator.py | 21 ----- .../func_noerror_property_affectation_py26.py | 24 ------ tests/input/func_noerror_yield_assign_py25.py | 21 ----- tests/input/func_noerror_yield_return_mix.py | 8 -- 19 files changed, 506 deletions(-) delete mode 100644 tests/input/func_noerror___init___return_from_inner_function.py delete mode 100644 tests/input/func_noerror_access_attr_before_def_false_positive.py delete mode 100644 tests/input/func_noerror_base_init_vars.py delete mode 100644 tests/input/func_noerror_builtin_module_test.py delete mode 100644 tests/input/func_noerror_class_attributes.py delete mode 100644 tests/input/func_noerror_classes_meth_could_be_a_function.py delete mode 100644 tests/input/func_noerror_classes_protected_member_access.py delete mode 100644 tests/input/func_noerror_decorator_scope.py delete mode 100644 tests/input/func_noerror_e1101_9588_base_attr_aug_assign.py delete mode 100644 tests/input/func_noerror_external_classmethod_crash.py delete mode 100644 tests/input/func_noerror_inner_classes.py delete mode 100644 tests/input/func_noerror_lambda_use_before_assign.py delete mode 100644 tests/input/func_noerror_mcs_attr_access.py delete mode 100644 tests/input/func_noerror_no_warning_docstring.py delete mode 100644 tests/input/func_noerror_object_as_class_attribute.py delete mode 100644 tests/input/func_noerror_overloaded_operator.py delete mode 100644 tests/input/func_noerror_property_affectation_py26.py delete mode 100644 tests/input/func_noerror_yield_assign_py25.py delete mode 100644 tests/input/func_noerror_yield_return_mix.py (limited to 'tests/input') diff --git a/tests/input/func_noerror___init___return_from_inner_function.py b/tests/input/func_noerror___init___return_from_inner_function.py deleted file mode 100644 index 769d5ac96..000000000 --- a/tests/input/func_noerror___init___return_from_inner_function.py +++ /dev/null @@ -1,12 +0,0 @@ -# pylint: disable=R0903, useless-object-inheritance -"""#10075""" - -__revision__ = 1 - -class Aaa(object): - """docstring""" - def __init__(self): - def inner_function(arg): - """inner docstring""" - return arg + 4 - self.func = inner_function diff --git a/tests/input/func_noerror_access_attr_before_def_false_positive.py b/tests/input/func_noerror_access_attr_before_def_false_positive.py deleted file mode 100644 index 3884c9980..000000000 --- a/tests/input/func_noerror_access_attr_before_def_false_positive.py +++ /dev/null @@ -1,98 +0,0 @@ -#pylint: disable=C0103,R0904,R0903,W0201,no-absolute-import, useless-object-inheritance -""" -This module demonstrates a possible problem of pyLint with calling __init__ s -from inherited classes. -Initializations done there are not considered, which results in Error E0203 for -self.cookedq. -""" - -from __future__ import print_function - -import telnetlib - -class SeeTelnet(telnetlib.Telnet): - """ - Extension of telnetlib. - """ - - def __init__(self, host=None, port=0): - """ - Constructor. - When called without arguments, create an unconnected instance. - With a hostname argument, it connects the instance; a port - number is optional. - Parameter: - - host: IP address of the host - - port: Port number - """ - telnetlib.Telnet.__init__(self, host, port) - - def readUntilArray(self, matches, _=None): - """ - Read until a given string is encountered or until timeout. - ... - """ - self.process_rawq() - maxLength = 0 - for match in matches: - if len(match) > maxLength: - maxLength = len(match) - -class Base(object): - """bla bla""" - dougloup_papa = None - - def __init__(self): - self._var = False - -class Derived(Base): - """derived blabla""" - dougloup_moi = None - def Work(self): - """do something""" - # E0203 - Access to member '_var' before its definition - if self._var: - print("True") - else: - print("False") - self._var = True - - # E0203 - Access to member 'dougloup_papa' before its definition - if self.dougloup_papa: - print('dougloup !') - self.dougloup_papa = True - # E0203 - Access to member 'dougloup_moi' before its definition - if self.dougloup_moi: - print('dougloup !') - self.dougloup_moi = True - - -class QoSALConnection(object): - """blabla""" - - _the_instance = None - - def __new__(cls): - if cls._the_instance is None: - cls._the_instance = object.__new__(cls) - return cls._the_instance - - def __init__(self): - pass - -class DefinedOutsideInit(object): - """use_attr is seen as the method defining attr because its in - first position - """ - def __init__(self): - self.reset() - - def use_attr(self): - """use and set members""" - if self.attr: - print('hop') - self.attr = 10 - - def reset(self): - """reset members""" - self.attr = 4 diff --git a/tests/input/func_noerror_base_init_vars.py b/tests/input/func_noerror_base_init_vars.py deleted file mode 100644 index 152cbfd47..000000000 --- a/tests/input/func_noerror_base_init_vars.py +++ /dev/null @@ -1,35 +0,0 @@ -# pylint:disable=R0201, print-statement, too-few-public-methods, useless-object-inheritance -"""Checks that class variables are seen as inherited ! -""" -__revision__ = '' - -class BaseClass(object): - """A simple base class - """ - - def __init__(self): - self.base_var = {} - - def met(self): - """yo""" - def meeting(self, with_): - """ye""" - return with_ -class MyClass(BaseClass): - """Inherits from BaseClass - """ - - def __init__(self): - BaseClass.__init__(self) - self.var = {} - - def met(self): - """Checks that base_var is not seen as defined outsite '__init__' - """ - self.var[1] = 'one' - self.base_var[1] = 'one' - return self.base_var, self.var - -if __name__ == '__main__': - OBJ = MyClass() - OBJ.met() diff --git a/tests/input/func_noerror_builtin_module_test.py b/tests/input/func_noerror_builtin_module_test.py deleted file mode 100644 index 9b1e7ce8e..000000000 --- a/tests/input/func_noerror_builtin_module_test.py +++ /dev/null @@ -1,11 +0,0 @@ -"""test import from a builtin module""" - -from __future__ import absolute_import -from math import log10 - -__revision__ = None - - -def log10_2(): - """bla bla bla""" - return log10(2) diff --git a/tests/input/func_noerror_class_attributes.py b/tests/input/func_noerror_class_attributes.py deleted file mode 100644 index b6fd4601e..000000000 --- a/tests/input/func_noerror_class_attributes.py +++ /dev/null @@ -1,18 +0,0 @@ -"""Test that valid class attribute doesn't trigger errors""" -__revision__ = 'sponge bob' -# pylint: disable=useless-object-inheritance - -class Clazz(object): - "dummy class" - - def __init__(self): - self.topic = 5 - self._data = 45 - - def change_type(self, new_class): - """Change type""" - self.__class__ = new_class - - def do_nothing(self): - "I do nothing useful" - return self.topic + 56 diff --git a/tests/input/func_noerror_classes_meth_could_be_a_function.py b/tests/input/func_noerror_classes_meth_could_be_a_function.py deleted file mode 100644 index 05a6c40d7..000000000 --- a/tests/input/func_noerror_classes_meth_could_be_a_function.py +++ /dev/null @@ -1,33 +0,0 @@ -# pylint: disable=C0111,R0903,W0232, useless-object-inheritance -""" -#2479 - -R0201 (formely W0212), Method could be a function shouldn't be emitted in case -like factory method pattern -""" -__revision__ = 1 - -class XAsub(object): - pass -class XBsub(XAsub): - pass -class XCsub(XAsub): - pass - -class Aimpl(object): - # disable "method could be a function" on classes which are not overriding - # the factory method because in that case the usage of polymorphism is not - # detected - # pylint: disable=R0201 - def makex(self): - return XAsub() - -class Bimpl(Aimpl): - - def makex(self): - return XBsub() - -class Cimpl(Aimpl): - - def makex(self): - return XCsub() diff --git a/tests/input/func_noerror_classes_protected_member_access.py b/tests/input/func_noerror_classes_protected_member_access.py deleted file mode 100644 index 516efd7d4..000000000 --- a/tests/input/func_noerror_classes_protected_member_access.py +++ /dev/null @@ -1,26 +0,0 @@ -""" -#3123: W0212 false positive on static method -""" -__revision__ = 1 - -# pylint: disable=no-classmethod-decorator, no-staticmethod-decorator, useless-object-inheritance -class A3123(object): - """oypuee""" - _protected = 1 - def __init__(self): - pass - - - def cmeth(cls, val): - """set protected member""" - cls._protected = +val - - cmeth = classmethod(cmeth) - - def smeth(val): - """set protected member""" - A3123._protected += val - - smeth = staticmethod(smeth) - - prop = property(lambda self: self._protected) diff --git a/tests/input/func_noerror_decorator_scope.py b/tests/input/func_noerror_decorator_scope.py deleted file mode 100644 index 8d35159e9..000000000 --- a/tests/input/func_noerror_decorator_scope.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- pylint: disable=W0232,R0903, useless-object-inheritance -"""Test that decorators sees the class namespace - just like -function default values does but function body doesn't. - -https://www.logilab.net/elo/ticket/3711 - bug finding decorator arguments -https://www.logilab.net/elo/ticket/5626 - name resolution bug inside classes -""" - -from __future__ import print_function - -class Test(object): - """test class""" - ident = lambda x: x - - @ident(ident) - def method(self, val=ident(7), func=ident): - """hop""" - print(self) - return func(val) diff --git a/tests/input/func_noerror_e1101_9588_base_attr_aug_assign.py b/tests/input/func_noerror_e1101_9588_base_attr_aug_assign.py deleted file mode 100644 index 11472010c..000000000 --- a/tests/input/func_noerror_e1101_9588_base_attr_aug_assign.py +++ /dev/null @@ -1,38 +0,0 @@ -# pylint: disable=R0903, useless-object-inheritance -""" -False positive case of E1101: - -The error is triggered when the attribute set in the base class is -modified with augmented assignment in a derived class. - -https://www.logilab.org/ticket/9588 -""" -__revision__ = 0 - -class BaseClass(object): - "The base class" - def __init__(self): - "Set an attribute." - self.e1101 = 1 - -class FalsePositiveClass(BaseClass): - "The first derived class which triggers the false positive" - def __init__(self): - "Augmented assignment triggers E1101." - BaseClass.__init__(self) - self.e1101 += 1 - - def countup(self): - "Consequently this also triggers E1101." - self.e1101 += 1 - -class NegativeClass(BaseClass): - "The second derived class, which does not trigger the error E1101" - def __init__(self): - "Ordinary assignment is OK." - BaseClass.__init__(self) - self.e1101 = self.e1101 + 1 - - def countup(self): - "No problem." - self.e1101 += 1 diff --git a/tests/input/func_noerror_external_classmethod_crash.py b/tests/input/func_noerror_external_classmethod_crash.py deleted file mode 100644 index e9842a5e5..000000000 --- a/tests/input/func_noerror_external_classmethod_crash.py +++ /dev/null @@ -1,21 +0,0 @@ -# pylint: disable=W0232,R0903,W0613, useless-object-inheritance -"""tagging a function as a class method cause a crash when checking for -signature overriding -""" - -def fetch_config(mainattr=None): - """return a class method""" - - def fetch_order(cls, attr, var): - """a class method""" - if attr == mainattr: - return var - return None - fetch_order = classmethod(fetch_order) - return fetch_order - -class Aaa(object): - """hop""" - fetch_order = fetch_config('A') - -__revision__ = None diff --git a/tests/input/func_noerror_inner_classes.py b/tests/input/func_noerror_inner_classes.py deleted file mode 100644 index 24a2edb80..000000000 --- a/tests/input/func_noerror_inner_classes.py +++ /dev/null @@ -1,33 +0,0 @@ -# pylint: disable=R0903, useless-object-inheritance, unnecessary-pass -"""Backend Base Classes for the schwelm user DB""" - -__revision__ = "alpha" - -class Aaa(object): - """docstring""" - def __init__(self): - self.__setattr__('a', 'b') - - - def one_public(self): - """docstring""" - pass - - def another_public(self): - """docstring""" - pass - -class Bbb(Aaa): - """docstring""" - pass - -class Ccc(Aaa): - """docstring""" - - class Ddd(Aaa): - """docstring""" - pass - - class Eee(Ddd): - """docstring""" - pass diff --git a/tests/input/func_noerror_lambda_use_before_assign.py b/tests/input/func_noerror_lambda_use_before_assign.py deleted file mode 100644 index af2775cae..000000000 --- a/tests/input/func_noerror_lambda_use_before_assign.py +++ /dev/null @@ -1,8 +0,0 @@ -"""https://www.logilab.net/elo/ticket/18862""" -from __future__ import print_function -__revision__ = 1 -def function(): - """hop""" - ggg = lambda: xxx - xxx = 1 - print(ggg()) diff --git a/tests/input/func_noerror_mcs_attr_access.py b/tests/input/func_noerror_mcs_attr_access.py deleted file mode 100644 index 149e07812..000000000 --- a/tests/input/func_noerror_mcs_attr_access.py +++ /dev/null @@ -1,20 +0,0 @@ -# pylint: disable=R0903, metaclass-assignment, useless-object-inheritance -"""test attribute access on metaclass""" - - -from __future__ import print_function - -class Meta(type): - """the meta class""" - def __init__(cls, name, bases, dictionary): - super(Meta, cls).__init__(name, bases, dictionary) - print(cls, cls._meta_args) - delattr(cls, '_meta_args') - -class Test(object): - """metaclassed class""" - __metaclass__ = Meta - _meta_args = ('foo', 'bar') - - def __init__(self): - print('__init__', self) diff --git a/tests/input/func_noerror_no_warning_docstring.py b/tests/input/func_noerror_no_warning_docstring.py deleted file mode 100644 index 315eeeaab..000000000 --- a/tests/input/func_noerror_no_warning_docstring.py +++ /dev/null @@ -1,42 +0,0 @@ -''' Test for inheritance ''' -from __future__ import print_function -__revision__ = 1 -# pylint: disable=too-few-public-methods, using-constant-test, useless-object-inheritance -class AAAA(object): - ''' class AAAA ''' - - def __init__(self): - pass - - def method1(self): - ''' method 1 ''' - print(self) - - def method2(self): - ''' method 2 ''' - print(self) - -class BBBB(AAAA): - ''' class BBBB ''' - - def __init__(self): - AAAA.__init__(self) - - # should ignore docstring calling from class AAAA - def method1(self): - AAAA.method1(self) - -class CCCC(BBBB): - ''' class CCCC ''' - - def __init__(self): - BBBB.__init__(self) - - # should ignore docstring since CCCC is inherited from BBBB which is - # inherited from AAAA containing method2 - if __revision__: - def method2(self): - AAAA.method2(self) - else: - def method2(self): - AAAA.method1(self) diff --git a/tests/input/func_noerror_object_as_class_attribute.py b/tests/input/func_noerror_object_as_class_attribute.py deleted file mode 100644 index 71cd027b7..000000000 --- a/tests/input/func_noerror_object_as_class_attribute.py +++ /dev/null @@ -1,18 +0,0 @@ -# pylint: disable=R0903, useless-object-inheritance -"""Test case for the problem described below : - - A class extends 'object' - - This class defines its own __init__() - * pylint will therefore check that baseclasses' init() - are called - - If this class defines an 'object' attribute, then pylint - will use this new definition when trying to retrieve - object.__init__() -""" - -__revision__ = None - -class Statement(object): - """ ... """ - def __init__(self): - pass - object = None diff --git a/tests/input/func_noerror_overloaded_operator.py b/tests/input/func_noerror_overloaded_operator.py deleted file mode 100644 index 3a158b00b..000000000 --- a/tests/input/func_noerror_overloaded_operator.py +++ /dev/null @@ -1,21 +0,0 @@ -# pylint: disable=C0111,R0903, useless-object-inheritance -"""#3291""" -from __future__ import print_function - -class Myarray(object): - def __init__(self, array): - self.array = array - - def __mul__(self, val): - return Myarray(val) - - def astype(self): - return "ASTYPE", self - -def randint(maximum): - if maximum is not None: - return Myarray([1, 2, 3]) * 2 - - return int(5) - -print(randint(1).astype()) # we don't wan't an error for astype access diff --git a/tests/input/func_noerror_property_affectation_py26.py b/tests/input/func_noerror_property_affectation_py26.py deleted file mode 100644 index 60118bbf6..000000000 --- a/tests/input/func_noerror_property_affectation_py26.py +++ /dev/null @@ -1,24 +0,0 @@ -# pylint: disable=R0903, useless-object-inheritance -""" -Simple test case for an annoying behavior in pylint. -""" - -__revision__ = 'pouet' - -class Test(object): - """Smallest test case for reported issue.""" - - def __init__(self): - self._thing = None - - @property - def myattr(self): - """Getter for myattr""" - return self._thing - - @myattr.setter - def myattr(self, value): - """Setter for myattr.""" - self._thing = value - -Test().myattr = 'grou' diff --git a/tests/input/func_noerror_yield_assign_py25.py b/tests/input/func_noerror_yield_assign_py25.py deleted file mode 100644 index 6a5ae00b2..000000000 --- a/tests/input/func_noerror_yield_assign_py25.py +++ /dev/null @@ -1,21 +0,0 @@ -"""https://www.logilab.org/ticket/8771""" - -from __future__ import print_function - -def generator(): - """yield as assignment""" - yield 45 - xxxx = yield 123 - print(xxxx) - -def generator_fp1(seq): - """W0631 false positive""" - for val in seq: - pass - for val in seq: - yield val - -def generator_fp2(): - """E0601 false positive""" - xxxx = 12 - yield xxxx diff --git a/tests/input/func_noerror_yield_return_mix.py b/tests/input/func_noerror_yield_return_mix.py deleted file mode 100644 index 8e050f0f0..000000000 --- a/tests/input/func_noerror_yield_return_mix.py +++ /dev/null @@ -1,8 +0,0 @@ -""" module doc """ -# pylint: disable=useless-return -__revision__ = None - -def somegen(): - """this kind of mix is OK""" - yield 1 - return -- cgit v1.2.1