summaryrefslogtreecommitdiff
path: root/tests/functional/c
diff options
context:
space:
mode:
authorMark Byrne <31762852+mbyrnepr2@users.noreply.github.com>2022-08-18 22:13:23 +0200
committerGitHub <noreply@github.com>2022-08-18 22:13:23 +0200
commit82d55aee4ae3718b77fbec70e5d7d80c70adfa27 (patch)
treeb8947faffa21e7401d176cc822ffe75191a18576 /tests/functional/c
parenta2c57ec06070b6d2485082e3a131a087f8d6d921 (diff)
downloadpylint-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/c')
-rw-r--r--tests/functional/c/cellvar_escaping_loop.py2
-rw-r--r--tests/functional/c/class_attributes.py6
-rw-r--r--tests/functional/c/class_members_py30.py14
-rw-r--r--tests/functional/c/class_scope.py7
-rw-r--r--tests/functional/c/class_scope.txt14
-rw-r--r--tests/functional/c/classes_meth_could_be_a_function.py8
-rw-r--r--tests/functional/c/classes_protected_member_access.py6
-rw-r--r--tests/functional/c/comparison_with_callable.py4
-rw-r--r--tests/functional/c/confidence_filter.py5
-rw-r--r--tests/functional/c/confidence_filter.txt2
-rw-r--r--tests/functional/c/consider/consider_iterating_dictionary.py4
-rw-r--r--tests/functional/c/consider/consider_using_enumerate.py8
-rw-r--r--tests/functional/c/crash_missing_module_type.py4
-rw-r--r--tests/functional/c/ctor_arguments.py12
14 files changed, 47 insertions, 49 deletions
diff --git a/tests/functional/c/cellvar_escaping_loop.py b/tests/functional/c/cellvar_escaping_loop.py
index 0de26bede..8781e6c5c 100644
--- a/tests/functional/c/cellvar_escaping_loop.py
+++ b/tests/functional/c/cellvar_escaping_loop.py
@@ -1,6 +1,6 @@
# pylint: disable=unnecessary-comprehension,missing-docstring,too-few-public-methods,unnecessary-direct-lambda-call
"""Tests for loopvar-in-closure."""
-from __future__ import print_function
+
from enum import Enum
diff --git a/tests/functional/c/class_attributes.py b/tests/functional/c/class_attributes.py
index 1d41f9d7a..ea3858876 100644
--- a/tests/functional/c/class_attributes.py
+++ b/tests/functional/c/class_attributes.py
@@ -1,8 +1,8 @@
"""Test that valid class attribute doesn't trigger errors"""
-__revision__ = 'sponge bob'
-# pylint: disable=useless-object-inheritance,missing-docstring,too-few-public-methods
+# pylint: disable=missing-docstring,too-few-public-methods
-class Clazz(object):
+
+class Clazz:
"dummy class"
def __init__(self):
diff --git a/tests/functional/c/class_members_py30.py b/tests/functional/c/class_members_py30.py
index afaee5872..0d65331f9 100644
--- a/tests/functional/c/class_members_py30.py
+++ b/tests/functional/c/class_members_py30.py
@@ -1,7 +1,7 @@
""" Various tests for class members access. """
-# pylint: disable=too-few-public-methods,import-error,missing-docstring, wrong-import-position,wrong-import-order, useless-object-inheritance, unnecessary-dunder-call
+# pylint: disable=too-few-public-methods,import-error,missing-docstring, wrong-import-position,wrong-import-order, unnecessary-dunder-call
from missing import Missing
-class MyClass(object):
+class MyClass:
"""class docstring"""
def __init__(self):
@@ -16,7 +16,7 @@ class MyClass(object):
self.nonexistent1.truc() # [no-member]
self.nonexistent2[1] = 'hehe' # [no-member]
-class XYZMixin(object):
+class XYZMixin:
"""access to undefined members should be ignored in mixin classes by
default
"""
@@ -24,14 +24,14 @@ class XYZMixin(object):
print(self.nonexistent)
-class NewClass(object):
+class NewClass:
"""use object.__setattr__"""
def __init__(self):
self.__setattr__('toto', 'tutu')
from abc import ABCMeta
-class TestMetaclass(object, metaclass=ABCMeta):
+class TestMetaclass(metaclass=ABCMeta):
""" Test attribute access for metaclasses. """
class Metaclass(type):
@@ -40,7 +40,7 @@ class Metaclass(type):
def test(cls):
""" classmethod """
-class UsingMetaclass(object, metaclass=Metaclass):
+class UsingMetaclass(metaclass=Metaclass):
""" empty """
TestMetaclass.register(int)
@@ -55,7 +55,7 @@ class NoKnownBases(Missing):
NoKnownBases().lalala()
-class MetaClass(object):
+class MetaClass:
"""Look some methods in the implicit metaclass."""
@classmethod
diff --git a/tests/functional/c/class_scope.py b/tests/functional/c/class_scope.py
index 74db27443..85ee86fbf 100644
--- a/tests/functional/c/class_scope.py
+++ b/tests/functional/c/class_scope.py
@@ -1,9 +1,8 @@
-# pylint: disable=too-few-public-methods, useless-object-inheritance, unnecessary-lambda-assignment
+# pylint: disable=too-few-public-methods, unnecessary-lambda-assignment
"""check for scope problems"""
-__revision__ = None
-class Well(object):
+class Well:
"""well"""
attr = 42
get_attr = lambda arg=attr: arg * 24
@@ -13,7 +12,7 @@ class Well(object):
bad_lambda = lambda: get_attr_bad # [undefined-variable]
bad_gen = list(attr + i for i in range(10)) # [undefined-variable]
- class Data(object):
+ class Data:
"""base hidden class"""
class Sub(Data):
"""whaou, is Data found???"""
diff --git a/tests/functional/c/class_scope.txt b/tests/functional/c/class_scope.txt
index d065c1b97..081387a22 100644
--- a/tests/functional/c/class_scope.txt
+++ b/tests/functional/c/class_scope.txt
@@ -1,7 +1,7 @@
-undefined-variable:11:39:11:46:Well.<lambda>:Undefined variable 'revattr':UNDEFINED
-used-before-assignment:11:30:11:37:Well.<lambda>:Using variable 'revattr' before assignment:HIGH
-undefined-variable:13:25:13:37:Well.<lambda>:Undefined variable 'get_attr_bad':UNDEFINED
-undefined-variable:14:19:14:23:Well:Undefined variable 'attr':UNDEFINED
-undefined-variable:20:15:20:19:Well.Sub:Undefined variable 'Data':UNDEFINED
-undefined-variable:23:15:23:18:Well.func:Undefined variable 'Sub':UNDEFINED
-undefined-variable:41:22:41:26:Wrong.work:Undefined variable 'self':UNDEFINED
+undefined-variable:10:39:10:46:Well.<lambda>:Undefined variable 'revattr':UNDEFINED
+used-before-assignment:10:30:10:37:Well.<lambda>:Using variable 'revattr' before assignment:HIGH
+undefined-variable:12:25:12:37:Well.<lambda>:Undefined variable 'get_attr_bad':UNDEFINED
+undefined-variable:13:19:13:23:Well:Undefined variable 'attr':UNDEFINED
+undefined-variable:19:15:19:19:Well.Sub:Undefined variable 'Data':UNDEFINED
+undefined-variable:22:15:22:18:Well.func:Undefined variable 'Sub':UNDEFINED
+undefined-variable:40:22:40:26:Wrong.work:Undefined variable 'self':UNDEFINED
diff --git a/tests/functional/c/classes_meth_could_be_a_function.py b/tests/functional/c/classes_meth_could_be_a_function.py
index 4a967a5b5..82f627dfb 100644
--- a/tests/functional/c/classes_meth_could_be_a_function.py
+++ b/tests/functional/c/classes_meth_could_be_a_function.py
@@ -1,20 +1,20 @@
-# pylint: disable=missing-docstring,too-few-public-methods,useless-object-inheritance
+# pylint: disable=missing-docstring,too-few-public-methods
"""
#2479
R0201 (formerly W0212), Method could be a function shouldn't be emitted in case
like factory method pattern
"""
-__revision__ = 1
-class XAsub(object):
+
+class XAsub:
pass
class XBsub(XAsub):
pass
class XCsub(XAsub):
pass
-class Aimpl(object):
+class Aimpl:
# 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
diff --git a/tests/functional/c/classes_protected_member_access.py b/tests/functional/c/classes_protected_member_access.py
index 516efd7d4..fe540be85 100644
--- a/tests/functional/c/classes_protected_member_access.py
+++ b/tests/functional/c/classes_protected_member_access.py
@@ -1,10 +1,10 @@
"""
#3123: W0212 false positive on static method
"""
-__revision__ = 1
-# pylint: disable=no-classmethod-decorator, no-staticmethod-decorator, useless-object-inheritance
-class A3123(object):
+
+# pylint: disable=no-classmethod-decorator, no-staticmethod-decorator
+class A3123:
"""oypuee"""
_protected = 1
def __init__(self):
diff --git a/tests/functional/c/comparison_with_callable.py b/tests/functional/c/comparison_with_callable.py
index 777594d75..1e8ea5d90 100644
--- a/tests/functional/c/comparison_with_callable.py
+++ b/tests/functional/c/comparison_with_callable.py
@@ -1,4 +1,4 @@
-# pylint: disable = disallowed-name, missing-docstring, useless-return, invalid-name, line-too-long, useless-object-inheritance, comparison-of-constants
+# pylint: disable = disallowed-name, missing-docstring, useless-return, invalid-name, line-too-long, comparison-of-constants
def foo():
return None
@@ -18,7 +18,7 @@ if foo() == goo():
pass
-class FakeClass(object):
+class FakeClass:
def __init__(self):
self._fake_prop = 'fake it till you make it!!'
diff --git a/tests/functional/c/confidence_filter.py b/tests/functional/c/confidence_filter.py
index 42351998d..5f8dfd4f0 100644
--- a/tests/functional/c/confidence_filter.py
+++ b/tests/functional/c/confidence_filter.py
@@ -1,8 +1,7 @@
"""Test for the confidence filter."""
-from __future__ import print_function
-# pylint: disable=useless-object-inheritance
-class Client(object):
+
+class Client:
"""use provider class"""
def __init__(self):
diff --git a/tests/functional/c/confidence_filter.txt b/tests/functional/c/confidence_filter.txt
index 86a0f28c4..ede967f68 100644
--- a/tests/functional/c/confidence_filter.txt
+++ b/tests/functional/c/confidence_filter.txt
@@ -1 +1 @@
-no-member:16:6:16:18::Instance of 'Client' has no 'foo' member:INFERENCE
+no-member:15:6:15:18::Instance of 'Client' has no 'foo' member:INFERENCE
diff --git a/tests/functional/c/consider/consider_iterating_dictionary.py b/tests/functional/c/consider/consider_iterating_dictionary.py
index 149810042..fdb76e869 100644
--- a/tests/functional/c/consider/consider_iterating_dictionary.py
+++ b/tests/functional/c/consider/consider_iterating_dictionary.py
@@ -1,11 +1,11 @@
# pylint: disable=missing-docstring, expression-not-assigned, too-few-public-methods
-# pylint: disable=no-member, import-error, line-too-long, useless-object-inheritance
+# pylint: disable=no-member, import-error, line-too-long
# pylint: disable=unnecessary-comprehension, use-dict-literal, use-implicit-booleaness-not-comparison
from unknown import Unknown
-class CustomClass(object):
+class CustomClass:
def keys(self):
return []
diff --git a/tests/functional/c/consider/consider_using_enumerate.py b/tests/functional/c/consider/consider_using_enumerate.py
index 359bb29fa..352669f6a 100644
--- a/tests/functional/c/consider/consider_using_enumerate.py
+++ b/tests/functional/c/consider/consider_using_enumerate.py
@@ -1,6 +1,6 @@
"""Emit a message for iteration through range and len is encountered."""
-# pylint: disable=missing-docstring, import-error, useless-object-inheritance, unsubscriptable-object, too-few-public-methods, unnecessary-list-index-lookup
+# pylint: disable=missing-docstring, import-error, unsubscriptable-object, too-few-public-methods, unnecessary-list-index-lookup
def bad():
iterable = [1, 2, 3]
@@ -10,7 +10,7 @@ def bad():
yield iterable[obj]
-class Bad(object):
+class Bad:
def __iter__(self):
iterable = [1, 2, 3]
@@ -60,7 +60,7 @@ def good():
yield test([1, 2, 3])
-class Good(object):
+class Good:
def __iter__(self):
# Should not suggest enumerate on self
@@ -74,7 +74,7 @@ def does_not_crash_on_range_without_args():
# False negative described in #3657
# https://github.com/PyCQA/pylint/issues/3657
-class MyClass(object):
+class MyClass:
def __init__(self):
self.my_list = []
diff --git a/tests/functional/c/crash_missing_module_type.py b/tests/functional/c/crash_missing_module_type.py
index d80d27afc..94b9af6ec 100644
--- a/tests/functional/c/crash_missing_module_type.py
+++ b/tests/functional/c/crash_missing_module_type.py
@@ -1,12 +1,12 @@
""" Test for a crash found in
https://bitbucket.org/logilab/astroid/issue/45/attributeerror-module-object-has-no#comment-11944673
"""
-# pylint: disable=invalid-name, too-few-public-methods, redefined-outer-name, useless-object-inheritance
+# pylint: disable=invalid-name, too-few-public-methods, redefined-outer-name
def decor(trop):
""" decorator """
return trop
-class Foo(object):
+class Foo:
""" Class """
@decor
def prop(self):
diff --git a/tests/functional/c/ctor_arguments.py b/tests/functional/c/ctor_arguments.py
index ee10413e3..954d9b8b2 100644
--- a/tests/functional/c/ctor_arguments.py
+++ b/tests/functional/c/ctor_arguments.py
@@ -2,18 +2,18 @@
Based on tests/functional/a/arguments.py
"""
-# pylint: disable=missing-docstring,too-few-public-methods,super-init-not-called,useless-object-inheritance
+# pylint: disable=missing-docstring,too-few-public-methods,super-init-not-called
-class Class1Arg(object):
+class Class1Arg:
def __init__(self, first_argument):
"""one argument function"""
-class Class3Arg(object):
+class Class3Arg:
def __init__(self, first_argument, second_argument, third_argument):
"""three arguments function"""
-class ClassDefaultArg(object):
+class ClassDefaultArg:
def __init__(self, one=1, two=2):
"""function with default value"""
@@ -27,7 +27,7 @@ class ClassAllArgs(Class1Arg):
class ClassMultiInheritance(Class1Arg, Class3Arg):
pass
-class ClassNew(object):
+class ClassNew:
def __new__(cls, first_argument, kwarg=None):
return first_argument, kwarg
@@ -85,7 +85,7 @@ class BuiltinExc(Exception):
BuiltinExc(42, 24, badarg=1) # [too-many-function-args,unexpected-keyword-arg]
-class Clsmethod(object):
+class Clsmethod:
def __init__(self, first, second):
self.first = first
self.second = second