Skip to content

gh-134357: Remove unused imports in tests #134340

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 6 commits into from
May 25, 2025

Conversation

hugovk
Copy link
Member

@hugovk hugovk commented May 20, 2025

Like #120417 and #131152, remove unused imports in tests.

Also add lint rule (F401) to the Ruff Lib/test/ config.

@hugovk hugovk changed the title Remove unused imports in tests gh-134357: Remove unused imports in tests May 20, 2025
@hugovk hugovk marked this pull request as ready for review May 20, 2025 16:24
Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM. I just have doubt about the Lib/test/support/__init__.py change.

@@ -2728,7 +2727,6 @@ def iter_builtin_types():
# Fall back to making a best-effort guess.
if hasattr(object, '__flags__'):
# Look for any type object with the Py_TPFLAGS_STATIC_BUILTIN flag set.
import datetime
Copy link
Member

Choose a reason for hiding this comment

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

This import has to stay. It deserves a # noqa: F401.

@encukou: Can you confirm?

@AlexWaygood AlexWaygood removed their request for review May 20, 2025 21:16
Comment on lines +9 to +10
ChannelError, ChannelNotFoundError, ChannelClosedError, # noqa: F401
ChannelEmptyError, ChannelNotEmptyError, # noqa: F401
Copy link
Member

Choose a reason for hiding this comment

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

In this specific case maybe better to add a per-file ignore?

Copy link
Member Author

Choose a reason for hiding this comment

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

Or would you prefer the two unused imports on the same line? That way we still check the rest of the file.

Suggested change
ChannelError, ChannelNotFoundError, ChannelClosedError, # noqa: F401
ChannelEmptyError, ChannelNotEmptyError, # noqa: F401
from _interpchannels import (
ChannelError, ChannelNotFoundError, ChannelEmptyError,
ChannelClosedError, ChannelNotEmptyError, # noqa: F401
)

Copy link
Member

Choose a reason for hiding this comment

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

I'm fine with the current PR: two lines with # noqa: F401.

@JelleZijlstra
Copy link
Member

I think a few new ones crept in

@hugovk hugovk enabled auto-merge (squash) May 25, 2025 20:01
@hugovk hugovk merged commit 328a778 into python:main May 25, 2025
38 checks passed
@hugovk hugovk deleted the 3.15-tests-rm-unused-imports branch May 25, 2025 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants