Skip to content

TYP: io.pytables types #29777

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -1404,7 +1404,7 @@ def _check_if_open(self):
if not self.is_open:
raise ClosedFileError("{0} file is not open!".format(self._path))

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

Expand Down Expand Up @@ -1597,10 +1597,9 @@ class TableIterator:
stop : the passed stop value (default is None)
iterator : bool, default False
Whether to use the default iterator.
chunksize : the passed chunking value (default is 50000)
chunksize : the passed chunking value (default is 100000)
auto_close : boolean, automatically close the store at the end of
iteration, default is False
kwargs : the passed kwargs
"""

chunksize: Optional[int]
Expand All @@ -1616,7 +1615,7 @@ def __init__(
start=None,
stop=None,
iterator: bool = False,
chunksize=None,
chunksize: Optional[int] = None,
auto_close: bool = False,
):
self.store = store
Expand Down Expand Up @@ -3448,15 +3447,14 @@ def _get_metadata_path(self, key) -> str:
""" return the metadata pathname for this key """
return "{group}/meta/{key}/meta".format(group=self.group._v_pathname, key=key)

def write_metadata(self, key, values):
def write_metadata(self, key: str, values):
"""
write out a meta data array to the key as a fixed-format Series

Parameters
----------
key : string
key : str
values : ndarray

"""
values = Series(values)
self.parent.put(
Expand All @@ -3468,7 +3466,7 @@ def write_metadata(self, key, values):
nan_rep=self.nan_rep,
)

def read_metadata(self, key):
def read_metadata(self, key: str):
""" return the meta data array for this key """
if getattr(getattr(self.group, "meta", None), key, None) is not None:
return self.parent.select(self._get_metadata_path(key))
Expand Down Expand Up @@ -4010,7 +4008,11 @@ def process_filter(field, filt):
return obj

def create_description(
self, complib=None, complevel=None, fletcher32: bool = False, expectedrows=None
self,
complib=None,
complevel=None,
fletcher32: bool = False,
expectedrows: Optional[int] = None,
):
""" create the description of the table from the axes & values """

Expand Down Expand Up @@ -4228,7 +4230,7 @@ def write(
# add the rows
self.write_data(chunksize, dropna=dropna)

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

Expand Down Expand Up @@ -4556,7 +4558,7 @@ class GenericTable(AppendableFrameTable):
obj_type = DataFrame

@property
def pandas_type(self):
def pandas_type(self) -> str:
return self.pandas_kind

@property
Expand Down Expand Up @@ -4608,7 +4610,7 @@ class AppendableMultiFrameTable(AppendableFrameTable):
_re_levels = re.compile(r"^level_\d+$")

@property
def table_type_short(self):
def table_type_short(self) -> str:
return "appendable_multi"

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