Skip to content

API: make delay_doc_updates context manager a noop under Python's optimized mode - #17572

Merged
pllim merged 1 commit into
astropy:mainfrom
neutrinoceros:io.registry/api/delay_doc_updates_as_noop_optimized_mode
Sep 22, 2025
Merged

pllim merged 1 commit into
astropy:mainfrom
neutrinoceros:io.registry/api/delay_doc_updates_as_noop_optimized_mode

Conversation

@neutrinoceros

Copy link
Copy Markdown
Contributor

Description

ref #17472
I'm not 100% sure this needs a changelog entry (because I don't know if this method is used downstream and/or considered public) but if so, I got one.

  • By checking this box, the PR author has requested that maintainers do NOT use the "Squash and Merge" button. Maintainers should respect this when possible; however, the final decision is at the discretion of the maintainer that merges the PR.

@neutrinoceros neutrinoceros added this to the v7.1.0 milestone Dec 20, 2024
@neutrinoceros neutrinoceros added the API change PRs and issues that change an existing API, possibly requiring a deprecation period label Dec 20, 2024
@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.

@github-actions

Copy link
Copy Markdown
Contributor

👋 Thank you for your draft pull request! Do you know that you can use [ci skip] or [skip ci] in your commit messages to skip running continuous integration tests until you are ready?

@neutrinoceros
neutrinoceros force-pushed the io.registry/api/delay_doc_updates_as_noop_optimized_mode branch 2 times, most recently from d13d95f to b8d372a Compare December 20, 2024 11:22
@neutrinoceros
neutrinoceros marked this pull request as ready for review December 20, 2024 11:51
Comment thread astropy/io/registry/base.py Outdated
see for example the source code of ``astropy.table.__init__``.
"""
self._delayed_docs_classes.add(cls)
if sys.flags.optimize < 2:

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.

It'd require less indenting to invert this branch and use both a yield and then return. Then the normal mode doesn't need to be indented.

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.

I normally prefer this style because it more clearly reflects that both path are branches from the same conditional, but here the new path is indeed short enough that it makes sense to write it as a guard clause.

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.

But what does this mean for end-users? Perhaps mention that the help stuff won't work? Will it throw exception instead?

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.

But what does this mean for end-users?

As I said in the original post I don't even know if this context manager has end users. I'd like inputs on that.

Perhaps mention that the help stuff won't work? Will it throw exception instead?

Changes to help functions are found in #17571, which has (hopefully) clear changelog fragments.
I will add a what's new entry for 7.1 once we're get a stable dedicated CI job, which will cover user-facing changes.

Comment on lines +34 to +40
SKIPIF_OPTIMIZED_PYTHON = pytest.mark.skipif(
sys.flags.optimize >= 2, reason="docstrings are not available at runtime"
)
ONLY_OPTIMIZED_PYTHON = pytest.mark.skipif(
sys.flags.optimize < 2,
reason="checking behavior specifically if docstrings are not present",
)

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.

Should these be generalized and reused elsewhere you did the optimized mode work? We probably don't need such specific reasons.

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.

I'm honestly not sure that it'd be worth the cost of less specific reasons + an additional indirection just to avoid repeating two lines over a couple files.
Though, if that's what the majority wants, maybe I could unify the implementation in a cleanup PR when everything is working ?

@neutrinoceros
neutrinoceros force-pushed the io.registry/api/delay_doc_updates_as_noop_optimized_mode branch from b8d372a to 482631d Compare December 21, 2024 13:24
@neutrinoceros neutrinoceros changed the title API: make delay_doc_updates context manager a noop under Python's optimized mode API: make delay_doc_updates context manager a noop under Python's optimized mode Dec 21, 2024
Comment thread astropy/io/registry/base.py Resolved
@neutrinoceros
neutrinoceros force-pushed the io.registry/api/delay_doc_updates_as_noop_optimized_mode branch from 482631d to ed64a99 Compare December 21, 2024 17:11
--------
see for example the source code of ``astropy.table.__init__``.
"""
if sys.flags.optimize >= 2:

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.

Do we not have a CI test for optimized python?

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.

Not yet: #17472

@astrofrog astrofrog modified the milestones: v7.1.0, v7.2.0 Apr 28, 2025
@github-actions github-actions Bot added the Close? Tell stale bot that this issue/PR is stale label May 21, 2025
@github-actions

Copy link
Copy Markdown
Contributor

Hi humans 👋 - this pull request hasn't had any new commits for approximately 4 months. I plan to close this in 30 days if the pull request doesn't have any new commits by then.

In lieu of a stalled pull request, please consider closing this and open an issue instead if a reminder is needed to revisit in the future. Maintainers may also choose to add keep-open label to keep this PR open but it is discouraged unless absolutely necessary.

If this PR still needs to be reviewed, as an author, you can rebase it to reset the clock.

If you believe I commented on this pull request incorrectly, please report this here.

@github-actions github-actions Bot added the closed-by-bot Closed by stale bot label Jun 21, 2025
@github-actions

Copy link
Copy Markdown
Contributor

I'm going to close this pull request as per my previous message. If you think what is being added/fixed here is still important, please remember to open an issue to keep track of it. Thanks!

If this is the first time I am commenting on this issue, or if you believe I closed this issue incorrectly, please report this here.

@github-actions github-actions Bot closed this Jun 21, 2025
@nstarman

Copy link
Copy Markdown
Member

@neutrinoceros was there anything uncertain about this PR?

@neutrinoceros neutrinoceros reopened this Sep 10, 2025
@neutrinoceros
neutrinoceros force-pushed the io.registry/api/delay_doc_updates_as_noop_optimized_mode branch from ed64a99 to cf47a12 Compare September 10, 2025 09:14
@neutrinoceros

Copy link
Copy Markdown
Contributor Author

not that I know of. It just got buried under a pile of other notifications. Let's try reviving it now.

@neutrinoceros neutrinoceros removed Close? Tell stale bot that this issue/PR is stale closed-by-bot Closed by stale bot labels Sep 10, 2025

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

:shipit:

@nstarman
nstarman requested a review from pllim September 22, 2025 00:09
@pllim
pllim merged commit ef211cf into astropy:main Sep 22, 2025
@neutrinoceros
neutrinoceros deleted the io.registry/api/delay_doc_updates_as_noop_optimized_mode branch September 22, 2025 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API change PRs and issues that change an existing API, possibly requiring a deprecation period io.registry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants