Skip to content

Commit e9f425a

Browse files
committed
rolled back some type, converted back to Type, in pandas & polars engine
1 parent cb86c29 commit e9f425a

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

pandera/engines/pandas_engine.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
Literal,
2222
NamedTuple,
2323
Optional,
24+
Type,
2425
Union,
2526
cast,
2627
)
@@ -1216,11 +1217,11 @@ def from_parametrized_dtype(cls, pd_dtype: pd.IntervalDtype):
12161217
class PydanticModel(DataType):
12171218
"""A pydantic model datatype applying to rows in a dataframe."""
12181219

1219-
type: type[BaseModel] = dataclasses.field(default=None, init=False) # type: ignore[assignment]
1220+
type: Type[BaseModel] = dataclasses.field(default=None, init=False) # type: ignore[assignment]
12201221
auto_coerce = True
12211222

12221223
# pylint:disable=super-init-not-called
1223-
def __init__(self, model: type[BaseModel]) -> None:
1224+
def __init__(self, model: Type[BaseModel]) -> None:
12241225
object.__setattr__(self, "type", model)
12251226

12261227
def coerce(self, data_container: PandasObject) -> PandasObject:
@@ -1281,7 +1282,7 @@ class PythonGenericType(DataType):
12811282
type: Any = dataclasses.field(default=None, init=False) # type: ignore
12821283
generic_type: Any = dataclasses.field(default=None, init=False)
12831284
special_type: Any = dataclasses.field(default=None, init=False)
1284-
coercion_model: type[BaseModel] = dataclasses.field( # type: ignore
1285+
coercion_model: Type[BaseModel] = dataclasses.field( # type: ignore
12851286
default=None, init=False
12861287
)
12871288
_pandas_type = object

pandera/engines/polars_engine.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@
55
import decimal
66
import inspect
77
import warnings
8-
from typing import (
9-
Any,
10-
Literal,
11-
Optional,
12-
Union,
13-
)
8+
from typing import Any, Literal, Optional, Union, Type
149
from collections.abc import Iterable, Mapping, Sequence
1510

1611
import polars as pl
@@ -229,8 +224,7 @@ def dtype(cls, data_type: Any) -> dtypes.DataType:
229224
pl_dtype = convert_py_dtype_to_polars_dtype(data_type)
230225
except ValueError:
231226
raise TypeError(
232-
f"data type '{data_type}' not understood by "
233-
f"{cls.__name__}."
227+
f"data type '{data_type}' not understood by {cls.__name__}."
234228
) from None
235229

236230
try:
@@ -455,7 +449,7 @@ class Date(DataType, dtypes.Date):
455449
class DateTime(DataType, dtypes.DateTime):
456450
"""Polars datetime data type."""
457451

458-
type: type[pl.Datetime] = pl.Datetime
452+
type: Type[pl.Datetime] = pl.Datetime
459453
time_zone_agnostic: bool = False
460454

461455
def __init__( # pylint:disable=super-init-not-called
@@ -464,7 +458,6 @@ def __init__( # pylint:disable=super-init-not-called
464458
time_zone: Optional[str] = None,
465459
time_unit: Optional[str] = None,
466460
) -> None:
467-
468461
_kwargs = {}
469462
if time_unit is not None:
470463
# avoid deprecated warning when initializing pl.Datetime:
@@ -566,7 +559,6 @@ def __init__( # pylint:disable=super-init-not-called
566559
*,
567560
width: Optional[int] = None,
568561
) -> None:
569-
570562
kwargs: dict[str, Union[int, tuple[int, ...]]] = {}
571563
if width is not None:
572564
kwargs["shape"] = width
@@ -713,8 +705,7 @@ def check(
713705
return False
714706

715707
return (
716-
self.type == pandera_dtype.type
717-
and (self.type.categories == pandera_dtype.categories).all() # type: ignore
708+
self.type == pandera_dtype.type and (self.type.categories == pandera_dtype.categories).all() # type: ignore
718709
)
719710

720711

0 commit comments

Comments
 (0)