fix: no spurious target-version warning when runtime version is included#5167
Open
wahajahmed010 wants to merge 2 commits into
Open
fix: no spurious target-version warning when runtime version is included#5167wahajahmed010 wants to merge 2 commits into
wahajahmed010 wants to merge 2 commits into
Conversation
Closes psf#5164 The function used to compare target versions against the runtime version, causing a spurious warning when users specified the runtime version alongside higher targets. Changed to so the warning only fires when ALL target versions exceed the runtime. If any target is at or below runtime, the AST safety check can succeed for that version. Signed-off-by: Wahaj Ahmed <wahajahmed010@gmail.com>
for more information, see https://pre-commit.ci
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.
Description
The
_target_versions_exceed_runtimefunction was usingmax()to comparetarget versions against the runtime version. This caused a spurious warning
when users specified the runtime version alongside higher target versions
(e.g.,
--target-version py314 --target-version py315on Python 3.14).The fix uses
min()instead: the warning now only fires when all targetversions exceed the runtime. If any target version is at or below the runtime,
the AST safety check can succeed for that version, making the warning
unnecessary.
Closes #5164.
Approach
max()tomin()in_target_versions_exceed_runtimeincluded in the target set
AI assistance disclosure
This contribution was developed with the assistance of an AI coding agent
(Buck/OpenClaw). All code was reviewed and verified by a human contributor
before submission.
Checklist - did you ...
--previewstyle, following the stability policy?CHANGES.mdif necessary?