Skip to content

Commit 16cd4e8

Browse files
authored
fix pyspark check registration (#2087)
Signed-off-by: cosmicBboy <[email protected]>
1 parent 2a0ee70 commit 16cd4e8

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

pandera/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@
3636
except ImportError as err:
3737
import warnings
3838

39-
if "pandas" in str(err) or "numpy" in str(err):
39+
err_msg = str(err)
40+
if err_msg in {"No module named 'pandas'", "No module named 'numpy'"}:
4041
warnings.warn(_warning_msg, UserWarning)
42+
elif err_msg.startswith("pandera requires pandas >= 2.1.1"):
43+
warnings.warn(err_msg, UserWarning)
4144
else:
4245
raise # Re-raise any other `ImportError` exceptions
4346

pandera/_pandas_deprecated.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,17 @@
2222
if parse(pd.__version__) < _min_pandas_version:
2323
raise ImportError(
2424
"pandera requires pandas >= 2.1.1, but you have pandas "
25-
f"{pd.__version__}. Please upgrade pandas to the minimum supported version."
25+
f"{pd.__version__}. Using the pandera.pandas module may not work as "
26+
"expected. It's highly recommended to upgrade pandas to the minimum "
27+
"supported version."
2628
)
2729

2830
if parse(np.__version__) < _min_numpy_version:
2931
raise ImportError(
3032
"pandera requires numpy >= 1.24.4, but you have numpy "
31-
f"{np.__version__}. Please upgrade numpy to the minimum supported version."
33+
f"{np.__version__}. Using the pandera.pandas module may not work as "
34+
"expected. It's highly recommended to upgrade numpy to the minimum "
35+
"supported version."
3236
)
3337

3438
from pandera._patch_numpy2 import _patch_numpy2

pandera/pyspark.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
_patch_numpy2()
77

8+
import pandera.backends.base.builtin_checks
9+
import pandera.backends.base.builtin_hypotheses
810
import pandera.backends.pyspark
911
from pandera import errors, external_config
1012
from pandera.accessors import pyspark_sql_accessor

0 commit comments

Comments
 (0)