astropy / package-template

Template for packages that use Astropy. Maintainer: @astrofrog
http://docs.astropy.org/projects/package-template/en/latest/
Other
60 stars 63 forks source link

DeprecationWarning automatically turned to Exceptions with current Astropy #69

Closed wkerzendorf closed 10 years ago

wkerzendorf commented 10 years ago

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?

embray commented 10 years ago

Wait, since when are DeprecationWarnings being raised as exceptions? That shouldn't be the case by default.

mdboom commented 10 years ago

This has been the case for some time. See astropy/astropy#1948. The method that does this is helper/treat_deprecations_as_exceptions.

mdboom commented 10 years ago

But, of course, that should only affect testing, not normal runtime, at least that's the intent.

wkerzendorf commented 10 years ago

@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?

wkerzendorf commented 10 years ago

@mdboom - I'm talking about testing, but when I test my package it will fail on deprecation warnings in imported packages.

embray commented 10 years ago

Ah, this is just in testing. I got the impression it was during normal execution.

wkerzendorf commented 10 years ago

that's right - but it's still problematic :wink:

astrofrog commented 10 years ago

@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.

wkerzendorf commented 10 years ago

@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.
astrofrog commented 10 years ago

Ok, that seems like a bug. Maybe @embray or @mdboom have an idea what is going on?

mdboom commented 10 years ago

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).

wkerzendorf commented 10 years ago

:+1: :+1: thanks!!

mdboom commented 10 years ago

See #70, and astropy/astropy#2572.