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

mypy: pa.typing.Series does not support pd.DatetimeTZDtype as a type argument #959

Closed
2 of 3 tasks
DXsmiley opened this issue Oct 10, 2022 · 1 comment · Fixed by #960
Closed
2 of 3 tasks

mypy: pa.typing.Series does not support pd.DatetimeTZDtype as a type argument #959

DXsmiley opened this issue Oct 10, 2022 · 1 comment · Fixed by #960
Labels
bug Something isn't working

Comments

@DXsmiley
Copy link

Describe the bug

Under mypy, pa.typing.Series does not support pd.DatetimeTZDtype as a valid type argument.

Bug occurs with and without pandera.mypy plugin

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of pandera.
  • (optional) I have confirmed this bug exists on the master branch of pandera.

Code Sample, a copy-pastable example

from typing import Annotated
import pandas as pd
import pandera as pa
from pandera.typing import Series

class MySchema(pa.SchemaModel):
    # both lines taken from the pandera documentation
    a: Series[Annotated[pd.DatetimeTZDtype, "ns", "UTC"]]
    b: Series[pd.DatetimeTZDtype] = pa.Field(dtype_kwargs={"unit": "ns", "tz": "UTC"})

Expected behavior

mypy should show no errors

Actual behaviour

mypy produces the following errors

test.py:8: error: Value of type variable "GenericDtype" of "Series" cannot be "DatetimeTZDtype"
test.py:9: error: Value of type variable "GenericDtype" of "Series" cannot be "DatetimeTZDtype"

Versions

pandas==1.5.0
pandas-stubs==1.4.3.220807
pandera==0.13.3
mypy==0.982
mypy-extensions==0.4.3
@cosmicBboy
Copy link
Collaborator

hi @DXsmiley, #960 should fix this!

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