iscoroutinefunction should use TypeIs
還沒有人認領這個 Issue。
評估
研究方向
找出 inspect.iscoroutinefunction 的 typeshed stub 項目,並將其標註與其他使用 TypeIs 的 inspect is... 函式進行比較。更新該標註,使兩個分支都如描述般進行縮窄,然後執行相關的型別檢查測試,以確認 coroutine 函式和 else 分支都能正確縮窄。
由索引模型根據 Issue 內容生成。
描述
One of the things I find myself writing a lot is
if iscoroutinefunction(myfunction):
do_something_with_async(myfunction)
else:
do_something_with_just_sync(myfunction)
however the else block doesn't narrow the type to non-awaitable. Shouldn't it? Some of the other is... functions in inspect seem to use TypeIs as well.
- 主要語言
- Python
- 星號
- 5.1k
- 分支
- 2.1k
- 平均合併
- 1 天 13 小時
- 30 天內合併 PR
- 73
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
python/typeshed 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 72/100
-
難度 2/5 1-3 小時 新手友好度 68/100
-
難度 2/5 1-3 小時 新手友好度 76/100
-
project: infrastructure
難度 2/5 1-3 小時 新手友好度 68/100
-
stubs: improvement
難度 2/5 1-3 小時 新手友好度 72/100
相似的 Issue
-
triage/confirmed
難度 2/5 1-3 小時 新手友好度 88/100
agentscope-ai/agentscope#2775 ·
-
comp/desktop P3 type/bug
難度 1/5 1 小時以內 新手友好度 92/100
NousResearch/hermes-agent#118866 ·
-
bug
難度 1/5 1 小時以內 新手友好度 90/100
apache/cloudstack#14222 ·
-
難度 2/5 1-3 小時 新手友好度 76/100
-
bug
難度 2/5 1-3 小時 新手友好度 82/100