Skip to main content
Filter by
Sorted by
Tagged with
1 vote
1 answer
30 views

I am trying to create a set of POJOs from an OpenAPI specification that is generated from a pydantic data model. The problem I'm hitting is with discriminators. I am currently using the following ...
Rob Spremulli's user avatar
Advice
0 votes
1 replies
37 views

Im trying to use Pydantic's RootModel to map a complex data structure. relations = dict( r2 = dict( index = 2, conditions = [ dict( ...
A H Bensiali's user avatar
0 votes
0 answers
84 views

I am creating a API to return pydantic backed object, with optional / "fetchable" fields that might not be fetched based on the API parameter passed in. when accessing these optional data ...
XXXHHHH's user avatar
  • 130
3 votes
3 answers
88 views

I'm building a FastAPI app (actually a small package) that defines a base model for a webhook endpoint. Other developers can inherit from this model and extend it for their own use cases. The webhook ...
zevi svei's user avatar
2 votes
0 answers
113 views

I use pydantic to be able to serialise and deserialise json data stored in a large database. Each of these json strings represent a pydantic model MyModel. class MyModel(BaseModel): attr1: int I ...
A-Abe's user avatar
  • 75
1 vote
0 answers
75 views

I am trying to use an ImportString to get an instance of a given object: from __future__ import annotations from pydantic.types import ImportString from pydantic import Field, BaseModel from typing ...
Tom McLean's user avatar
  • 6,633
1 vote
0 answers
151 views

The Pydantic documentation explicitly describes the order of field validators, but what about model_validators? In what order do model_validators run? Specifically, how are they ordered in an ...
kviLL's user avatar
  • 444
5 votes
1 answer
756 views

Is there any way to change the validation messages from pydantic? The problem is this: I want to return these validation messages to my frontend but not all of the users prefer the language english ...
Clyde's user avatar
  • 62
1 vote
0 answers
117 views

I’m experimenting with Python 3.13 and Pydantic v2.11.7. My goal is to avoid writing GenericTraining[Discriminate[L1LossConfig]] over and over—I’d like a terse alias such that I can do TrainingLike[...
Danilo Horta's user avatar
1 vote
0 answers
146 views

I'm using Pydantic v2 to define different response models depending on the use case. Some models reflect the structure of the ORM model exactly, and .model_validate(obj) works fine in those cases. ...
Bogdan's user avatar
  • 11
2 votes
0 answers
252 views

I'm using a library that utilizes Pydantic v2 and .model_json_schema()['properties'] to pull information and metadata about the class properties (like those set by Field json_schema_extra). I've found ...
Forgen's user avatar
  • 66
1 vote
0 answers
156 views

Using Python 3.10, I have a base type definition that I use in many models: Alpha = Annotated[str, Field(pattern=r'[A-Za-z]')] I want to create additional specialised types based on this type, for ...
snakecharmerb's user avatar
2 votes
1 answer
124 views

I have this pydantic model with a field, and this field could be either an int or a non numeric value like a str or list. from pydantic import BaseModel, Field class Foo(BaseModel): bar: str | ...
A-Abe's user avatar
  • 75
0 votes
1 answer
61 views

Say I have the following Pydantic 2.10.6 model, where x is dynamically calculated from another field, y: from pydantic import BaseModel, Field, field_validator, ValidationInfo class Foo(BaseModel): ...
Migwell's user avatar
  • 20.4k
1 vote
2 answers
990 views

I have an app that is largely configured by environment variables. I use Pydantic Settings to define the settings available, and validate them. I have an initial set of settings, and the regular app ...
John's user avatar
  • 2,784
1 vote
0 answers
22 views

We are using pydantic to validate our API request payload. We have insert and update endpoint. Both endpoint have same payload requirements. We created model for that: from pydantic import Field from ...
NPatel's user avatar
  • 21.4k
2 votes
1 answer
348 views

I'm validating inputs to a function using Pydantic's @validate_call as follows: from typing import Literal from pydantic import validate_call @validate_call def foo(a: Literal[0, 90, 180, 270]) -> ...
kviLL's user avatar
  • 444
0 votes
0 answers
2k views

I updated the pydantic version and code is breaking with the error Field 'allowed_type' defined on a base class was overridden by a non-annotated attribute. All field definitions, including overrides, ...
Tanu's user avatar
  • 1,712
0 votes
2 answers
132 views

maybe someone can help me out with a pydantic issue. I have been reading up on some reports of this, but I still do not understand how to circumvent the problem: https://docs.pydantic.dev/latest/...
GermanExpress's user avatar
0 votes
0 answers
55 views

I have the following code: from .consts import BASE_URL, HOSTNAME_PATTERN class GenericParseException(Exception): pass def validate_hostname(value: str) -> str: if value.startswith("...
EldadT's user avatar
  • 932
1 vote
0 answers
476 views

I am encountering an error when trying to import OpenAIEmbeddings from langchain_openai. Here is the exact import statement I am using: from langchain_openai import OpenAIEmbeddings When I run this ...
Daniyal Khan's user avatar
2 votes
1 answer
127 views

in V1 I was able to recursively add information to the BaseModel.dict method. Is something similar possible in V2? In V1 this was possible: from typing import Optional from pydantic.v1 import ...
GermanExpress's user avatar
0 votes
1 answer
487 views

I am trying to create the following JSON Schema from pydantic import BaseModel, Field class VendorInfo(BaseModel): vendor_name: str = Field("", description= "Vendor Name") ...
Soumadeep Dutta's user avatar
3 votes
2 answers
982 views

I'm trying to implement a Lazily evaluated generic field type for Pydantic v2. This is the simple implementation I have. You can assign either a value, a function or an async function to the lazy ...
Dulaj Disanayaka's user avatar
-1 votes
1 answer
251 views

someone before asked this question but the answers didnt help in my case, im trying to use an app called powershell-empire starkiller on kali linux, running it from terminal looks like: sudo ...
winstar345's user avatar