Skip to content

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

Merged
ZeroIntensity merged 3 commits into
python:mainfrom
ZeroIntensity:ctypes/deprecate-test-util
Sep 19, 2026
Merged

ZeroIntensity merged 3 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.

@ZeroIntensity
ZeroIntensity enabled auto-merge (squash) September 19, 2026 14:30
@ZeroIntensity
ZeroIntensity merged commit c81693b into python:main Sep 19, 2026
52 checks passed
@ZeroIntensity
ZeroIntensity deleted the ctypes/deprecate-test-util branch September 19, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants