Repository navigation
Conversation
|
Why only "related" to #74? Isn't this fixing the issue (so should be |
|
Thanks for digging into this, but I don't think there's a bug here — the test passes on
So the existing Whereas My guess is Correcting something I said in an earlier version of this comment: I claimed hatch will use whatever interpreter it finds unless one is pinned. That's not right on current hatch. I checked — hatch 1.18.1 resolves the env interpreter from So the toolchain does already guard this, and a stray 3.11 points at an older hatch or a pytest invocation outside the env rather than at anything missing in the repo. Closing this and #74. |
There was a problem hiding this comment.
@benoit74
Thank you for the clarification. After looking into the CPython changes and the project's configuration, I believe I have identified the reason for the discrepancy.
I tested this on Python 3.12.3, as shown in the screenshots attached to this PR. With exit_on_error=False, the test raises SystemExit: 2 in that version. I also reproduced the same behavior in a clean clone of the upstream repository.
The difference appears to be related to subsequent changes in argparse:
- CPython Issue #121018 reported cases where
exit_on_error=Falsedid not prevent the parser from exiting. - CPython commit 8ea6cc1 introduced changes to additional error-handling paths, replacing calls to
self.error()withArgumentError. - These changes are included in Python 3.12.5, released on August 6, 2024.
This explains why Python 3.12.3 raises SystemExit, while newer versions such as 3.12.15 raise argparse.ArgumentError.
The project's pyproject.toml specifies requires-python = ">=3.12,<3.13".
The Hatch test matrix also specifies Python 3.12, and both GitHub Actions workflows use python-version-file: pyproject.toml.
Therefore, the declared supported range includes both the earlier and newer Python 3.12 releases.
So, I think the CI should either account for the different behavior across all Python 3.12 patch versions, or specify Python 3.12.5 as the minimum supported version, since that's where these changes were introduced.
Thanks again for looking into this and helping clarify the issue.
Summary
Fixes the failing "test_flags_missing_selector" test in "tests/test_generator.py".
The test previously expected an "argparse.ArgumentError", but "argparse" raises "SystemExit" with exit code "2" when a required mutually exclusive argument group is missing.
Updated the test to correctly assert "SystemExit" and verify the exit code.
Testing
Fixes #74