Skip to content

Commit

Permalink
Typing: Narrow down types of arguments (NDFrame) #10 (#52754)
Browse files Browse the repository at this point in the history
* improved specificationfor date_unit in to_json more precisely

* improved specification mode in to_hdf

* added the Literal to complib of to_hdf

* improved format for to_hdf

* address PR review

* Update generic.py

removed the new line in the import

* ran "pre-commit" to fix trailing whitespace
  • Loading branch information
mKlepsch authored Apr 25, 2023
1 parent 360bf21 commit aa1f96b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions pandas/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ def closed(self) -> bool:
AlignJoin = Literal["outer", "inner", "left", "right"]
DtypeBackend = Literal["pyarrow", "numpy_nullable"]

TimeUnit = Literal["s", "ms", "us", "ns"]
OpenFileErrors = Literal[
"strict",
"ignore",
Expand Down
9 changes: 5 additions & 4 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
TimedeltaConvertibleTypes,
TimeNonexistent,
TimestampConvertibleTypes,
TimeUnit,
ValueKeyFunc,
WriteBuffer,
WriteExcelBuffer,
Expand Down Expand Up @@ -2284,7 +2285,7 @@ def to_json(
date_format: str | None = None,
double_precision: int = 10,
force_ascii: bool_t = True,
date_unit: str = "ms",
date_unit: TimeUnit = "ms",
default_handler: Callable[[Any], JSONSerializable] | None = None,
lines: bool_t = False,
compression: CompressionOptions = "infer",
Expand Down Expand Up @@ -2564,11 +2565,11 @@ def to_hdf(
self,
path_or_buf: FilePath | HDFStore,
key: str,
mode: str = "a",
mode: Literal["a", "w", "r+"] = "a",
complevel: int | None = None,
complib: str | None = None,
complib: Literal["zlib", "lzo", "bzip2", "blosc"] | None = None,
append: bool_t = False,
format: str | None = None,
format: Literal["fixed", "table"] | None = None,
index: bool_t = True,
min_itemsize: int | dict[str, int] | None = None,
nan_rep=None,
Expand Down

0 comments on commit aa1f96b

Please sign in to comment.