Skip to content

Commit 71c4963

Browse files
authored
remove top-level pandera __init__ import warning (#2088)
* remove top-level pandera __init__ import warning Signed-off-by: cosmicBboy <[email protected]> * fix lint Signed-off-by: cosmicBboy <[email protected]> --------- Signed-off-by: cosmicBboy <[email protected]>
1 parent 16cd4e8 commit 71c4963

File tree

3 files changed

+9
-19
lines changed

3 files changed

+9
-19
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ print(Schema.validate(df))
140140
>
141141
> And all of the rest of your pandera code should work. Using the top-level
142142
> `pandera` module to access `DataFrameSchema` and the other pandera classes
143-
> or functions will be deprecated in a future version
143+
> or functions will be deprecated in version `0.29.0`
144144
145145
146146
## Next steps

docs/source/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ import pandera.pandas as pa
257257

258258
And all of the rest of your pandera code should work. Using the top-level
259259
`pandera` module to access `DataFrameSchema` and the other pandera classes
260-
or functions will be deprecated in a future version
260+
or functions will be deprecated in version `0.29.0`
261261
:::
262262

263263
## Informative Errors

pandera/__init__.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,6 @@
44
from pandera._version import __version__
55

66

7-
_warning_msg = """Pandas and numpy have been removed from the base pandera
8-
dependencies. Please install pandas as part of your environment's
9-
dependencies or install the pandas extra with:
10-
11-
```bash
12-
pip install pandas pandera
13-
14-
# or
15-
pip install 'pandera[pandas]'
16-
```
17-
"""
18-
19-
207
try:
218
# Only add pandas to the top-level pandera namespace
229
# if pandas and numpy are installed
@@ -33,14 +20,17 @@
3320
*_pandas_deprecated_all,
3421
]
3522

36-
except ImportError as err:
23+
except (ImportError, ModuleNotFoundError) as err:
3724
import warnings
3825

3926
err_msg = str(err)
40-
if err_msg in {"No module named 'pandas'", "No module named 'numpy'"}:
41-
warnings.warn(_warning_msg, UserWarning)
42-
elif err_msg.startswith("pandera requires pandas >= 2.1.1"):
27+
if err_msg.startswith("pandera requires pandas >= 2.1.1"):
4328
warnings.warn(err_msg, UserWarning)
29+
elif err_msg.startswith(
30+
("No module named 'pandas'", "No module named 'numpy'")
31+
):
32+
# ignore this error
33+
pass
4434
else:
4535
raise # Re-raise any other `ImportError` exceptions
4636

0 commit comments

Comments
 (0)