Skip to content

gh-151428: Remove unused imports from stdlib#151478

Open
hugovk wants to merge 2 commits into
python:mainfrom
hugovk:3.16-rm-unused-imports
Open

gh-151428: Remove unused imports from stdlib#151478
hugovk wants to merge 2 commits into
python:mainfrom
hugovk:3.16-rm-unused-imports

Conversation

@hugovk

@hugovk hugovk commented Jun 14, 2026

Copy link
Copy Markdown
Member

Follow on from #151440 and #151442.

Also add Ruff F401 to help avoid this in the future, and exclude any files with false positives (rather than adding noqa comments).

Comment thread .pre-commit-config.yaml

@StanFromIreland StanFromIreland left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

Pablo might need to update his "Attracts linker errors" line to "Attracts linker errors and unused imports," I think I see a pattern in the affected files ;-)

@johnslavik

johnslavik commented Jun 15, 2026

Copy link
Copy Markdown
Member

Pablo might need to update his "Attracts linker errors" line to "Attracts linker errors and unused imports," I think I see a pattern in the affected files ;-)

Attracts lin[kt]er errors

@AlexWaygood AlexWaygood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(I only reviewed the changes to the config files)

Comment thread Tools/.ruff.toml
Comment on lines +3 to +4
[per-file-target-version]
"jit/example_trace_dump.py" = "py312" # Reused-quote f-strings (PEP 701)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should this be the target version for the whole jit directory, rather than just one file...?

Comment thread Tools/.ruff.toml
Comment on lines +11 to +14
[lint.per-file-ignores]
"c-analyzer/c_parser/__init__.py" = ["F401"] # Re-exports from submodules
"c-analyzer/c_parser/preprocessor/__init__.py" = ["F401"] # Re-exports from submodules
"c-analyzer/c_parser/preprocessor/common.py" = ["F401"] # Re-exported by preprocessor/__init__.py

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Adding __all__ and listing the re-exports in __all__ would probably be a more idiomatic way of fixing these errors (but perhaps that's something for a followup PR, since there's a chance it could be controversial :-)

Comment thread Lib/.ruff.toml

[lint.per-file-ignores]
"ctypes/__init__.py" = ["F401"] # Re-exports from _ctypes
"ensurepip/__init__.py" = ["F401"] # `import zlib` availability check

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

in a case like this where there's only one error, I'd usually lean towards using a noqa comment in the code rather than per-file-ignores. But, again, perhaps that's best done as a followup..

@pablogsal

Copy link
Copy Markdown
Member

LGTM

Pablo might need to update his "Attracts linker errors" line to "Attracts linker errors and unused imports," I think I see a pattern in the affected files ;-)

Keeping those linters busy man 😉

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