diff options
author | Mark Byrne <31762852+mbyrnepr2@users.noreply.github.com> | 2022-08-18 22:13:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-18 22:13:23 +0200 |
commit | 82d55aee4ae3718b77fbec70e5d7d80c70adfa27 (patch) | |
tree | b8947faffa21e7401d176cc822ffe75191a18576 /tests/functional/a | |
parent | a2c57ec06070b6d2485082e3a131a087f8d6d921 (diff) | |
download | pylint-git-82d55aee4ae3718b77fbec70e5d7d80c70adfa27.tar.gz |
Remove Python 2 code from the tests & refactor (#7320)
- Refactor Classes which inherit from `object`.
- Remove `import print_function from __future__`.
- Remove assignments to `__revision__` from the functional test module when it is never used throughout the module.
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Diffstat (limited to 'tests/functional/a')
17 files changed, 116 insertions, 119 deletions
diff --git a/tests/functional/a/abstract/abstract_abc_methods.py b/tests/functional/a/abstract/abstract_abc_methods.py index d63389c50..4d4af2cdb 100644 --- a/tests/functional/a/abstract/abstract_abc_methods.py +++ b/tests/functional/a/abstract/abstract_abc_methods.py @@ -1,9 +1,9 @@ """ This should not warn about `prop` being abstract in Child """
-# pylint: disable=too-few-public-methods, useless-object-inheritance
+# pylint: disable=too-few-public-methods
import abc
-class Parent(object):
+class Parent:
"""Abstract Base Class """
__metaclass__ = abc.ABCMeta
diff --git a/tests/functional/a/abstract/abstract_class_instantiated.py b/tests/functional/a/abstract/abstract_class_instantiated.py index bf1666a85..289870c9d 100644 --- a/tests/functional/a/abstract/abstract_class_instantiated.py +++ b/tests/functional/a/abstract/abstract_class_instantiated.py @@ -4,31 +4,31 @@ abstract methods. """ # pylint: disable=too-few-public-methods, missing-docstring -# pylint: disable=abstract-method, import-error, useless-object-inheritance +# pylint: disable=abstract-method, import-error import abc import weakref from lala import Bala -class GoodClass(object, metaclass=abc.ABCMeta): +class GoodClass(metaclass=abc.ABCMeta): pass -class SecondGoodClass(object, metaclass=abc.ABCMeta): +class SecondGoodClass(metaclass=abc.ABCMeta): def test(self): """ do nothing. """ -class ThirdGoodClass(object, metaclass=abc.ABCMeta): +class ThirdGoodClass(metaclass=abc.ABCMeta): """ This should not raise the warning. """ def test(self): raise NotImplementedError() -class BadClass(object, metaclass=abc.ABCMeta): +class BadClass(metaclass=abc.ABCMeta): @abc.abstractmethod def test(self): """ do nothing. """ -class SecondBadClass(object, metaclass=abc.ABCMeta): +class SecondBadClass(metaclass=abc.ABCMeta): @property @abc.abstractmethod def test(self): @@ -38,7 +38,7 @@ class ThirdBadClass(SecondBadClass): pass -class Structure(object, metaclass=abc.ABCMeta): +class Structure(metaclass=abc.ABCMeta): @abc.abstractmethod def __iter__(self): pass @@ -112,12 +112,12 @@ def main(): if 1: # pylint: disable=using-constant-test - class FourthBadClass(object, metaclass=abc.ABCMeta): + class FourthBadClass(metaclass=abc.ABCMeta): def test(self): pass else: - class FourthBadClass(object, metaclass=abc.ABCMeta): + class FourthBadClass(metaclass=abc.ABCMeta): @abc.abstractmethod def test(self): diff --git a/tests/functional/a/abstract/abstract_class_instantiated_in_class.py b/tests/functional/a/abstract/abstract_class_instantiated_in_class.py index daaa3b689..e31f9470d 100644 --- a/tests/functional/a/abstract/abstract_class_instantiated_in_class.py +++ b/tests/functional/a/abstract/abstract_class_instantiated_in_class.py @@ -1,11 +1,11 @@ """Don't warn if the class is instantiated in its own body."""
-# pylint: disable=missing-docstring, useless-object-inheritance
+# pylint: disable=missing-docstring
import abc
-class Ala(object, metaclass=abc.ABCMeta):
+class Ala(metaclass=abc.ABCMeta):
@abc.abstractmethod
def bala(self):
diff --git a/tests/functional/a/abstract/abstract_method.py b/tests/functional/a/abstract/abstract_method.py index 2ea751141..75ffda220 100644 --- a/tests/functional/a/abstract/abstract_method.py +++ b/tests/functional/a/abstract/abstract_method.py @@ -1,12 +1,12 @@ """Test abstract-method warning.""" -from __future__ import print_function + # pylint: disable=missing-docstring -# pylint: disable=too-few-public-methods, useless-object-inheritance +# pylint: disable=too-few-public-methods import abc -class Abstract(object): +class Abstract: def aaaa(self): """should be overridden in concrete class""" raise NotImplementedError() @@ -51,7 +51,7 @@ class Concrete(Abstract): # [abstract-method] """overridden form Abstract""" -class Structure(object, metaclass=abc.ABCMeta): +class Structure(metaclass=abc.ABCMeta): @abc.abstractmethod def __iter__(self): pass 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 index c723eb099..ebdb76c6a 100644 --- a/tests/functional/a/access/access_attr_before_def_false_positive.py +++ b/tests/functional/a/access/access_attr_before_def_false_positive.py @@ -1,11 +1,10 @@ # pylint: disable=invalid-name,too-many-public-methods,attribute-defined-outside-init -# pylint: disable=useless-object-inheritance,too-few-public-methods,deprecated-module +# pylint: disable=too-few-public-methods,deprecated-module """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 @@ -37,7 +36,7 @@ class SeeTelnet(telnetlib.Telnet): if len(match) > maxLength: maxLength = len(match) -class Base(object): +class Base: """bla bla""" dougloup_papa = None @@ -66,7 +65,7 @@ class Derived(Base): self.dougloup_moi = True -class QoSALConnection(object): +class QoSALConnection: """blabla""" _the_instance = None @@ -79,7 +78,7 @@ class QoSALConnection(object): def __init__(self): pass -class DefinedOutsideInit(object): +class DefinedOutsideInit: """use_attr is seen as the method defining attr because its in first position """ diff --git a/tests/functional/a/access/access_member_before_definition.py b/tests/functional/a/access/access_member_before_definition.py index 224e6e43e..6ffebdd03 100644 --- a/tests/functional/a/access/access_member_before_definition.py +++ b/tests/functional/a/access/access_member_before_definition.py @@ -1,8 +1,8 @@ # pylint: disable=missing-docstring,too-few-public-methods,invalid-name -# pylint: disable=attribute-defined-outside-init, useless-object-inheritance +# pylint: disable=attribute-defined-outside-init -class Aaaa(object): +class Aaaa: """class with attributes defined in wrong order""" def __init__(self): @@ -11,7 +11,7 @@ class Aaaa(object): self._var3 = var1 -class Bbbb(object): +class Bbbb: A = 23 B = A @@ -31,7 +31,7 @@ class Bbbb(object): return attr -class Mixin(object): +class Mixin: def test_mixin(self): """Don't emit access-member-before-definition for mixin classes.""" if self.already_defined: diff --git a/tests/functional/a/access/access_to__name__.py b/tests/functional/a/access/access_to__name__.py index 9f16d3a7a..18445f7b4 100644 --- a/tests/functional/a/access/access_to__name__.py +++ b/tests/functional/a/access/access_to__name__.py @@ -1,8 +1,8 @@ -# pylint: disable=too-few-public-methods, useless-object-inheritance +# pylint: disable=too-few-public-methods """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""" @@ -10,7 +10,7 @@ class Aaaa: print(self.__name__) # [no-member] print(self.__class__.__name__) -class NewClass(object): +class NewClass: """new class""" def __new__(cls, *args, **kwargs): diff --git a/tests/functional/a/access/access_to_protected_members.py b/tests/functional/a/access/access_to_protected_members.py index a521a6467..9ca221628 100644 --- a/tests/functional/a/access/access_to_protected_members.py +++ b/tests/functional/a/access/access_to_protected_members.py @@ -1,9 +1,8 @@ # pylint: disable=too-few-public-methods, super-init-not-called -# pylint: disable=no-classmethod-decorator,useless-object-inheritance +# pylint: disable=no-classmethod-decorator """Test external access to protected class members.""" -from __future__ import print_function -class MyClass(object): +class MyClass: """Class with protected members.""" _cls_protected = 5 @@ -44,7 +43,7 @@ INST._cls_protected = 3 # [protected-access] print(INST._cls_protected) # [protected-access] -class Issue1031(object): +class Issue1031: """Test for GitHub issue 1031""" _attr = 1 @@ -59,7 +58,7 @@ class Issue1031(object): return None -class Issue1802(object): +class Issue1802: """Test for GitHub issue 1802""" def __init__(self, value): self._foo = value @@ -101,7 +100,7 @@ class Issue1802(object): return False -class Issue1159OtherClass(object): +class Issue1159OtherClass: """Test for GitHub issue 1159""" _foo = 0 @@ -110,7 +109,7 @@ class Issue1159OtherClass(object): self._bar = 0 -class Issue1159(object): +class Issue1159: """Test for GitHub issue 1159""" _foo = 0 diff --git a/tests/functional/a/access/access_to_protected_members.txt b/tests/functional/a/access/access_to_protected_members.txt index d9dfd96ce..b49a915a4 100644 --- a/tests/functional/a/access/access_to_protected_members.txt +++ b/tests/functional/a/access/access_to_protected_members.txt @@ -1,28 +1,28 @@ -protected-access:19:14:19:31:MyClass.test:Access to a protected member _haha of a client class:UNDEFINED -protected-access:41:0:41:15::Access to a protected member _protected of a client class:UNDEFINED -protected-access:42:6:42:21::Access to a protected member _protected of a client class:UNDEFINED -protected-access:43:0:43:19::Access to a protected member _cls_protected of a client class:UNDEFINED -protected-access:44:6:44:25::Access to a protected member _cls_protected of a client class:UNDEFINED -protected-access:58:19:58:40:Issue1031.incorrect_access:Access to a protected member _protected of a client class:UNDEFINED -protected-access:72:48:72:63:Issue1802.__eq__:Access to a protected member __private of a client class:UNDEFINED -protected-access:80:32:80:42:Issue1802.not_in_special:Access to a protected member _foo of a client class:UNDEFINED -protected-access:100:32:100:42:Issue1802.__fake_special__:Access to a protected member _foo of a client class:UNDEFINED -protected-access:162:8:162:21:Issue1159.access_other_attr:Access to a protected member _bar of a client class:UNDEFINED -protected-access:163:12:163:25:Issue1159.access_other_attr:Access to a protected member _foo of a client class:UNDEFINED -no-member:194:12:194:25:Issue1159Subclass.access_missing_member:Instance of 'Issue1159Subclass' has no '_baz' member; maybe '_bar'?:INFERENCE -protected-access:194:12:194:25:Issue1159Subclass.access_missing_member:Access to a protected member _baz of a client class:UNDEFINED -attribute-defined-outside-init:203:8:203:21:Issue1159Subclass.assign_missing_member:Attribute '_qux' defined outside __init__:UNDEFINED -protected-access:212:8:212:21:Issue1159Subclass.access_other_attr:Access to a protected member _bar of a client class:UNDEFINED -protected-access:213:12:213:25:Issue1159Subclass.access_other_attr:Access to a protected member _foo of a client class:UNDEFINED -protected-access:232:8:232:30:Issue3066.foobar:Access to a protected member _attr of a client class:UNDEFINED -protected-access:233:8:233:37:Issue3066.foobar:Access to a protected member _attr of a client class:UNDEFINED -protected-access:236:8:236:29:Issue3066.foobar:Access to a protected member _bar of a client class:UNDEFINED -protected-access:237:8:237:36:Issue3066.foobar:Access to a protected member _bar of a client class:UNDEFINED -protected-access:247:12:247:27:Issue3066.Aclass.foobar:Access to a protected member _attr of a client class:UNDEFINED -protected-access:249:12:249:41:Issue3066.Aclass.foobar:Access to a protected member _attr of a client class:UNDEFINED -protected-access:251:12:251:26:Issue3066.Aclass.foobar:Access to a protected member _bar of a client class:UNDEFINED -protected-access:253:12:253:40:Issue3066.Aclass.foobar:Access to a protected member _bar of a client class:UNDEFINED -protected-access:267:16:267:31:Issue3066.Aclass.Bclass.foobar:Access to a protected member _attr of a client class:UNDEFINED -protected-access:268:16:268:38:Issue3066.Aclass.Bclass.foobar:Access to a protected member _attr of a client class:UNDEFINED -protected-access:271:16:271:30:Issue3066.Aclass.Bclass.foobar:Access to a protected member _bar of a client class:UNDEFINED -protected-access:272:16:272:37:Issue3066.Aclass.Bclass.foobar:Access to a protected member _bar of a client class:UNDEFINED +protected-access:18:14:18:31:MyClass.test:Access to a protected member _haha of a client class:UNDEFINED +protected-access:40:0:40:15::Access to a protected member _protected of a client class:UNDEFINED +protected-access:41:6:41:21::Access to a protected member _protected of a client class:UNDEFINED +protected-access:42:0:42:19::Access to a protected member _cls_protected of a client class:UNDEFINED +protected-access:43:6:43:25::Access to a protected member _cls_protected of a client class:UNDEFINED +protected-access:57:19:57:40:Issue1031.incorrect_access:Access to a protected member _protected of a client class:UNDEFINED +protected-access:71:48:71:63:Issue1802.__eq__:Access to a protected member __private of a client class:UNDEFINED +protected-access:79:32:79:42:Issue1802.not_in_special:Access to a protected member _foo of a client class:UNDEFINED +protected-access:99:32:99:42:Issue1802.__fake_special__:Access to a protected member _foo of a client class:UNDEFINED +protected-access:161:8:161:21:Issue1159.access_other_attr:Access to a protected member _bar of a client class:UNDEFINED +protected-access:162:12:162:25:Issue1159.access_other_attr:Access to a protected member _foo of a client class:UNDEFINED +no-member:193:12:193:25:Issue1159Subclass.access_missing_member:Instance of 'Issue1159Subclass' has no '_baz' member; maybe '_bar'?:INFERENCE +protected-access:193:12:193:25:Issue1159Subclass.access_missing_member:Access to a protected member _baz of a client class:UNDEFINED +attribute-defined-outside-init:202:8:202:21:Issue1159Subclass.assign_missing_member:Attribute '_qux' defined outside __init__:UNDEFINED +protected-access:211:8:211:21:Issue1159Subclass.access_other_attr:Access to a protected member _bar of a client class:UNDEFINED +protected-access:212:12:212:25:Issue1159Subclass.access_other_attr:Access to a protected member _foo of a client class:UNDEFINED +protected-access:231:8:231:30:Issue3066.foobar:Access to a protected member _attr of a client class:UNDEFINED +protected-access:232:8:232:37:Issue3066.foobar:Access to a protected member _attr of a client class:UNDEFINED +protected-access:235:8:235:29:Issue3066.foobar:Access to a protected member _bar of a client class:UNDEFINED +protected-access:236:8:236:36:Issue3066.foobar:Access to a protected member _bar of a client class:UNDEFINED +protected-access:246:12:246:27:Issue3066.Aclass.foobar:Access to a protected member _attr of a client class:UNDEFINED +protected-access:248:12:248:41:Issue3066.Aclass.foobar:Access to a protected member _attr of a client class:UNDEFINED +protected-access:250:12:250:26:Issue3066.Aclass.foobar:Access to a protected member _bar of a client class:UNDEFINED +protected-access:252:12:252:40:Issue3066.Aclass.foobar:Access to a protected member _bar of a client class:UNDEFINED +protected-access:266:16:266:31:Issue3066.Aclass.Bclass.foobar:Access to a protected member _attr of a client class:UNDEFINED +protected-access:267:16:267:38:Issue3066.Aclass.Bclass.foobar:Access to a protected member _attr of a client class:UNDEFINED +protected-access:270:16:270:30:Issue3066.Aclass.Bclass.foobar:Access to a protected member _bar of a client class:UNDEFINED +protected-access:271:16:271:37:Issue3066.Aclass.Bclass.foobar:Access to a protected member _bar of a client class:UNDEFINED diff --git a/tests/functional/a/arguments.py b/tests/functional/a/arguments.py index 9e533161e..a065e517e 100644 --- a/tests/functional/a/arguments.py +++ b/tests/functional/a/arguments.py @@ -1,5 +1,5 @@ # pylint: disable=too-few-public-methods, missing-docstring,import-error,wrong-import-position -# pylint: disable=wrong-import-order, useless-object-inheritance,unnecessary-lambda, consider-using-f-string +# pylint: disable=wrong-import-order, unnecessary-lambda, consider-using-f-string # pylint: disable=unnecessary-lambda-assignment def decorator(fun): @@ -7,7 +7,7 @@ def decorator(fun): return fun -class DemoClass(object): +class DemoClass: """Test class for method invocations.""" @staticmethod @@ -84,7 +84,7 @@ def method_tests(): # Test a regression (issue #234) import sys -class Text(object): +class Text: """ Regression """ if sys.version_info > (3,): @@ -98,7 +98,7 @@ class Text(object): Text() -class TestStaticMethod(object): +class TestStaticMethod: @staticmethod def test(first, second=None, **kwargs): @@ -112,7 +112,7 @@ class TestStaticMethod(object): self.test(42, 42, 42) # [too-many-function-args] -class TypeCheckConstructor(object): +class TypeCheckConstructor: def __init__(self, first, second): self.first = first self.second = second @@ -125,7 +125,7 @@ class TypeCheckConstructor(object): type(self)(first=1, second=2) -class Test(object): +class Test: """ lambda needs Test instance as first argument """ lam = lambda self, icon: (self, icon) @@ -139,7 +139,7 @@ Test().lam() # [no-value-for-parameter] # Don't emit a redundant-keyword-arg for this example, # it's perfectly valid -class Issue642(object): +class Issue642: attr = 0 def __str__(self): return "{self.attr}".format(self=self) diff --git a/tests/functional/a/arguments_differ.py b/tests/functional/a/arguments_differ.py index 1dbd40086..f579f89a6 100644 --- a/tests/functional/a/arguments_differ.py +++ b/tests/functional/a/arguments_differ.py @@ -1,7 +1,7 @@ """Test that we are emitting arguments-differ when the arguments are different."""
-# pylint: disable=missing-docstring, too-few-public-methods, unused-argument,useless-super-delegation, useless-object-inheritance, unused-private-member
+# pylint: disable=missing-docstring, too-few-public-methods, unused-argument,useless-super-delegation, unused-private-member
-class Parent(object):
+class Parent:
def test(self):
pass
@@ -13,7 +13,7 @@ class Child(Parent): pass
-class ParentDefaults(object):
+class ParentDefaults:
def test(self, arg=None, barg=None):
pass
@@ -24,7 +24,7 @@ class ChildDefaults(ParentDefaults): pass
-class Classmethod(object):
+class Classmethod:
@classmethod
def func(cls, data):
@@ -54,7 +54,7 @@ class Builtins(dict): pass
-class Varargs(object):
+class Varargs:
def has_kwargs(self, arg, **kwargs):
pass
@@ -72,7 +72,7 @@ class VarargsChild(Varargs): "Addition of kwargs does not violate LSP, but first argument's name has changed."
-class Super(object):
+class Super:
def __init__(self):
pass
@@ -108,7 +108,7 @@ class Sub(Super): pass
-class Staticmethod(object):
+class Staticmethod:
@staticmethod
def func(data):
@@ -122,7 +122,7 @@ class StaticmethodChild(Staticmethod): return data
-class Property(object):
+class Property:
@property
def close(self):
@@ -145,7 +145,7 @@ class StaticmethodChild2(Staticmethod): super().func(data)
-class SuperClass(object):
+class SuperClass:
@staticmethod
def impl(arg1, arg2, **kwargs):
@@ -169,7 +169,7 @@ class MyClass(SuperClass): return arg1 + arg2
-class FirstHasArgs(object):
+class FirstHasArgs:
def test(self, *args):
pass
@@ -181,7 +181,7 @@ class SecondChangesArgs(FirstHasArgs): pass
-class Positional(object):
+class Positional:
def test(self, first, second):
pass
@@ -195,7 +195,7 @@ class PositionalChild(Positional): """
super().test(args[0], args[1])
-class Mixed(object):
+class Mixed:
def mixed(self, first, second, *, third, fourth):
pass
@@ -219,7 +219,7 @@ class MixedChild2(Mixed): super().mixed(first, *args, third, **kwargs)
-class HasSpecialMethod(object):
+class HasSpecialMethod:
def __getitem__(self, key):
return key
@@ -232,7 +232,7 @@ class OverridesSpecialMethod(HasSpecialMethod): return cheie + 1
-class ParentClass(object):
+class ParentClass:
def meth(self, arg, arg1):
raise NotImplementedError
diff --git a/tests/functional/a/arguments_renamed.py b/tests/functional/a/arguments_renamed.py index b9145eb9a..73105f824 100644 --- a/tests/functional/a/arguments_renamed.py +++ b/tests/functional/a/arguments_renamed.py @@ -1,4 +1,4 @@ -# pylint: disable=unused-argument, missing-docstring, line-too-long, useless-object-inheritance, too-few-public-methods +# pylint: disable=unused-argument, missing-docstring, line-too-long, too-few-public-methods import enum @@ -27,7 +27,7 @@ class Banana(Fruit): def eat_with_condiment(self, fruit_name: str, condiment: Condiment, error: str): # [arguments-differ] print(f"Eating a fruit named {fruit_name} with {condiment}") -class Parent(object): +class Parent: def test(self, arg): return arg + 1 @@ -51,7 +51,7 @@ class Child2(Parent): def kwargs_test(self, *, var1, kw2): #[arguments-differ] print(f"keyword parameters are {var1} and {kw2}.") -class ParentDefaults(object): +class ParentDefaults: def test1(self, arg, barg): print(f"Argument values are {arg} and {barg}") diff --git a/tests/functional/a/assigning/assigning_non_slot.py b/tests/functional/a/assigning/assigning_non_slot.py index d4e9d1d45..6e1fcd255 100644 --- a/tests/functional/a/assigning/assigning_non_slot.py +++ b/tests/functional/a/assigning/assigning_non_slot.py @@ -1,15 +1,15 @@ """ Checks assigning attributes not found in class slots will trigger assigning-non-slot warning. """ -# pylint: disable=too-few-public-methods, missing-docstring, import-error, useless-object-inheritance, redundant-u-string-prefix, unnecessary-dunder-call +# pylint: disable=too-few-public-methods, missing-docstring, import-error, redundant-u-string-prefix, unnecessary-dunder-call from collections import deque from missing import Unknown -class Empty(object): +class Empty: """ empty """ -class Bad(object): +class Bad: """ missing not in slots. """ __slots__ = ['member'] @@ -17,7 +17,7 @@ class Bad(object): def __init__(self): self.missing = 42 # [assigning-non-slot] -class Bad2(object): +class Bad2: """ missing not in slots """ __slots__ = [deque.__name__, 'member'] @@ -45,7 +45,7 @@ class Good(Empty): def __init__(self): self.missing = 42 -class Good2(object): +class Good2: """ Using __dict__ in slots will be safe. """ __slots__ = ['__dict__', 'comp'] @@ -54,7 +54,7 @@ class Good2(object): self.comp = 4 self.missing = 5 -class PropertyGood(object): +class PropertyGood: """ Using properties is safe. """ __slots__ = ['tmp', '_value'] @@ -71,7 +71,7 @@ class PropertyGood(object): def __init__(self): self.test = 42 -class PropertyGood2(object): +class PropertyGood2: """ Using properties in the body of the class is safe. """ __slots__ = ['_value'] @@ -87,7 +87,7 @@ class PropertyGood2(object): def __init__(self): self.test = 24 -class UnicodeSlots(object): +class UnicodeSlots: """Using unicode objects in __slots__ is okay. On Python 3.3 onward, u'' is equivalent to '', @@ -100,7 +100,7 @@ class UnicodeSlots(object): self.second = 24 -class DataDescriptor(object): +class DataDescriptor: def __init__(self, name, default=''): self.__name = name self.__default = default @@ -112,12 +112,12 @@ class DataDescriptor(object): setattr(inst, self.__name, value) -class NonDataDescriptor(object): +class NonDataDescriptor: def __get__(self, inst, cls): return 42 -class SlotsWithDescriptor(object): +class SlotsWithDescriptor: __slots__ = ['_err'] data_descriptor = DataDescriptor('_err') non_data_descriptor = NonDataDescriptor() @@ -132,18 +132,18 @@ def dont_emit_for_descriptors(): inst.non_data_descriptor = 'lala' # [assigning-non-slot] -class ClassWithSlots(object): +class ClassWithSlots: __slots__ = ['foobar'] -class ClassReassigningDunderClass(object): +class ClassReassigningDunderClass: __slots__ = ['foobar'] def release(self): self.__class__ = ClassWithSlots -class ClassReassingingInvalidLayoutClass(object): +class ClassReassingingInvalidLayoutClass: __slots__ = [] def release(self): @@ -175,7 +175,7 @@ class Cls(Generic[TYPE]): self.value = value -class ClassDefiningSetattr(object): +class ClassDefiningSetattr: __slots__ = ["foobar"] def __init__(self): diff --git a/tests/functional/a/assignment/assignment_from_no_return_2.py b/tests/functional/a/assignment/assignment_from_no_return_2.py index fd1489dbc..f42b66545 100644 --- a/tests/functional/a/assignment/assignment_from_no_return_2.py +++ b/tests/functional/a/assignment/assignment_from_no_return_2.py @@ -1,4 +1,4 @@ -# pylint: disable=useless-return, useless-object-inheritance, condition-evals-to-constant +# pylint: disable=useless-return, condition-evals-to-constant """check assignment to function call where the function doesn't return 'E1111': ('Assigning to function call which doesn\'t return', @@ -9,7 +9,6 @@ inferred function returns nothing but None.'), """ -from __future__ import generators, print_function def func_no_return(): """function without return""" @@ -50,7 +49,7 @@ def generator(): A = generator() -class Abstract(object): +class Abstract: """bla bla""" def abstract_method(self): diff --git a/tests/functional/a/assignment/assignment_from_no_return_2.txt b/tests/functional/a/assignment/assignment_from_no_return_2.txt index b6aec14da..bc1fff92b 100644 --- a/tests/functional/a/assignment/assignment_from_no_return_2.txt +++ b/tests/functional/a/assignment/assignment_from_no_return_2.txt @@ -1,4 +1,4 @@ -assignment-from-no-return:18:0:18:20::Assigning result of a function call, where the function has no return:UNDEFINED -assignment-from-none:26:0:26:22::Assigning result of a function call, where the function returns None:UNDEFINED -assignment-from-none:33:0:33:31::Assigning result of a function call, where the function returns None:UNDEFINED -assignment-from-none:36:0:36:14::Assigning result of a function call, where the function returns None:INFERENCE +assignment-from-no-return:17:0:17:20::Assigning result of a function call, where the function has no return:UNDEFINED +assignment-from-none:25:0:25:22::Assigning result of a function call, where the function returns None:UNDEFINED +assignment-from-none:32:0:32:31::Assigning result of a function call, where the function returns None:UNDEFINED +assignment-from-none:35:0:35:14::Assigning result of a function call, where the function returns None:INFERENCE diff --git a/tests/functional/a/async_functions.py b/tests/functional/a/async_functions.py index e2b005f28..315055e9c 100644 --- a/tests/functional/a/async_functions.py +++ b/tests/functional/a/async_functions.py @@ -1,6 +1,6 @@ """Check that Python 3.5's async functions are properly analyzed by Pylint.""" # pylint: disable=missing-docstring,invalid-name,too-few-public-methods -# pylint: disable=using-constant-test, useless-object-inheritance +# pylint: disable=using-constant-test async def next(): # [redefined-builtin] pass @@ -9,14 +9,14 @@ async def some_function(arg1, arg2): # [unused-argument] await arg1 -class OtherClass(object): +class OtherClass: @staticmethod def test(): return 42 -class Class(object): +class Class: async def some_method(self): super(OtherClass, self).test() # [bad-super-call] diff --git a/tests/functional/a/attribute_defined_outside_init.py b/tests/functional/a/attribute_defined_outside_init.py index 1cb319c61..0b6f1ef49 100644 --- a/tests/functional/a/attribute_defined_outside_init.py +++ b/tests/functional/a/attribute_defined_outside_init.py @@ -1,6 +1,6 @@ -# pylint: disable=missing-docstring,too-few-public-methods,invalid-name, useless-object-inheritance +# pylint: disable=missing-docstring,too-few-public-methods,invalid-name -class A(object): +class A: def __init__(self): self.x = 0 @@ -26,7 +26,7 @@ class B(A): self.z = 44 # [attribute-defined-outside-init] -class C(object): +class C: def __init__(self): self._init() @@ -35,7 +35,7 @@ class C(object): self.z = 44 -class D(object): +class D: def setUp(self): self.set_z() @@ -44,7 +44,7 @@ class D(object): self.z = 42 -class E(object): +class E: def __init__(self): i = self._init @@ -54,7 +54,7 @@ class E(object): self.z = 44 -class Mixin(object): +class Mixin: def test_mixin(self): """Don't emit attribute-defined-outside-init for mixin classes.""" |