Skip to content

Commit 0975509

Browse files
jorisvandenbosschejreback
authored andcommitted
Use DeprecationWarning for core.common deprecations (GH13634)
Related to second question in #13634 (whether to use FutureWarning or DeprecationWarning in deprecating the public pandas.core.common functions). As those functions are mostly used in library code, and less directly by users in their own code, I think a DeprecationWarning is more appropriate in this case. For example, in our own docs, we started to get warnings due to an example with a statsmodels regression that uses patsy using one of those functions. Note that recent IPython also shows DeprecationWarnings when using a deprecated function interactively. Author: Joris Van den Bossche <[email protected]> Closes #13990 from jorisvandenbossche/common-depr-warning and squashes the following commits: 2de5d48 [Joris Van den Bossche] Use DeprecationWarning for core.common deprecations (GH13634)
1 parent 1f88312 commit 0975509

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

doc/source/whatsnew/v0.19.0.txt

+5-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pandas development API
3131
As part of making pandas APi more uniform and accessible in the future, we have created a standard
3232
sub-package of pandas, ``pandas.api`` to hold public API's. We are starting by exposing type
3333
introspection functions in ``pandas.api.types``. More sub-packages and officially sanctioned API's
34-
will be published in future versions of pandas.
34+
will be published in future versions of pandas (:issue:`13147`, :issue:`13634`)
3535

3636
The following are now part of this API:
3737

@@ -42,6 +42,10 @@ The following are now part of this API:
4242
funcs = [ f for f in dir(types) if not f.startswith('_') ]
4343
pprint.pprint(funcs)
4444

45+
.. note::
46+
47+
Calling these functions from the internal module ``pandas.core.common`` will now show a ``DeprecationWarning`` (:issue:`13990`)
48+
4549
.. _whatsnew_0190.enhancements.asof_merge:
4650

4751
``merge_asof`` for asof-style time-series joining

pandas/api/tests/test_api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def test_types(self):
163163
self.check(types, self.allowed)
164164

165165
def check_deprecation(self, fold, fnew):
166-
with tm.assert_produces_warning(FutureWarning):
166+
with tm.assert_produces_warning(DeprecationWarning):
167167
try:
168168
result = fold('foo')
169169
expected = fnew('foo')

pandas/core/common.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def wrapper(*args, **kwargs):
3131
warnings.warn("pandas.core.common.{t} is deprecated. "
3232
"import from the public API: "
3333
"pandas.api.types.{t} instead".format(t=t),
34-
FutureWarning, stacklevel=3)
34+
DeprecationWarning, stacklevel=3)
3535
return getattr(types, t)(*args, **kwargs)
3636
return wrapper
3737

@@ -57,7 +57,7 @@ def wrapper(*args, **kwargs):
5757
"These are not longer public API functions, "
5858
"but can be imported from "
5959
"pandas.types.common.{t} instead".format(t=t),
60-
FutureWarning, stacklevel=3)
60+
DeprecationWarning, stacklevel=3)
6161
return getattr(common, t)(*args, **kwargs)
6262
return wrapper
6363

0 commit comments

Comments
 (0)