✨ feat(py_info): add system_exe, a narrowed system executable - #127
Merged
Conversation
`system_executable` holds `None` between construction and `resolve_to_system`, so a consumer reading it after discovery must narrow a value that resolution has settled. virtualenv carries ten identical ty suppressions for this one gap. `system_exe` falls back to `executable`, the value resolution writes when a prefix links back to its own interpreter, and the anchor `iter_interpreters` uses for deduplication. It joins `system_prefix` and `system_exec_prefix` as a narrowed reader of the system interpreter.
This was referenced Aug 28, 2026
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.
PythonInfo.system_executablehas typestr | None, because_fast_get_system_executable()gives up on a virtual environment whose base it cannot determine by inspection.resolve_to_system()then walks the prefix chain and fills the field in, and every discovery entry point runs it before handing aPythonInfoout. 🔍 The annotation cannot express that ordering, so a consumer reading the field past discovery has to narrow a value resolution has settled. virtualenv carries eleventy: ignoresuppressions doing just that, spread across its CPython, PyPy, GraalPy and RustPython creators, and pypa/virtualenv#3223 adds a twelfth.system_exegives those callers a reader typedstr. It falls back toexecutable, which carries typestr, so the property needs no suppression of its own rather than relocating one out of virtualenv. ✨ This repository follows that same fallback in two other spots.resolve_to_system()writes it when a prefix links back to its own interpreter, and_discovery.pyanchors deduplication on it, whichdocs/explanation.rstrecords as how iteration skips candidates it has seen. The property sits besidesystem_prefixandsystem_exec_prefix, which coverreal_prefix or base_prefix or prefixthe same way.Nothing existing changes, since this only adds a reader.
_discovery.pycould use it too, but theis Noneguard there cannot fire givenexecutable: str, and untangling that dead branch belongs in its own change.