Repository: pandas-dev/pandas-stubs (language: python)

Issue:
Series apply frozenset raises error, frozenset not in enumerated Callable output types
**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).

https://github.com/pandas-dev/pandas-stubs/blob/23b35e48fb6b159d9ddab7f007ede26ae8a05564/pandas-stubs/core/series.pyi#L930-L937

**To Reproduce**

1. Provide a minimal runnable `pandas` example that is not properly checked by the stubs.

```python
import pandas as pd

s = pd.Series(["A", "B", "AB"])

s.apply(tuple)
s.apply(list)
s.apply(set)
s.apply(frozenset)
```

2. Indicate which type checker you are using (`mypy` or  `pyright`).

`mypy`

3. Show the error message received from that type checker while checking your example.

```none
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`



Discussion / hints:
PS. also happy to work on this, but I'll start with #203 
> 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:
https://github.com/pandas-dev/pandas-stubs/blob/23b35e48fb6b159d9ddab7f007ede26ae8a05564/pandas-stubs/core/series.pyi#L933

And add a test.

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

Fix patch:
diff --git a/pandas-stubs/core/series.pyi b/pandas-stubs/core/series.pyi
index d38b54da..58e09d6f 100644
--- a/pandas-stubs/core/series.pyi
+++ b/pandas-stubs/core/series.pyi
@@ -939,7 +939,9 @@ class Series(IndexOpsMixin[S1], NDFrame):
     @overload
     def apply(
         self,
-        func: Callable[..., Scalar | Sequence | set | Mapping | NAType | None],
+        func: Callable[
+            ..., Scalar | Sequence | set | Mapping | NAType | frozenset | None
+        ],
         convertDType: _bool = ...,
         args: tuple = ...,
         **kwds,


Test patch:
diff --git a/tests/test_series.py b/tests/test_series.py
index 8bbe0f8d..5fbf88c3 100644
--- a/tests/test_series.py
+++ b/tests/test_series.py
@@ -3069,3 +3069,11 @@ def first_arg_not_series(argument_1: int, ser: pd.Series) -> pd.Series:
             ),
             1,
         )
+
+
+def test_series_apply() -> None:
+    s = pd.Series(["A", "B", "AB"])
+    check(assert_type(s.apply(tuple), "pd.Series[Any]"), pd.Series)
+    check(assert_type(s.apply(list), "pd.Series[Any]"), pd.Series)
+    check(assert_type(s.apply(set), "pd.Series[Any]"), pd.Series)
+    check(assert_type(s.apply(frozenset), "pd.Series[Any]"), pd.Series)