"Awaitable" is insufficiently expressive, as one may await something other than Futures
還沒有人認領這個 Issue。
評估
研究方向
先閱讀 issue 中描述的 Awaitable 定義和 await 協定,然後比較 Future、Deferred、curio traps 和 Trio traps 的表示方式。只有在形成一個關於如何表達不相容的 scheduling 協定、同時保留相容的 awaitables 的共識模型後,工作才算完成;未指定檔案或測試。
由索引模型根據 Issue 內容生成。
描述
In the wild, today, if you await something, there are several potentially valid things to bubble back out from the innermost await
- an
asyncio.Future - a curio "trap" (which I gather is defined as something like
Tuple[curio.traps.Traps, Any, ...]) - a Trio trap, (which I gather is defined as something like
Iterable[WaitTaskRescheduled]although I haven't quite found the bottom of that stack) - a
Deferred
Not all of these are mutually compatible. However, Awaitable is parameterized only on one type - the type of its result. This results in code like this:
def some_deferred() -> Awaitable[int]: ...
def some_future() -> Awaitable[int]: ...
async def x() -> Awaitable[List[int]]:
y = []
y.append(await some_deferred())
y.append(await some_future())
return y
type-checking even though it should fail.
I'd like to be able to express this as
def some_deferred() -> Awaitable[int, Deferred]: ...
def some_future() -> Awaitable[int]: ... # presumably Future is the default
async def x() -> Awaitable[List[int]]:
y = []
y.append(await some_deferred()) # <-- automatically specialize to `Awaitable[List[int], Deferred]` here, if possible?
y.append(await some_future()) # <-- type error!
return y
This is made slightly more complex by the fact that some awaitables are mutually intelligible - for example, anything that awaits a Deferred should eventually be able to await a Future directly, once we've made a few more changes to Twisted. We could also do this in the other direction if __await__ were changed to pass the loop along. Whereas, some of these types are incompatible by design; my understanding is that await implies a completely different, and somewhat higher-level, scheduling protocol in Trio, for example.
- 主要語言
- Python
- 星號
- 1.8k
- 分支
- 302
- 平均合併
- 4 小時 38 分鐘
- 30 天內合併 PR
- 6
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
python/typing 的其他 Issue
-
topic: typing spec
難度 2/5 1-3 小時 新手友好度 72/100
-
topic: typing spec
難度 2/5 1-3 小時 新手友好度 75/100
-
Update reference/generics.html with PEP695 type parameter syntax可能已有人在做 @BHUVANSH855 於 181 天前認領。 未關閉topic: documentation
難度 2/5 1-3 小時 新手友好度 76/100
-
topic: documentation
難度 2/5 1-3 小時 新手友好度 65/100
-
Finals and Literals: Spec contradiction可能已有人在做 @srittau 於 34 天前認領。 未關閉topic: conformance tests topic: typing spec
難度 3/5 1-2 天 新手友好度 72/100
相似的 Issue
-
feature:LinkChecker
難度 2/5 1-3 小時 新手友好度 66/100
digitalfabrik/integreat-cms#4594 ·
維護者通常 5 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 70/100
EleutherAI/lm-evaluation-harness#4319 ·
維護者通常 1 天內回覆
-
needs triage
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
json_params_matcher fails on falsy top-level JSON primitives (0, False, "")可能已有人在做 @mayureshsonawane17 今天認領。 未關閉Waiting for: Product Owner
難度 2/5 1-3 小時 新手友好度 84/100
維護者通常 5 天內回覆