-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DEPR: relocate exceptions in pandas.core.common #14800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I can do this, just looking at the |
I don't think using the existing
This scenario involves selectively deprecating individual exceptions in one module So when I execute the following: from pandas.core.common import PandasError I should get:
If I import This is how I'm using # module: pandas.api.exceptions
from pandas.util.depr_module import _DeprecatedModule
exceptions = _DeprecatedModule('pandas.core.common')
PandasError = exceptions.PandasError When I import
Several problems with the above:
The only way I could I could see fixing (2) is by passing in the name of the module where the I'm trying to think of solution which satisfies the following criteria:
|
We had quite a long discussion in #14479 about deprecating an Exception (and the conclusion was more or less that it is not possible), but not sure if it is fully similar situation, as there it was about renaming a warning, where here it is about moving it. |
@m-charlton you might be able to easily do this by: a) moving the exception definition to |
Had a look at the way functions are deprecated in The function deprecation warnings would appear every time an attempt to invoke When deprecating an exception you'd want the deprecation warning to appear on If warnings were added at import time: # module: pandas.core.common
class PandasError(Exception):
warnings.warn('...', DeprecationWarning)
... Then you'd see a warning anytime anything from the enclosing module were Using the imported referenced exception in #module: pandas.api.exceptions
import pandas.core.common
...
PandasError = pandas.core.common.PandasError Will still result in a warning message being issued, if of course I don't know if there is some decorator/metaclass magic which could be used. Short of duplicating code in |
@m-charlton maybe was not clear here. I want to completely move all of the exceptions to we want to have a warning message printed when someone does This is the purpose of the THEN internaly in pandas we will always import from This is almost exactly what we did with |
My bad, that makes more sense. Will start work now. |
Move exceptions/warnings from pandas.core.common to pandas.api.exceptions The exceptions/warnings can still be imported from pandas.core.common however a DeprecationWarning will be issued when they are raised.
move all exception / warning impls (and references) from pandas.core.common and pandas.io.common closes pandas-dev#14800
move all exception / warning impls (and references) from pandas.core.common and pandas.io.common closes pandas-dev#14800
move all exception / warning impls (and references) from pandas.core.common and pandas.io.common closes pandas-dev#14800
move all exception / warning impls (and references) from pandas.core.common and pandas.io.common closes pandas-dev#14800
move all exception / warning impls (and references) from pandas.core.common and pandas.io.common closes pandas-dev#14800
move all exception / warning impls (and references) from pandas.core.common and pandas.io.common closes pandas-dev#14800
move all exception / warning impls (and references) from pandas.core.common and pandas.io.common closes pandas-dev#14800
move all exception / warning impls (and references) from pandas.core.common and pandas.io.common closes pandas-dev#14800
move all exception / warning impls (and references) from pandas.core.common and pandas.io.common closes pandas-dev#14800
move all exception / warning impls (and references) from pandas.core.common and pandas.io.common closes pandas-dev#14800
move all exception / warning impls (and references) from pandas.core.common and pandas.io.common closes pandas-dev#14800
move these to
pandas.api.exceptions
using
pandas.util.depr_module
this should be straightforwardThe text was updated successfully, but these errors were encountered: