fix: Adapt for dataclasses._MISSING_TYPE replaced with sentinel in Python 3.15#4211
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe PR updates ChangesArgument help formatting compatibility
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
33670f4 to
76fcb10
Compare
…3.15 See python/cpython#149086 and PEP 661.
76fcb10 to
6d13f11
Compare
🤖 I have created a release *beep* *boop* --- ## [9.22.0](v9.21.1...v9.22.0) (2026-06-01) ### Features * add semantic helper functions choose_file/choose_folder/choose_tmp and allow all semantic helper functions to be used when parsing resources ([#3820](#3820)) ([d3c2386](d3c2386)) * add temp to default pathvars ([#4108](#4108)) ([917fb11](917fb11)) * add workflow info to log ([#4079](#4079)) ([e40e15b](e40e15b)) * support python 3.14 ([#3739](#3739)) ([7e3be0c](7e3be0c)) ### Bug Fixes * Adapt for dataclasses._MISSING_TYPE replaced with sentinel in Python 3.15 ([#4211](#4211)) ([b7fb8df](b7fb8df)) * ensure that storage is not actually retrieved with --touch ([#4212](#4212)) ([2726cae](2726cae)) * symlink to directory "has older modification time" than target ([#3782](#3782)) ([#3784](#3784)) ([41903d8](41903d8)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
See python/cpython#149086 and PEP 661 for context.
This fixes a traceback from
snakemake --helpin Python 3.15.0b1:The
TypeErroris supposed to happen, but it is supposed to be caught: https://github.com/python/cpython/blob/f31a89bb901067dd105b00cfa90523cf7ffdbbdd/Lib/argparse.py#L2877-L2882; that’s all in the Python standard library. But then theAttributeErroron_MISSING_TYPEhappens, and that’s the bug/regression in Snakemake.After this PR,
snakemake --helpworks as expected. Trying again in a Python 3.14 virtualenv, I confirm thatsnakemake --helpstill works as expected.There are probably 100 different ways that this PR could have been written differently, and half of them are actually reasonable. I’m happy to consider style and implementation changes if requested.
One thing I considered is that it might be just as good to always test against
dataclasses.MISSING, which already existed with sentinel semantics even before the introduction of the PEP 661sentineltype. I think that this probably works as expected, and it’s a lot simpler:It’s worth considering that both of these approaches rely on implementation details of
dataclasses.MISSING, and either of them may break at any point in the future. See the warning in https://docs.python.org/3.14/library/dataclasses.html#dataclasses.field that “No code should directly use theMISSINGvalue.” Maybe taking a step back and reflecting on the bigger picture could reveal a better approach that sidesteps the issue completely. I’m not prepared to spend any more time on it right now, so please take this PR as a combined bug report and initial suggestion.QC
snakemake --helpdoesn’t crash, but I’m not prepared to contribute a test case. I welcome the addition of a relevant test case to this PR, but my own contribution will be limited to fixing the regression and confirming the fix manually.docs/) is updated to reflect the changes or this is not necessary (e.g. if the change does neither modify the language nor the behavior or functionalities of Snakemake). not necessaryAI-assistance disclosure
I used AI assistance for:
I did not use any AI assistance at any point in preparing this PR.
Summary by CodeRabbit