Skip to content

[BUG CLIENT]: Py3.9.10 failing with typing error #142

@tcapelle

Description

@tcapelle

Python -VV

Python 3.9.10 | packaged by conda-forge | (main, Feb  1 2022, 21:25:34)
[Clang 11.1.0 ]

Pip Freeze

annotated-types==0.7.0
anyio==4.4.0
certifi==2024.8.30
exceptiongroup==1.2.2
h11==0.14.0
httpcore==1.0.5
httpx==0.27.2
idna==3.8
jsonpath-python==1.0.6
mistralai==1.0.3
mypy-extensions==1.0.0
pydantic==2.8.2
pydantic_core==2.20.1
python-dateutil==2.9.0.post0
six==1.16.0
sniffio==1.3.1
typing-inspect==0.9.0
typing_extensions==4.12.2

Reproduction Steps

python -c "import mistralai"

you get:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/tcapelle/miniforge3/envs/py39/lib/python3.9/site-packages/mistralai/__init__.py", line 3, in <module>
    from .sdk import *
  File "/Users/tcapelle/miniforge3/envs/py39/lib/python3.9/site-packages/mistralai/sdk.py", line 3, in <module>
    from .basesdk import BaseSDK
  File "/Users/tcapelle/miniforge3/envs/py39/lib/python3.9/site-packages/mistralai/basesdk.py", line 3, in <module>
    from .sdkconfiguration import SDKConfiguration
  File "/Users/tcapelle/miniforge3/envs/py39/lib/python3.9/site-packages/mistralai/sdkconfiguration.py", line 8, in <module>
    from mistralai import models
  File "/Users/tcapelle/miniforge3/envs/py39/lib/python3.9/site-packages/mistralai/models/__init__.py", line 3, in <module>
    from .agentscompletionrequest import AgentsCompletionRequest, AgentsCompletionRequestMessages, AgentsCompletionRequestMessagesTypedDict, AgentsCompletionRequestStop, AgentsCompletionRequestStopTypedDict, AgentsCompletionRequestToolChoice, AgentsCompletionRequestTypedDict
  File "/Users/tcapelle/miniforge3/envs/py39/lib/python3.9/site-packages/mistralai/models/agentscompletionrequest.py", line 8, in <module>
    from .usermessage import UserMessage, UserMessageTypedDict
  File "/Users/tcapelle/miniforge3/envs/py39/lib/python3.9/site-packages/mistralai/models/usermessage.py", line 4, in <module>
    from .textchunk import TextChunk, TextChunkTypedDict
  File "/Users/tcapelle/miniforge3/envs/py39/lib/python3.9/site-packages/mistralai/models/textchunk.py", line 14, in <module>
    class TextChunk(BaseModel):
  File "/Users/tcapelle/miniforge3/envs/py39/lib/python3.9/site-packages/pydantic/_internal/_model_construction.py", line 200, in __new__
    set_model_fields(cls, bases, config_wrapper, types_namespace)
  File "/Users/tcapelle/miniforge3/envs/py39/lib/python3.9/site-packages/pydantic/_internal/_model_construction.py", line 469, in set_model_fields
    fields, class_vars = collect_model_fields(cls, bases, config_wrapper, types_namespace, typevars_map=typevars_map)
  File "/Users/tcapelle/miniforge3/envs/py39/lib/python3.9/site-packages/pydantic/_internal/_fields.py", line 132, in collect_model_fields
    type_hints = get_cls_type_hints_lenient(cls, types_namespace)
  File "/Users/tcapelle/miniforge3/envs/py39/lib/python3.9/site-packages/pydantic/_internal/_typing_extra.py", line 228, in get_cls_type_hints_lenient
    hints[name] = eval_type_lenient(value, globalns, localns)
  File "/Users/tcapelle/miniforge3/envs/py39/lib/python3.9/site-packages/pydantic/_internal/_typing_extra.py", line 240, in eval_type_lenient
    return eval_type_backport(value, globalns, localns)
  File "/Users/tcapelle/miniforge3/envs/py39/lib/python3.9/site-packages/pydantic/_internal/_typing_extra.py", line 264, in eval_type_backport
    return typing._eval_type(  # type: ignore
  File "/Users/tcapelle/miniforge3/envs/py39/lib/python3.9/typing.py", line 292, in _eval_type
    return t._evaluate(globalns, localns, recursive_guard)
  File "/Users/tcapelle/miniforge3/envs/py39/lib/python3.9/typing.py", line 554, in _evaluate
    eval(self.__forward_code__, globalns, localns),
  File "<string>", line 1, in <module>
  File "/Users/tcapelle/miniforge3/envs/py39/lib/python3.9/typing.py", line 277, in inner
    return func(*args, **kwds)
  File "/Users/tcapelle/miniforge3/envs/py39/lib/python3.9/typing.py", line 1339, in __class_getitem__
    origin = _type_check(params[0], msg)
  File "/Users/tcapelle/miniforge3/envs/py39/lib/python3.9/typing.py", line 158, in _type_check
    raise TypeError(f"{arg} is not valid as type argument")
TypeError: typing.Final[typing.Optional[str]] is not valid as type argument

Expected Behavior

Should just work

Additional Context

Fresh python 3.9.10 env, we catched this on our CI, I was using newer pythons on my computer.

Suggested Solutions

bump requirements or change Final[Optional]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions