Closed wkerzendorf closed 10 years ago
Wait, since when are DeprecationWarnings being raised as exceptions? That shouldn't be the case by default.
This has been the case for some time. See astropy/astropy#1948. The method that does this is helper/treat_deprecations_as_exceptions
.
But, of course, that should only affect testing, not normal runtime, at least that's the intent.
@mdboom @embray - the problem I'm running into is that other packages use deprecated functions and that they are then raised in the affiliated package (or semi-affiliated package in my case :wink: ). Is there a way to disable this in the setup.cfg?
@mdboom - I'm talking about testing, but when I test my package it will fail on deprecation warnings in imported packages.
Ah, this is just in testing. I got the impression it was during normal execution.
that's right - but it's still problematic :wink:
@wkerzendorf - are those other packages using astropy deprecated functions? My impression was that only astropy deprecation warnings would be raised as exceptions during testing. In any case, I agree this could maybe be made an option that can be turned off.
@astrofrog no it seems to target all deprecationwarnings:
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/io/pytables.py:528:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
args = ('tardis/tests/data/He_nlte_pops.h5', 'a'), kwargs = {}
def oldfunc(*args, **kwargs):
> warn(warnmsg, DeprecationWarning, stacklevel=2)
E DeprecationWarning: openFile() is pending deprecation, use open_file() instead. You may use the pt2to3 tool to update your source code.
Ok, that seems like a bug. Maybe @embray or @mdboom have an idea what is going on?
From astropy's perspective, this is deliberate: We want to be certain we aren't using deprecated APIs in Numpy or Python. Obviously for affiliated packages who may have other external requirements, this is not good behavior. I'm working up a PR now that will allow that behavior to be switched on and off (and we'll leave it on by default in astropy, probably off by default for affiliated packages).
:+1: :+1: thanks!!
See #70, and astropy/astropy#2572.
As @astrofrog pointed out some of the functionality of the new astropy-helpers needs
atropy-0.4dev
to work. This comes with the problem that the new astropy turns DeprecationWarnings into Exceptions during testing, which is also true for external packages. Is there an easy way to turn them back into warnings?