From 01bcef2a3fd1973e939b70c1ac4fb1e4beb37d52 Mon Sep 17 00:00:00 2001 From: manel-ab <55874070+manel-ab@users.noreply.github.com> Date: Thu, 1 Jun 2023 15:53:15 +0200 Subject: [PATCH] Static type hint error on class pandera DataFrame (#1207) Signed-off-by: Niels Bantilan --- pandera/typing/pandas.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pandera/typing/pandas.py b/pandera/typing/pandas.py index d1c6b9cd5..6d0618b65 100644 --- a/pandera/typing/pandas.py +++ b/pandera/typing/pandas.py @@ -9,6 +9,7 @@ Generic, List, Tuple, + Type, TypeVar, Union, _type_check, @@ -211,7 +212,7 @@ def pydantic_validate(cls, obj: Any, field: ModelField) -> pd.DataFrame: @staticmethod def from_records( # type: ignore - schema: T, + schema: Type[T], data: Union[ # type: ignore np.ndarray, List[Tuple[Any, ...]], Dict[Any, Any], pd.DataFrame ], @@ -230,7 +231,7 @@ def from_records( # type: ignore schema_index = schema.index.names if schema.index is not None else None if "index" not in kwargs: kwargs["index"] = schema_index - return DataFrame[T]( + return DataFrame[schema]( # type: ignore pd.DataFrame.from_records(data=data, **kwargs,)[ schema.columns.keys() ] # set the column order according to schema