Repository navigation
API: make help methods raise an error if called under Python's optimized mode - #17571
Conversation
|
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.
|
|
👋 Thank you for your draft pull request! Do you know that you can use |
6a767ad to
0abc647
Compare
0abc647 to
b63c7a7
Compare
|
I tried and When calling astropy/astropy/config/configuration.py Lines 102 to 104 in ce37ada astropy/astropy/config/tests/test_configs.py Line 252 in ce37ada but if it turns out to be too complicated then perhaps we should just use "" as the fallback option.
Have you checked how the IO help methods behave with |
Fair enough. I'll add
it kinda does; the problem is that we have many tests for this function which check for the presence of specific fragments in the help messages, while the expected source of these fragment is unspecified and sometimes unclear. The fallback string doesn't have all these fragments, and neither would a simpler fallback. About why I went with raising an exception; this approach has the benefit of being easily testable, while a non-blocking no-op (for instance) is in principle much harder to test; how can one check that there are zero unintended consequences to letting the function flow ? |
Actually, I'm not sure this is a good idea, because the >>> from astropy import conf
>>> conf.help()
RuntimeError: astropy.conf.help is not availablewithout hard-coding |
|
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. |
| module=astropy | ||
| value=False | ||
| """ | ||
| if sys.flags.optimize >= 2: |
There was a problem hiding this comment.
Are we planning to have a test for Python in optimized mode?
|
|
||
| OLD_CONFIG = {} | ||
|
|
||
| SKIPIF_OPTIMIZED_PYTHON = pytest.mark.skipif( |
There was a problem hiding this comment.
Can this be moved to a common conftest? I see this is copied in another file.
There was a problem hiding this comment.
It's a bit cumbersome, but this got me thinking there's a better way: subprocesses. I'll give it a try now.
There was a problem hiding this comment.
turns out if was actually much easier to define pytest markers
| out : None or file-like | ||
| Output destination (default is stdout via a pager) | ||
| """ | ||
| if sys.flags.optimize >= 2: |
There was a problem hiding this comment.
What about making a PYTHON_OPTIMIZED in astropy.utils ?
There was a problem hiding this comment.
I'm not seeing the benefit, I prefer keeping this as is if you don't mind
b63c7a7 to
cd2dc48
Compare
cd2dc48 to
a937edf
Compare
a937edf to
fdf135f
Compare
|
Sorry for this record-breaking wait (>1year !). I think I've addressed (or replied to) all your comments. |
Description
ref #17472
following the discussion in #17555
Although I marked this as an "API change" (because it technically is), I'd like to stress that this setup (
PYTHONOPTIMIZE=2) was never explicitly supported and is very broken under astropy 7.0.x so it shouldn't actually be breaking to anyone.