Repository navigation
Enable ignoring deprecation warnings from entire module - #6334
Conversation
|
Hi there @pllim 👋 - thanks for the pull request! I'm just a friendly 🤖 that checks for issues related to the changelog and making sure that this pull request is milestoned and labelled correctly. This is mainly intended for the maintainers, so if you are not a maintainer you can ignore this, and a maintainer will let you know if any action is required on your part 😃. I noticed the following issue with this pull request:
Would it be possible to fix this? Thanks! |
|
@eteq @astrofrog - We can still add this to the release, right? Please :) |
astrofrog
left a comment
There was a problem hiding this comment.
This seems sensible to me. I think it'd be fine to backport.
|
Except it doesn't seem to be working, but I'm about to leave so it was just a very quick test. @pllim - could you check whether having this as your astropy version, the tests pass on reproject dev, when you do: There are a bunch of AstropyDeprecationWarnings coming from pytest arraydiff when using astropy dev, and the whole motivation was that upstream issues like this shouldn't really affect reproject tests as in most cases we can do nothing about them. |
|
This only catch |
|
To be more specific, class AstropyWarning(Warning):
"""
The base warning class from which all Astropy warnings should inherit.
Any warning inheriting from this class is handled by the Astropy logger.
"""
class AstropyDeprecationWarning(AstropyWarning):
"""
A warning class to indicate a deprecated feature.
"""
class AstropyPendingDeprecationWarning(PendingDeprecationWarning, AstropyWarning):
"""
A warning class to indicate a soon-to-be deprecated feature.
""" |
@pllim - because DeprecationWarning is hidden by default and we didn't want that to be the case for Astropy deprecation warnings, by design |
|
I am wary of extending this new keyword option to also include AstropyDeprecationWarning, as it might be very confusing since we already have |
|
@pllim - I think the idea was that @bsipocz wants the fine-grained control this implemented but for the astropy deprecation warnings? If I'm interpreting this right, then I think the idea is that (And just to be clear, I'm 👍 to this idea, but think it's much more useful if it applies to the Astropy deprecation machinery) |
|
@eteq , if you set if _include_astropy_deprecations:
warnings.filterwarnings("error", ".*", AstropyDeprecationWarning)
warnings.filterwarnings("error", ".*", AstropyPendingDeprecationWarning)Therefore, just by setting |
|
@eteq , oh wait... Maybe I misunderstood you in my comment above... 🤔 |
|
@pllim - yeah, I meant that if you do choose Although I'm mostly channeling @bsipocz here, so she might know better what she meant 😉 |
| # This ignores all deprecation warnings from given module(s), | ||
| # not just on import, for use of Astropy affiliated packages. | ||
| for m in _warnings_to_ignore_entire_module: | ||
| warnings.filterwarnings('ignore', category=DeprecationWarning, |
There was a problem hiding this comment.
Might it work to just add below here:
if _include_astropy_deprecations:
warnings.filterwarnings('ignore', category= AstropyDeprecationWarning, module=m)
warnings.filterwarnings('ignore', category= AstropyPendingDeprecationWarning, module=m)
to address #6334 (comment) ?
There was a problem hiding this comment.
Yes, that makes sense. I'll add that and see if it works.
|
"Changelog entry present but Affects-dev label set" -- o_O so strict... How do I make |
|
|
@pllim - I think @bsipocz wanted this for 2.0, so that's the target! (we're probably delaying the release one more day for the package maintainers to catch up) Also, agreed that @astropy-bot is being a bit strict here. A workaround would be to drop |
|
Technically speaking the astropy-bot status check is non-blocking, so you can merge anyway even if it fails - thus, no need to play around with removing/adding labels. |
|
I've dropped |
|
So, what I really wanted originally is to filter both (*) actually this can be tricky, as the warnings are actually coming from astropy itself, but the problematic code is in |
|
OK. I can confirm that this now works with reproject if: But not when |
|
Hmm. Adding "astropy" to that list will theoretically ignore all warnings from Astropy, which is basically same as "include_astropy_deprecations=False", no? |
|
Actually setting So listing packages in |
|
Rebased to resolve CHANGELOG conflict. @astrofrog - the bot doesn't like the new changelog format.... |
|
@bsipocz - will fix the bot tomorrow, now that I can parse the rst normally this should be easy to do in a general way (can't simply replace '-----' by '=====' since some changelogs use '-----' for the version headers...) |
|
I've tried to look into this more, but cannot find a solution. Even though the deprecated usage happens in pytest-arraydiff, the actual warning is coming from astropy, and I didn't find any way to get the name of the module from the second to last step of the traceback. Thus I think we should merge this once CI passed as it still provides a valuable improvement. |
|
Thanks @pllim! |
|
Would it be better if there's a way to include specific message to ignore, as an addition to this? I see that this already merged, so any improvement can be for 2.0.1 or 3.0, if desired. Sorry it's not the ideal solution you were looking for. |
|
@pllim - I'm not sure the solution I was looking for actually exists, and this is definitely an improvement. |
Enable ignoring deprecation warnings from entire module
Fix #5917 ; Follow-up of #6223. Since I still need to add change log and then let CI run to enable merge button, I have skipped the CI for now.
See https://gist.github.com/pllim/3a76f3ea1dd0bd394a2dbe1614faae31 for how this would work.
TODO:
p.s. Took me 2 minutes to implement the code, but 2 hours to test... 😅