Skip to content

fix: no spurious target-version warning when runtime version is included#5167

Open
wahajahmed010 wants to merge 2 commits into
psf:mainfrom
wahajahmed010:fix/5164-target-version-warning-mixed-versions
Open

fix: no spurious target-version warning when runtime version is included#5167
wahajahmed010 wants to merge 2 commits into
psf:mainfrom
wahajahmed010:fix/5164-target-version-warning-mixed-versions

Conversation

@wahajahmed010
Copy link
Copy Markdown

Description

The _target_versions_exceed_runtime function was using max() to compare
target 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 py315 on Python 3.14).

The fix uses min() instead: the warning now only fires when all target
versions 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

  • Changed max() to min() in _target_versions_exceed_runtime
  • Added regression test that verifies no warning when runtime version is
    included in the target set
  • Updated the docstring to clarify the semantics

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 ...

  • Implement any code style changes under the --preview style, following the stability policy?
  • Add an entry in CHANGES.md if necessary?
  • Add / update tests if necessary?
  • Add new / update outdated documentation?

Wahaj Ahmed and others added 2 commits June 4, 2026 01:42
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unexpected version warning

1 participant