Skip to content

Commit e77e737

Browse files
jbrockmendelproost
authored andcommitted
CLN: fix pytables passing too many kwargs (pandas-dev#29951)
1 parent ae783f2 commit e77e737

File tree

1 file changed

+44
-12
lines changed

1 file changed

+44
-12
lines changed

pandas/io/pytables.py

+44-12
Original file line numberDiff line numberDiff line change
@@ -1431,16 +1431,20 @@ def _validate_format(self, format: str, kwargs: Dict[str, Any]) -> Dict[str, Any
14311431
return kwargs
14321432

14331433
def _create_storer(
1434-
self, group, format=None, value=None, **kwargs
1434+
self,
1435+
group,
1436+
format=None,
1437+
value=None,
1438+
encoding: str = "UTF-8",
1439+
errors: str = "strict",
14351440
) -> Union["GenericFixed", "Table"]:
14361441
""" return a suitable class to operate """
14371442

14381443
def error(t):
14391444
# return instead of raising so mypy can tell where we are raising
14401445
return TypeError(
14411446
f"cannot properly create the storer for: [{t}] [group->"
1442-
f"{group},value->{type(value)},format->{format},"
1443-
f"kwargs->{kwargs}]"
1447+
f"{group},value->{type(value)},format->{format}"
14441448
)
14451449

14461450
pt = _ensure_decoded(getattr(group._v_attrs, "pandas_type", None))
@@ -1476,7 +1480,9 @@ def error(t):
14761480
# a storer node
14771481
if "table" not in pt:
14781482
try:
1479-
return globals()[_STORER_MAP[pt]](self, group, **kwargs)
1483+
return globals()[_STORER_MAP[pt]](
1484+
self, group, encoding=encoding, errors=errors
1485+
)
14801486
except KeyError:
14811487
raise error("_STORER_MAP")
14821488

@@ -1517,7 +1523,9 @@ def error(t):
15171523
pass
15181524

15191525
try:
1520-
return globals()[_TABLE_MAP[tt]](self, group, **kwargs)
1526+
return globals()[_TABLE_MAP[tt]](
1527+
self, group, encoding=encoding, errors=errors
1528+
)
15211529
except KeyError:
15221530
raise error("_TABLE_MAP")
15231531

@@ -1526,11 +1534,20 @@ def _write_to_group(
15261534
key: str,
15271535
value,
15281536
format,
1537+
axes=None,
15291538
index=True,
15301539
append=False,
15311540
complib=None,
1541+
complevel: Optional[int] = None,
1542+
fletcher32=None,
1543+
min_itemsize=None,
1544+
chunksize=None,
1545+
expectedrows=None,
1546+
dropna=False,
1547+
nan_rep=None,
1548+
data_columns=None,
15321549
encoding=None,
1533-
**kwargs,
1550+
errors: str = "strict",
15341551
):
15351552
group = self.get_node(key)
15361553

@@ -1565,7 +1582,7 @@ def _write_to_group(
15651582
group = self._handle.create_group(path, p)
15661583
path = new_path
15671584

1568-
s = self._create_storer(group, format, value, encoding=encoding, **kwargs)
1585+
s = self._create_storer(group, format, value, encoding=encoding, errors=errors)
15691586
if append:
15701587
# raise if we are trying to append to a Fixed format,
15711588
# or a table that exists (and we are putting)
@@ -1580,7 +1597,20 @@ def _write_to_group(
15801597
raise ValueError("Compression not supported on Fixed format stores")
15811598

15821599
# write the object
1583-
s.write(obj=value, append=append, complib=complib, **kwargs)
1600+
s.write(
1601+
obj=value,
1602+
axes=axes,
1603+
append=append,
1604+
complib=complib,
1605+
complevel=complevel,
1606+
fletcher32=fletcher32,
1607+
min_itemsize=min_itemsize,
1608+
chunksize=chunksize,
1609+
expectedrows=expectedrows,
1610+
dropna=dropna,
1611+
nan_rep=nan_rep,
1612+
data_columns=data_columns,
1613+
)
15841614

15851615
if isinstance(s, Table) and index:
15861616
s.create_index(columns=index)
@@ -2524,10 +2554,11 @@ class Fixed:
25242554
ndim: int
25252555
parent: HDFStore
25262556
group: "Node"
2557+
errors: str
25272558
is_table = False
25282559

25292560
def __init__(
2530-
self, parent: HDFStore, group: "Node", encoding=None, errors="strict", **kwargs
2561+
self, parent: HDFStore, group: "Node", encoding=None, errors: str = "strict"
25312562
):
25322563
assert isinstance(parent, HDFStore), type(parent)
25332564
assert _table_mod is not None # needed for mypy
@@ -3199,8 +3230,10 @@ class Table(Fixed):
31993230
metadata: List
32003231
info: Dict
32013232

3202-
def __init__(self, parent: HDFStore, group: "Node", **kwargs):
3203-
super().__init__(parent, group, **kwargs)
3233+
def __init__(
3234+
self, parent: HDFStore, group: "Node", encoding=None, errors: str = "strict"
3235+
):
3236+
super().__init__(parent, group, encoding=encoding, errors=errors)
32043237
self.index_axes = []
32053238
self.non_index_axes = []
32063239
self.values_axes = []
@@ -4076,7 +4109,6 @@ def write(
40764109
dropna=False,
40774110
nan_rep=None,
40784111
data_columns=None,
4079-
errors="strict", # not used here, but passed to super
40804112
):
40814113

40824114
if not append and self.is_exists:

0 commit comments

Comments
 (0)