1
1
""" orc compat """
2
2
3
3
import distutils
4
+ from typing import List , Optional
4
5
5
6
from pandas .compat ._optional import import_optional_dependency
6
7
from pandas .errors import AbstractMethodError
7
8
8
9
from pandas import DataFrame , get_option
10
+ from pandas ._typing import FilePathOrBuffer
9
11
10
12
from pandas .io .common import get_filepath_or_buffer
11
13
12
14
13
- def get_engine (engine ) :
15
+ def get_engine (engine : str ) -> "PyArrowImpl" :
14
16
""" return our implementation """
15
17
16
18
if engine == "auto" :
@@ -42,7 +44,7 @@ class BaseImpl:
42
44
api = None # module
43
45
44
46
@staticmethod
45
- def validate_dataframe (df ):
47
+ def validate_dataframe (df : DataFrame ):
46
48
47
49
if not isinstance (df , DataFrame ):
48
50
raise ValueError ("to_orc only supports IO with DataFrames" )
@@ -58,10 +60,12 @@ def validate_dataframe(df):
58
60
if not valid_names :
59
61
raise ValueError ("Index level names must be strings" )
60
62
61
- def write (self , df , path , compression , ** kwargs ):
63
+ def write (self , df : DataFrame , path : FilePathOrBuffer , compression : str , ** kwargs ):
62
64
raise AbstractMethodError (self )
63
65
64
- def read (self , path , columns = None , ** kwargs ):
66
+ def read (
67
+ self , path : FilePathOrBuffer , columns : Optional [List [str ]] = None , ** kwargs
68
+ ):
65
69
raise AbstractMethodError (self )
66
70
67
71
@@ -81,7 +85,9 @@ def __init__(self):
81
85
82
86
self .api = pyarrow
83
87
84
- def read (self , path , columns = None , ** kwargs ):
88
+ def read (
89
+ self , path : FilePathOrBuffer , columns : Optional [List [str ]] = None , ** kwargs
90
+ ) -> DataFrame :
85
91
path , _ , _ , _ = get_filepath_or_buffer (path )
86
92
87
93
py_file = self .api .input_stream (path )
@@ -92,7 +98,12 @@ def read(self, path, columns=None, **kwargs):
92
98
return result
93
99
94
100
95
- def read_orc (path , engine = "auto" , columns = None , ** kwargs ):
101
+ def read_orc (
102
+ path : FilePathOrBuffer ,
103
+ engine : str = "auto" ,
104
+ columns : Optional [List [str ]] = None ,
105
+ ** kwargs ,
106
+ ):
96
107
"""
97
108
Load an ORC object from the file path, returning a DataFrame.
98
109
0 commit comments