Skip to content

Odd behavior in DEV version of mypy on pandas-stubs #19711

@Dr-Irv

Description

@Dr-Irv

We just did an update on pandas-stubs, and in our tests, we look to see if we are capturing certain error messages.

If you pull the latest pandas-stubs at commit pandas-dev/pandas-stubs@fd43653 and do

mypy --no-incremental pandas-stubs tests/series/arithmetic/str/test_add.py

With mypy 1.17.1, we have no errors.

But with the current version in DEV : https://github.com/mypyc/mypy_mypyc-wheels/releases/download/v1.18.0%2Bdev.b99948bc13832666515bc11b1b8410890badebd0/mypy-1.18.0%2Bdev-py3-none-any.whl

we get this error:

tests\series\arithmetic\str\test_add.py:38: error: Unused "type: ignore" comment  [unused-ignore]
tests\series\arithmetic\str\test_add.py:38: error: Argument 1 to "radd" of "Series" has incompatible type "int"; expected "str | Sequence[str] | ndarray[tuple[Any, ...], dtype[str_]] | Series[str]"  [arg-type]

Now if you look at lines 34 and 38, they are testing to see if we detect a call-overload error. The change reported with the DEV version of mypy reporting arg-type makes sense.

But the puzzling part is why didn't it report an arg-type error on line 34 in the call to left.add(), when the stubs are similar for both add() and radd() in pandas-stubs/core/series.pyi

This brings up another issue - is there a way to check the version of the type checker inside the code, so I can check for one type of error with mypy 1.17.1, and a different error in a newer/dev version?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions