Skip to content

Commit d4b9f8f

Browse files
Type fixes for main (and the files main depends on) (#424)
## Summary Type fixes. --- - [x] "I certify that all code in this PR is my own, except as noted below." ## Use of AI - [ ] Includes AI-assisted code completion - [ ] Includes code generated by an AI application - [ ] Includes AI-generated tests (NOTE: AI written tests should have a docstring that includes `## WRITTEN BY AI ##`)
2 parents c31fdde + 5638472 commit d4b9f8f

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

src/guidellm/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
try:
3434
import uvloop
3535
except ImportError:
36-
uvloop = None
36+
uvloop = None # type: ignore[assignment] # Optional dependency
3737

3838
from guidellm.backends import BackendType
3939
from guidellm.benchmark import (
@@ -124,7 +124,7 @@ def benchmark():
124124
dir_okay=False,
125125
path_type=Path,
126126
),
127-
click.Choice(get_builtin_scenarios().keys()),
127+
click.Choice(tuple(get_builtin_scenarios().keys())),
128128
),
129129
default=None,
130130
help=(

src/guidellm/benchmark/schemas.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from __future__ import annotations
1414

15+
import inspect
1516
import json
1617
import random
1718
import time
@@ -1140,7 +1141,8 @@ def update_estimate(
11401141
else None
11411142
)
11421143
request_duration = (
1143-
request_end_time - request_start_time if request_end_time else None
1144+
(request_end_time - request_start_time)
1145+
if request_end_time and request_start_time else None
11441146
)
11451147

11461148
# Always track concurrency
@@ -1791,7 +1793,7 @@ def create(
17911793
return cls.model_validate(constructor_kwargs)
17921794

17931795
@classmethod
1794-
def get_default(cls: BenchmarkGenerativeTextArgs, field: str) -> Any:
1796+
def get_default(cls: type[BenchmarkGenerativeTextArgs], field: str) -> Any:
17951797
"""
17961798
Get default value for a model field.
17971799
@@ -1805,10 +1807,17 @@ def get_default(cls: BenchmarkGenerativeTextArgs, field: str) -> Any:
18051807
)
18061808

18071809
field_info = BenchmarkGenerativeTextArgs.model_fields[field]
1808-
if field_info.default_factory is not None:
1809-
return field_info.default_factory()
1810+
factory = field_info.default_factory
1811+
1812+
if factory is None:
1813+
return field_info.default
1814+
1815+
if len(inspect.signature(factory).parameters) == 0:
1816+
return factory() # type: ignore[call-arg] # Confirmed correct at runtime by code above
1817+
else:
1818+
return factory({}) # type: ignore[call-arg] # Confirmed correct at runtime by code above
1819+
18101820

1811-
return field_info.default
18121821

18131822
model_config = ConfigDict(
18141823
extra="ignore",

0 commit comments

Comments
 (0)