Skip to content

Deprecate deprecations as exceptions and friends#12633

Merged
pllim merged 11 commits into
astropy:mainfrom
pllim:deprecate-deprecations-as-exceptions
Dec 31, 2021
Merged

Deprecate deprecations as exceptions and friends#12633
pllim merged 11 commits into
astropy:mainfrom
pllim:deprecate-deprecations-as-exceptions

Conversation

@pllim

@pllim pllim commented Dec 24, 2021

Copy link
Copy Markdown
Member

Description

This pull request is to deprecate and remove some old code from core testing infrastructure. I think these should all go together, as it would be more confusing to do them one at a time. 🔥 🔥 🔥

Deprecated Use this
astropy.io.ascii.tests.common.raises pytest.raises
astropy.tests.helper.raises pytest.raises
astropy.tests.helper.catch_warnings pytest.warns
astropy.tests.helper.ignore_warnings https://docs.pytest.org/en/stable/warnings.html
astropy.tests.helper.enable_deprecations_as_exceptions https://docs.pytest.org/en/stable/warnings.html
astropy.tests.helper.treat_deprecations_as_exceptions https://docs.pytest.org/en/stable/warnings.html
Removed Use this
astropy.tests.disable_internet pytest_remotedata.disable_internet
astropy.tests.helper.remote_data pytest.mark.remote_data
astropy.tests.plugins.display pytest-astropy-header package

Checklist for package maintainer(s)

This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.

  • Do the proposed changes actually accomplish desired goals?
  • Do the proposed changes follow the Astropy coding guidelines?
  • Are tests added/updated as required? If so, do they follow the Astropy testing guidelines?
  • Are docs added/updated as required? If so, do they follow the Astropy documentation guidelines?
  • Is rebase and/or squash necessary? If so, please provide the author with appropriate instructions. Also see "When to rebase and squash commits".
  • Did the CI pass? If no, are the failures related? If you need to run daily and weekly cron jobs as part of the PR, please apply the Extra CI label.
  • Is a change log needed? If yes, did the change log check pass? If no, add the no-changelog-entry-needed label. If this is a manual backport, use the skip-changelog-checks label unless special changelog handling is necessary.
  • Is a milestone set? Milestone must be set but astropy-bot check might be missing; do not let the green checkmark fool you.
  • At the time of adding the milestone, if the milestone set requires a backport to release branch(es), apply the appropriate backport-X.Y.x label(s) before merge.

@pllim pllim added Refactoring Extra CI Run cron CI as part of PR labels Dec 24, 2021
@pllim pllim added this to the v5.1 milestone Dec 24, 2021
@pllim pllim requested review from a team, astrofrog and mhvk December 24, 2021 17:33
@pllim

pllim commented Dec 24, 2021

Copy link
Copy Markdown
Member Author

I see the following at the top of my local run though they did not fail the CI. I cannot figure out where they are coming from. Will have to see if they show up in CI too or is it just me.

WARNING: AstropyDeprecationWarning: The ignore_warnings class is deprecated and may be removed in a future version.
        Use pytest.mark.filterwarnings instead. [pytest_astropy_header.display]
WARNING: AstropyDeprecationWarning: The catch_warnings class is deprecated and may be removed in a future version.
        Use pytest.warns instead. [astropy.tests.helper]

@pllim

pllim commented Dec 24, 2021

Copy link
Copy Markdown
Member Author

Mystery warnings also appear in CI but does not fail the tests.

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR looks good modulo some small nitpicks.

The warnings arise, I think, because the rather old version of pytest_astropy_header imports ignore_warnings (which subclasses from catch_warnings, causing the second warning). We should release a new version!

Comment thread astropy/utils/tests/test_decorators.py Outdated
def test_wraps():
"""
Tests the compatibility replacement for functools.wraps which supports
Make sure functools.wraps supports

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we just delete the test? Not much point testing the python library...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember why we had this. I just thought this would at least guard against regression if Python ever changed its behavior in the future. But if no one thinks it is useful, I can remove. Will wait for a second opinion first though.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Astropy's wraps was removed in #7554 so 👍 with removing the test.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, done!

Comment thread docs/changes/tests/12633.api.2.rst
Comment thread docs/changes/tests/12633.api.1.rst Outdated
@@ -0,0 +1,9 @@
The following are deprecated and will be removed in a future release.
Use ``pytest`` warnings handling instead:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe "pytest warning and exception handling"

@pllim pllim mentioned this pull request Dec 27, 2021
9 tasks
@pllim

This comment has been minimized.

@pllim

pllim commented Dec 27, 2021

Copy link
Copy Markdown
Member Author

I made the grammatical changes suggested by @mhvk and also incorporated #12634 from @nstarman.

The runs should now pick up new pytest-astropy-header 0.2.0 that I just released. So, hopefully mystery warnings seen at the beginning of test runs should be gone? 🤞

@mhvk

mhvk commented Dec 27, 2021

Copy link
Copy Markdown
Contributor

It errors on something unrelated:

E     File "/home/runner/work/astropy/astropy/astropy/utils/misc.py", line 41
E       _NOT_OVERWRITING_MSG_MATCH = ('File .* already exists\. If you mean to '
E                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E   SyntaxError: invalid escape sequence '\.'

I think this is just a matter of adding making it a raw string, but no idea why this was not caught before!?

@eerovaher

Copy link
Copy Markdown
Member

Although the regex template should be built with raw strings, there is something else going on beyond that, see #12641 (comment)

@pllim

pllim commented Dec 27, 2021

Copy link
Copy Markdown
Member Author

I think something in the new pytest-astropy-header release is incompatible. I'll have to investigate.

Update: Might have to just pin it (#12643) until we can figure out astropy/pytest-astropy-header#41

@pllim pllim force-pushed the deprecate-deprecations-as-exceptions branch from 4c2f3be to 6b912be Compare December 28, 2021 21:53
@pllim

pllim commented Dec 28, 2021

Copy link
Copy Markdown
Member Author

I guess I'll try my luck with CI again after #12639 ... 😿

pllim and others added 4 commits December 30, 2021 17:37
Signed-off-by: Nathaniel Starkman (@nstarman) <nstarkman@protonmail.com>
since astropy wraps was removed in astropy#7554

@saimn saimn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me !

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Nice removal of old cruft!

@pllim

pllim commented Dec 30, 2021

Copy link
Copy Markdown
Member Author

Don't forget to stop using these in your downstream packages... 😬

@pllim

pllim commented Dec 31, 2021

Copy link
Copy Markdown
Member Author

Let's do this. Thanks for the approvals!

I have started attempts to patch downstream packages for the Astropy Coordinated Packages, infrastrucuture-related packages, and those relevant to my own projects. As for the rest, hopefully people pay attention to deprecation warnings and test their stuff against astropy dev. 🤞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecate treat_deprecations_as_exceptions Deprecate catch_warnings and raises in favor of pytest machinery?

5 participants