14
0
forked from pool/python-pylint

Accepting request 913328 from home:bnavigator:branches:devel:languages:python

- Update to 2.9.6
  * Fix a false positive undefined-variable when variable name in
    decoration matches function argument
- Many more release notes from 2.9.0 to 2.9.5:
  * https://github.com/PyCQA/pylint/releases
  * Added time.clock to deprecated functions/methods for python 3.3
  * No longer emit consider-using-with for ThreadPoolExecutor and
    ProcessPoolExecutor as they have legitimate use cases without a
    with block.
  * The similarity checker no longer add three trailing whitespaces
    for empty lines in its report.
  * Python 3.10 is now supported.
  * Added various deprecated functions/methods for python 3.10,
    3.7, 3.6 and 3.3
  * setuptools_scm has been removed and replaced by tbump in order
    to not have hidden runtime dependencies to setuptools
- Drop pylint-pr4450-import-init.patch
- Add pylint-pr4816-astroid27.patch
  * gh#PyCQA/pylint#4816
  * remove astroid upper bound -- the previous pin broke a lot of
    packages through the pkg_resources check

OBS-URL: https://build.opensuse.org/request/show/913328
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-pylint?expand=0&rev=126
This commit is contained in:
2021-08-20 13:19:59 +00:00
committed by Git OBS Bridge
parent b26a14df86
commit c5965e1f08
6 changed files with 398 additions and 59 deletions

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0a049c5d47b629d9070c3932d13bff482b12119b6a241a93bc460b0be16953c8
size 745073

3
pylint-2.9.6-gh.tar.gz Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:e6335c810ee3ff4b59e3990db49cf0d1e263e122b766853755436d88133c9496
size 779390

View File

@@ -1,47 +0,0 @@
From 4ad9037c5e2fde8f598ad92b24d07cb7abac6c2b Mon Sep 17 00:00:00 2001
From: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Date: Fri, 7 May 2021 14:45:42 +0200
Subject: [PATCH] Fix broken tests
---
tests/test_self.py | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/tests/test_self.py b/tests/test_self.py
index 55cfbbc827..7f26ddeb3a 100644
--- a/tests/test_self.py
+++ b/tests/test_self.py
@@ -1077,20 +1077,24 @@ def test_allow_import_of_files_found_in_modules_during_parallel_check(self, tmpd
code=0,
)
- def test_can_list_directories_without_dunder_init(self, tmpdir):
+ @staticmethod
+ def test_can_list_directories_without_dunder_init(tmpdir):
test_directory = tmpdir / "test_directory"
test_directory.mkdir()
spam_module = test_directory / "spam.py"
spam_module.write("'Empty'")
- with tmpdir.as_cwd():
- self._runtest(
- [
- "--disable=missing-docstring, missing-final-newline",
- "test_directory",
- ],
- code=0,
- )
+ subprocess.check_output(
+ [
+ sys.executable,
+ "-m",
+ "pylint",
+ "--disable=missing-docstring, missing-final-newline",
+ "test_directory",
+ ],
+ cwd=str(tmpdir),
+ stderr=subprocess.PIPE,
+ )
def test_jobs_score(self):
path = join(HERE, "regrtest_data", "unused_variable.py")

View File

