File tree Expand file tree Collapse file tree 4 files changed +23
-5
lines changed
Expand file tree Collapse file tree 4 files changed +23
-5
lines changed Original file line number Diff line number Diff line change 2626from pandas .io .common import get_filepath_or_buffer
2727from pandas .io .sas ._sas import Parser
2828import pandas .io .sas .sas_constants as const
29+ from pandas .io .sas .sasreader import ReaderBase
2930
3031
3132class _subheader_pointer :
@@ -37,7 +38,7 @@ class _column:
3738
3839
3940# SAS7BDAT represents a SAS data file in SAS7BDAT format.
40- class SAS7BDATReader (abc .Iterator ):
41+ class SAS7BDATReader (ReaderBase , abc .Iterator ):
4142 """
4243 Read SAS files in SAS7BDAT format.
4344
Original file line number Diff line number Diff line change 1919import pandas as pd
2020
2121from pandas .io .common import get_filepath_or_buffer
22+ from pandas .io .sas .sasreader import ReaderBase
2223
2324_correct_line1 = (
2425 "HEADER RECORD*******LIBRARY HEADER RECORD!!!!!!!"
@@ -239,7 +240,7 @@ def _parse_float_vec(vec):
239240 return ieee
240241
241242
242- class XportReader (abc .Iterator ):
243+ class XportReader (ReaderBase , abc .Iterator ):
243244 __doc__ = _xport_reader_doc
244245
245246 def __init__ (
Original file line number Diff line number Diff line change 11"""
22Read SAS sas7bdat or xport files.
33"""
4+
5+ from abc import ABCMeta , abstractmethod
6+
47from pandas .io .common import stringify_path
58
69
10+ # TODO: replace with Protocol in Python 3.8
11+ class ReaderBase (metaclass = ABCMeta ):
12+ """
13+ Protocol for XportReader and SAS7BDATReader classes.
14+ """
15+
16+ @abstractmethod
17+ def read (self , nrows = None ):
18+ pass
19+
20+ @abstractmethod
21+ def close (self ):
22+ pass
23+
24+
725def read_sas (
826 filepath_or_buffer ,
927 format = None ,
@@ -62,6 +80,7 @@ def read_sas(
6280 else :
6381 raise ValueError ("unable to infer format of SAS file" )
6482
83+ reader : ReaderBase
6584 if format .lower () == "xport" :
6685 from pandas .io .sas .sas_xport import XportReader
6786
Original file line number Diff line number Diff line change @@ -291,9 +291,6 @@ check_untyped_defs=False
291291[mypy-pandas.io.sas.sas7bdat]
292292check_untyped_defs =False
293293
294- [mypy-pandas.io.sas.sasreader]
295- check_untyped_defs =False
296-
297294[mypy-pandas.io.stata]
298295check_untyped_defs =False
299296
You can’t perform that action at this time.
0 commit comments