From cd699657e5ad44dcdab325a9dbbdb47199e57f09 Mon Sep 17 00:00:00 2001 From: phofl Date: Thu, 23 Dec 2021 13:19:18 +0100 Subject: [PATCH 1/4] TYP: Fix wrong type annotations in pytables --- pandas/io/pytables.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index ef9026a870423..f97c905dc27e5 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -1078,7 +1078,7 @@ def put( complevel: int | None = None, min_itemsize: int | dict[str, int] | None = None, nan_rep=None, - data_columns: list[str] | None = None, + data_columns: bool | list[str] | None = None, encoding=None, errors: str = "strict", track_times: bool = True, @@ -1102,7 +1102,7 @@ def put( subsets of the data. append : bool, default False This will force Table format, append the input data to the existing. - data_columns : list, default None + data_columns : list, bool, default None List of columns to create as data columns, or True to use all columns. See `here `__. @@ -1208,7 +1208,7 @@ def append( chunksize=None, expectedrows=None, dropna: bool | None = None, - data_columns: list[str] | None = None, + data_columns: bool | list[str] | None = None, encoding=None, errors: str = "strict", ): @@ -3263,8 +3263,7 @@ class Table(Fixed): values_axes : a list of the columns which comprise the data of this table data_columns : a list of the columns that we are allowing indexing - (these become single columns in values_axes), or True to force all - columns + (these become single columns in values_axes) nan_rep : the string to use for nan representations for string objects levels : the names of levels From 8ddd81b1e6e4d9759a303d81958548849a2cdf7d Mon Sep 17 00:00:00 2001 From: phofl Date: Thu, 23 Dec 2021 13:23:14 +0100 Subject: [PATCH 2/4] Replace with literal --- pandas/io/pytables.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index f97c905dc27e5..c574b8addb80b 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -19,6 +19,7 @@ Any, Callable, Hashable, + Literal, Sequence, cast, ) @@ -272,7 +273,7 @@ def to_hdf( min_itemsize: int | dict[str, int] | None = None, nan_rep=None, dropna: bool | None = None, - data_columns: bool | list[str] | None = None, + data_columns: Literal[True] | list[str] | None = None, errors: str = "strict", encoding: str = "UTF-8", ) -> None: @@ -1078,7 +1079,7 @@ def put( complevel: int | None = None, min_itemsize: int | dict[str, int] | None = None, nan_rep=None, - data_columns: bool | list[str] | None = None, + data_columns: Literal[True] | list[str] | None = None, encoding=None, errors: str = "strict", track_times: bool = True, @@ -1208,7 +1209,7 @@ def append( chunksize=None, expectedrows=None, dropna: bool | None = None, - data_columns: bool | list[str] | None = None, + data_columns: Literal[True] | list[str] | None = None, encoding=None, errors: str = "strict", ): From 1c6125f95121b04f894f113f9add189746353e3e Mon Sep 17 00:00:00 2001 From: phofl Date: Thu, 23 Dec 2021 13:24:47 +0100 Subject: [PATCH 3/4] Adjust docstring --- pandas/io/pytables.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index c574b8addb80b..3ce5cb31a127a 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -1103,7 +1103,7 @@ def put( subsets of the data. append : bool, default False This will force Table format, append the input data to the existing. - data_columns : list, bool, default None + data_columns : list of columns or True, default None List of columns to create as data columns, or True to use all columns. See `here `__. From f320348cb8355e31fb093d9f81ab9d99ae340bef Mon Sep 17 00:00:00 2001 From: phofl Date: Thu, 23 Dec 2021 14:42:35 +0100 Subject: [PATCH 4/4] Fix typing issue --- pandas/core/generic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index bbdb88a4b04a7..fc15c846b1907 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -2625,7 +2625,7 @@ def to_hdf( min_itemsize: int | dict[str, int] | None = None, nan_rep=None, dropna: bool_t | None = None, - data_columns: bool_t | list[str] | None = None, + data_columns: Literal[True] | list[str] | None = None, errors: str = "strict", encoding: str = "UTF-8", ) -> None: