Skip to content

check_index and check_like requirement on assert_series_equal #417

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

Closed
williamjamir opened this issue Nov 8, 2022 · 1 comment · Fixed by #418
Closed

check_index and check_like requirement on assert_series_equal #417

williamjamir opened this issue Nov 8, 2022 · 1 comment · Fixed by #418

Comments

@williamjamir
Copy link

Describe the bug

Actually, I don't know if this is a proper bug, a safeguard, or maybe a misunderstanding.

But, the assert_series_equalrequires that the keyword argument check_like is informed as False when check_index is False, but as stated over the docs, check_like default value is False.

So, in this case, it would not make more sense to allow only inform check_index when its set to False?

To Reproduce

  1. Provide a minimal runnable pandas example that is not properly checked by the stubs.
import pandas as pd

df = pd.DataFrame({'temp_c': [17.0, 25.0]}, index=['Portland', 'Berkeley'])

pd.testing.assert_series_equal(df.temp_c, df.temp_c, check_index=False)
  1. Indicate which type checker you are using (mypy or pyright).
>>> mypy --version 
mypy 0.982 (compiled: yes)
  1. Show the error message received from that type checker while checking your example.
error: No overload variant of "assert_series_equal" matches argument types "Series[Any]", "Series[Any]", "bool"  [call-overload]
note: Possible overload variants:
 def assert_series_equal(
     left: Series[Any], 
     right: Series[Any], 
     check_dtype: bool = ..., 
     check_index_type: Union[bool, str] = ..., 
     check_series_type: bool = ..., 
     check_names: bool = ..., 
     check_exact: bool = ..., 
     check_datetimelike_compat: bool = ..., 
     check_categorical: bool = ..., 
     check_category_order: bool = ..., 
     check_freq: bool = ..., 
     check_flags: bool = ..., 
     rtol: float = ..., 
     atol: float = ..., 
     obj: str = ..., 
     *,
     check_index: Literal[False], 
     check_like: Literal[False]
 ) -> None
    

note:    def assert_series_equal(
    left: Series[Any],
    right: Series[Any],
    check_dtype: bool = ...,
    check_index_type: Union[bool, str] = ...,
    check_series_type: bool = ...,
    check_names: bool = ...,
    check_exact: bool = ...,
    check_datetimelike_compat: bool = ...,
    check_categorical: bool = ...,
    check_category_order: bool = ..., 
    check_freq: bool = ..., 
    check_flags: bool = ...,
    rtol: float = ..., 
    atol: float = ...,
    obj: str = ..., 
    *, 
    check_index: Literal[True] = ...,
    check_like: bool = ...
) -> None


**Please complete the following information:**

Please complete the following information:
OS: MacOS M1
OS Version Ventura 13.0
python version: 3.9.12
version of type checker: mypy 0.982 (compiled: yes)
version of installed pandas-stubs
pandas==1.5.1
pandas-stubs==1.5.1.221024


**Additional context**
Add any other context about the problem here.
@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Nov 8, 2022

I think we have to change the first overload for assert_series_equal() to move check_like above the * so it says check_like: Literal[False] = ...

And add a test in tests/test_testing.py .

Maybe @bashtage can take a look, as this was added in #338

bashtage added a commit to bashtage/pandas-stubs that referenced this issue Nov 8, 2022
Add default arg for overload

closes pandas-dev#417
bashtage added a commit to bashtage/pandas-stubs that referenced this issue Nov 8, 2022
Add default arg for overload

closes pandas-dev#417
Dr-Irv pushed a commit that referenced this issue Nov 8, 2022
Add default arg for overload

closes #417
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 a pull request may close this issue.

2 participants