From 3f5e5ca49ad53e018d437469c945b2d33dae2534 Mon Sep 17 00:00:00 2001 From: Yasin Tatar Date: Tue, 18 Apr 2023 15:29:56 +0200 Subject: [PATCH 1/2] add: literal type hints --- pandas/core/generic.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 582a043a8a78a..d46ba6c8d7f08 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -2125,7 +2125,7 @@ def to_excel( index_label: IndexLabel = None, startrow: int = 0, startcol: int = 0, - engine: str | None = None, + engine: Literal["openpyxl", "xlsxwriter"] | None = None, merge_cells: bool_t = True, inf_rep: str = "inf", freeze_panes: tuple[int, int] | None = None, @@ -2272,7 +2272,7 @@ def to_excel( def to_json( self, path_or_buf: FilePath | WriteBuffer[bytes] | WriteBuffer[str] | None = None, - orient: str | None = None, + orient: Literal["split", "records", "index", "table"] | None = None, date_format: str | None = None, double_precision: int = 10, force_ascii: bool_t = True, @@ -11499,7 +11499,7 @@ def rolling( win_type: str | None = None, on: str | None = None, axis: Axis | lib.NoDefault = lib.no_default, - closed: str | None = None, + closed: Literal["right", "left", "both", "neither"] | None = None, step: int | None = None, method: str = "single", ) -> Window | Rolling: @@ -11558,7 +11558,7 @@ def expanding( self, min_periods: int = 1, axis: Axis | lib.NoDefault = lib.no_default, - method: str = "single", + method: Literal["single", "table"] = "single", ) -> Expanding: if axis is not lib.no_default: axis = self._get_axis_number(axis) @@ -11596,7 +11596,7 @@ def ewm( ignore_na: bool_t = False, axis: Axis | lib.NoDefault = lib.no_default, times: np.ndarray | DataFrame | Series | None = None, - method: str = "single", + method: Literal["single", "table"] = "single", ) -> ExponentialMovingWindow: if axis is not lib.no_default: axis = self._get_axis_number(axis) From d90da323e03f7957d94031ab824b58158ebf8e31 Mon Sep 17 00:00:00 2001 From: Yasin Tatar Date: Wed, 19 Apr 2023 17:55:38 +0200 Subject: [PATCH 2/2] review comments --- pandas/core/generic.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index d46ba6c8d7f08..dc54a6fa7fc72 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -2272,7 +2272,8 @@ def to_excel( def to_json( self, path_or_buf: FilePath | WriteBuffer[bytes] | WriteBuffer[str] | None = None, - orient: Literal["split", "records", "index", "table"] | None = None, + orient: Literal["split", "records", "index", "table", "columns", "values"] + | None = None, date_format: str | None = None, double_precision: int = 10, force_ascii: bool_t = True, @@ -11499,7 +11500,7 @@ def rolling( win_type: str | None = None, on: str | None = None, axis: Axis | lib.NoDefault = lib.no_default, - closed: Literal["right", "left", "both", "neither"] | None = None, + closed: IntervalClosedType | None = None, step: int | None = None, method: str = "single", ) -> Window | Rolling: