Skip to content

[BUG CLIENT]: TypeError: 'type' object is not subscriptable in Python 3.8 when importing client #191

@somebodyawesome-dev

Description

@somebodyawesome-dev

Python -VV

Python 3.8.19 (default, Aug 28 2024, 16:24:50) 
[GCC 11.4.0]

Pip Freeze

annotated-types==0.7.0
anyio==4.5.2
asgiref==3.8.1
attrs==25.1.0
backports.zoneinfo==0.2.1
certifi==2025.1.31
charset-normalizer==3.4.1
click==8.1.8
distro==1.9.0
Django==4.1
django-cors-headers==4.4.0
django-jsonform==2.23.2
djangorestframework==3.15.1
djangorestframework-simplejwt==5.3.1
drf-spectacular==0.28.0
eval_type_backport==0.2.2
exceptiongroup==1.2.2
filelock==3.16.1
fsspec==2025.2.0
gunicorn==23.0.0
h11==0.14.0
httpcore==1.0.7
httpx==0.28.1
huggingface-hub==0.29.1
idna==3.10
importlib_resources==6.4.5
inflection==0.5.1
Jinja2==3.1.5
jiter==0.8.2
jiwer==3.1.0
joblib==1.4.2
jsonpath-python==1.0.6
jsonschema==4.23.0
jsonschema-specifications==2023.12.1
Levenshtein==0.25.1
lxml==5.3.1
MarkupSafe==2.1.5
mistralai==1.5.1
mpmath==1.3.0
mypy-extensions==1.0.0
networkx==3.1
numpy==1.24.4
nvidia-cublas-cu12==12.1.3.1
nvidia-cuda-cupti-cu12==12.1.105
nvidia-cuda-nvrtc-cu12==12.1.105
nvidia-cuda-runtime-cu12==12.1.105
nvidia-cudnn-cu12==9.1.0.70
nvidia-cufft-cu12==11.0.2.54
nvidia-curand-cu12==10.3.2.106
nvidia-cusolver-cu12==11.4.5.107
nvidia-cusparse-cu12==12.1.0.106
nvidia-nccl-cu12==2.20.5
nvidia-nvjitlink-cu12==12.8.61
nvidia-nvtx-cu12==12.1.105
openai==1.63.2
packaging==24.2
pandas==2.0.3
pdf2image==1.17.0
pillow==10.4.0
pkgutil_resolve_name==1.3.10
pydantic==2.10.6
pydantic_core==2.27.2
PyJWT==2.9.0
PyMuPDF==1.24.11
pymupdf4llm==0.0.17
pytesseract==0.3.13
python-dateutil==2.9.0.post0
python-docx==1.1.2
python-dotenv==1.0.1
python-Levenshtein==0.25.1
pytz==2025.1
PyYAML==6.0.2
rapidfuzz==3.9.7
referencing==0.35.1
regex==2024.11.6
requests==2.32.3
rpds-py==0.20.1
safetensors==0.5.2
scikit-learn==1.3.2
scipy==1.10.1
sentence-transformers==3.2.1
six==1.17.0
sniffio==1.3.1
sqlparse==0.5.3
sympy==1.13.3
threadpoolctl==3.5.0
tika==2.6.0
tokenizers==0.20.3
torch==2.4.1
tqdm==4.67.1
transformers==4.46.3
triton==3.0.0
typing-inspect==0.9.0
typing_extensions==4.12.2
tzdata==2025.1
uritemplate==4.1.1
urllib3==2.2.3
zipp==3.20.2

Reproduction Steps

  • Install mistralai in a Python 3.8 environment.
  • Import any component that uses response_format_from_pydantic_model().
  • Observe the error.

Error example (it doesnt matter what component i import from mistralai module):

  File "/home/somebodyawesome/my-project/utils/extractor.py", line 15, in <module>
    from mistralai.models import OCRResponse
  File "/home/somebodyawesome/.local/share/virtualenvs/my-project4OTrfiFS/lib/python3.8/site-packages/mistralai/__init__.py", line 10, in <module>
    from .sdk import *
  File "/home/somebodyawesome/.local/share/virtualenvs/my-project-4OTrfiFS/lib/python3.8/site-packages/mistralai/sdk.py", line 13, in <module>
    from mistralai.chat import Chat
  File "/home/somebodyawesome/.local/share/virtualenvs/my-project-4OTrfiFS/lib/python3.8/site-packages/mistralai/chat.py", line 12, in <module>
    from mistralai.extra import (
  File "/home/somebodyawesome/.local/share/virtualenvs/my-project-4OTrfiFS/lib/python3.8/site-packages/mistralai/extra/__init__.py", line 1, in <module>
    from .struct_chat import ParsedChatCompletionResponse, convert_to_parsed_chat_completion_response
  File "/home/somebodyawesome/.local/share/virtualenvs/my-project-4OTrfiFS/lib/python3.8/site-packages/mistralai/extra/struct_chat.py", line 2, in <module>
    from .utils.response_format import  CustomPydanticModel, pydantic_model_from_json
  File "/home/somebodyawesome/.local/share/virtualenvs/my-project-4OTrfiFS/lib/python3.8/site-packages/mistralai/extra/utils/__init__.py", line 1, in <module>
    from .response_format import response_format_from_pydantic_model
  File "/home/somebodyawesome/.local/share/virtualenvs/my-project-4OTrfiFS/lib/python3.8/site-packages/mistralai/extra/utils/response_format.py", line 10, in <module>
    model: type[CustomPydanticModel],
TypeError: 'type' object is not subscriptable

Expected Behavior

Import should go through with no error

Additional Context

No response

Suggested Solutions

No response

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