Infer Python version from .python-version file when no backend is set#1802
Closed
Copilot wants to merge 1 commit into
Closed
Infer Python version from .python-version file when no backend is set#1802Copilot wants to merge 1 commit into
.python-version file when no backend is set#1802Copilot wants to merge 1 commit into
Conversation
9 tasks
Copilot
AI
changed the title
[WIP] [WIP] Address feedback on inferring Python version with .python-version file
Infer Python version from Apr 4, 2026
.python-version file when no backend is set
Collaborator
|
Empty |
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.
When no package manager backend is active and
requires-pythonis absent or yields no matches, usethis was unconditionally falling back to the running interpreter version. This ignores projects that pin their Python version via a.python-versionfile.Changes
PythonVersion.from_python_version_file(path)— new classmethod onPythonVersionthat reads and parses a.python-versionfile, raisingFileNotFoundErrororPythonVersionParseErroron failure._get_current_python_version()— new private helper inenviron/python.pythat prefers.python-version(project root) and falls back to the running interpreter only when the file is absent or unparseable.get_supported_minor_python_versions()— all threePythonVersion.from_interpreter()call sites replaced with_get_current_python_version(), covering the no-requires-python, empty-match, and out-of-bounds warning paths. Warning message updated from "Current Python interpreter" to "Current Python version" to reflect the broader source._get_current_python_versionis placed above its caller per the project's step-down convention (follow-up commit).