Skip to content

Use better typing for Series.apply based on return type of the callable determining return type of Series.apply() #293

Closed
@phofl

Description

@phofl

Describe the bug
A clear and concise description of what the bug is.

Series().apply().tolist() errors with

error: "Series[Any]" not callable  [operator]

after latest release.

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.
s = pd.Series([1, 2, 3]).apply(lambda x: x).tolist()
error: "Series[Any]" not callable  [operator]

Please complete the following information:

  • OS: [e.g. Windows, Linux, MacOS] MacOS
  • OS Version [e.g. 22] 12.5.1
  • python version 3.10
  • version of type checker mypy 0.960
  • version of installed pandas-stubs [v1.4.4.220906]

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ApplyApply, Aggregate, TransformRegressionFunctionality that used to work in a prior pandas versionSeriesSeries data structure

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions