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/s | |
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/s')
-rw-r--r-- | tests/functional/s/self/self_cls_assignment.py | 5 | ||||
-rw-r--r-- | tests/functional/s/self/self_cls_assignment.txt | 10 | ||||
-rw-r--r-- | tests/functional/s/signature_differs.py | 4 | ||||
-rw-r--r-- | tests/functional/s/singledispatch_functions.py | 5 | ||||
-rw-r--r-- | tests/functional/s/singledispatch_functions.txt | 10 | ||||
-rw-r--r-- | tests/functional/s/slots_checks.py | 50 | ||||
-rw-r--r-- | tests/functional/s/socketerror_import.py | 4 | ||||
-rw-r--r-- | tests/functional/s/statement_without_effect.py | 4 | ||||
-rw-r--r-- | tests/functional/s/statement_without_effect_py36.py | 4 | ||||
-rw-r--r-- | tests/functional/s/string/string_formatting.py | 12 | ||||
-rw-r--r-- | tests/functional/s/string/string_formatting_error.py | 1 | ||||
-rw-r--r-- | tests/functional/s/string/string_formatting_error.txt | 28 | ||||
-rw-r--r-- | tests/functional/s/subclassed_final_class_py38.py | 2 | ||||
-rw-r--r-- | tests/functional/s/super/super_checks.py | 18 | ||||
-rw-r--r-- | tests/functional/s/suspicious_str_strip_call.py | 2 |
15 files changed, 78 insertions, 81 deletions
diff --git a/tests/functional/s/self/self_cls_assignment.py b/tests/functional/s/self/self_cls_assignment.py index a9da8767c..820531c61 100644 --- a/tests/functional/s/self/self_cls_assignment.py +++ b/tests/functional/s/self/self_cls_assignment.py @@ -1,8 +1,7 @@ """Warning about assigning self/cls variable.""" -from __future__ import print_function -# pylint: disable=too-few-public-methods, useless-object-inheritance +# pylint: disable=too-few-public-methods -class Foo(object): +class Foo: """Class with methods that check for self/cls assignment""" # pylint: disable=no-self-argument diff --git a/tests/functional/s/self/self_cls_assignment.txt b/tests/functional/s/self/self_cls_assignment.txt index efc6b5f95..dd3383e38 100644 --- a/tests/functional/s/self/self_cls_assignment.txt +++ b/tests/functional/s/self/self_cls_assignment.txt @@ -1,5 +1,5 @@ -self-cls-assignment:11:8:11:17:Foo.self_foo:Invalid assignment to bar_ in method:UNDEFINED -self-cls-assignment:15:8:15:19:Foo.self_foofoo:Invalid assignment to self in method:UNDEFINED -self-cls-assignment:16:8:16:27:Foo.self_foofoo:Invalid assignment to self in method:UNDEFINED -self-cls-assignment:22:8:22:20:Foo.cls_foo:Invalid assignment to cls in method:UNDEFINED -self-cls-assignment:45:12:45:24:TestNonLocal.function._set_param:Invalid assignment to self in method:UNDEFINED +self-cls-assignment:10:8:10:17:Foo.self_foo:Invalid assignment to bar_ in method:UNDEFINED +self-cls-assignment:14:8:14:19:Foo.self_foofoo:Invalid assignment to self in method:UNDEFINED +self-cls-assignment:15:8:15:27:Foo.self_foofoo:Invalid assignment to self in method:UNDEFINED +self-cls-assignment:21:8:21:20:Foo.cls_foo:Invalid assignment to cls in method:UNDEFINED +self-cls-assignment:44:12:44:24:TestNonLocal.function._set_param:Invalid assignment to self in method:UNDEFINED diff --git a/tests/functional/s/signature_differs.py b/tests/functional/s/signature_differs.py index 45631bbd6..929921cf3 100644 --- a/tests/functional/s/signature_differs.py +++ b/tests/functional/s/signature_differs.py @@ -1,6 +1,6 @@ -# pylint: disable=too-few-public-methods, missing-docstring, useless-object-inheritance +# pylint: disable=too-few-public-methods, missing-docstring -class Abcd(object): +class Abcd: def __init__(self): self.aarg = False diff --git a/tests/functional/s/singledispatch_functions.py b/tests/functional/s/singledispatch_functions.py index cfd4d873c..931bfd30d 100644 --- a/tests/functional/s/singledispatch_functions.py +++ b/tests/functional/s/singledispatch_functions.py @@ -1,6 +1,5 @@ # pylint: disable=missing-docstring,import-error,unused-import,assignment-from-no-return -# pylint: disable=invalid-name, too-few-public-methods, useless-object-inheritance -from __future__ import print_function +# pylint: disable=invalid-name, too-few-public-methods from UNINFERABLE import uninferable_func try: @@ -11,7 +10,7 @@ except ImportError: my_single_dispatch = singledispatch -class FakeSingleDispatch(object): +class FakeSingleDispatch: @staticmethod def register(function): diff --git a/tests/functional/s/singledispatch_functions.txt b/tests/functional/s/singledispatch_functions.txt index 88973375f..93fc30496 100644 --- a/tests/functional/s/singledispatch_functions.txt +++ b/tests/functional/s/singledispatch_functions.txt @@ -1,5 +1,5 @@ -unused-variable:60:4:60:10:_:Unused variable 'unused':UNDEFINED -unused-argument:65:24:65:27:not_single_dispatch:Unused argument 'arg':HIGH -unused-argument:70:24:70:27:bad_single_dispatch:Unused argument 'arg':HIGH -function-redefined:75:0:75:23:bad_single_dispatch:function already defined line 70:UNDEFINED -unused-argument:75:24:75:27:bad_single_dispatch:Unused argument 'arg':HIGH +unused-variable:59:4:59:10:_:Unused variable 'unused':UNDEFINED +unused-argument:64:24:64:27:not_single_dispatch:Unused argument 'arg':HIGH +unused-argument:69:24:69:27:bad_single_dispatch:Unused argument 'arg':HIGH +function-redefined:74:0:74:23:bad_single_dispatch:function already defined line 69:UNDEFINED +unused-argument:74:24:74:27:bad_single_dispatch:Unused argument 'arg':HIGH diff --git a/tests/functional/s/slots_checks.py b/tests/functional/s/slots_checks.py index 2cae34acd..e8d55d967 100644 --- a/tests/functional/s/slots_checks.py +++ b/tests/functional/s/slots_checks.py @@ -1,6 +1,6 @@ """ Checks that classes uses valid __slots__ """ -# pylint: disable=too-few-public-methods, missing-docstring, useless-object-inheritance +# pylint: disable=too-few-public-methods, missing-docstring # pylint: disable=using-constant-test, wrong-import-position, no-else-return, line-too-long, unused-private-member from collections import deque @@ -11,26 +11,26 @@ def func(): return [str(var) for var in range(3)] -class NotIterable(object): +class NotIterable: def __iter_(self): """ do nothing """ -class Good(object): +class Good: __slots__ = () -class SecondGood(object): +class SecondGood: __slots__ = [] -class ThirdGood(object): +class ThirdGood: __slots__ = ['a'] -class FourthGood(object): +class FourthGood: __slots__ = (f'a{i}' for i in range(10)) -class FifthGood(object): +class FifthGood: __slots__ = deque(["a", "b", "c"]) -class SixthGood(object): +class SixthGood: __slots__ = {"a": "b", "c": "d"} class SeventhGood: @@ -45,34 +45,34 @@ class EigthGood: else: __slots__ = ("y",) -class Bad(object): # [invalid-slots] +class Bad: # [invalid-slots] __slots__ = list -class SecondBad(object): # [invalid-slots] +class SecondBad: # [invalid-slots] __slots__ = 1 -class ThirdBad(object): +class ThirdBad: __slots__ = ('a', 2) # [invalid-slots-object] -class FourthBad(object): # [invalid-slots] +class FourthBad: # [invalid-slots] __slots__ = NotIterable() -class FifthBad(object): +class FifthBad: __slots__ = ("a", "b", "") # [invalid-slots-object] -class SixthBad(object): # [single-string-used-for-slots] +class SixthBad: # [single-string-used-for-slots] __slots__ = "a" -class SeventhBad(object): # [single-string-used-for-slots] +class SeventhBad: # [single-string-used-for-slots] __slots__ = ('foo') -class EighthBad(object): # [single-string-used-for-slots] +class EighthBad: # [single-string-used-for-slots] __slots__ = deque.__name__ -class NinthBad(object): +class NinthBad: __slots__ = [str] # [invalid-slots-object] -class TenthBad(object): +class TenthBad: __slots__ = [1 + 2 + 3] # [invalid-slots-object] class EleventhBad: # [invalid-slots] @@ -86,10 +86,10 @@ class TwelfthBad: # [invalid-slots] else: __slots__ = None -class PotentiallyGood(object): +class PotentiallyGood: __slots__ = func() -class PotentiallySecondGood(object): +class PotentiallySecondGood: __slots__ = ('a', deque.__name__) @@ -100,17 +100,17 @@ class Metaclass(type): yield str(value) -class IterableClass(object, metaclass=Metaclass): +class IterableClass(metaclass=Metaclass): pass -class PotentiallyThirdGood(object): +class PotentiallyThirdGood: __slots__ = IterableClass -class PotentiallyFourthGood(object): +class PotentiallyFourthGood: __slots__ = Good.__slots__ -class ValueInSlotConflict(object): +class ValueInSlotConflict: __slots__ = ('first', 'second', 'third', 'fourth') # [class-variable-slots-conflict, class-variable-slots-conflict, class-variable-slots-conflict] first = None @@ -122,7 +122,7 @@ class ValueInSlotConflict(object): return self.third -class Parent(object): +class Parent: first = 42 diff --git a/tests/functional/s/socketerror_import.py b/tests/functional/s/socketerror_import.py index df5de2957..f9403d966 100644 --- a/tests/functional/s/socketerror_import.py +++ b/tests/functional/s/socketerror_import.py @@ -1,6 +1,6 @@ """ds""" -from __future__ import absolute_import, print_function + from socket import error -__revision__ = '$Id: socketerror_import.py,v 1.2 2005-12-28 14:58:22 syt Exp $' + print(error) diff --git a/tests/functional/s/statement_without_effect.py b/tests/functional/s/statement_without_effect.py index 31fc7250f..60694ff96 100644 --- a/tests/functional/s/statement_without_effect.py +++ b/tests/functional/s/statement_without_effect.py @@ -1,5 +1,5 @@ """Test for statements without effects.""" -# pylint: disable=too-few-public-methods, useless-object-inheritance, unnecessary-comprehension, unnecessary-ellipsis, use-list-literal +# pylint: disable=too-few-public-methods, unnecessary-comprehension, unnecessary-ellipsis, use-list-literal # +1:[pointless-string-statement] """inline doc string should use a separated message""" @@ -35,7 +35,7 @@ to_be().title # [expression-not-assigned] GOOD_ATTRIBUTE_DOCSTRING = 42 """Module level attribute docstring is fine. """ -class ClassLevelAttributeTest(object): +class ClassLevelAttributeTest: """ test attribute docstrings. """ good_attribute_docstring = 24 diff --git a/tests/functional/s/statement_without_effect_py36.py b/tests/functional/s/statement_without_effect_py36.py index 59745ce2b..841ed5bd9 100644 --- a/tests/functional/s/statement_without_effect_py36.py +++ b/tests/functional/s/statement_without_effect_py36.py @@ -1,8 +1,8 @@ """Test for statements without effects.""" -# pylint: disable=too-few-public-methods, useless-object-inheritance +# pylint: disable=too-few-public-methods -class ClassLevelAttributeTest(object): +class ClassLevelAttributeTest: """ test attribute docstrings. """ some_variable: int = 42 diff --git a/tests/functional/s/string/string_formatting.py b/tests/functional/s/string/string_formatting.py index b72e9f676..cb88680e1 100644 --- a/tests/functional/s/string/string_formatting.py +++ b/tests/functional/s/string/string_formatting.py @@ -1,32 +1,32 @@ """Test for Python 3 string formatting error"""
# pylint: disable=too-few-public-methods, import-error, unused-argument, line-too-long,
-# pylint: disable=useless-object-inheritance, consider-using-f-string
+# pylint: disable=consider-using-f-string
import os
import sys
import logging
from missing import Missing
-class Custom(object):
+class Custom:
""" Has a __getattr__ """
def __getattr__(self, _):
return self
-class Test(object):
+class Test:
""" test format attribute access """
custom = Custom()
ids = [1, 2, 3, [4, 5, 6]]
-class Getitem(object):
+class Getitem:
""" test custom getitem for lookup access """
def __getitem__(self, index):
return 42
-class ReturnYes(object):
+class ReturnYes:
""" can't be properly inferred """
missing = Missing()
@@ -181,7 +181,7 @@ def issue373(): """
Ignore any object coming from an argument.
"""
- class SomeClass(object):
+ class SomeClass:
""" empty docstring. """
def __init__(self, opts=None):
self.opts = opts
diff --git a/tests/functional/s/string/string_formatting_error.py b/tests/functional/s/string/string_formatting_error.py index 681fedd56..0e57946ee 100644 --- a/tests/functional/s/string/string_formatting_error.py +++ b/tests/functional/s/string/string_formatting_error.py @@ -1,6 +1,5 @@ """test string format error""" # pylint: disable=unsupported-binary-operation,line-too-long, consider-using-f-string -from __future__ import print_function PARG_1 = PARG_2 = PARG_3 = 1 diff --git a/tests/functional/s/string/string_formatting_error.txt b/tests/functional/s/string/string_formatting_error.txt index fec5246d1..19653c617 100644 --- a/tests/functional/s/string/string_formatting_error.txt +++ b/tests/functional/s/string/string_formatting_error.txt @@ -1,15 +1,15 @@ -too-few-format-args:10:10:10:46:pprint:Not enough arguments for format string:UNDEFINED -too-many-format-args:11:10:11:33:pprint:Too many arguments for format string:UNDEFINED -mixed-format-string:12:10:12:54:pprint:Mixing named and unnamed conversion specifiers in format string:UNDEFINED -missing-format-string-key:13:10:13:49:pprint:Missing key 'PARG_2' in format string dictionary:UNDEFINED -unused-format-string-key:14:10:14:73:pprint:Unused key 'PARG_3' in format string dictionary:UNDEFINED -bad-format-string-key:15:10:15:54:pprint:Format string dictionary key should be a string, not 2:UNDEFINED -missing-format-string-key:15:10:15:54:pprint:Missing key 'PARG_2' in format string dictionary:UNDEFINED -format-needs-mapping:16:10:16:42:pprint:Expected mapping for format string, not Tuple:UNDEFINED -format-needs-mapping:17:10:17:42:pprint:Expected mapping for format string, not List:UNDEFINED -bad-format-character:18:10:18:24:pprint:Unsupported format character 'z' (0x7a) at index 2:UNDEFINED -truncated-format-string:19:10:19:38:pprint:Format string ends in middle of conversion specifier:UNDEFINED -format-string-without-interpolation:21:10:21:27:pprint:Using formatting for a string that does not have any interpolated variables:UNDEFINED +too-few-format-args:9:10:9:46:pprint:Not enough arguments for format string:UNDEFINED +too-many-format-args:10:10:10:33:pprint:Too many arguments for format string:UNDEFINED +mixed-format-string:11:10:11:54:pprint:Mixing named and unnamed conversion specifiers in format string:UNDEFINED +missing-format-string-key:12:10:12:49:pprint:Missing key 'PARG_2' in format string dictionary:UNDEFINED +unused-format-string-key:13:10:13:73:pprint:Unused key 'PARG_3' in format string dictionary:UNDEFINED +bad-format-string-key:14:10:14:54:pprint:Format string dictionary key should be a string, not 2:UNDEFINED +missing-format-string-key:14:10:14:54:pprint:Missing key 'PARG_2' in format string dictionary:UNDEFINED +format-needs-mapping:15:10:15:42:pprint:Expected mapping for format string, not Tuple:UNDEFINED +format-needs-mapping:16:10:16:42:pprint:Expected mapping for format string, not List:UNDEFINED +bad-format-character:17:10:17:24:pprint:Unsupported format character 'z' (0x7a) at index 2:UNDEFINED +truncated-format-string:18:10:18:38:pprint:Format string ends in middle of conversion specifier:UNDEFINED +format-string-without-interpolation:20:10:20:27:pprint:Using formatting for a string that does not have any interpolated variables:UNDEFINED +format-string-without-interpolation:21:10:21:23:pprint:Using formatting for a string that does not have any interpolated variables:UNDEFINED format-string-without-interpolation:22:10:22:23:pprint:Using formatting for a string that does not have any interpolated variables:UNDEFINED -format-string-without-interpolation:23:10:23:23:pprint:Using formatting for a string that does not have any interpolated variables:UNDEFINED -format-string-without-interpolation:24:10:24:25:pprint:Using formatting for a string that does not have any interpolated variables:UNDEFINED +format-string-without-interpolation:23:10:23:25:pprint:Using formatting for a string that does not have any interpolated variables:UNDEFINED diff --git a/tests/functional/s/subclassed_final_class_py38.py b/tests/functional/s/subclassed_final_class_py38.py index 6aca83352..60e9a7625 100644 --- a/tests/functional/s/subclassed_final_class_py38.py +++ b/tests/functional/s/subclassed_final_class_py38.py @@ -1,7 +1,7 @@ """Since Python version 3.8, a class decorated with typing.final cannot be subclassed """ -# pylint: disable=useless-object-inheritance, missing-docstring, too-few-public-methods +# pylint: disable=missing-docstring, too-few-public-methods from typing import final diff --git a/tests/functional/s/super/super_checks.py b/tests/functional/s/super/super_checks.py index ca35d52ae..050fd3c81 100644 --- a/tests/functional/s/super/super_checks.py +++ b/tests/functional/s/super/super_checks.py @@ -1,4 +1,4 @@ -# pylint: disable=too-few-public-methods,import-error, missing-docstring, useless-object-inheritance +# pylint: disable=too-few-public-methods,import-error, missing-docstring # pylint: disable=useless-super-delegation,wrong-import-position,invalid-name, wrong-import-order # pylint: disable=super-with-arguments from unknown import Missing @@ -12,7 +12,7 @@ class Aaaa: def __init__(self): super(Aaaa, self).__init__() -class NewAaaa(object): +class NewAaaa: """old style""" def hop(self): """hop""" @@ -36,19 +36,19 @@ class WrongNameRegression(Py3kAaaa): def __init__(self): super(Missing, self).__init__() # [bad-super-call] -class Getattr(object): +class Getattr: """ crash """ name = NewAaaa -class CrashSuper(object): +class CrashSuper: """ test a crash with this checker """ def __init__(self): super(Getattr.name, self).__init__() # [bad-super-call] -class Empty(object): +class Empty: """Just an empty class.""" -class SuperDifferentScope(object): +class SuperDifferentScope: """Don'emit bad-super-call when the super call is in another scope. For reference, see https://bitbucket.org/logilab/pylint/issue/403. """ @@ -72,7 +72,7 @@ class UnknownBases(Missing): # Test that we are detecting proper super errors. -class BaseClass(object): +class BaseClass: not_a_method = 42 @@ -114,12 +114,12 @@ except AttributeError: super(TimeoutExpired, self).__init__("", returncode) -class SuperWithType(object): +class SuperWithType: """type(self) may lead to recursion loop in derived classes""" def __init__(self): super(type(self), self).__init__() # [bad-super-call] -class SuperWithSelfClass(object): +class SuperWithSelfClass: """self.__class__ may lead to recursion loop in derived classes""" def __init__(self): super(self.__class__, self).__init__() # [bad-super-call] diff --git a/tests/functional/s/suspicious_str_strip_call.py b/tests/functional/s/suspicious_str_strip_call.py index 40684cc1d..1c49ca534 100644 --- a/tests/functional/s/suspicious_str_strip_call.py +++ b/tests/functional/s/suspicious_str_strip_call.py @@ -1,6 +1,6 @@ """Suspicious str.strip calls.""" # pylint: disable=redundant-u-string-prefix -__revision__ = 1 + ''.strip('yo') ''.strip() |