From 6175335d2361eecd801c223c070e007babd32d68 Mon Sep 17 00:00:00 2001 From: yurekami Date: Thu, 25 Dec 2025 03:49:14 +0900 Subject: [PATCH] [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 --- vllm/config/pooler.py | 2 +- vllm/multimodal/image.py | 2 +- vllm/profiler/utils.py | 4 ++-- vllm/version.py | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/vllm/config/pooler.py b/vllm/config/pooler.py index 976ae8c063eb7..7cd04ed2f830c 100644 --- a/vllm/config/pooler.py +++ b/vllm/config/pooler.py @@ -108,7 +108,7 @@ class PoolerConfig: 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: logger.warning_once( "softmax will be deprecated and will be removed in v0.15. " diff --git a/vllm/multimodal/image.py b/vllm/multimodal/image.py index 8e1178bc7ea44..091bb419a462e 100644 --- a/vllm/multimodal/image.py +++ b/vllm/multimodal/image.py @@ -38,7 +38,7 @@ def rgba_to_rgb( 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: return image elif image.mode == "RGBA" and to_mode == "RGB": diff --git a/vllm/profiler/utils.py b/vllm/profiler/utils.py index c95f9f4ac9779..27705a8ae15fb 100644 --- a/vllm/profiler/utils.py +++ b/vllm/profiler/utils.py @@ -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: offset = len(string) - width + 3 string = string[offset:] @@ -20,7 +20,7 @@ def trim_string_front(string, width): return string -def trim_string_back(string, width): +def trim_string_back(string: str, width: int) -> str: if len(string) > width: offset = len(string) - width + 3 string = string[:-offset] diff --git a/vllm/version.py b/vllm/version.py index 63095f8bce1ea..6cea1d409a6eb 100644 --- a/vllm/version.py +++ b/vllm/version.py @@ -12,7 +12,7 @@ except Exception as e: __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. 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}" -def _prev_minor_version(): +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)