Make mypy behave like a proper pre-commit hook (#25313)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
Harry Mellor
2025-09-22 12:23:45 +00:00
committed by GitHub
co-authored by gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
parent 64c824cd78
commit 3d2c56b7a9
9 changed files with 166 additions and 87 deletions
+5 -4
View File
@@ -551,9 +551,10 @@ class AsyncMicrobatchTokenizer:
# If every request uses identical kwargs we can run a single
# batched tokenizer call for a big speed-up.
if can_batch and len(prompts) > 1:
encode_fn = partial(self.tokenizer, prompts, **kwargs)
batch_encode_fn = partial(self.tokenizer, prompts,
**kwargs)
results = await self._loop.run_in_executor(
self._executor, encode_fn)
self._executor, batch_encode_fn)
for i, fut in enumerate(result_futures):
if not fut.done():
@@ -889,7 +890,7 @@ def get_open_port() -> int:
def get_open_ports_list(count: int = 5) -> list[int]:
"""Get a list of open ports."""
ports = set()
ports = set[int]()
while len(ports) < count:
ports.add(get_open_port())
return list(ports)
@@ -1279,7 +1280,7 @@ def as_list(maybe_list: Iterable[T]) -> list[T]:
def as_iter(obj: Union[T, Iterable[T]]) -> Iterable[T]:
if isinstance(obj, str) or not isinstance(obj, Iterable):
obj = [obj]
return [obj] # type: ignore[list-item]
return obj