mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2026-07-10 08:27:08 +08:00
[Code Quality] Add missing return type annotations to misc modules
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>
This commit is contained in:
parent
09dc7c690c
commit
6175335d23
@ -108,7 +108,7 @@ class PoolerConfig:
|
|||||||
return hash_str
|
return hash_str
|
||||||
|
|
||||||
|
|
||||||
def get_use_activation(o: object):
|
def get_use_activation(o: object) -> bool | None:
|
||||||
if softmax := getattr(o, "softmax", None) is not None:
|
if softmax := getattr(o, "softmax", None) is not None:
|
||||||
logger.warning_once(
|
logger.warning_once(
|
||||||
"softmax will be deprecated and will be removed in v0.15. "
|
"softmax will be deprecated and will be removed in v0.15. "
|
||||||
|
|||||||
@ -38,7 +38,7 @@ def rgba_to_rgb(
|
|||||||
return converted
|
return converted
|
||||||
|
|
||||||
|
|
||||||
def convert_image_mode(image: Image.Image, to_mode: str):
|
def convert_image_mode(image: Image.Image, to_mode: str) -> Image.Image:
|
||||||
if image.mode == to_mode:
|
if image.mode == to_mode:
|
||||||
return image
|
return image
|
||||||
elif image.mode == "RGBA" and to_mode == "RGB":
|
elif image.mode == "RGBA" and to_mode == "RGB":
|
||||||
|
|||||||
@ -11,7 +11,7 @@ from torch._C._profiler import _EventType, _ProfilerEvent, _TensorMetadata
|
|||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
def trim_string_front(string, width):
|
def trim_string_front(string: str, width: int) -> str:
|
||||||
if len(string) > width:
|
if len(string) > width:
|
||||||
offset = len(string) - width + 3
|
offset = len(string) - width + 3
|
||||||
string = string[offset:]
|
string = string[offset:]
|
||||||
@ -20,7 +20,7 @@ def trim_string_front(string, width):
|
|||||||
return string
|
return string
|
||||||
|
|
||||||
|
|
||||||
def trim_string_back(string, width):
|
def trim_string_back(string: str, width: int) -> str:
|
||||||
if len(string) > width:
|
if len(string) > width:
|
||||||
offset = len(string) - width + 3
|
offset = len(string) - width + 3
|
||||||
string = string[:-offset]
|
string = string[:-offset]
|
||||||
|
|||||||
@ -12,7 +12,7 @@ except Exception as e:
|
|||||||
__version_tuple__ = (0, 0, __version__)
|
__version_tuple__ = (0, 0, __version__)
|
||||||
|
|
||||||
|
|
||||||
def _prev_minor_version_was(version_str):
|
def _prev_minor_version_was(version_str: str) -> bool:
|
||||||
"""Check whether a given version matches the previous minor version.
|
"""Check whether a given version matches the previous minor version.
|
||||||
|
|
||||||
Return True if version_str matches the previous minor version.
|
Return True if version_str matches the previous minor version.
|
||||||
@ -32,7 +32,7 @@ def _prev_minor_version_was(version_str):
|
|||||||
return version_str == f"{__version_tuple__[0]}.{__version_tuple__[1] - 1}"
|
return version_str == f"{__version_tuple__[0]}.{__version_tuple__[1] - 1}"
|
||||||
|
|
||||||
|
|
||||||
def _prev_minor_version():
|
def _prev_minor_version() -> str:
|
||||||
"""For the purpose of testing, return a previous minor version number."""
|
"""For the purpose of testing, return a previous minor version number."""
|
||||||
# In dev tree, this will return "0.-1", but that will work fine"
|
# In dev tree, this will return "0.-1", but that will work fine"
|
||||||
assert isinstance(__version_tuple__[1], int)
|
assert isinstance(__version_tuple__[1], int)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user