Skip to content

Commit

Permalink
make pandera.typing.Series[TYPE] error in polars DataFrameModel more …
Browse files Browse the repository at this point in the history
…readable (#1588)

Signed-off-by: cosmicBboy <niels.bantilan@gmail.com>
  • Loading branch information
cosmicBboy committed Apr 19, 2024
1 parent 8a9d733 commit 249cab2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pandera/api/polars/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,19 @@ def _build_columns( # pylint:disable=too-many-locals
columns[field_name] = Column(**column_kwargs)

else:
origin_name = (
f"{annotation.origin.__module__}."
f"{annotation.origin.__name__}"
)
msg = (
" Series[TYPE] annotations are not supported for polars. "
"Use the bare TYPE directly"
if origin_name == "pandera.typing.pandas.Series"
else ""
)
raise SchemaInitError(
f"Invalid annotation '{field_name}: "
f"{annotation.raw_annotation}'"
f"{annotation.raw_annotation}'.{msg}"
)

return columns
Expand Down

0 comments on commit 249cab2

Please sign in to comment.