Initial Checks
Description
The maxlen property of the deque field seems to be set to None when the queue item type is provided.
In the example below I first create an untyped deque and upon instancing everything goes well - the maxlen is set to 15.
However when the model definitions is more specific: deque[int] or Deque[int] then the maxlen value cannot be set.
Example Code
>>> from pydantic import BaseModel
>>> from collections import deque
>>> class D(BaseModel):
... q: deque = deque(maxlen=10)
...
>>> d = D(q=deque(maxlen=15))
>>> d
D(q=deque([], maxlen=15))
>>>
>>>
>>> class DI(BaseModel):
... q: deque[int] = deque(maxlen=10)
...
>>> d = DI(q=deque(maxlen=15))
>>> d
DI(q=deque([]))
>>>
>>> from typing import Deque
>>>
>>> class DT(BaseModel):
... q: Deque[int] = deque(maxlen=10)
...
>>> d = DT(q=deque(maxlen=15))
>>> d
DT(q=deque([]))
Python, Pydantic & OS Version
pydantic version: 1.10.5
pydantic compiled: True
install path: /opt/venv/lib/python3.11/site-packages/pydantic
python version: 3.11.4 (main, Jun 13 2023, 15:08:32) [GCC 10.2.1 20210110]
platform: Linux-5.15.90.1-microsoft-standard-WSL2-x86_64-with-glibc2.31
optional deps. installed: ['typing-extensions']
Affected Components
Selected Assignee: @davidhewitt
Initial Checks
Description
The
maxlenproperty of thedequefield seems to be set toNonewhen the queue item type is provided.In the example below I first create an untyped deque and upon instancing everything goes well - the
maxlenis set to15.However when the model definitions is more specific:
deque[int]orDeque[int]then themaxlenvalue cannot be set.Example Code
Python, Pydantic & OS Version
Affected Components
.dict()and.json()construct(), pickling, private attributes, ORM modeSelected Assignee: @davidhewitt