Skip to content

TYP: read_sas #47410

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 7 commits into from
Jun 24, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
16 changes: 8 additions & 8 deletions pandas/io/sas/sas7bdat.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,12 @@ def __init__(
self,
path_or_buf: FilePath | ReadBuffer[bytes],
index=None,
convert_dates=True,
blank_missing=True,
chunksize=None,
encoding=None,
convert_text=True,
convert_header_text=True,
convert_dates: bool = True,
blank_missing: bool = True,
chunksize: int | None = None,
encoding: str | None = None,
convert_text: bool = True,
convert_header_text: bool = True,
compression: CompressionOptions = "infer",
) -> None:

Expand Down Expand Up @@ -732,7 +732,7 @@ def _process_format_subheader(self, offset: int, length: int) -> None:
self.column_formats.append(column_format)
self.columns.append(col)

def read(self, nrows: int | None = None) -> DataFrame | None:
def read(self, nrows: int | None = None) -> DataFrame:

if (nrows is None) and (self.chunksize is not None):
nrows = self.chunksize
Expand All @@ -744,7 +744,7 @@ def read(self, nrows: int | None = None) -> DataFrame | None:
raise EmptyDataError("No columns to parse from file")

if nrows > 0 and self._current_row_in_file_index >= self.row_count:
return None
return pd.DataFrame()

m = self.row_count - self._current_row_in_file_index
if nrows > m:
Expand Down
4 changes: 2 additions & 2 deletions pandas/io/sas/sas_xport.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def __init__(
self.close()
raise

def close(self):
def close(self) -> None:
self.handles.close()

def _get_row(self):
Expand Down Expand Up @@ -463,7 +463,7 @@ def _missing_double(self, vec):
return miss

@Appender(_read_method_doc)
def read(self, nrows=None):
def read(self, nrows: int | None = None) -> pd.DataFrame:

if nrows is None:
nrows = self.nobs
Expand Down
8 changes: 4 additions & 4 deletions pandas/io/sas/sasreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ class ReaderBase(metaclass=ABCMeta):
"""

@abstractmethod
def read(self, nrows=None):
def read(self, nrows: int | None = None) -> DataFrame:
pass

@abstractmethod
def close(self):
def close(self) -> None:
pass

def __enter__(self):
def __enter__(self) -> ReaderBase:
return self

def __exit__(self, exc_type, exc_value, traceback):
def __exit__(self, exc_type, exc_value, traceback) -> None:
self.close()


Expand Down
3 changes: 1 addition & 2 deletions pyright_reportGeneralTypeIssues.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@
"pandas/io/parsers/base_parser.py",
"pandas/io/parsers/c_parser_wrapper.py",
"pandas/io/pytables.py",
"pandas/io/sas/sas7bdat.py",
"pandas/io/sas/sasreader.py",
"pandas/io/sas/sas_xport.py",
"pandas/io/sql.py",
"pandas/io/stata.py",
"pandas/io/xml.py",
Expand Down