A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/KotlinIsland/pydantic-basedtyping below:

KotlinIsland/pydantic-basedtyping: pydantic plugin to provide support for basedtyping

support for basedtyping features with pydantic:

from __future__ import annotations

from pydantic import BaseModel

class A(BaseModel):
    a: 1 | 2
A(a=1)  # A(a=1)
A(a=2)  # A(a=2)
A(a=3)  # ValidationError

Note

the types need to be written as a string, or __future__.annotations needs to be enabled

  1. add pydantic-basedtyping as a dependency
  2. install the plugin with:
    python -m pydantic_basedtyping install

if you are using pyprojectx, this can be configured:

[tool.pyprojectx]
install = ["uv sync", "uv run python -m pydantic_basedtyping install"]

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4