Skip to content
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

Use TypeVarTuple in our APIs #2881

Merged
merged 29 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
bd5a451
Use TypeVarTuple in various functions
TeamSpen210 Aug 21, 2023
97d6e0e
Use TypeVarTuple in _run
TeamSpen210 Aug 21, 2023
9bcb185
Cast this partial() definition, we know it's safe
TeamSpen210 Sep 20, 2023
6f8153f
Fix some uncovered type errors
TeamSpen210 Sep 20, 2023
52c69c8
This now passes mypy checking
TeamSpen210 Nov 19, 2023
13d5d63
Fix return types here
TeamSpen210 Nov 19, 2023
9ed1d08
Fix more errors
TeamSpen210 Nov 19, 2023
0933718
Bump Mypy version
TeamSpen210 Nov 19, 2023
a0e9966
Fix docs failure
TeamSpen210 Nov 19, 2023
5899ad4
Add type tests for Nursery.start[_soon] methods
TeamSpen210 Nov 19, 2023
e12273f
Revert using TypeVarTuple for Nursery.start()
TeamSpen210 Nov 23, 2023
5a39c8b
This seems to be a mypy bug?
TeamSpen210 Nov 23, 2023
5b0215c
This type-error is resolved in Mypy master
TeamSpen210 Nov 23, 2023
342733c
Add missing import for PosArgT in _generated_run
TeamSpen210 Nov 23, 2023
749ef94
The StatusT typevar can't be used here without TVT
TeamSpen210 Nov 23, 2023
1a0daa6
Make gen_exports create an __all__ list
TeamSpen210 Nov 30, 2023
ff01a82
Merge branch 'master' into use-typevartuple
TeamSpen210 Nov 30, 2023
b91b4b9
Run _core/_tests/type_tests under Pyright also
TeamSpen210 Nov 30, 2023
972961e
Add newsfragment
TeamSpen210 Nov 30, 2023
bbd436d
Default args are intentionally not considered by Pyright with TypeVar…
TeamSpen210 Nov 30, 2023
bac6558
Type tests shouldn't be checked by coverage
TeamSpen210 Dec 1, 2023
9783f8b
Handle Enum.__signature__ not being detected by Mypy
TeamSpen210 Dec 1, 2023
e1edda0
Mypy does see copy/deepcopy now, this is no longer required
TeamSpen210 Dec 1, 2023
176092b
Merge branch 'master' into use-typevartuple
CoolCat467 Dec 6, 2023
2903a59
Fix type issue from merge
CoolCat467 Dec 6, 2023
d9d7a3d
Remove unnecessary ignore
TeamSpen210 Dec 6, 2023
580627d
Merge branch 'master' into use-typevartuple
A5rocks Dec 13, 2023
e012611
Pyright-related changes
A5rocks Dec 13, 2023
9f94f97
Fix strict-mode error
A5rocks Dec 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ check_untyped_defs = true

[tool.pyright]
pythonVersion = "3.8"
reportUnnecessaryTypeIgnoreComment = true
A5rocks marked this conversation as resolved.
Show resolved Hide resolved

[tool.pytest.ini_options]
addopts = ["--strict-markers", "--strict-config", "-p trio._tests.pytest_plugin"]
Expand Down
13 changes: 12 additions & 1 deletion src/trio/_core/_tests/type_tests/nursery_start.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Test variadic generic typing for Nursery.start[_soon]()."""
from typing import Awaitable, Callable

from trio import TASK_STATUS_IGNORED, Nursery, TaskStatus


Expand Down Expand Up @@ -70,9 +72,18 @@ def check_start_soon(nursery: Nursery) -> None:

nursery.start_soon(task_2b, "abc") # type: ignore
nursery.start_soon(task_2a, 38, "46")
nursery.start_soon(task_2c, "abc", 12)
nursery.start_soon(task_2c, "abc", 12, True)

# Calling a 3-arg positional func, but using the default.
# Pyright intentionally ignores the default arg status here when converting
# callable -> typevartuple, but Mypy supports this.
# https://github.com/microsoft/pyright/issues/3775
nursery.start_soon(task_2c, "abc", 12) # pyright: ignore
task_2c_cast: Callable[
[str, int], Awaitable[object]
] = task_2c # The assignment makes it work.
nursery.start_soon(task_2c_cast, "abc", 12)

nursery.start_soon(task_requires_kw, 12, True) # type: ignore
# Tasks following the start() API can be made to work.
nursery.start_soon(task_startable_1, "cdf")