79600360

Date: 2025-04-30 13:01:24
Score: 0.5
Natty:
Report link

There is also an alternative solution written in the docs,

https://docs.pydantic.dev/latest/concepts/pydantic_settings/#disabling-json-parsing

For the above example, this could means,

# Note - showing only new items that need to be imported
from typing import Annotated
from pydantic_settings import NoDecode

class JobSettings(BaseSettings):
    wp_generate_funnel_box: bool = Field(True)
    wp_funnel_box_dims_mm: Annotated[Tuple[int, int, int], NoDecode] = Field((380, 90, 380))

    @field_validator('wp_funnel_box_dims_mm', mode='before')
    @classmethod
    def parse_int_tuple(cls, v) -> tuple[int, int, int]:
        output = tuple(int(x.strip()) for x in v.split(','))
        assert len(output) == 3
        return output

    model_config = {
        "env_file": ".env",
        "env_file_encoding": "utf-8",
        "extra": "ignore",
    }
Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: G K Patel