@@ -0,0 +1,359 @@
From 12097bdb8912abff4edd41e92fffcf780c9cccbc Mon Sep 17 00:00:00 2001
From: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Date: Sun, 8 Aug 2021 20:53:56 +0200
Subject: [PATCH 1/5] Fix functional test no-value-for-parameter when
instancing an enum
---
tests/functional/a/arguments_renamed.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: pylint-2.9.6/tests/functional/a/arguments_renamed.py
===================================================================
--- pylint-2.9.6.orig/tests/functional/a/arguments_renamed.py
+++ pylint-2.9.6/tests/functional/a/arguments_renamed.py
@@ -17,7 +17,7 @@ class Orange(Fruit):
def brew(self, orange_name: str): # [arguments-renamed]
print(f"Brewing an orange named {orange_name}")
- def eat_with_condiment(self, orange_name: str, condiment: Condiment()): #[arguments-renamed]
+ def eat_with_condiment(self, orange_name: str, condiment: Condiment): #[arguments-renamed]
print(f"Eating a fruit named {orange_name} with {condiment}")
class Banana(Fruit):
Index: pylint-2.9.6/tests/functional/e/enum_subclasses.py
===================================================================
--- pylint-2.9.6.orig/tests/functional/e/enum_subclasses.py
+++ pylint-2.9.6/tests/functional/e/enum_subclasses.py
@@ -1,9 +1,10 @@
-# pylint: disable=missing-docstring
-from enum import Enum, IntEnum
+# pylint: disable=missing-docstring, invalid-name
+from enum import Enum, IntEnum, auto
class Issue1932(IntEnum):
"""https://github.com/PyCQA/pylint/issues/1932"""
+
FOO = 1
def whats_my_name(self):
@@ -12,8 +13,67 @@ class Issue1932(IntEnum):
class Issue2062(Enum):
"""https://github.com/PyCQA/pylint/issues/2062"""
+
FOO = 1
BAR = 2
def __str__(self):
return self.name.lower()
+
+
+class OrderedEnum(Enum):
+ def __ge__(self, other):
+ if self.__class__ is other.__class__:
+ return self.value >= other.value # line 11
+ return NotImplemented
+
+ def __gt__(self, other):
+ if self.__class__ is other.__class__:
+ return self.value > other.value # line 16
+ return NotImplemented
+
+
+class Color(OrderedEnum):
+ red = 0
+ green = 1
+
+
+class People(Enum):
+ jack = 0
+ john = 1
+
+
+print(Color.red.value) # line 29
+print(People.jack.name)
+
+
+class BaseEnum(Enum):
+ def some_behavior(self):
+ pass
+
+
+class MyEnum(BaseEnum):
+
+ FOO = 1
+ BAR = 2
+
+
+print(MyEnum.FOO.value)
+
+class TestBase(Enum):
+ """Adds a special method to enums."""
+
+ def hello_pylint(self) -> str:
+ """False positive."""
+ return self.name
+
+
+class TestEnum(TestBase):
+ """Tests the false positive for enums."""
+
+ a = auto()
+ b = auto()
+
+
+test_enum = TestEnum.a
+assert test_enum.hello_pylint() == test_enum.name
Index: pylint-2.9.6/tests/functional/d/dataclass_with_default_factory.py
===================================================================
--- pylint-2.9.6.orig/tests/functional/d/dataclass_with_default_factory.py
+++ pylint-2.9.6/tests/functional/d/dataclass_with_default_factory.py
@@ -1,6 +1,9 @@
-"""A test script the confuses pylint."""
-# https://github.com/PyCQA/pylint/issues/2605
+"""Various regression tests for dataclasses."""
+# See issues:
+# - https://github.com/PyCQA/pylint/issues/2605
+# - https://github.com/PyCQA/pylint/issues/2698
from dataclasses import dataclass, field
+import dataclasses as dc
@dataclass
@@ -13,3 +16,28 @@ class Test:
TEST = Test()
TEST.test.append(1)
print(TEST.test[0])
+
+
+@dc.dataclass # Note the use of dc instead of dataclasses
+class Test2:
+ """Test dataclass that uses a renamed import of dataclasses"""
+ int_prop: int = dc.field(default=10)
+ list_prop: list = dc.field(default_factory=list)
+ dict_prop: dict = dc.field(default_factory=dict)
+
+
+TEST2 = Test2()
+for _ in TEST2.list_prop: # This is okay
+ pass
+
+
+TEST2.dict_prop["key"] = "value" # This is okay
+
+
+# Test2.int_prop is inferred as 10, not a Field
+print(Test2.int_prop + 1)
+for _ in Test2.int_prop: # [not-an-iterable]
+ pass
+
+
+Test2.int_prop["key"] = "value" # [unsupported-assignment-operation]
Index: pylint-2.9.6/tests/functional/d/dataclass_with_default_factory.txt
===================================================================
--- /dev/null
+++ pylint-2.9.6/tests/functional/d/dataclass_with_default_factory.txt
@@ -0,0 +1,2 @@
+not-an-iterable:39:9::Non-iterable value Test2.int_prop is used in an iterating context:HIGH
+unsupported-assignment-operation:43:0::'Test2.int_prop' does not support item assignment:HIGH
Index: pylint-2.9.6/tests/functional/i/invalid/invalid_name_issue_3405.py
===================================================================
--- /dev/null
+++ pylint-2.9.6/tests/functional/i/invalid/invalid_name_issue_3405.py
@@ -0,0 +1,11 @@
+""" Regression test for https://github.com/PyCQA/pylint/issues/3405. """
+
+import dataclasses
+from typing import ClassVar
+
+
+@dataclasses.dataclass
+class Foo:
+ """ClassVar attribute should be matched against class-attribute-rgx, not attr-rgx"""
+ # class-attribute-rgx='^y$'
+ x: ClassVar[int] = 0 # [invalid-name]
Index: pylint-2.9.6/tests/functional/i/invalid/invalid_name_issue_3405.rc
===================================================================
--- /dev/null
+++ pylint-2.9.6/tests/functional/i/invalid/invalid_name_issue_3405.rc
@@ -0,0 +1,9 @@
+[MESSAGES CONTROL]
+enable=invalid-name
+
+[BASIC]
+attr-rgx=^x$
+class-attribute-rgx=^y$
+
+[testoptions]
+min_pyver=3.7
Index: pylint-2.9.6/tests/functional/i/invalid/invalid_name_issue_3405.txt
===================================================================
--- /dev/null
+++ pylint-2.9.6/tests/functional/i/invalid/invalid_name_issue_3405.txt
@@ -0,0 +1 @@
+invalid-name:11:4:Foo:"Class attribute name ""x"" doesn't conform to '^y$' pattern":HIGH
Index: pylint-2.9.6/tests/functional/n/no/no_member_dataclasses.py
===================================================================
--- /dev/null
+++ pylint-2.9.6/tests/functional/n/no/no_member_dataclasses.py
@@ -0,0 +1,83 @@
+"""Test various regressions for dataclasses and no-member.
+"""
+# pylint: disable=missing-docstring, too-few-public-methods
+from abc import ABCMeta, abstractmethod
+from dataclasses import asdict, dataclass, field
+from typing import Any, Dict
+
+
+# https://github.com/PyCQA/pylint/issues/3754
+@dataclass(frozen=True)
+class DeploymentState(metaclass=ABCMeta):
+ type: str
+
+ @abstractmethod
+ def to_dict(self) -> Dict:
+ """
+ Serializes given DeploymentState instance to Dict.
+ :return:
+ """
+
+
+@dataclass(frozen=True)
+class DeploymentStateEcs(DeploymentState):
+ blue: Any
+ green: Any
+ candidate: Any
+
+ def to_dict(self) -> Dict:
+ return {
+ 'type': self.type, # No error here
+ 'blue': asdict(self.blue),
+ 'green': asdict(self.green),
+ 'candidate': self.candidate.value,
+ }
+
+
+@dataclass(frozen=True)
+class DeploymentStateLambda(DeploymentState):
+ current: Any
+ candidate: Any
+
+ def to_dict(self) -> Dict:
+ return {
+ 'type': self.type, # No error here
+ 'current': asdict(self.current),
+ 'candidate': asdict(self.candidate) if self.candidate else None,
+ }
+
+
+# https://github.com/PyCQA/pylint/issues/2600
+@dataclass
+class TestClass:
+ attr1: str
+ attr2: str
+ dict_prop: Dict[str, str] = field(default_factory=dict)
+
+ def some_func(self) -> None:
+ for key, value in self.dict_prop.items(): # No error here
+ print(key)
+ print(value)
+
+
+class TestClass2: # not a dataclass, field inferred to a Field
+ attr1: str
+ attr2: str
+ dict_prop: Dict[str, str] = field(default_factory=dict)
+
+ def some_func(self) -> None:
+ for key, value in self.dict_prop.items(): # [no-member]
+ print(key)
+ print(value)
+
+
+@dataclass
+class TestClass3:
+ attr1: str
+ attr2: str
+ dict_prop = field(default_factory=dict) # No type annotation, not treated as field
+
+ def some_func(self) -> None:
+ for key, value in self.dict_prop.items(): # [no-member]
+ print(key)
+ print(value)
Index: pylint-2.9.6/tests/functional/n/no/no_member_dataclasses.rc
===================================================================
--- /dev/null
+++ pylint-2.9.6/tests/functional/n/no/no_member_dataclasses.rc
@@ -0,0 +1,2 @@
+[testoptions]
+min_pyver=3.7
Index: pylint-2.9.6/tests/functional/n/no/no_member_dataclasses.txt
===================================================================
--- /dev/null
+++ pylint-2.9.6/tests/functional/n/no/no_member_dataclasses.txt
@@ -0,0 +1,2 @@
+no-member:69:26:TestClass2.some_func:Instance of 'Field' has no 'items' member:INFERENCE
+no-member:81:26:TestClass3.some_func:Instance of 'Field' has no 'items' member:INFERENCE
Index: pylint-2.9.6/tests/functional/t/too/too_many_instance_attributes.py
===================================================================
--- pylint-2.9.6.orig/tests/functional/t/too/too_many_instance_attributes.py
+++ pylint-2.9.6/tests/functional/t/too/too_many_instance_attributes.py
@@ -1,5 +1,6 @@
# pylint: disable=missing-docstring, too-few-public-methods, useless-object-inheritance
+
class Aaaa(object): # [too-many-instance-attributes]
def __init__(self):
Index: pylint-2.9.6/tests/functional/t/too/too_many_instance_attributes.txt
===================================================================
--- pylint-2.9.6.orig/tests/functional/t/too/too_many_instance_attributes.txt
+++ pylint-2.9.6/tests/functional/t/too/too_many_instance_attributes.txt
@@ -1 +1 @@
-too-many-instance-attributes:3:0:Aaaa:Too many instance attributes (21/7)
+too-many-instance-attributes:4:0:Aaaa:Too many instance attributes (21/7):HIGH
Index: pylint-2.9.6/setup.cfg
===================================================================
--- pylint-2.9.6.orig/setup.cfg
+++ pylint-2.9.6/setup.cfg
@@ -42,7 +42,7 @@ project_urls =
[options]
packages = find:
install_requires =
- astroid>=2.6.5,<2.7 # (You should also upgrade requirements_test_min.txt)
+ astroid>=2.7
isort>=4.2.5,<6
mccabe>=0.6,<0.7
toml>=0.7.1
Index: pylint-2.9.6/tests/functional/t/too/too_many_instance_attributes_py37.py
===================================================================
--- /dev/null
+++ pylint-2.9.6/tests/functional/t/too/too_many_instance_attributes_py37.py
@@ -0,0 +1,18 @@
+# pylint: disable=missing-docstring, too-few-public-methods, useless-object-inheritance
+from dataclasses import dataclass, InitVar
+
+# InitVars should not count as instance attributes (see issue #3754)
+# Default max_instance_attributes is 7
+@dataclass
+class Hello:
+ a_1: int
+ a_2: int
+ a_3: int
+ a_4: int
+ a_5: int
+ a_6: int
+ a_7: int
+ a_8: InitVar[int]
+
+ def __post_init__(self, a_8):
+ self.a_1 += a_8
Index: pylint-2.9.6/tests/functional/t/too/too_many_instance_attributes_py37.rc
===================================================================
--- /dev/null
+++ pylint-2.9.6/tests/functional/t/too/too_many_instance_attributes_py37.rc
@@ -0,0 +1,2 @@
+[testoptions]
+min_pyver=3.7

View File

@@ -1,3 +1,28 @@
-------------------------------------------------------------------
Fri Aug 20 10:03:42 UTC 2021 - Ben Greiner <code@bnavigator.de>
- Update to 2.9.6
* Fix a false positive undefined-variable when variable name in
decoration matches function argument
- Many more release notes from 2.9.0 to 2.9.5:
* https://github.com/PyCQA/pylint/releases
* Added time.clock to deprecated functions/methods for python 3.3
* No longer emit consider-using-with for ThreadPoolExecutor and
ProcessPoolExecutor as they have legitimate use cases without a
with block.
* The similarity checker no longer add three trailing whitespaces
for empty lines in its report.
* Python 3.10 is now supported.
* Added various deprecated functions/methods for python 3.10,
3.7, 3.6 and 3.3
* setuptools_scm has been removed and replaced by tbump in order
to not have hidden runtime dependencies to setuptools
- Drop pylint-pr4450-import-init.patch
- Add pylint-pr4816-astroid27.patch
* gh#PyCQA/pylint#4816
* remove astroid upper bound -- the previous pin broke a lot of
packages through the pkg_resources check
-------------------------------------------------------------------
Sun Jun 6 12:04:43 UTC 2021 - Dirk Müller <dmueller@suse.com>

View File

@@ -20,29 +20,28 @@
%bcond_without tests
%define skip_python2 1
Name: python-pylint
Version: 2.8.3
Version: 2.9.6
Release: 0
Summary: Syntax and style checker for Python code
License: GPL-2.0-or-later
Group: Development/Languages/Python
URL: https://github.com/pycqa/pylint
Source: https://files.pythonhosted.org/packages/source/p/pylint/pylint-%{version}.tar.gz
# PATCH-FIX-UPSTREAM pylint-pr4450-import-init.patch -- gh#PyCQA/pylint#4450 fix broken tests
Patch1: https://github.com/PyCQA/pylint/pull/4450.patch#/pylint-pr4450-import-init.patch
BuildRequires: %{python_module setuptools_scm}
# Tests are no longer packaged in the PyPI sdist, use GitHub archive
Source: https://github.com/PyCQA/pylint/archive/refs/tags/v%{version}.tar.gz#/pylint-%{version}-gh.tar.gz
# PATCH-FIX-UPSTREAM pylint-pr4816-astroid27.patch - gh#PyCQA/pylint#4816 + removed upper bound
Patch0: pylint-pr4816-astroid27.patch
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: python-astroid >= 2.5.6
Requires: python-astroid >= 2.7
Requires: python-isort >= 4.2.5
Requires: python-mccabe >= 0.6
Requires: python-toml >= 0.7.1
%if %{with tests}
BuildRequires: %{python_module astroid >= 2.5.6}
BuildRequires: %{python_module astroid >= 2.7}
BuildRequires: %{python_module isort >= 4.2.5}
BuildRequires: %{python_module mccabe >= 0.6}
BuildRequires: %{python_module pytest-benchmark}
BuildRequires: %{python_module pytest-runner}
BuildRequires: %{python_module pytest-xdist}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module toml >= 0.7.1}
@@ -91,7 +90,10 @@ export LC_ALL="en_US.UTF-8"
# https://github.com/PyCQA/pylint/issues/3636
# so make sure that the macro set PYTHONPATH does not result in conflicting imports
mv pylint pylint.tmp
%pytest --benchmark-disable --ignore tests/test_epylint.py
# numpy inference in python39 and python38 broken -- https://github.com/PyCQA/pylint/issues/4877
python39_donttest=("-k" "not (test_functional and (len_checks or nan_comparison_check))")
python38_donttest=("${python39_donttest[@]}")
%pytest --benchmark-disable --ignore tests/test_epylint.py "${$python_donttest[@]}"
# result of the mentioned tampering: other tests must not have pwd in PYTHONPATH, but test_epylint needs it
export PYTHONPATH=$PWD
%pytest --benchmark-disable tests/test_epylint.py