-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Description
Problem
When defining a Patito model field using a Literal of non-string values (e.g. Literal[1, 2, 3]) and specifying an integer dtype (e.g. dtype=pl.Int64), Patito still raises an error that enum values must be strings. This appears to occur because Patito validates any Literal as if it were a pl.Enum, regardless of the intended dtype.
Steps to Reproduce
import patito
import polars as pl
from typing import Literal
class MyModel(patito.Model):
my_field: Literal[1, 2, 3] = patito.Field(dtype=pl.Int64)
MyModel.validate_schema()Running this raises:
TypeError: Enums used to annotate Patito model fields must be strings. Encountered type: int.
MattG-bci
Metadata
Metadata
Assignees
Labels
No labels