Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix target version inference. #3583

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Commits on Feb 26, 2023

  1. Document that we treat empty requires-python metadata as if it was no…

    …t present.
    
    This clarifies that it is a deliberate choice instead of implementing the “correct” semantics.
    manueljacob committed Feb 26, 2023
    Configuration menu
    Copy the full SHA
    c4b9464 View commit details
    Browse the repository at this point in the history

Commits on Feb 27, 2023

  1. Factor out list of all TargetVersions.

    The next commit will add a lot of test cases that will use this.
    manueljacob committed Feb 27, 2023
    Configuration menu
    Copy the full SHA
    c1eaae1 View commit details
    Browse the repository at this point in the history
  2. Fix target version inference.

    Fixes psf#3581.
    
    The old algorithm checked, for each target version 3.X, whether 3.X (which is roughly the same as 3.X.0) is contained in a version specifier that was modified from the requires-python project metadata to be less strict regarding patch versions. One problem of it was that, for a requires-python value of ">3.X" (which means the same as ">3.X.0"), it concluded that target version 3.X is not supported although Python versions >= 3.X.1 are included in the version specifier. I found the old approach hard to reason about and hard to fix.
    
    To correctly check whether a target version 3.X is supported, the algorithm must check whether 3.X.* overlaps the version specifier in the requires-python project metadata. Checking only specific versions (like 3.X.0) is not sufficient in general. The `packaging` library, which implements the logic for (PEP440-compatible) versions and version specifiers, doesn’t implement checking for overlap of two version specifiers, however.
    
    The new algorithm works by converting the version specifiers to interval sets, which are then checked for overlap.
    manueljacob committed Feb 27, 2023
    Configuration menu
    Copy the full SHA
    03203ca View commit details
    Browse the repository at this point in the history