Skip to content

python 3.8 compatibility issue #6

@idc9

Description

@idc9

Thanks for making tooldantic!

The current version of the package does not work for python 3.8 because of an import from typing import Annotated. See below for some examples.

One potential solution (chatgpt suggested) is

from typing_extensions import Annotated

Example code

from tooldantic import ToolBaseModel as BaseModel
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[4], line 2
      1 # drop in replacement for pydantic.BaseModel
----> 2 from tooldantic import ToolBaseModel as BaseModel
      5 class InnerModel(BaseModel):
      6     """nested inner model"""

File ~/anaconda3/envs/cpath/lib/python3.8/site-packages/tooldantic/__init__.py:3
      1 from pydantic import Field, ValidationError
----> 3 from .builder import ModelBuilder
      4 from .decorators import AsyncToolWrapper, ToolWrapper, ToolWrapperBase
      5 from .dispatch import ToolDispatch

File ~/anaconda3/envs/cpath/lib/python3.8/site-packages/tooldantic/builder.py:4
      2 import inspect
      3 import logging
----> 4 from typing import (
      5     Annotated,
      6     Any,
      7     Callable,
      8     Dict,
      9     List,
     10     Literal,
     11     Optional,
     12     Tuple,
     13     Type,
     14     Union,
     15     get_args,
     16     get_origin,
     17 )
     19 import docstring_parser
     20 import pydantic

ImportError: cannot import name 'Annotated' from 'typing' (/Users/iain/anaconda3/envs/cpath/lib/python3.8/typing.py)

or for a more simple demonstration

from typing import Annotated
ImportError                               Traceback (most recent call last)
Cell In[5], line 1
----> 1 from typing import Annotated

ImportError: cannot import name 'Annotated' from 'typing' (/Users/iain/anaconda3/envs/cpath/lib/python3.8/typing.py)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions