Skip to content

Commit f760452

Browse files
author
Laurent Mutricy
committed
Adding overload and test to cover when litteral is not used
1 parent bc05ade commit f760452

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

pandas-stubs/core/frame.pyi

+8
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,14 @@ class DataFrame(NDFrame, OpsMixin):
289289
orient: Literal["columns", "tight"] = ...,
290290
dtype: AstypeArg | None = ...,
291291
) -> DataFrame: ...
292+
@overload
293+
@classmethod
294+
def from_dict(
295+
cls,
296+
data: dict[Any, Any],
297+
orient: str,
298+
dtype: AstypeArg | None = ...,
299+
) -> DataFrame: ...
292300
def to_numpy(
293301
self,
294302
dtype: npt.DTypeLike | None = ...,

tests/test_frame.py

+9
Original file line numberDiff line numberDiff line change
@@ -1546,6 +1546,15 @@ def test_types_from_dict() -> None:
15461546
),
15471547
pd.DataFrame,
15481548
)
1549+
# check when not using Literal
1550+
orient_str = "index"
1551+
check(
1552+
assert_type(
1553+
pd.DataFrame.from_dict(data, orient=orient_str),
1554+
pd.DataFrame,
1555+
),
1556+
pd.DataFrame,
1557+
)
15491558

15501559

15511560
def test_pipe() -> None:

0 commit comments

Comments
 (0)