You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched (google, github) for similar issues and couldn't find anything
I have read and followed the docs and still think this is a bug
Bug
It wasn't clear to me from the description of the breaking changes described in 1.8.0 whether it is expected that variable length tuples should now be handled differently, but I'm seeing something similar to #2132 when nesting generics inside of a variable length tuple:
TypeError Traceback (most recent call last)
~/miniconda3/envs/napdev/lib/python3.8/site-packages/pydantic/validators.cpython-38-darwin.so in pydantic.validators.find_validators()
TypeError: issubclass() arg 1 must be a class
During handling of the above exception, another exception occurred:
RuntimeError Traceback (most recent call last)
<ipython-input-3-3f541325cc4d> in <module>
----> 1 class C(BaseModel):
2 t: Tuple[Tuple[int], ...] = ()
3
~/miniconda3/envs/napdev/lib/python3.8/site-packages/pydantic/main.cpython-38-darwin.so in pydantic.main.ModelMetaclass.__new__()
~/miniconda3/envs/napdev/lib/python3.8/site-packages/pydantic/fields.cpython-38-darwin.so in pydantic.fields.ModelField.infer()
~/miniconda3/envs/napdev/lib/python3.8/site-packages/pydantic/fields.cpython-38-darwin.so in pydantic.fields.ModelField.__init__()
~/miniconda3/envs/napdev/lib/python3.8/site-packages/pydantic/fields.cpython-38-darwin.so in pydantic.fields.ModelField.prepare()
~/miniconda3/envs/napdev/lib/python3.8/site-packages/pydantic/fields.cpython-38-darwin.so in pydantic.fields.ModelField.populate_validators()
~/miniconda3/envs/napdev/lib/python3.8/site-packages/pydantic/validators.cpython-38-darwin.so in find_validators()
RuntimeError: error checking inheritance of typing.Tuple[int] (type: Tuple[int])
Output of python -c "import pydantic.utils; print(pydantic.utils.version_info())":
Hi @tlambert03 and thanks for reporting 🙏
Indeed I changed recently the code related to tuple to be more explicit and support () (empty tuple) but missed the case of Ellipsis with compound type as first argument.
I open a PR to fix this 👍
Checks
Bug
It wasn't clear to me from the description of the breaking changes described in 1.8.0 whether it is expected that variable length tuples should now be handled differently, but I'm seeing something similar to #2132 when nesting generics inside of a variable length tuple:
Output of
python -c "import pydantic.utils; print(pydantic.utils.version_info())"
:The text was updated successfully, but these errors were encountered: