Skip to content

Series.shift does not always preserve input dtype, but is typed as if it does #1111

Closed
@MarcoGorelli

Description

@MarcoGorelli

Describe the bug
``

To Reproduce

  1. Provide a minimal runnable pandas example that is not properly checked by the stubs.
  2. Indicate which type checker you are using (mypy or pyright).
  3. Show the error message received from that type checker while checking your example.
import pandas as pd


reveal_type(pd.Series([1,2,3]).shift())
#  t.py:4: note: Revealed type is "pandas.core.series.Series[builtins.int]"

however, the result is actually Series['float']

It's not clear to me if/how pandas-stubs distinguishes ints and nullable ints #1110

Please complete the following information:

  • OS: [e.g. Windows, Linux, MacOS] linux
  • OS Version [e.g. 22] 22.04
  • python version 3.12.5
  • version of type checker mypy 1.15
  • version of installed pandas-stubs 2.2.3.241126

Additional context
noticed looking into #1108

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