Skip to content

Commit 398b563

Browse files
TYP: type annotations for read_sas (#34697)
1 parent a999d8d commit 398b563

File tree

1 file changed

+37
-8
lines changed

1 file changed

+37
-8
lines changed

pandas/io/sas/sasreader.py

+37-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
"""
22
Read SAS sas7bdat or xport files.
33
"""
4-
54
from abc import ABCMeta, abstractmethod
5+
from typing import TYPE_CHECKING, Optional, Union, overload
6+
7+
from pandas._typing import FilePathOrBuffer, Label
68

79
from pandas.io.common import stringify_path
810

11+
if TYPE_CHECKING:
12+
from pandas import DataFrame # noqa: F401
13+
914

1015
# TODO(PY38): replace with Protocol in Python 3.8
1116
class ReaderBase(metaclass=ABCMeta):
@@ -22,14 +27,38 @@ def close(self):
2227
pass
2328

2429

30+
@overload
31+
def read_sas(
32+
filepath_or_buffer: FilePathOrBuffer,
33+
format: Optional[str] = ...,
34+
index: Optional[Label] = ...,
35+
encoding: Optional[str] = ...,
36+
chunksize: int = ...,
37+
iterator: bool = ...,
38+
) -> ReaderBase:
39+
...
40+
41+
42+
@overload
43+
def read_sas(
44+
filepath_or_buffer: FilePathOrBuffer,
45+
format: Optional[str] = ...,
46+
index: Optional[Label] = ...,
47+
encoding: Optional[str] = ...,
48+
chunksize: None = ...,
49+
iterator: bool = ...,
50+
) -> Union["DataFrame", ReaderBase]:
51+
...
52+
53+
2554
def read_sas(
26-
filepath_or_buffer,
27-
format=None,
28-
index=None,
29-
encoding=None,
30-
chunksize=None,
31-
iterator=False,
32-
):
55+
filepath_or_buffer: FilePathOrBuffer,
56+
format: Optional[str] = None,
57+
index: Optional[Label] = None,
58+
encoding: Optional[str] = None,
59+
chunksize: Optional[int] = None,
60+
iterator: bool = False,
61+
) -> Union["DataFrame", ReaderBase]:
3362
"""
3463
Read SAS files stored as either XPORT or SAS7BDAT format files.
3564

0 commit comments

Comments
 (0)