Skip to content

Commit 11993e0

Browse files
jbrockmendeljreback
authored andcommitted
TYP: io.pytables types (#29777)
1 parent 1819bbb commit 11993e0

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

pandas/io/pytables.py

+14-12
Original file line numberDiff line numberDiff line change
@@ -1401,7 +1401,7 @@ def _check_if_open(self):
14011401
if not self.is_open:
14021402
raise ClosedFileError("{0} file is not open!".format(self._path))
14031403

1404-
def _validate_format(self, format, kwargs):
1404+
def _validate_format(self, format: str, kwargs: Dict[str, Any]) -> Dict[str, Any]:
14051405
""" validate / deprecate formats; return the new kwargs """
14061406
kwargs = kwargs.copy()
14071407

@@ -1594,10 +1594,9 @@ class TableIterator:
15941594
stop : the passed stop value (default is None)
15951595
iterator : bool, default False
15961596
Whether to use the default iterator.
1597-
chunksize : the passed chunking value (default is 50000)
1597+
chunksize : the passed chunking value (default is 100000)
15981598
auto_close : boolean, automatically close the store at the end of
15991599
iteration, default is False
1600-
kwargs : the passed kwargs
16011600
"""
16021601

16031602
chunksize: Optional[int]
@@ -1613,7 +1612,7 @@ def __init__(
16131612
start=None,
16141613
stop=None,
16151614
iterator: bool = False,
1616-
chunksize=None,
1615+
chunksize: Optional[int] = None,
16171616
auto_close: bool = False,
16181617
):
16191618
self.store = store
@@ -3399,15 +3398,14 @@ def _get_metadata_path(self, key) -> str:
33993398
""" return the metadata pathname for this key """
34003399
return "{group}/meta/{key}/meta".format(group=self.group._v_pathname, key=key)
34013400

3402-
def write_metadata(self, key, values):
3401+
def write_metadata(self, key: str, values):
34033402
"""
34043403
write out a meta data array to the key as a fixed-format Series
34053404
34063405
Parameters
34073406
----------
3408-
key : string
3407+
key : str
34093408
values : ndarray
3410-
34113409
"""
34123410
values = Series(values)
34133411
self.parent.put(
@@ -3419,7 +3417,7 @@ def write_metadata(self, key, values):
34193417
nan_rep=self.nan_rep,
34203418
)
34213419

3422-
def read_metadata(self, key):
3420+
def read_metadata(self, key: str):
34233421
""" return the meta data array for this key """
34243422
if getattr(getattr(self.group, "meta", None), key, None) is not None:
34253423
return self.parent.select(self._get_metadata_path(key))
@@ -3966,7 +3964,11 @@ def process_filter(field, filt):
39663964
return obj
39673965

39683966
def create_description(
3969-
self, complib=None, complevel=None, fletcher32: bool = False, expectedrows=None
3967+
self,
3968+
complib=None,
3969+
complevel=None,
3970+
fletcher32: bool = False,
3971+
expectedrows: Optional[int] = None,
39703972
):
39713973
""" create the description of the table from the axes & values """
39723974

@@ -4150,7 +4152,7 @@ def write(
41504152
# add the rows
41514153
self.write_data(chunksize, dropna=dropna)
41524154

4153-
def write_data(self, chunksize, dropna=False):
4155+
def write_data(self, chunksize: Optional[int], dropna: bool = False):
41544156
""" we form the data into a 2-d including indexes,values,mask
41554157
write chunk-by-chunk """
41564158

@@ -4478,7 +4480,7 @@ class GenericTable(AppendableFrameTable):
44784480
obj_type = DataFrame
44794481

44804482
@property
4481-
def pandas_type(self):
4483+
def pandas_type(self) -> str:
44824484
return self.pandas_kind
44834485

44844486
@property
@@ -4530,7 +4532,7 @@ class AppendableMultiFrameTable(AppendableFrameTable):
45304532
_re_levels = re.compile(r"^level_\d+$")
45314533

45324534
@property
4533-
def table_type_short(self):
4535+
def table_type_short(self) -> str:
45344536
return "appendable_multi"
45354537

45364538
def write(self, obj, data_columns=None, **kwargs):

0 commit comments

Comments
 (0)