Skip to content

Commit a25272b

Browse files
jorisvandenbosschejreback
authored andcommitted
CLN: update pandas.lib deprecation messages (GH15936) (#16021)
1 parent d791362 commit a25272b

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

pandas/__init__.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,11 @@
7575
parser = _DeprecatedModule(deprmod='pandas.parser',
7676
removals=['na_values'],
7777
moved={'CParserError': 'pandas.errors.ParserError'})
78-
lib = _DeprecatedModule(deprmod='pandas.lib', deprmodto='pandas._libs.lib',
79-
moved={'infer_dtype': 'pandas.api.lib.infer_dtype'})
78+
lib = _DeprecatedModule(deprmod='pandas.lib', deprmodto=False,
79+
moved={'Timestamp': 'pandas.Timestamp',
80+
'Timedelta': 'pandas.Timedelta',
81+
'NaT': 'pandas.NaT',
82+
'infer_dtype': 'pandas.api.lib.infer_dtype'})
8083
tslib = _DeprecatedModule(deprmod='pandas.tslib',
8184
moved={'Timestamp': 'pandas.Timestamp',
8285
'Timedelta': 'pandas.Timedelta',

pandas/util/depr_module.py

+16-9
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,22 @@ def __getattr__(self, name):
7575
FutureWarning, stacklevel=2)
7676
else:
7777
deprmodto = self.deprmodto
78-
if deprmodto is None:
79-
deprmodto = "{modname}.{name}".format(
80-
modname=obj.__module__, name=name)
81-
# The object is actually located in another module.
82-
warnings.warn(
83-
"{deprmod}.{name} is deprecated. Please use "
84-
"{deprmodto}.{name} instead.".format(
85-
deprmod=self.deprmod, name=name, deprmodto=deprmodto),
86-
FutureWarning, stacklevel=2)
78+
if deprmodto is False:
79+
warnings.warn(
80+
"{deprmod}.{name} is deprecated and will be removed in "
81+
"a future version.".format(
82+
deprmod=self.deprmod, name=name),
83+
FutureWarning, stacklevel=2)
84+
else:
85+
if deprmodto is None:
86+
deprmodto = "{modname}.{name}".format(
87+
modname=obj.__module__, name=name)
88+
# The object is actually located in another module.
89+
warnings.warn(
90+
"{deprmod}.{name} is deprecated. Please use "
91+
"{deprmodto}.{name} instead.".format(
92+
deprmod=self.deprmod, name=name, deprmodto=deprmodto),
93+
FutureWarning, stacklevel=2)
8794

8895
return obj
8996

0 commit comments

Comments
 (0)