Skip to content

Commit f2a01bc

Browse files
Update type hints to align util/testing.py and picke.py
1 parent e736b0a commit f2a01bc

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

pandas/io/pickle.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
""" pickle compat """
22
import pickle
3-
from typing import Any, Optional
3+
from typing import Optional
44
import warnings
55

6-
from pandas._typing import FilePathOrBuffer
6+
from pandas._typing import FilePathOrBuffer, FrameOrSeries
77
from pandas.compat import pickle_compat as pc
88

99
from pandas.io.common import get_filepath_or_buffer, get_handle
1010

1111

1212
def to_pickle(
13-
obj: Any,
13+
obj: FrameOrSeries,
1414
filepath_or_buffer: FilePathOrBuffer,
1515
compression: Optional[str] = "infer",
1616
protocol: int = pickle.HIGHEST_PROTOCOL,
@@ -20,7 +20,7 @@ def to_pickle(
2020
2121
Parameters
2222
----------
23-
obj : any object
23+
obj : any pandas object
2424
Any python object.
2525
filepath_or_buffer : str, path object or file-like object
2626
File path, URL, or buffer where the pickled object will be stored.

pandas/util/testing.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
)
2323

2424
import pandas._libs.testing as _testing
25-
from pandas._typing import FrameOrSeries
25+
from pandas._typing import FilePathOrBuffer, FrameOrSeries
2626
from pandas.compat import _get_lzma_file, _import_lzma
2727

2828
from pandas.core.dtypes.common import (
@@ -101,7 +101,9 @@ def reset_display_options():
101101
pd.reset_option("^display.", silent=True)
102102

103103

104-
def round_trip_pickle(obj: FrameOrSeries, path: Optional[str] = None) -> FrameOrSeries:
104+
def round_trip_pickle(
105+
obj: FrameOrSeries, path: FilePathOrBuffer = None
106+
) -> FrameOrSeries:
105107
"""
106108
Pickle an object and then read it again.
107109

0 commit comments

Comments
 (0)