Vonage / vonage-python-sdk

Vonage Server SDK for Python. API support for Voice, SMS, WhatsApp, Verify (2FA), Video Meetings and more.
https://developer.vonage.com
Apache License 2.0
192 stars 118 forks source link

Pydantic v2 not compatible with Vonage Python SDK #283

Closed Mroldpeng closed 9 months ago

Mroldpeng commented 1 year ago

import vonage

python3.11 pydantic2.2.1

File "D:\Program Files\Python\Python3.11.4\Lib\site-packages\vonage__init.py", line 1, in from .client import * File "D:\Program Files\Python\Python3.11.4\Lib\site-packages\vonage\client.py", line 20, in from .verify2 import Verify2 File "D:\Program Files\Python\Python3.11.4\Lib\site-packages\vonage\verify2.py", line 17, in class Verify2: File "D:\Program Files\Python\Python3.11.4\Lib\site-packages\vonage\verify2.py", line 67, in Verify2 class VerifyRequest(BaseModel): File "D:\Program Files\Python\Python3.11.4\Lib\site-packages\pydantic_internal_model_construction.py", line 177, in new set_model_fields(cls, bases, config_wrapper, types_namespace) File "D:\Program Files\Python\Python3.11.4\Lib\site-packages\pydantic_internal_model_construction.py", line 405, in set_model_fields fields, class_vars = collect_model_fields(cls, bases, config_wrapper, types_namespace, typevars_map=typevars_map) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Program Files\Python\Python3.11.4\Lib\site-packages\pydantic_internal_fields.py", line 98, in collect_model_fields type_hints = get_cls_type_hints_lenient(cls, types_namespace) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Program Files\Python\Python3.11.4\Lib\site-packages\pydantic_internal_typing_extra.py", line 212, in get_cls_type_hints_lenient hints[name] = eval_type_lenient(value, globalns, localns) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Program Files\Python\Python3.11.4\Lib\site-packages\pydantic_internal_typing_extra.py", line 224, in eval_type_lenient return typing._eval_type(value, globalns, localns) # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Program Files\Python\Python3.11.4\Lib\typing.py", line 371, in _eval_type return t._evaluate(globalns, localns, recursive_guard) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Program Files\Python\Python3.11.4\Lib\typing.py", line 877, in _evaluate eval(self.forward_code__, globalns, localns), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1, in TypeError: constr() got an unexpected keyword argument 'regex'

maxkahan commented 1 year ago

Hi, right now we're using pydantic v1, and our code isn't compatible with v2 yet. We hope to get this sorted soon, but if it can't wait I'm also happy to take a PR!

rodriheck commented 9 months ago

This problem persists.

maxkahan commented 9 months ago

Hi, we've just released v3.13.0 of the Vonage Python SDK which adds support for Pydantic v2, install it with pip install -U vonage 🙂