Uh oh!
There was an error while loading. Please reload this page.
Allow adding test cases testing version-dependent Python features - #9238
Conversation
Uh oh!
There was an error while loading. Please reload this page.
sobolevn
left a comment
There was a problem hiding this comment.
This looks like a good work-around!
Ideally we can teach mypy not to trigger unused ignore on unreachable code as well.
Thanks!
JelleZijlstra
left a comment
There was a problem hiding this comment.
I suppose this won't work if we want test cases for things that were removed in a later version, but we'll have to figure out an approach for that when we get to it.
AlexWaygood
commented
Nov 21, 2022
Here's hoping nobody proposes to add test cases for things that have already been deprecated and removed in released versions of Python :) |
It's currently impossible to add a test case for
ExceptionGrouporBaseExceptionGroup: see #9230. You'd think that you'd be able to just put the test behind anif sys.version_info >= (3, 11)guard, and pyright is indeed fine with that. Mypy, however, is not: when you run the test case with--python-version 3.10, it complains about many "unused type ignore" comments (it detects thetype: ignorecomments behind theif sys.version_info >= (3, 11)guard, even though it considers the whole block unreachable with--python-version 3.10, meaning it considers alltype: ignores within that block to be "unused").This PR works around that mypy annoyance. If this PR is merged, the test-case file can simply be renamed to be
test_cases/stdlib/builtins/check_exception_group-py311.py, andpython tests/regr_test.py --allshould pass.Cc. @sobolevn