Skip to content

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

Closed
@ljmc-github

Description

@ljmc-github

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions