Pandera Series generic argument does not allow the `typing.List` etc. types
sam-goodwin opened this issue · comments
sam commented
Code Sample, a copy-pastable example
import pandera as pa
import pandera.typing as pdt
class MySchema(pa.DataFrameModel):
int32: pdt.Series[list[pdt.Int32]] = pa.Field()
Run mypy
and get the following error:
error: Type argument "list[Int32]" of "Series" must be a subtype of "bool | int | str | float | ExtensionDtype | Bool | Date | Timestamp | Decimal | Timedelta | Category | Float | Float16 | Float32 | Float64 | Int | Int8 | Int16 | Int32 | Int64 | UInt8 | UInt16 | UInt32 | UInt64 | INT8 | INT16 | INT32 | INT64 | UINT8 | UINT16 | UINT32 | UINT64 | Object | String | STRING | Geometry" [type-var]
Expected behavior
The type checking should not fail.
Niels Bantilan commented
@sam-goodwin feel free to make a PR to add the generic types here and here.
Also, FYI you can use the type without pdt.Series
int32: pdt.list[pdt.Int32] = pa.Field()
sam commented
My plan was to fix this today.
RE: dropping the series type, I'm waiting for this PR to make its way into Pypi:
sam commented
Interesting, adding the types here is a new case as this is a recursive types. Would I add list[Any]
or is there a better type for the parameter?
List[Any],
Dict[Any, Any],
Tuple[Any],
NamedTuple,