Skip to content

Ensure no global changes to the warnings filter. - #18568

Merged
pllim merged 1 commit into
astropy:mainfrom
mhvk:units-stubs-warning-filter
Aug 29, 2025
Merged

pllim merged 1 commit into
astropy:mainfrom
mhvk:units-stubs-warning-filter

Conversation

@mhvk

@mhvk mhvk commented Aug 29, 2025

Copy link
Copy Markdown
Contributor

Fixes #18567.

Ping @nstarman, @mikez - I think this ensures that we don't show DeprecationWarnings yet do not affect code running later. I found that the test now no longer has to worry about them, so it seems better.

@mhvk mhvk added this to the v7.2.0 milestone Aug 29, 2025
@mhvk mhvk added testing units Bug Affects-dev PRs and issues that do not impact an existing Astropy release no-changelog-entry-needed labels Aug 29, 2025
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.

  • 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 instructions for rebase and squash.
  • 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. Codestyle issues can be fixed by the bot.
  • 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 this a big PR that makes a "What's new?" entry worthwhile and if so, is (1) a "what's new" entry included in this PR and (2) the "whatsnew-needed" label applied?
  • 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.

stub_lines = generate_stub_lines(module)
_write_stub_file(stub_file_path, stub_lines)
# Ignore deprecation warnings triggered by accessing units in deprecated.py
with warnings.catch_warnings(action="ignore", category=AstropyDeprecationWarning):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Available since python 3.11, which is our minimum version.

@pllim pllim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Much cleaner. Thank you!

@pllim

pllim commented Aug 29, 2025

Copy link
Copy Markdown
Member

The devdeps pickling failures are unrelated (#18569)

@pllim
pllim enabled auto-merge August 29, 2025 19:09
@pllim
pllim merged commit 7ebd375 into astropy:main Aug 29, 2025
@mhvk
mhvk deleted the units-stubs-warning-filter branch March 27, 2026 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Affects-dev PRs and issues that do not impact an existing Astropy release Bug no-changelog-entry-needed testing units

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TST: Localize warning ignore in typestubs_for_units.py

3 participants