mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2026-03-30 20:17:04 +08:00
Add return type annotations to functions in: - vllm/version.py: _prev_minor_version_was(), _prev_minor_version() - vllm/config/pooler.py: get_use_activation() - vllm/multimodal/image.py: convert_image_mode() - vllm/profiler/utils.py: trim_string_front(), trim_string_back() Signed-off-by: yurekami <yurekami@users.noreply.github.com>
40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
# SPDX-License-Identifier: Apache-2.0
|
|
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
|
|
|
try:
|
|
from ._version import __version__, __version_tuple__
|
|
except Exception as e:
|
|
import warnings
|
|
|
|
warnings.warn(f"Failed to read commit hash:\n{e}", RuntimeWarning, stacklevel=2)
|
|
|
|
__version__ = "dev"
|
|
__version_tuple__ = (0, 0, __version__)
|
|
|
|
|
|
def _prev_minor_version_was(version_str: str) -> bool:
|
|
"""Check whether a given version matches the previous minor version.
|
|
|
|
Return True if version_str matches the previous minor version.
|
|
|
|
For example - return True if the current version if 0.7.4 and the
|
|
supplied version_str is '0.6'.
|
|
|
|
Used for --show-hidden-metrics-for-version.
|
|
"""
|
|
# Match anything if this is a dev tree
|
|
if __version_tuple__[0:2] == (0, 0):
|
|
return True
|
|
|
|
# Note - this won't do the right thing when we release 1.0!
|
|
assert __version_tuple__[0] == 0
|
|
assert isinstance(__version_tuple__[1], int)
|
|
return version_str == f"{__version_tuple__[0]}.{__version_tuple__[1] - 1}"
|
|
|
|
|
|
def _prev_minor_version() -> str:
|
|
"""For the purpose of testing, return a previous minor version number."""
|
|
# In dev tree, this will return "0.-1", but that will work fine"
|
|
assert isinstance(__version_tuple__[1], int)
|
|
return f"{__version_tuple__[0]}.{__version_tuple__[1] - 1}"
|