creamy-flower-43589
08/24/2026, 4:18 PMty)broad-monitor-993
08/24/2026, 4:19 PMmaincreamy-flower-43589
08/24/2026, 4:20 PMbroad-monitor-993
08/24/2026, 4:31 PMxarray and very soon tensordict, I think pandera.typing.Field would be more future-proof.
Just thinking through an alternative… but could we do something akin to Pydantic and use Annotated? pandera--2448.org.readthedocs.build/en/2448/dataframe_models.html#…
• T required column, non-null by default
• T | None required, nullable
• Annotated[T, pa.Field(required=False)] optional columnbroad-monitor-993
08/24/2026, 4:32 PMAnnotated solution somehowcreamy-flower-43589
08/24/2026, 4:38 PMField
• As a matter of fact, my two references for the implementation were SQLAlchemy and pydantic, so the current impl supposedly combines the best of both worlds. I can change it to Annotated.broad-monitor-993
08/24/2026, 4:40 PMAnnotated for now. If you’re still feeling the pain we can revisit adding pandera.typing.Fieldbroad-monitor-993
08/24/2026, 4:46 PMrequired kwarg needs to be added to pa.Fieldcreamy-flower-43589
08/24/2026, 6:33 PMty from emitting false positives cannot be addressed without a pandera.typing.Field as a descriptor layer. How about:
from typing import Annotated
from pandera.typing import Field as TypedField
import pandera.polars as pa
class Schema(pa.DataFrameModel):
values: Annotated[TypedField[pl.List], pa.Field()]
nullable: Annotated[TypedField[int | None], pa.Field()]
optional: Annotated[TypedField[int], pa.Field(required=False)]
The responsibilities stay separate:
• pandera.typing.Field[T] tells ty that class-level access is str.
• Annotated[...] remains the standard metadata carrier.
• Runtime pa.Field(...) still handles checks, aliases, required, etc.
• Pandera unwraps TypedField[T] back to T when building the schema.broad-monitor-993
08/24/2026, 8:16 PMpandera.typing.Field, how about something more concise (going back to your original idea):
from pandera.typing import FieldType
import pandera.polars as pa
class Schema(pa.DataFrameModel):
values: FieldType[pl.List, pa.Field()]
nullable_field: FieldType[int | None, pa.Field()]
optional_field: FieldType[int] | Nonebroad-monitor-993
08/24/2026, 8:18 PMfield: FieldType[T] = pa.Field(...)creamy-flower-43589
08/25/2026, 6:31 PMbroad-monitor-993
08/25/2026, 7:10 PMcreamy-flower-43589
08/25/2026, 7:43 PMbroad-monitor-993
08/25/2026, 7:45 PMcreamy-flower-43589
08/25/2026, 7:50 PMbroad-monitor-993
08/25/2026, 7:50 PMcreamy-flower-43589
08/25/2026, 7:52 PMbroad-monitor-993
08/25/2026, 7:53 PMcreamy-flower-43589
08/26/2026, 8:00 PMConnectionRefusedError: [Errno 61] Connection refused). What can I do about that?broad-monitor-993
08/26/2026, 8:01 PMbroad-monitor-993
08/26/2026, 8:02 PMbroad-monitor-993
08/26/2026, 8:02 PMcreamy-flower-43589
08/26/2026, 8:03 PMAnnotated compatibility for existing dtype metadata and field declarations, while making FieldType the primary descriptor contract.broad-monitor-993
08/26/2026, 8:05 PMAnnotated syntax (and preserve mention of it in the documentation)creamy-flower-43589
08/26/2026, 8:06 PMcreamy-flower-43589
08/26/2026, 8:18 PMYou can also embed field metadata with {data}`typing.Annotated`:
```{code-cell} python
from typing import Annotated
class AnnotatedSchema(pa.DataFrameModel):
value: Annotated[int, pa.Field(gt=0, description="A positive value")]
AnnotatedSchema.to_schema().columns["value"].description
This syntax is valid at runtime and may be convenient when you prefer standard typing constructs. Its trade-off is that Annotated preserves the underlying int annotation for static analysis; it does not provide the class-level str descriptor contract. If model fields are not passed to string-taking APIs, this limitation may not matter. If ty is part of your tooling, use FieldType instead.```