Support `Literal` types
還沒有人認領這個 Issue。
評估
研究方向
先追蹤 typeclass、AssociatedType、Supports 和 @some.instance 如何處理委派型別,接著將這條路徑與 Literal[1] 範例進行比較。完成的標準是該範例能通過型別檢查,且 some(1) 能透過 Literal 註冊正確解析,同時保留現有的委派行為。
由索引模型根據 Issue 內容生成。
描述
After we have delegate in-place we can use Literal types.
But, now they are not supported.
Ideally, something like this should work:
from classes import typeclass, AssociatedType, Supports
from typing_extensions import Literal
class SomeDelegate(object):
... # TODO: write proper `__instancecheck__`
class A(AssociatedType):
...
@typeclass(A)
def some(instance) -> int:
...
@some.instance(Literal[1], delegate=SomeDelegate)
def _some_tuple(instance: Literal[1]) -> int:
return instance
def test(i: Supports[A]):
return some(i)
some(1)
- 主要語言
- Python
- 星號
- 730
- 分支
- 30
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
dry-python/classes 的其他 Issue
-
難度 3/5 1-2 天 新手友好度 35/100
dry-python/classes#496 ·
-
bug
難度 2/5 1-3 小時 新手友好度 45/100
dry-python/classes#494 ·
-
bug
難度 2/5 1-3 小時 新手友好度 52/100
dry-python/classes#492 · 2 則留言 ·
-
bug
難度 3/5 1-2 天 新手友好度 35/100
dry-python/classes#481 · 5 則留言 · 4 個 reaction ·
-
bug
難度 2/5 1-3 小時 新手友好度 35/100
dry-python/classes#386 ·
查看 dry-python/classes 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 78/100
conda-forge/conda-build-feedstock#289 · 1 則留言 · 1 個 reaction ·
-
`pulptest` no longer works in 4.0.0: `ImportError: Start directory is not importable: 'pulp/tests'`未關閉
難度 2/5 1-3 小時 新手友好度 75/100
-
難度 2/5 1-3 小時 新手友好度 72/100
-
難度 2/5 1-3 小時 新手友好度 78/100
-
難度 2/5 1-3 小時 新手友好度 72/100
TomCasavant/ohio-sites#224 ·