Skip to content

Commit

Permalink
[Backport maintenance/2.17.x] Add regression test for #7506 (#8531)
Browse files Browse the repository at this point in the history
* Add regression test for #7506 (#8432)

(cherry picked from commit 1fa16c2)

---------

Co-authored-by: Pierre Sassoulas <[email protected]>
Co-authored-by: Jacob Walls <[email protected]>
  • Loading branch information
3 people authored Apr 3, 2023
1 parent 574edc3 commit 84c197d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
3 changes: 3 additions & 0 deletions doc/whatsnew/fragments/7506.false_positive
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix ``unused-import`` false positive for usage of ``six.with_metaclass``.

Closes #7506
1 change: 1 addition & 0 deletions requirements_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 5 additions & 2 deletions tests/functional/u/unused/unused_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# +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
Expand Down Expand Up @@ -98,8 +99,10 @@ def blop(self):
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
Expand Down
12 changes: 6 additions & 6 deletions tests/functional/u/unused/unused_import.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 84c197d

Please sign in to comment.