unionai-oss / pandera

A light-weight, flexible, and expressive statistical data testing library
https://www.union.ai/pandera
MIT License
3.27k stars 305 forks source link

MyPy failure with BOOL data type #925

Closed airibarne closed 1 year ago

airibarne commented 2 years ago

Description

MyPy gives the following error with a schema containing a Series[BOOL] typed column:

error: Value of type variable "GenericDtype" of "Series" cannot be "BOOL"

Code Sample

from pandera import BOOL, Field, SchemaModel
from pandera.typing import Series

class MySchema(SchemaModel):
    """Test schema."""

    my_bool: Series[BOOL]

Expected behavior

I would expect MyPy not to fail at all.

Desktop (please complete the following information):

Requeriments

pip install mypy pandera[mypy]

mypy==0.971 mypy-extensions==0.4.3 numpy==1.23.2 packaging==21.3 pandas==1.4.3 pandas-stubs==1.4.3.220807 pandera==0.12.0 pyarrow==9.0.0 pydantic==1.9.2 pyparsing==3.0.9 python-dateutil==2.8.2 pytz==2022.2.1 six==1.16.0 tomli==2.0.1 types-pytz==2022.2.1.0 typing-extensions==4.3.0 typing-inspect==0.8.0 wrapt==1.14.1

cosmicBboy commented 1 year ago

hi @airibarne, I believe this got fixed in https://github.com/unionai-oss/pandera/commit/5f9c713c6a9e3654f23e3c1a24b7ad39a8979e2e

You can update to pandera >= 0.13.0 and this should work.