Open fingon opened 1 week ago
hey @fingon can you share your sample code for repro'ing the typing error?
Given this ,litellm.py
:
import litellm
model_list: list[litellm.DeploymentTypedDict] = [
{
"model_name": "gpt-3.5-turbo",
"litellm_params": {
"model": "azure/gpt-35-turbo",
"api_key": "x",
"api_version": "y",
"api_base": "z",
},
},
]
router = litellm.Router(model_list=model_list)
Shell action:
mstenber@koneko ~>python3 --version
Python 3.11.9
mstenber@koneko ~>mypy --version
mypy 1.10.0 (compiled: yes)
mstenber@koneko ~>mypy ,litellm.py
,litellm.py:30: error: Argument "model_list" to "Router" has incompatible type "list[DeploymentTypedDict]"; expected "list[DeploymentTypedDict | dict[Any, Any]] | None" [arg-type]
,litellm.py:30: note: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
,litellm.py:30: note: Consider using "Sequence" instead, which is covariant
Found 1 error in 1 file (checked 1 source file)
Note that your typing should really use Sequence
instead of list
too, as it is covariant.
What happened?
I attempted to pass
list[litellm.DeploymentTypedDict]
to the litellm.Router as a parameter. That doesn't really work, unfortunately, as shown below.I would perhaps rather type it as
Relevant log output