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

Issue:
Index.rename() should return Self
**Describe the bug**
`Index.rename()` should return `Self`

**To Reproduce**
```python
import pandas as pd

ind = pd.Index([1,2,3], name="foo")
ind2 = ind.rename("goo")
reveal_type(ind2)
```
shows that `ind2` is unknown


**Please complete the following information:**
 - OS: Windows 10
 - OS Version ??
 - python version  3.9
 - version of type checker  pyright 1.1.362
 - version of installed `pandas-stubs` :  2.2.2.240514  






Discussion / hints:
Need to fix `rename()` in `core/indexes/base.pyi`
May I take up this issue?
> May I take up this issue?

Assigned to you.  go ahead.  Need a fix and a test.

Fix patch:
diff --git a/pandas-stubs/core/indexes/base.pyi b/pandas-stubs/core/indexes/base.pyi
index 388b3d33..b8dc9444 100644
--- a/pandas-stubs/core/indexes/base.pyi
+++ b/pandas-stubs/core/indexes/base.pyi
@@ -292,7 +292,7 @@ class Index(IndexOpsMixin[S1]):
     @names.setter
     def names(self, names: list[_str]): ...
     def set_names(self, names, *, level=..., inplace: bool = ...): ...
-    def rename(self, name, inplace: bool = ...): ...
+    def rename(self, name, inplace: bool = ...) -> Self: ...
     @property
     def nlevels(self) -> int: ...
     def sortlevel(self, level=..., ascending: bool = ..., sort_remaining=...): ...


Test patch:
diff --git a/tests/test_indexes.py b/tests/test_indexes.py
index 84c3c491..e59fc0ca 100644
--- a/tests/test_indexes.py
+++ b/tests/test_indexes.py
@@ -113,6 +113,12 @@ def test_str_split() -> None:
     check(assert_type(ind.str.split("-", expand=True), pd.MultiIndex), pd.MultiIndex)
 
 
+def test_index_rename() -> None:
+    ind = pd.Index([1, 2, 3], name="foo")
+    ind2 = ind.rename("goo")
+    check(assert_type(ind2, "pd.Index[int]"), pd.Index, np.integer)
+
+
 def test_index_dropna():
     idx = pd.Index([1, 2])