Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pandera Series generic argument does not allow the typing.List etc. types #1555

Open
sam-goodwin opened this issue Apr 4, 2024 · 3 comments · May be fixed by #1556
Open

Pandera Series generic argument does not allow the typing.List etc. types #1555

sam-goodwin opened this issue Apr 4, 2024 · 3 comments · May be fixed by #1556
Labels
bug Something isn't working

Comments

@sam-goodwin
Copy link
Contributor

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.

@sam-goodwin sam-goodwin added the bug Something isn't working label Apr 4, 2024
@cosmicBboy
Copy link
Collaborator

@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-goodwin
Copy link
Contributor Author

My plan was to fix this today.

RE: dropping the series type, I'm waiting for this PR to make its way into Pypi:

#1547

@sam-goodwin
Copy link
Contributor Author

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,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants