Skip to content

Add regression test for #7506 #8432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already had tests depending on six, and we were already installing six as a transitive dependency of pytest-profiling, but I figure it's better to make it explicit in case that ever changes.

# 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):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was altered in #7320 to remove six, but that made it unable to target the astroid behavior. The original test in #7153 didn't quite test this correctly: it confounded things by adding , object.

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/pylint-dev/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