Skip to content

Commit 638397f

Browse files
mutricylLaurent Mutricy
and
Laurent Mutricy
authored
add overload for itertuples with name None, resolves #854 (#915)
* add overload for itertuples with name None, resolves #854 * allow positional name --------- Co-authored-by: Laurent Mutricy <[email protected]>
1 parent d34e0a8 commit 638397f

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

pandas-stubs/core/frame.pyi

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,14 @@ class DataFrame(NDFrame, OpsMixin):
267267
def style(self) -> Styler: ...
268268
def items(self) -> Iterable[tuple[Hashable, Series]]: ...
269269
def iterrows(self) -> Iterable[tuple[Hashable, Series]]: ...
270+
@overload
270271
def itertuples(
271-
self, index: _bool = ..., name: _str | None = ...
272+
self, index: _bool = ..., name: _str = ...
272273
) -> Iterable[_PandasNamedTuple]: ...
274+
@overload
275+
def itertuples(
276+
self, index: _bool = ..., name: None = None
277+
) -> Iterable[tuple[Any, ...]]: ...
273278
def __len__(self) -> int: ...
274279
@overload
275280
def dot(self, other: DataFrame | ArrayLike) -> DataFrame: ...

tests/test_frame.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,9 +471,9 @@ def test_types_itertuples() -> None:
471471
_PandasNamedTuple,
472472
)
473473
check(
474-
assert_type(df.itertuples(index=False, name=None), Iterable[_PandasNamedTuple]),
474+
assert_type(df.itertuples(index=False, name=None), Iterable[tuple[Any, ...]]),
475475
Iterable,
476-
_PandasNamedTuple,
476+
object,
477477
)
478478

479479

0 commit comments

Comments
 (0)