8000 Regression: Series.apply is too strict, does not allow to return a DateOffset · Issue #454 · pandas-dev/pandas-stubs · GitHub
[go: up one dir, main page]

8000
Skip to content
Regression: Series.apply is too strict, does not allow to return a DateOffset #454
@phofl

Description

@phofl

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

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.

Arguments and return value are both too strict:

months = [1, 2, 3]
pd.Series(months).apply(lambda x: pd.DateOffset(months=x))

returns

error: Argument 1 to "apply" of "Series" has incompatible type "Callable[[Any], DateOffset]"; expected "Callable[..., Union[str, bytes, date, timedelta, complex, Sequence[Any], Mapping[Any, Any]]]"  [arg-type]
error: Incompatible return value type (got "DateOffset", expected "Union[str, bytes, date, timedelta, complex, Sequence[Any], Mapping[Any, Any]]")  [return-value]

Please complete the following information:

  • OS: [e.g. Windows, Linux, MacOS] macOS
  • OS Version [e.g. 22] Ventura 13.01
  • python version 3.10.5
  • version of type checker mypy 0.990
  • version of installed pandas-stubs pandas_stubs-1.5.2.221124

Additional context
Add any other context about the problem here.

This was caused by #401

Metadata

Metadata

Assignees

No one assigned

    Labels

    ApplyApply, Aggregate, TransformRegressionFunctionality that used to work in a prior pandas version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0