Summary
I'm not sure if this is a patito-specific issue or a more general metaclass lookup issue.
https://play.ty.dev/2e6bfe16-f59c-46f0-82c0-aaebcacb942d
Context
- polars is a popular dataframe library
- patito allows you to define the schema of individual rows as pydantic models
- This code checks in pyright/basepyright. I haven't checked mypy, pyre or others.
The implementation relies on a metaclass to define some of this behavior.
In particular in the following code
import patito as pt
class Person(pt.Model):
name: str
results = Person.DataFrame(...)
The Person.DataFrame class var is added by the patito.pydantic.ModelMetaclass(PydanticModelMetaclass). It's a common and convenient shortcut for the getting a dataframe constructor that's already bound to the correct generic type var and run time model class to allow for runtime schema validation. The alternative would be something like the following.
results = pt.DataFrame[Person]().set_model(Person)
Version
ty 0.0.1-alpha.20 (f41f00a 2025-09-03)
Summary
I'm not sure if this is a patito-specific issue or a more general metaclass lookup issue.
https://play.ty.dev/2e6bfe16-f59c-46f0-82c0-aaebcacb942d
Context
The implementation relies on a metaclass to define some of this behavior.
In particular in the following code
The
Person.DataFrameclass var is added by thepatito.pydantic.ModelMetaclass(PydanticModelMetaclass). It's a common and convenient shortcut for the getting a dataframe constructor that's already bound to the correct generic type var and run time model class to allow for runtime schema validation. The alternative would be something like the following.Version
ty 0.0.1-alpha.20 (f41f00a 2025-09-03)