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 --- .../access_attr_before_def_false_positive.py | 98 ++++++++++++++++++++ .../a/access/access_member_before_definition.py | 40 ++++++++ .../a/access/access_member_before_definition.txt | 2 + tests/functional/a/access/access_to__name__.py | 21 +++++ tests/functional/a/access/access_to__name__.txt | 2 + .../a/access/access_to_protected_members.py | 101 +++++++++++++++++++++ .../a/access/access_to_protected_members.txt | 9 ++ .../a/access_member_before_definition.py | 40 -------- .../a/access_member_before_definition.txt | 2 - tests/functional/a/access_to__name__.py | 21 ----- tests/functional/a/access_to__name__.txt | 2 - tests/functional/a/access_to_protected_members.py | 101 --------------------- tests/functional/a/access_to_protected_members.txt | 9 -- tests/functional/b/base_init_vars.py | 35 +++++++ tests/functional/b/builtin_module_test.py | 11 +++ tests/functional/c/class_attributes.py | 18 ++++ .../c/classes_meth_could_be_a_function.py | 33 +++++++ .../c/classes_protected_member_access.py | 26 ++++++ tests/functional/d/decorator_scope.py | 19 ++++ .../e/e1101_9588_base_attr_aug_assign.py | 38 ++++++++ tests/functional/e/external_classmethod_crash.py | 21 +++++ .../i/init_return_from_inner_function.py | 12 +++ tests/functional/i/inner_classes.py | 33 +++++++ tests/functional/l/lambda_use_before_assign.py | 8 ++ tests/functional/m/metaclass_attr_access.py | 20 ++++ tests/functional/n/no/no_warning_docstring.py | 42 +++++++++ tests/functional/o/object_as_class_attribute.py | 18 ++++ tests/functional/o/overloaded_operator.py | 21 +++++ tests/functional/p/property_affectation_py26.py | 24 +++++ tests/functional/y/yield_assign_py25.py | 21 +++++ tests/functional/y/yield_return_mix.py | 8 ++ ..._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 -- tests/test_func.py | 2 +- 51 files changed, 682 insertions(+), 682 deletions(-) create mode 100644 tests/functional/a/access/access_attr_before_def_false_positive.py create mode 100644 tests/functional/a/access/access_member_before_definition.py create mode 100644 tests/functional/a/access/access_member_before_definition.txt create mode 100644 tests/functional/a/access/access_to__name__.py create mode 100644 tests/functional/a/access/access_to__name__.txt create mode 100644 tests/functional/a/access/access_to_protected_members.py create mode 100644 tests/functional/a/access/access_to_protected_members.txt delete mode 100644 tests/functional/a/access_member_before_definition.py delete mode 100644 tests/functional/a/access_member_before_definition.txt delete mode 100644 tests/functional/a/access_to__name__.py delete mode 100644 tests/functional/a/access_to__name__.txt delete mode 100644 tests/functional/a/access_to_protected_members.py delete mode 100644 tests/functional/a/access_to_protected_members.txt create mode 100644 tests/functional/b/base_init_vars.py create mode 100644 tests/functional/b/builtin_module_test.py create mode 100644 tests/functional/c/class_attributes.py create mode 100644 tests/functional/c/classes_meth_could_be_a_function.py create mode 100644 tests/functional/c/classes_protected_member_access.py create mode 100644 tests/functional/d/decorator_scope.py create mode 100644 tests/functional/e/e1101_9588_base_attr_aug_assign.py create mode 100644 tests/functional/e/external_classmethod_crash.py create mode 100644 tests/functional/i/init_return_from_inner_function.py create mode 100644 tests/functional/i/inner_classes.py create mode 100644 tests/functional/l/lambda_use_before_assign.py create mode 100644 tests/functional/m/metaclass_attr_access.py create mode 100644 tests/functional/n/no/no_warning_docstring.py create mode 100644 tests/functional/o/object_as_class_attribute.py create mode 100644 tests/functional/o/overloaded_operator.py create mode 100644 tests/functional/p/property_affectation_py26.py create mode 100644 tests/functional/y/yield_assign_py25.py create mode 100644 tests/functional/y/yield_return_mix.py 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 diff --git a/tests/functional/a/access/access_attr_before_def_false_positive.py b/tests/functional/a/access/access_attr_before_def_false_positive.py new file mode 100644 index 000000000..3884c9980 --- /dev/null +++ b/tests/functional/a/access/access_attr_before_def_false_positive.py @@ -0,0 +1,98 @@ +#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/functional/a/access/access_member_before_definition.py b/tests/functional/a/access/access_member_before_definition.py new file mode 100644 index 000000000..d8a97b4c7 --- /dev/null +++ b/tests/functional/a/access/access_member_before_definition.py @@ -0,0 +1,40 @@ +# pylint: disable=missing-docstring,too-few-public-methods,invalid-name +# pylint: disable=attribute-defined-outside-init, useless-object-inheritance + +class Aaaa(object): + """class with attributes defined in wrong order""" + + def __init__(self): + var1 = self._var2 # [access-member-before-definition] + self._var2 = 3 + self._var3 = var1 + + +class Bbbb(object): + A = 23 + B = A + + def __getattr__(self, attr): + try: + return self.__repo + except AttributeError: + self.__repo = attr + return attr + + + def catchme(self, attr): + """no AttributeError catched""" + try: + return self._repo # [access-member-before-definition] + except ValueError: + self._repo = attr + return attr + + +class Mixin(object): + + def test_mixin(self): + """Don't emit access-member-before-definition for mixin classes.""" + if self.already_defined: + # pylint: disable=attribute-defined-outside-init + self.already_defined = None diff --git a/tests/functional/a/access/access_member_before_definition.txt b/tests/functional/a/access/access_member_before_definition.txt new file mode 100644 index 000000000..76ba5de50 --- /dev/null +++ b/tests/functional/a/access/access_member_before_definition.txt @@ -0,0 +1,2 @@ +access-member-before-definition:8:15:Aaaa.__init__:Access to member '_var2' before its definition line 9 +access-member-before-definition:28:19:Bbbb.catchme:Access to member '_repo' before its definition line 30 diff --git a/tests/functional/a/access/access_to__name__.py b/tests/functional/a/access/access_to__name__.py new file mode 100644 index 000000000..82dcdbe78 --- /dev/null +++ b/tests/functional/a/access/access_to__name__.py @@ -0,0 +1,21 @@ +# pylint: disable=too-few-public-methods, print-statement, useless-object-inheritance +"""test access to __name__ gives undefined member on new/old class instances +but not on new/old class object +""" +from __future__ import print_function + +class Aaaa: + """old class""" + def __init__(self): + print(self.__name__) # [no-member] + print(self.__class__.__name__) + +class NewClass(object): + """new class""" + + def __new__(cls, *args, **kwargs): + print('new', cls.__name__) + return object.__new__(cls, *args, **kwargs) + + def __init__(self): + print('init', self.__name__) # [no-member] diff --git a/tests/functional/a/access/access_to__name__.txt b/tests/functional/a/access/access_to__name__.txt new file mode 100644 index 000000000..5e1f80e2a --- /dev/null +++ b/tests/functional/a/access/access_to__name__.txt @@ -0,0 +1,2 @@ +no-member:10:14:Aaaa.__init__:Instance of 'Aaaa' has no '__name__' member:INFERENCE +no-member:21:22:NewClass.__init__:Instance of 'NewClass' has no '__name__' member:INFERENCE diff --git a/tests/functional/a/access/access_to_protected_members.py b/tests/functional/a/access/access_to_protected_members.py new file mode 100644 index 000000000..737d8b9d6 --- /dev/null +++ b/tests/functional/a/access/access_to_protected_members.py @@ -0,0 +1,101 @@ +# pylint: disable=too-few-public-methods, W0231, print-statement, useless-object-inheritance +# pylint: disable=no-classmethod-decorator +"""Test external access to protected class members.""" +from __future__ import print_function + +class MyClass(object): + """Class with protected members.""" + _cls_protected = 5 + + def __init__(self, other): + MyClass._cls_protected = 6 + self._protected = 1 + self.public = other + self.attr = 0 + + def test(self): + """Docstring.""" + self._protected += self._cls_protected + print(self.public._haha) # [protected-access] + + def clsmeth(cls): + """Docstring.""" + cls._cls_protected += 1 + print(cls._cls_protected) + clsmeth = classmethod(clsmeth) + + def _private_method(self): + """Doing nothing.""" + + +class Subclass(MyClass): + """Subclass with protected members.""" + + def __init__(self): + MyClass._protected = 5 + super()._private_method() + +INST = Subclass() +INST.attr = 1 +print(INST.attr) +INST._protected = 2 # [protected-access] +print(INST._protected) # [protected-access] +INST._cls_protected = 3 # [protected-access] +print(INST._cls_protected) # [protected-access] + + +class Issue1031(object): + """Test for GitHub issue 1031""" + _attr = 1 + + def correct_access(self): + """Demonstrates correct access""" + return type(self)._attr + + def incorrect_access(self): + """Demonstrates incorrect access""" + if self._attr == 1: + return type(INST)._protected # [protected-access] + return None + + +class Issue1802(object): + """Test for GitHub issue 1802""" + def __init__(self, value): + self._foo = value + self.__private = 2 * value + + def __eq__(self, other): + """Test a correct access as the access to protected member is in a special method""" + if isinstance(other, self.__class__): + answer = self._foo == other._foo + return answer and self.__private == other.__private # [protected-access] + return False + + def not_in_special(self, other): + """ + Test an incorrect access as the access to protected member is not inside a special method + """ + if isinstance(other, self.__class__): + return self._foo == other._foo # [protected-access] + return False + + def __le__(self, other): + """ + Test a correct access as the access to protected member + is inside a special method even if it is deeply nested + """ + if 2 > 1: + if isinstance(other, self.__class__): + if "answer" == "42": + return self._foo == other._foo + return False + + def __fake_special__(self, other): + """ + Test an incorrect access as the access + to protected member is not inside a licit special method + """ + if isinstance(other, self.__class__): + return self._foo == other._foo # [protected-access] + return False diff --git a/tests/functional/a/access/access_to_protected_members.txt b/tests/functional/a/access/access_to_protected_members.txt new file mode 100644 index 000000000..f1a545b27 --- /dev/null +++ b/tests/functional/a/access/access_to_protected_members.txt @@ -0,0 +1,9 @@ +protected-access:19:14:MyClass.test:Access to a protected member _haha of a client class +protected-access:41:0::Access to a protected member _protected of a client class +protected-access:42:6::Access to a protected member _protected of a client class +protected-access:43:0::Access to a protected member _cls_protected of a client class +protected-access:44:6::Access to a protected member _cls_protected of a client class +protected-access:58:19:Issue1031.incorrect_access:Access to a protected member _protected of a client class +protected-access:72:48:Issue1802.__eq__:Access to a protected member __private of a client class +protected-access:80:32:Issue1802.not_in_special:Access to a protected member _foo of a client class +protected-access:100:32:Issue1802.__fake_special__:Access to a protected member _foo of a client class diff --git a/tests/functional/a/access_member_before_definition.py b/tests/functional/a/access_member_before_definition.py deleted file mode 100644 index d8a97b4c7..000000000 --- a/tests/functional/a/access_member_before_definition.py +++ /dev/null @@ -1,40 +0,0 @@ -# pylint: disable=missing-docstring,too-few-public-methods,invalid-name -# pylint: disable=attribute-defined-outside-init, useless-object-inheritance - -class Aaaa(object): - """class with attributes defined in wrong order""" - - def __init__(self): - var1 = self._var2 # [access-member-before-definition] - self._var2 = 3 - self._var3 = var1 - - -class Bbbb(object): - A = 23 - B = A - - def __getattr__(self, attr): - try: - return self.__repo - except AttributeError: - self.__repo = attr - return attr - - - def catchme(self, attr): - """no AttributeError catched""" - try: - return self._repo # [access-member-before-definition] - except ValueError: - self._repo = attr - return attr - - -class Mixin(object): - - def test_mixin(self): - """Don't emit access-member-before-definition for mixin classes.""" - if self.already_defined: - # pylint: disable=attribute-defined-outside-init - self.already_defined = None diff --git a/tests/functional/a/access_member_before_definition.txt b/tests/functional/a/access_member_before_definition.txt deleted file mode 100644 index 76ba5de50..000000000 --- a/tests/functional/a/access_member_before_definition.txt +++ /dev/null @@ -1,2 +0,0 @@ -access-member-before-definition:8:15:Aaaa.__init__:Access to member '_var2' before its definition line 9 -access-member-before-definition:28:19:Bbbb.catchme:Access to member '_repo' before its definition line 30 diff --git a/tests/functional/a/access_to__name__.py b/tests/functional/a/access_to__name__.py deleted file mode 100644 index 82dcdbe78..000000000 --- a/tests/functional/a/access_to__name__.py +++ /dev/null @@ -1,21 +0,0 @@ -# pylint: disable=too-few-public-methods, print-statement, useless-object-inheritance -"""test access to __name__ gives undefined member on new/old class instances -but not on new/old class object -""" -from __future__ import print_function - -class Aaaa: - """old class""" - def __init__(self): - print(self.__name__) # [no-member] - print(self.__class__.__name__) - -class NewClass(object): - """new class""" - - def __new__(cls, *args, **kwargs): - print('new', cls.__name__) - return object.__new__(cls, *args, **kwargs) - - def __init__(self): - print('init', self.__name__) # [no-member] diff --git a/tests/functional/a/access_to__name__.txt b/tests/functional/a/access_to__name__.txt deleted file mode 100644 index 5e1f80e2a..000000000 --- a/tests/functional/a/access_to__name__.txt +++ /dev/null @@ -1,2 +0,0 @@ -no-member:10:14:Aaaa.__init__:Instance of 'Aaaa' has no '__name__' member:INFERENCE -no-member:21:22:NewClass.__init__:Instance of 'NewClass' has no '__name__' member:INFERENCE diff --git a/tests/functional/a/access_to_protected_members.py b/tests/functional/a/access_to_protected_members.py deleted file mode 100644 index 737d8b9d6..000000000 --- a/tests/functional/a/access_to_protected_members.py +++ /dev/null @@ -1,101 +0,0 @@ -# pylint: disable=too-few-public-methods, W0231, print-statement, useless-object-inheritance -# pylint: disable=no-classmethod-decorator -"""Test external access to protected class members.""" -from __future__ import print_function - -class MyClass(object): - """Class with protected members.""" - _cls_protected = 5 - - def __init__(self, other): - MyClass._cls_protected = 6 - self._protected = 1 - self.public = other - self.attr = 0 - - def test(self): - """Docstring.""" - self._protected += self._cls_protected - print(self.public._haha) # [protected-access] - - def clsmeth(cls): - """Docstring.""" - cls._cls_protected += 1 - print(cls._cls_protected) - clsmeth = classmethod(clsmeth) - - def _private_method(self): - """Doing nothing.""" - - -class Subclass(MyClass): - """Subclass with protected members.""" - - def __init__(self): - MyClass._protected = 5 - super()._private_method() - -INST = Subclass() -INST.attr = 1 -print(INST.attr) -INST._protected = 2 # [protected-access] -print(INST._protected) # [protected-access] -INST._cls_protected = 3 # [protected-access] -print(INST._cls_protected) # [protected-access] - - -class Issue1031(object): - """Test for GitHub issue 1031""" - _attr = 1 - - def correct_access(self): - """Demonstrates correct access""" - return type(self)._attr - - def incorrect_access(self): - """Demonstrates incorrect access""" - if self._attr == 1: - return type(INST)._protected # [protected-access] - return None - - -class Issue1802(object): - """Test for GitHub issue 1802""" - def __init__(self, value): - self._foo = value - self.__private = 2 * value - - def __eq__(self, other): - """Test a correct access as the access to protected member is in a special method""" - if isinstance(other, self.__class__): - answer = self._foo == other._foo - return answer and self.__private == other.__private # [protected-access] - return False - - def not_in_special(self, other): - """ - Test an incorrect access as the access to protected member is not inside a special method - """ - if isinstance(other, self.__class__): - return self._foo == other._foo # [protected-access] - return False - - def __le__(self, other): - """ - Test a correct access as the access to protected member - is inside a special method even if it is deeply nested - """ - if 2 > 1: - if isinstance(other, self.__class__): - if "answer" == "42": - return self._foo == other._foo - return False - - def __fake_special__(self, other): - """ - Test an incorrect access as the access - to protected member is not inside a licit special method - """ - if isinstance(other, self.__class__): - return self._foo == other._foo # [protected-access] - return False diff --git a/tests/functional/a/access_to_protected_members.txt b/tests/functional/a/access_to_protected_members.txt deleted file mode 100644 index f1a545b27..000000000 --- a/tests/functional/a/access_to_protected_members.txt +++ /dev/null @@ -1,9 +0,0 @@ -protected-access:19:14:MyClass.test:Access to a protected member _haha of a client class -protected-access:41:0::Access to a protected member _protected of a client class -protected-access:42:6::Access to a protected member _protected of a client class -protected-access:43:0::Access to a protected member _cls_protected of a client class -protected-access:44:6::Access to a protected member _cls_protected of a client class -protected-access:58:19:Issue1031.incorrect_access:Access to a protected member _protected of a client class -protected-access:72:48:Issue1802.__eq__:Access to a protected member __private of a client class -protected-access:80:32:Issue1802.not_in_special:Access to a protected member _foo of a client class -protected-access:100:32:Issue1802.__fake_special__:Access to a protected member _foo of a client class diff --git a/tests/functional/b/base_init_vars.py b/tests/functional/b/base_init_vars.py new file mode 100644 index 000000000..152cbfd47 --- /dev/null +++ b/tests/functional/b/base_init_vars.py @@ -0,0 +1,35 @@ +# 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/functional/b/builtin_module_test.py b/tests/functional/b/builtin_module_test.py new file mode 100644 index 000000000..9b1e7ce8e --- /dev/null +++ b/tests/functional/b/builtin_module_test.py @@ -0,0 +1,11 @@ +"""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/functional/c/class_attributes.py b/tests/functional/c/class_attributes.py new file mode 100644 index 000000000..b6fd4601e --- /dev/null +++ b/tests/functional/c/class_attributes.py @@ -0,0 +1,18 @@ +"""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/functional/c/classes_meth_could_be_a_function.py b/tests/functional/c/classes_meth_could_be_a_function.py new file mode 100644 index 000000000..05a6c40d7 --- /dev/null +++ b/tests/functional/c/classes_meth_could_be_a_function.py @@ -0,0 +1,33 @@ +# 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/functional/c/classes_protected_member_access.py b/tests/functional/c/classes_protected_member_access.py new file mode 100644 index 000000000..516efd7d4 --- /dev/null +++ b/tests/functional/c/classes_protected_member_access.py @@ -0,0 +1,26 @@ +""" +#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/functional/d/decorator_scope.py b/tests/functional/d/decorator_scope.py new file mode 100644 index 000000000..8d35159e9 --- /dev/null +++ b/tests/functional/d/decorator_scope.py @@ -0,0 +1,19 @@ +# -*- 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/functional/e/e1101_9588_base_attr_aug_assign.py b/tests/functional/e/e1101_9588_base_attr_aug_assign.py new file mode 100644 index 000000000..11472010c --- /dev/null +++ b/tests/functional/e/e1101_9588_base_attr_aug_assign.py @@ -0,0 +1,38 @@ +# 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/functional/e/external_classmethod_crash.py b/tests/functional/e/external_classmethod_crash.py new file mode 100644 index 000000000..e9842a5e5 --- /dev/null +++ b/tests/functional/e/external_classmethod_crash.py @@ -0,0 +1,21 @@ +# 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/functional/i/init_return_from_inner_function.py b/tests/functional/i/init_return_from_inner_function.py new file mode 100644 index 000000000..769d5ac96 --- /dev/null +++ b/tests/functional/i/init_return_from_inner_function.py @@ -0,0 +1,12 @@ +# 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/functional/i/inner_classes.py b/tests/functional/i/inner_classes.py new file mode 100644 index 000000000..24a2edb80 --- /dev/null +++ b/tests/functional/i/inner_classes.py @@ -0,0 +1,33 @@ +# 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/functional/l/lambda_use_before_assign.py b/tests/functional/l/lambda_use_before_assign.py new file mode 100644 index 000000000..af2775cae --- /dev/null +++ b/tests/functional/l/lambda_use_before_assign.py @@ -0,0 +1,8 @@ +"""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/functional/m/metaclass_attr_access.py b/tests/functional/m/metaclass_attr_access.py new file mode 100644 index 000000000..149e07812 --- /dev/null +++ b/tests/functional/m/metaclass_attr_access.py @@ -0,0 +1,20 @@ +# 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/functional/n/no/no_warning_docstring.py b/tests/functional/n/no/no_warning_docstring.py new file mode 100644 index 000000000..315eeeaab --- /dev/null +++ b/tests/functional/n/no/no_warning_docstring.py @@ -0,0 +1,42 @@ +''' 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/functional/o/object_as_class_attribute.py b/tests/functional/o/object_as_class_attribute.py new file mode 100644 index 000000000..71cd027b7 --- /dev/null +++ b/tests/functional/o/object_as_class_attribute.py @@ -0,0 +1,18 @@ +# 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/functional/o/overloaded_operator.py b/tests/functional/o/overloaded_operator.py new file mode 100644 index 000000000..3a158b00b --- /dev/null +++ b/tests/functional/o/overloaded_operator.py @@ -0,0 +1,21 @@ +# 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/functional/p/property_affectation_py26.py b/tests/functional/p/property_affectation_py26.py new file mode 100644 index 000000000..60118bbf6 --- /dev/null +++ b/tests/functional/p/property_affectation_py26.py @@ -0,0 +1,24 @@ +# 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/functional/y/yield_assign_py25.py b/tests/functional/y/yield_assign_py25.py new file mode 100644 index 000000000..6a5ae00b2 --- /dev/null +++ b/tests/functional/y/yield_assign_py25.py @@ -0,0 +1,21 @@ +"""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/functional/y/yield_return_mix.py b/tests/functional/y/yield_return_mix.py new file mode 100644 index 000000000..8e050f0f0 --- /dev/null +++ b/tests/functional/y/yield_return_mix.py @@ -0,0 +1,8 @@ +""" module doc """ +# pylint: disable=useless-return +__revision__ = None + +def somegen(): + """this kind of mix is OK""" + yield 1 + return 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 diff --git a/tests/test_func.py b/tests/test_func.py index 6cc5dbd87..170055918 100644 --- a/tests/test_func.py +++ b/tests/test_func.py @@ -120,7 +120,7 @@ def gen_tests(filter_rgx): tests.append((module_file, messages_file, dependencies)) if UPDATE_FILE.exists(): return tests - assert len(tests) < 49, "Please do not add new test cases here." + assert len(tests) < 28, "Please do not add new test cases here." return tests -- cgit v1.2.1