[pylint] Allow os._exit imports in import-private-name (PLC2701) - #27738
Merged
Conversation
ntBre
approved these changes
Aug 14, 2026
ntBre
left a comment
Contributor
There was a problem hiding this comment.
Thanks! This looks good to me, I just had one nit/suggestion about the helper name.
|
ntBre
approved these changes
Aug 14, 2026
ntBre
enabled auto-merge (squash)
August 14, 2026 19:23
George-Ogden
pushed a commit
to George-Ogden/ruff
that referenced
this pull request
Aug 16, 2026
…1`) (astral-sh#27738) ## Summary `PLC2701` currently reports `from os import _exit` as a private import, even though `os._exit` is a documented public API. `SLF001` already handles `os._exit` as an exception to the usual leading-underscore rule. This change moves that exception into a shared helper so `PLC2701` and `SLF001` treat `os._exit` consistently. Fixes astral-sh#18143. ## Test Plan - Added tests for direct and aliased `os._exit` imports. - Added negative cases to make sure `_exit` from other modules and other private `os` members are still reported. - Added coverage for mixed imports and aliased `SLF001` access. - Ran the relevant Ruff tests, Clippy, formatting checks, and `prek`.
1 task
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PLC2701currently reportsfrom os import _exitas a private import, even thoughos._exitis a documented public API.SLF001already handlesos._exitas an exception to the usual leading-underscore rule.This change moves that exception into a shared helper so
PLC2701andSLF001treatos._exitconsistently.Fixes #18143.
Test Plan
os._exitimports._exitfrom other modules and other privateosmembers are still reported.SLF001access.prek.