-
-
Notifications
You must be signed in to change notification settings - Fork 368
add deprecation warning for specifying strict_exception_groups=False #2941
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Zac-HD
merged 2 commits into
python-trio:master
from
jakkdl:deprecate_exceptiongroups_false
Feb 1, 2024
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/trio/_tests/test_deprecate_strict_exception_groups_false.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
from typing import Awaitable, Callable | ||
|
||
import pytest | ||
|
||
import trio | ||
|
||
|
||
async def test_deprecation_warning_open_nursery() -> None: | ||
with pytest.warns( | ||
trio.TrioDeprecationWarning, match="strict_exception_groups=False" | ||
) as record: | ||
async with trio.open_nursery(strict_exception_groups=False): | ||
... | ||
assert len(record) == 1 | ||
async with trio.open_nursery(strict_exception_groups=True): | ||
... | ||
async with trio.open_nursery(): | ||
... | ||
|
||
|
||
def test_deprecation_warning_run() -> None: | ||
async def foo() -> None: ... | ||
|
||
async def foo_nursery() -> None: | ||
# this should not raise a warning, even if it's implied loose | ||
async with trio.open_nursery(): | ||
... | ||
|
||
async def foo_loose_nursery() -> None: | ||
# this should raise a warning, even if specifying the parameter is redundant | ||
async with trio.open_nursery(strict_exception_groups=False): | ||
... | ||
|
||
def helper(fun: Callable[..., Awaitable[None]], num: int) -> None: | ||
with pytest.warns( | ||
trio.TrioDeprecationWarning, match="strict_exception_groups=False" | ||
) as record: | ||
trio.run(fun, strict_exception_groups=False) | ||
assert len(record) == num | ||
|
||
helper(foo, 1) | ||
helper(foo_nursery, 1) | ||
helper(foo_loose_nursery, 2) | ||
|
||
|
||
def test_deprecation_warning_start_guest_run() -> None: | ||
# "The simplest possible "host" loop." | ||
from .._core._tests.test_guest_mode import trivial_guest_run | ||
|
||
async def trio_return(in_host: object) -> str: | ||
await trio.lowlevel.checkpoint() | ||
return "ok" | ||
|
||
with pytest.warns( | ||
trio.TrioDeprecationWarning, match="strict_exception_groups=False" | ||
) as record: | ||
trivial_guest_run( | ||
trio_return, | ||
strict_exception_groups=False, | ||
) | ||
assert len(record) == 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.