[Python] TypeError: conlist() got an unexpected keyword argument 'min_items'

Discussão em 'Python' iniciado por Stack, Abril 3, 2025.

  1. Stack

    Stack Membro Participativo

    I am using pydantic and strictyaml to read a yaml config file. I am using this class

    class CarData(BaseModel):
    model: str
    length: float
    width: float
    height: float
    fuel_efficiency: conlist(item_type=float, min_items=3, max_items=3) # Ensures exactly 3 values
    # fuel_efficiency: list[float]


    and I am following what is written in the documentation of conlist, however when I run the script I got

    TypeError: conlist() got an unexpected keyword argument 'min_items'


    Why is this happening, and how can it be corrected? (My pydantic version is 2.9.2 just in case)

    Continue reading...

Compartilhe esta Página