python / python/cpython

add bound syntax for type variable tuples and parameter specifications

未關閉
#148,945 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

interpreter-core topic-typing type-feature
主要語言
Python
星號
77.2k
分支
35.9k
PR 合併指標
PR 指標待擷取

描述

Feature or enhancement

Proposal:
# typical forms
class A[T: int, *Ts: int, **P: [int]]: ...
A[
    str, # error
    int, # ok, matching Ts bound
    str, # error, not matching Ts bound
    [str], # error, not matching P bound
]

A[
    int, # ok
    int, # ok, matching Ts bound
    bool, # ok, matching Ts bound
    [int], # ok, matching P bound
]

# tvt unpacked form
class B[*Ts: *tuple[int, str]]: ...

B[
    int, # ok
    int, # error, not subtype of str
    int, # error, too many types
]
Has this already been discussed elsewhere?

I have already discussed this feature proposal on Discourse

Links to previous discussion of this feature:

https://discuss.python.org/t/parameter-specification-and-type-variable-tuple-should-support-bounds/107068/6

Linked PRs
  • gh-148946

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

未指定實作檔案或測試。先閱讀連結的 Discourse 討論和 PR gh-148946,然後追蹤提案中的有界型別變數元組和參數規格範例應如何表現。完成標準是,文件中的範例接受有效參數,並拒絕無效的界限和元數。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
compilers
Issue 類型
功能
難度
5/5
預估耗時
一週以上
活躍度
停滯
描述清晰度
基本清楚
新手友好度
30/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。