Skip to content

Commit

Permalink
Type hints and revert back to catch warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ryankarlos committed Dec 28, 2019
1 parent 7dfce82 commit 54ce63e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
6 changes: 3 additions & 3 deletions pandas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ def __init__(self):
def __getattr__(self, item):
self.warnings.warn(
"The pandas.datetime module is deprecated "
"and will be removed from pandas in a future version."
"Import datetime directly instead.",
"and will be removed from pandas in a future version. "
"Import datetime directly instead",
FutureWarning,
stacklevel=2,
)
Expand All @@ -305,7 +305,7 @@ def __getattr__(self, item):
except AttributeError:
raise AttributeError(f"module datetime has no attribute {item}")

datetime = __Datetime()
datetime = __Datetime().datetime


# module level doc-string
Expand Down
13 changes: 4 additions & 9 deletions pandas/tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class TestPDApi(Base):
deprecated_classes_in_future: List[str] = []

# external modules exposed in pandas namespace
modules = []
modules: List[str] = []

# top-level functions
funcs = [
Expand Down Expand Up @@ -239,16 +239,11 @@ def test_depr(self):

def test_datetime():
from datetime import datetime
import warnings

msg = (
"The pandas.datetime module is deprecated "
"and will be removed from pandas in a future version. "
"Import datetime directly instead."
)

with tm.assert_produces_warning(FutureWarning) as w:
with warnings.catch_warnings():
warnings.simplefilter("ignore", FutureWarning)
assert datetime(2015, 1, 2, 0, 0) == pd.datetime(2015, 1, 2, 0, 0)
assert msg in str(w[-1].message)


def test_np():
Expand Down

0 comments on commit 54ce63e

Please sign in to comment.