Skip to content

check_index and check_like requirement on assert_series_equal #417

@williamjamir

Description

@williamjamir

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions