Skip to content

gh-157763: Soft-deprecate ctypes.util.test - #157776

Open
ZeroIntensity wants to merge 2 commits into
python:mainfrom
ZeroIntensity:ctypes/deprecate-test-util
Open

ZeroIntensity wants to merge 2 commits into
python:mainfrom
ZeroIntensity:ctypes/deprecate-test-util

Conversation

@ZeroIntensity

@ZeroIntensity ZeroIntensity commented Sep 18, 2026

Copy link
Copy Markdown
Member

@ZeroIntensity

Copy link
Copy Markdown
Member Author

@hugovk Any idea what's wrong with the lint job? The code that Ruff is complaining about is unrelated to this PR.

@BHUVANSH855 BHUVANSH855 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think dllist is still intentionally reexported as ctypes.util.dllist, removing test() only removed its last in-module reference, so ruff now reports F401.

@ZeroIntensity

Copy link
Copy Markdown
Member Author

Hm, okay. Why is Ruff linting ctypes at all? I thought the lint jobs were supposed to be limited to a specific list of modules, because the stdlib is chock full of weird things that linters don't like.

@hugovk

hugovk commented Sep 19, 2026

Copy link
Copy Markdown
Member

@hugovk Any idea what's wrong with the lint job? The code that Ruff is complaining about is unrelated to this PR.

Error: Lib/ctypes/util.py:419:25: F401 `_ctypes.dllist` imported but unused; consider using `importlib.util.find_spec` to test for availability

You've deleted code that used the import, so delete the import as well.

@hugovk

hugovk commented Sep 19, 2026

Copy link
Copy Markdown
Member

Hm, okay. Why is Ruff linting ctypes at all? I thought the lint jobs were supposed to be limited to a specific list of modules, because the stdlib is chock full of weird things that linters don't like.

We only lint for unused imports (F401) in the stdlib:

#151478

Before this, we've had lots of PRs to remove unused imports:

https://github.com/python/cpython/pulls?q=is%3Apr+state%3Aclosed+%22remove+unused+imports%22

It's often an easy little performance improvement, keeps the code tidier, and lint lets us avoid them in the first place.

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.

3 participants