-
-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Default TaskStatus to use None if unspecified * Default Matcher to BaseException if unspecified * Update Sphinx logic for new typevar name * Add some type tests for defaulted typevar classes
- Loading branch information
1 parent
b93d8a6
commit 26cc6ee
Showing
5 changed files
with
91 additions
and
34 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,29 @@ | ||
"""Check that started() can only be called for TaskStatus[None].""" | ||
|
||
from trio import TaskStatus | ||
from typing_extensions import assert_type | ||
|
||
|
||
async def check_status( | ||
none_status_explicit: TaskStatus[None], | ||
none_status_implicit: TaskStatus, | ||
int_status: TaskStatus[int], | ||
) -> None: | ||
assert_type(none_status_explicit, TaskStatus[None]) | ||
assert_type(none_status_implicit, TaskStatus[None]) # Default typevar | ||
assert_type(int_status, TaskStatus[int]) | ||
|
||
# Omitting the parameter is only allowed for None. | ||
none_status_explicit.started() | ||
none_status_implicit.started() | ||
int_status.started() # type: ignore | ||
|
||
# Explicit None is allowed. | ||
none_status_explicit.started(None) | ||
none_status_implicit.started(None) | ||
int_status.started(None) # type: ignore | ||
|
||
none_status_explicit.started(42) # type: ignore | ||
none_status_implicit.started(42) # type: ignore | ||
int_status.started(42) | ||
int_status.started(True) |
This file contains 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