@@ -61,6 +61,21 @@ def warn_incompatible_dep(
61
61
)
62
62
63
63
64
+ def pandas ():
65
+ try :
66
+ return importlib .import_module ("pandas" )
67
+ except ImportError :
68
+ return MissingPandas ()
69
+
70
+
71
+ def pyarrow ():
72
+ try :
73
+ pyarrow = importlib .import_module ("pyarrow" )
74
+ return pyarrow
75
+ except ImportError :
76
+ raise errors .MissingDependencyError ("pyarrow" )
77
+
78
+
64
79
def _import_or_missing_pandas_option () -> (
65
80
tuple [ModuleLikeObject , ModuleLikeObject , bool ]
66
81
):
@@ -114,6 +129,12 @@ def _import_or_missing_pandas_option() -> (
114
129
return MissingPandas (), MissingPandas (), False
115
130
116
131
132
+ def installed_pandas () -> bool :
133
+ """This function checks if pandas is available and compatible."""
134
+ _ , _ , installed = _import_or_missing_pandas_option ()
135
+ return installed
136
+
137
+
117
138
def _import_or_missing_keyring_option () -> tuple [ModuleLikeObject , bool ]:
118
139
"""This function tries importing the following packages: keyring.
119
140
@@ -127,5 +148,22 @@ def _import_or_missing_keyring_option() -> tuple[ModuleLikeObject, bool]:
127
148
128
149
129
150
# Create actual constants to be imported from this file
130
- pandas , pyarrow , installed_pandas = _import_or_missing_pandas_option ()
151
+ try :
152
+ pyarrow = importlib .import_module ("pyarrow" )
153
+ except ImportError :
154
+ raise errors .MissingDependencyError ("pyarrow" )
155
+
131
156
keyring , installed_keyring = _import_or_missing_keyring_option ()
157
+
158
+
159
+ def __getattr__ (name ):
160
+ if name == "pandas" :
161
+ try :
162
+ return importlib .import_module ("pandas" )
163
+ except ImportError :
164
+ return MissingPandas ()
165
+
166
+ elif name == "installed_pandas" :
167
+ return installed_pandas ()
168
+
169
+ raise AttributeError (f"module { __name__ !r} has no attribute { name !r} " )
0 commit comments