Repository navigation
BUG: ensure Config classes' docstrings remain available at runtime for introspection (fix calling ConfigNamespace.help under Python's optimized mode) - #17548
Merged
pllim merged 1 commit intoDec 17, 2024
Conversation
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.
|
Contributor
|
👋 Thank you for your draft pull request! Do you know that you can use |
1 task
Config classes' docstrings remain available at runtime for introspection (fix calling ConfigNamespace.help under Python's optimized mode)
neutrinoceros
force-pushed
the
config/bug/fix_ConfigNamespace_help_optimized_mode
branch
from
December 17, 2024 11:11
4730ae9 to
2e7dd3a
Compare
…r introspection (fix calling ConfigNamespace.help under Python's optimized mode)
neutrinoceros
force-pushed
the
config/bug/fix_ConfigNamespace_help_optimized_mode
branch
from
December 17, 2024 11:21
2e7dd3a to
328c92d
Compare
neutrinoceros
marked this pull request as ready for review
December 17, 2024 11:46
neutrinoceros
requested review from
astrofrog,
larrybradley,
saimn and
taldcroft
as code owners
December 17, 2024 11:46
pllim
approved these changes
Dec 17, 2024
pllim
left a comment
Member
There was a problem hiding this comment.
LGTM since the changes do not fail CI and doc renders okay. Thanks!
neutrinoceros
deleted the
config/bug/fix_ConfigNamespace_help_optimized_mode
branch
December 18, 2024 07:09
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
ref #17472
This is a direct follow up to #13499 by @eerovaher
Since
ConfigNamespace.helprelies on the availability of docstrings at runtime, we can override the optimization that drops them by setting a class level__doc__attribute instead of writing a docstring normally.To be clear, it is probably not a great idea to use the optimized mode (supposedly meant for production-ready applications) with the
help(which I think is targetted at REPL users), but if we can make it work for cheap, I think it's still worth a shot.Specifically, this patch allows the following tests to pass with
PYTHONOPTIMIZE=2: