Skip to content

[fix] No overload variant of "isna" matches argument type "NAType" [call-overload] #279

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

Merged
merged 5 commits into from
Sep 7, 2022

Conversation

LeMeteore
Copy link
Contributor

…all-overload]

Update `isna` & `notna` overloads inside pandas-stubs/core/dtypes/missing.pyi
Update `test_isna` function inside tests/test_pandas.py file

Refs #264
@LeMeteore
Copy link
Contributor Author

When I tried to test with:

check(assert_type(pd.isna(pd.NA), bool), bool)                                                                                              
check(assert_type(pd.notna(pd.NA), bool), bool)

I had the following errors:

tests/test_pandas.py:130: error: Expression is of type "Any", not "bool"  [assert-type]
tests/test_pandas.py:130: error: No overload variant of "isna" matches argument type "NAType"  [call-overload]
tests/test_pandas.py:130: note: Possible overload variants:
tests/test_pandas.py:130: note:     def isna(obj: DataFrame) -> DataFrame
tests/test_pandas.py:130: note:     def isna(obj: Series[Any]) -> Series[bool]
tests/test_pandas.py:130: note:     def isna(obj: Union[Index, List[Any], Union[ExtensionArray, ndarray[Any, Any]]]) -> ndarray[Any, Any]
tests/test_pandas.py:130: note:     def isna(obj: Union[Union[str, bytes, date, datetime, timedelta, bool, complex, Timestamp, Timedelta], NaTType]) -> bool
tests/test_pandas.py:131: error: Expression is of type "Any", not "bool"  [assert-type]
tests/test_pandas.py:131: error: No overload variant of "notna" matches argument type "NAType"  [call-overload]
tests/test_pandas.py:131: note: Possible overload variants:
tests/test_pandas.py:131: note:     def notna(obj: DataFrame) -> DataFrame
tests/test_pandas.py:131: note:     def notna(obj: Series[Any]) -> Series[bool]
tests/test_pandas.py:131: note:     def notna(obj: Union[Index, List[Any], Union[ExtensionArray, ndarray[Any, Any]]]) -> ndarray[Any, Any]
tests/test_pandas.py:131: note:     def notna(obj: Union[Union[str, bytes, date, datetime, timedelta, bool, complex, Timestamp, Timedelta], NaTType]) -> bool

I decided to use np.nan instead of pd.NA:

check(assert_type(pd.isna(np.nan), bool), bool)                                                                                             
check(assert_type(pd.notna(np.nan), bool), bool) 

@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Sep 7, 2022

I decided to use np.nan instead of pd.NA:

I think you pulled the wrong type. You need to use NAType and NaTType. The first corresponds to pd.NA, the second to pd.NaT (which you should also test as well).

>>> import pandas as pd
>>> type(pd.NA)
<class 'pandas._libs.missing.NAType'>
>>> type(pd.NaT)
<class 'pandas._libs.tslibs.nattype.NaTType'>

…all-overload]

Update `isna` & `notna` overloads inside pandas-stubs/core/dtypes/missing.pyi
Update `test_isna` function inside tests/test_pandas.py file

Refs #264
Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks good except for one small thing.

…all-overload]

Update `isna` & `notna` overloads inside pandas-stubs/core/dtypes/missing.pyi
Update `test_isna` function inside tests/test_pandas.py file

Refs #264
Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hit the wrong button - make the changes with the tests and we should be good

…all-overload]

Update `isna` & `notna` overloads inside pandas-stubs/core/dtypes/missing.pyi
Update `test_isna` function inside tests/test_pandas.py file

Refs #264
…all-overload]

Update `isna` & `notna` overloads inside pandas-stubs/core/dtypes/missing.pyi
Update `test_isna` function inside tests/test_pandas.py file

Refs #264
Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @LeMeteore

@LeMeteore
Copy link
Contributor Author

Thanks @LeMeteore

Thanks to you all o/ I've learned something today.

@marcglobality
Copy link

re this one, I'm getting errors in mypy due pd.isna(None). Is this expected behaviour? Could we cover also None ?

@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Sep 20, 2022

re this one, I'm getting errors in mypy due pd.isna(None). Is this expected behaviour? Could we cover also None ?

Can you create an issue, with the example, and the output of mypy?

@marcglobality
Copy link

here you go #318

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants