Skip to content

Fix false positive target version warning when current Python is included - #5168

Closed
raywcm wants to merge 1 commit into
psf:mainfrom
raywcm:fix/target-version-warning
Closed

raywcm wants to merge 1 commit into
psf:mainfrom
raywcm:fix/target-version-warning

Conversation

@raywcm

@raywcm raywcm commented Jun 4, 2026 •

Copy link
Copy Markdown

Problem

_target_versions_exceed_runtime compares only the maximum target version against the runtime. This causes a false positive when users specify multiple target versions including their current Python.

Example: running Python 3.14 with -t py310 -t py311 -t py312 -t py313 -t py314 -t py315 shows:

Warning: Python 3.14 cannot parse code formatted for Python 3.15.

This warning is misleading — the user explicitly asked for 3.14-compatible output by including it in the target list.

Fix

Changed _target_versions_exceed_runtime to check whether all target versions exceed the runtime, not just the maximum. If any target version is ≤ the runtime version, the formatted output will be parseable and no warning is needed.

Closes #5164
Closes #5167

…uded

_target_versions_exceed_runtime previously compared only the maximum
target version against the runtime. This caused a false positive warning
when users specified multiple --target-version flags including their
current Python version alongside a future one.

For example, running Python 3.14 with:
  -t py310 -t py311 -t py312 -t py313 -t py314 -t py315
would incorrectly warn that 3.14 cannot parse code formatted for 3.15,
even though 3.14 is explicitly listed as a target.

The fix checks whether ALL target versions exceed the runtime. If at
least one target version matches the runtime, no warning is needed.
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

diff-shades results comparing this PR (a89cace) to main (ce1897a):

--preview style: no changes

--stable style: no changes


What is this? | Workflow run | diff-shades documentation

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