Repository navigation
BUG: fix astropy.utils.decorators compatibility with Python's optimized mode (classproperty and format_doc) - #17549
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 |
|
Since this is deep down in utils, I am triggering Extra CI, just to be sure. FYI. |
mhvk
left a comment
There was a problem hiding this comment.
This looks OK, though I wonder if it woudn't be easier to skip the whole test suite if optimization is on. But since the work is already done, maybe best to just stick with what you have...
|
I want to keep this approach as a last resort so I can get as many things actually working as expected first, but maybe I'll need to skip a couple tests in a further PR indeed. |
|
|
||
| # Raises an valueerror if input is empty | ||
| with pytest.raises(ValueError): | ||
| if sys.flags.optimize < 2: |
There was a problem hiding this comment.
Might be less confusing if you move this one out into a different test function and use @pytest.mark.skipif(sys.flags.optimize >= 2, reason="NA for Python optimized mode")
1e77e91 to
56b239f
Compare
…ed mode (classproperty and format_doc)
56b239f to
e81222d
Compare
classproperty and format_doc)
Description
ref #17472
fix running
pytest astropy/utils/tests/test_decorators.pywithPYTHONOPTIMIZE=2.For this one I needed to update tests, which is almost never a good sign; I figure we can still run most of our tests with
PYTHONOPTIMIZE=2(checking that the behavior aligns with non-decorated functions, namely that docstrings areNoneat runtime), however there's one part offormat_docthat I don't think we should be testing under this setup: the runtime checking of its arguments (e.g., exceptions being raised). This remains up for discussion of course.Note to reviewers: the first commit from #17472 is needed to get passed pytest's initialization. Alternatively, you may turn off warnings as errors.