-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Empty tuple type #2318
Comments
This looks like you might be mixing up types and instances by using You can specify a variable length tuple with a single type as Here's an explicit example: from typing import Tuple
from pydantic import BaseModel, Field
class T(BaseModel):
example: Tuple[int, ...] = Field(default_factory=tuple)
def demo() -> int:
a = T()
b = T(example=(1,2))
for x in (a, b):
print(x)
return 0
demo() |
@mpkocher the syntax may not be the one you expected but it's the one chosen in PEP 484
So if you want to enforce in pydantic an empty tuple, you don't want to set |
@PrettyWood Thanks for clarifying. |
Bug
Output of
python -c "import pydantic.utils; print(pydantic.utils.version_info())"
:Will result in:
The text was updated successfully, but these errors were encountered: