Question Details

No question body available.

Tags

python pydantic

Answers (1)

January 28, 2026 Score: 0 Rep: 2,295 Quality: Low Completeness: 60%

Use handler.generateschema(...) (not Model.pydanticcoreschema) and build a variadic tuple schema with variadicitemindex=1. The “class not fully defined” happens because you’re grabbing the other models’ core schemas too early.

from future import annotations

from pydantic import RootModel from pydanticcore import coreschema

class ParsedDatFile(RootModel, frozen=True): root: tuple # (ClrNamePro, Game, Game, ...)

@classmethod def getpydanticcoreschema(cls, sourcetype, handler): return coreschema.tupleschema( itemsschema=[ handler.generateschema(ClrNamePro), # first item handler.generateschema(Game), # repeated item ], variadicitemindex=1, # repeat schema at index 1 minlength=1, # must have at least the first item )

ParsedDatFile.modelrebuild()

That’s it: first element must validate as ClrNamePro, and it may be followed by zero or more Games.