Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Series apply frozenset raises error, frozenset not in enumerated Callable output types #871

Closed
ljmc-github opened this issue Feb 16, 2024 · 3 comments · Fixed by #903
Closed
Assignees
Labels
Apply Apply, Aggregate, Transform good first issue

Comments

@ljmc-github
Copy link
Contributor

Describe the bug
Series.apply has two overloads, the first one enumerates the possible return types of a Callable, this is missing frozenset (probably others as well).

@overload
def apply(
self,
func: Callable[..., Scalar | Sequence | set | Mapping | NAType | None],
convertDType: _bool = ...,
args: tuple = ...,
**kwds,
) -> Series: ...

To Reproduce

  1. Provide a minimal runnable pandas example that is not properly checked by the stubs.
import pandas as pd

s = pd.Series(["A", "B", "AB"])

s.apply(tuple)
s.apply(list)
s.apply(set)
s.apply(frozenset)
  1. Indicate which type checker you are using (mypy or pyright).

mypy

  1. Show the error message received from that type checker while checking your example.
series-apply.py:8: error: Argument 1 to "apply" of "Series" has incompatible type "type[frozenset[Any]]"; expected "Callable[..., str | bytes | date | datetime | timedelta | datetime64 | timedelta64 | bool | int | float | Timestamp | Timedelta | complex | Sequence[Any] | set[Any] | Mapping[Any, Any] | NAType | None]"  [arg-type]
Found 1 error in 1 file (checked 1 source file)

Please complete the following information:

  • OS: MacOS
  • OS Version 14.1.2 (23B92)
  • python version 3.11.4 (pyenv managed)
  • version of type checker mypy==1.8.0
  • version of installed pandas-stubs==2.1.4.231227
@ljmc-github
Copy link
Contributor Author

PS. also happy to work on this, but I'll start with #203

@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Feb 16, 2024

PS. also happy to work on this, but I'll start with #203

I think this one is easy - we just have to add frozenset to:

func: Callable[..., Scalar | Sequence | set | Mapping | NAType | None],

And add a test.

@Dr-Irv Dr-Irv added good first issue Apply Apply, Aggregate, Transform labels Feb 16, 2024
@teshao
Copy link
Contributor

teshao commented Mar 29, 2024

Hi, I mentioned in the slack, but am I allowed to take this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Apply Apply, Aggregate, Transform good first issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants