Compatibility with python 3.7, 3.8
JianxinMa opened this issue · comments
Is it possible for you to change list[str]
to List[str]
(from typing import List
) or list
such that it is compatible with python 3.8? There are still many production environments that use py 3.8.
>>> import modelscope_studio
Traceback (most recent call last):
File "/home/majx13/miniconda3/envs/py38/lib/python3.8/site-packages/pydantic/_internal/_typing_extra.py", line 240, in eval_type_backport
return typing._eval_type( # type: ignore
File "/home/majx13/miniconda3/envs/py38/lib/python3.8/typing.py", line 270, in _eval_type
return t._evaluate(globalns, localns)
File "/home/majx13/miniconda3/envs/py38/lib/python3.8/typing.py", line 518, in _evaluate
eval(self.__forward_code__, globalns, localns),
File "<string>", line 1, in <module>
TypeError: 'type' object is not subscriptable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/majx13/miniconda3/envs/py38/lib/python3.8/site-packages/modelscope_studio/__init__.py", line 1, in <module>
from .components.Chatbot import ModelScopeChatbot as Chatbot
File "/home/majx13/miniconda3/envs/py38/lib/python3.8/site-packages/modelscope_studio/components/Chatbot/__init__.py", line 24, in <module>
class MultimodalMessage(GradioModel):
File "/home/majx13/miniconda3/envs/py38/lib/python3.8/site-packages/pydantic/_internal/_model_construction.py", line 178, in __new__
set_model_fields(cls, bases, config_wrapper, types_namespace)
File "/home/majx13/miniconda3/envs/py38/lib/python3.8/site-packages/pydantic/_internal/_model_construction.py", line 452, in set_model_fields
fields, class_vars = collect_model_fields(cls, bases, config_wrapper, types_namespace, typevars_map=typevars_map)
File "/home/majx13/miniconda3/envs/py38/lib/python3.8/site-packages/pydantic/_internal/_fields.py", line 122, in collect_model_fields
type_hints = get_cls_type_hints_lenient(cls, types_namespace)
File "/home/majx13/miniconda3/envs/py38/lib/python3.8/site-packages/pydantic/_internal/_typing_extra.py", line 212, in get_cls_type_hints_lenient
hints[name] = eval_type_lenient(value, globalns, localns)
File "/home/majx13/miniconda3/envs/py38/lib/python3.8/site-packages/pydantic/_internal/_typing_extra.py", line 224, in eval_type_lenient
return eval_type_backport(value, globalns, localns)
File "/home/majx13/miniconda3/envs/py38/lib/python3.8/site-packages/pydantic/_internal/_typing_extra.py", line 249, in eval_type_backport
raise TypeError(
TypeError: You have a type annotation 'Optional[Union[list[str], str]]' which makes use of newer typing features than are supported in your version of Python. To handle this error, you should either remove the use of new syntax or install the `eval_type_backport` package.
Or add eval_type_backport
to the requirements.txt
We have adapted Python 3.8 inmodelscope_studio@0.1.6
, Thanks!