diff options
author | github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | 2023-04-03 14:13:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-03 14:13:08 +0200 |
commit | 84c197d1674eb2aa1642e84a2580987190971ed1 (patch) | |
tree | d41812228d5e27a348a2e1f83bdbe0c504210fd6 | |
parent | 574edc3da35a750ef1ffe2bc4167acdb9e9bd357 (diff) | |
download | pylint-git-84c197d1674eb2aa1642e84a2580987190971ed1.tar.gz |
[Backport maintenance/2.17.x] Add regression test for #7506 (#8531)
* Add regression test for #7506 (#8432)
(cherry picked from commit 1fa16c2d8a7e97223541069731d28896f651b1ab)
---------
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
-rw-r--r-- | doc/whatsnew/fragments/7506.false_positive | 3 | ||||
-rw-r--r-- | requirements_test.txt | 1 | ||||
-rw-r--r-- | tests/functional/u/unused/unused_import.py | 7 | ||||
-rw-r--r-- | tests/functional/u/unused/unused_import.txt | 12 |
4 files changed, 15 insertions, 8 deletions
diff --git a/doc/whatsnew/fragments/7506.false_positive b/doc/whatsnew/fragments/7506.false_positive new file mode 100644 index 000000000..c6424e1f2 --- /dev/null +++ b/doc/whatsnew/fragments/7506.false_positive @@ -0,0 +1,3 @@ +Fix ``unused-import`` false positive for usage of ``six.with_metaclass``. + +Closes #7506 diff --git a/requirements_test.txt b/requirements_test.txt index 3a9ad3f36..8a42362bf 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -6,6 +6,7 @@ contributors-txt>=1.0.0 pytest-cov~=4.0 pytest-profiling~=1.7 pytest-xdist~=3.2 +six # Type packages for mypy types-pkg_resources==0.1.3 tox>=3 diff --git a/tests/functional/u/unused/unused_import.py b/tests/functional/u/unused/unused_import.py index 3534cd0cf..0abc7bf4d 100644 --- a/tests/functional/u/unused/unused_import.py +++ b/tests/functional/u/unused/unused_import.py @@ -10,6 +10,7 @@ from sys import flags # [unused-import] # +1:[unused-import,unused-import] from collections import deque, OrderedDict, Counter import re, html.parser # [unused-import] +import six DATA = Counter() # pylint: disable=self-assigning-variable @@ -98,8 +99,10 @@ if TYPE_CHECKING: import zoneinfo -class WithMetaclass(metaclass=ABCMeta): - pass +class WithMetaclass(six.with_metaclass(ABCMeta)): + """Regression test for https://github.com/PyCQA/pylint/issues/7506. + + Requires six.""" # Regression test for https://github.com/PyCQA/pylint/issues/3765 diff --git a/tests/functional/u/unused/unused_import.txt b/tests/functional/u/unused/unused_import.txt index f242bcb23..f356843fa 100644 --- a/tests/functional/u/unused/unused_import.txt +++ b/tests/functional/u/unused/unused_import.txt @@ -6,9 +6,9 @@ unused-import:8:0:8:21::Unused flags imported from sys:UNDEFINED unused-import:11:0:11:51::Unused OrderedDict imported from collections:UNDEFINED unused-import:11:0:11:51::Unused deque imported from collections:UNDEFINED unused-import:12:0:12:22::Unused import re:UNDEFINED -unused-import:16:0:16:40::Unused SomeOtherName imported from fake:UNDEFINED -unused-import:53:0:53:9::Unused import os:UNDEFINED -unused-import:88:4:88:19::Unused import unittest:UNDEFINED -unused-import:90:4:90:15::Unused import uuid:UNDEFINED -unused-import:92:4:92:19::Unused import warnings:UNDEFINED -unused-import:94:4:94:21::Unused import compileall:UNDEFINED +unused-import:17:0:17:40::Unused SomeOtherName imported from fake:UNDEFINED +unused-import:54:0:54:9::Unused import os:UNDEFINED +unused-import:89:4:89:19::Unused import unittest:UNDEFINED +unused-import:91:4:91:15::Unused import uuid:UNDEFINED +unused-import:93:4:93:19::Unused import warnings:UNDEFINED +unused-import:95:4:95:21::Unused import compileall:UNDEFINED |