Support full prerelease versions in the compat table (#11228)

* Support full prerelease versions in the compat table

* Fix types
This commit is contained in:
Adriane Boyd 2022-08-04 15:14:19 +02:00 committed by GitHub
parent cd09614ab2
commit b07708d5d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -7,6 +7,7 @@ import typer
from ._util import app, Arg, Opt, WHEEL_SUFFIX, SDIST_SUFFIX from ._util import app, Arg, Opt, WHEEL_SUFFIX, SDIST_SUFFIX
from .. import about from .. import about
from ..util import is_package, get_minor_version, run_command from ..util import is_package, get_minor_version, run_command
from ..util import is_prerelease_version
from ..errors import OLD_MODEL_SHORTCUTS from ..errors import OLD_MODEL_SHORTCUTS
@ -74,7 +75,10 @@ def download(model: str, direct: bool = False, sdist: bool = False, *pip_args) -
def get_compatibility() -> dict: def get_compatibility() -> dict:
version = get_minor_version(about.__version__) if is_prerelease_version(about.__version__):
version: Optional[str] = about.__version__
else:
version = get_minor_version(about.__version__)
r = requests.get(about.__compatibility__) r = requests.get(about.__compatibility__)
if r.status_code != 200: if r.status_code != 200:
msg.fail( msg.fail(

View File

@ -795,6 +795,15 @@ def get_model_lower_version(constraint: str) -> Optional[str]:
return None return None
def is_prerelease_version(version: str) -> bool:
"""Check whether a version is a prerelease version.
version (str): The version, e.g. "3.0.0.dev1".
RETURNS (bool): Whether the version is a prerelease version.
"""
return Version(version).is_prerelease
def get_base_version(version: str) -> str: def get_base_version(version: str) -> str:
"""Generate the base version without any prerelease identifiers. """Generate the base version without any prerelease identifiers.