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

Issue:
itertuples doesn't respect name parameter
**Describe the bug**

Per [the docs](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.itertuples.html) `name` is:
> The name of the returned namedtuples or None to return regular tuples.

But this repo only gives:
https://github.com/pandas-dev/pandas-stubs/blob/56eafc1ee579bfc3a145c71ec5deb0d5dd7b00ba/pandas-stubs/core/frame.pyi#L249-L251

Where:
https://github.com/pandas-dev/pandas-stubs/blob/56eafc1ee579bfc3a145c71ec5deb0d5dd7b00ba/pandas-stubs/core/frame.pyi#L2276-L2277


**To Reproduce**


```py
df = DataFrame({'num_legs': [4, 2], 'num_wings': [0, 2]},
               index=['dog', 'hawk'])
tuples: Iterable[tuple[int, int]] = df.itertuples(name=None)
```

Pyright:
```
Expression of type "Iterable[_PandasNamedTuple]" cannot be assigned to declared type "Iterable[tuple[int, int]]"
  "Iterable[_PandasNamedTuple]" is incompatible with "Iterable[tuple[int, int]]"
    Type parameter "_T_co@Iterable" is covariant, but "_PandasNamedTuple" is not a subtype of "tuple[int, int]"
      "_PandasNamedTuple" is incompatible with "tuple[int, int]"
        Tuple size mismatch; expected 2 but received indeterminatePylance[reportGeneralTypeIssues](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportGeneralTypeIssues)
```



**Please complete the following information:**
 - OS: Ubuntu 20.04.6 LTS
 - python 3.11.4
 - pyright v1.1.347
 - pandas-stubs 2.1.4.231227


**Additional context**

Also notable that the _actual_ returned type is either `map` or `zip` for `name` `Pandas` or `None` respectively.
itertuples doesn't respect name parameter
**Describe the bug**

Per [the docs](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.itertuples.html) `name` is:
> The name of the returned namedtuples or None to return regular tuples.

But this repo only gives:
https://github.com/pandas-dev/pandas-stubs/blob/56eafc1ee579bfc3a145c71ec5deb0d5dd7b00ba/pandas-stubs/core/frame.pyi#L249-L251

Where:
https://github.com/pandas-dev/pandas-stubs/blob/56eafc1ee579bfc3a145c71ec5deb0d5dd7b00ba/pandas-stubs/core/frame.pyi#L2276-L2277


**To Reproduce**


```py
df = DataFrame({'num_legs': [4, 2], 'num_wings': [0, 2]},
               index=['dog', 'hawk'])
tuples: Iterable[tuple[int, int]] = df.itertuples(name=None)
```

Pyright:
```
Expression of type "Iterable[_PandasNamedTuple]" cannot be assigned to declared type "Iterable[tuple[int, int]]"
  "Iterable[_PandasNamedTuple]" is incompatible with "Iterable[tuple[int, int]]"
    Type parameter "_T_co@Iterable" is covariant, but "_PandasNamedTuple" is not a subtype of "tuple[int, int]"
      "_PandasNamedTuple" is incompatible with "tuple[int, int]"
        Tuple size mismatch; expected 2 but received indeterminatePylance[reportGeneralTypeIssues](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportGeneralTypeIssues)
```



**Please complete the following information:**
 - OS: Ubuntu 20.04.6 LTS
 - python 3.11.4
 - pyright v1.1.347
 - pandas-stubs 2.1.4.231227


**Additional context**

Also notable that the _actual_ returned type is either `map` or `zip` for `name` `Pandas` or `None` respectively.


Discussion / hints:
Thanks for the report.  I think we need to add an `@overload` on `itertuples()` for when `name = None` that returns a `tuple[Any, ...]` 
@Dr-Irv I can do a PR, I need to finish #818 anyway :)
Thanks for the report.  I think we need to add an `@overload` on `itertuples()` for when `name = None` that returns a `tuple[Any, ...]` 
@Dr-Irv I can do a PR, I need to finish #818 anyway :)

Fix patch:
diff --git a/pandas-stubs/core/frame.pyi b/pandas-stubs/core/frame.pyi
index 066bedeb..78384247 100644
--- a/pandas-stubs/core/frame.pyi
+++ b/pandas-stubs/core/frame.pyi
@@ -267,9 +267,14 @@ class DataFrame(NDFrame, OpsMixin):
     def style(self) -> Styler: ...
     def items(self) -> Iterable[tuple[Hashable, Series]]: ...
     def iterrows(self) -> Iterable[tuple[Hashable, Series]]: ...
+    @overload
     def itertuples(
-        self, index: _bool = ..., name: _str | None = ...
+        self, index: _bool = ..., name: _str = ...
     ) -> Iterable[_PandasNamedTuple]: ...
+    @overload
+    def itertuples(
+        self, index: _bool = ..., name: None = None
+    ) -> Iterable[tuple[Any, ...]]: ...
     def __len__(self) -> int: ...
     @overload
     def dot(self, other: DataFrame | ArrayLike) -> DataFrame: ...


Test patch:
diff --git a/tests/test_frame.py b/tests/test_frame.py
index a6658dcc..f156a8e3 100644
--- a/tests/test_frame.py
+++ b/tests/test_frame.py
@@ -471,9 +471,9 @@ def test_types_itertuples() -> None:
         _PandasNamedTuple,
     )
     check(
-        assert_type(df.itertuples(index=False, name=None), Iterable[_PandasNamedTuple]),
+        assert_type(df.itertuples(index=False, name=None), Iterable[tuple[Any, ...]]),
         Iterable,
-        _PandasNamedTuple,
+        object,
     )