Skip to content

Commit 54ce63e

Browse files
committed
Type hints and revert back to catch warnings
1 parent 7dfce82 commit 54ce63e

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

pandas/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ def __init__(self):
294294
def __getattr__(self, item):
295295
self.warnings.warn(
296296
"The pandas.datetime module is deprecated "
297-
"and will be removed from pandas in a future version."
298-
"Import datetime directly instead.",
297+
"and will be removed from pandas in a future version. "
298+
"Import datetime directly instead",
299299
FutureWarning,
300300
stacklevel=2,
301301
)
@@ -305,7 +305,7 @@ def __getattr__(self, item):
305305
except AttributeError:
306306
raise AttributeError(f"module datetime has no attribute {item}")
307307

308-
datetime = __Datetime()
308+
datetime = __Datetime().datetime
309309

310310

311311
# module level doc-string

pandas/tests/api/test_api.py

+4-9
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class TestPDApi(Base):
101101
deprecated_classes_in_future: List[str] = []
102102

103103
# external modules exposed in pandas namespace
104-
modules = []
104+
modules: List[str] = []
105105

106106
# top-level functions
107107
funcs = [
@@ -239,16 +239,11 @@ def test_depr(self):
239239

240240
def test_datetime():
241241
from datetime import datetime
242+
import warnings
242243

243-
msg = (
244-
"The pandas.datetime module is deprecated "
245-
"and will be removed from pandas in a future version. "
246-
"Import datetime directly instead."
247-
)
248-
249-
with tm.assert_produces_warning(FutureWarning) as w:
244+
with warnings.catch_warnings():
245+
warnings.simplefilter("ignore", FutureWarning)
250246
assert datetime(2015, 1, 2, 0, 0) == pd.datetime(2015, 1, 2, 0, 0)
251-
assert msg in str(w[-1].message)
252247

253248

254249
def test_np():

0 commit comments

Comments
 (0)