typing docs: Use soft deprecation
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- PR 合併指標
- PR 指標待擷取
描述
A while ago we introduced the concept of "soft deprecation" in PEP 387 (https://peps.python.org/pep-0387/#soft-deprecation): for things that we no longer recommend using, but which we aren't planning to remove in the near future.
The typing docs already list four classes of objects that are deprecated without a scheduled removal (https://docs.python.org/3.14/library/typing.html#deprecation-timeline-of-major-features):
- Pre-PEP-585 generic aliases (e.g.
List) TextHashableandSizedTypeAlias
I'd like to also soft-deprecate the following:
Optional(obviated by PEP-604)NoReturn(preferNever)typing.ForwardRef(deprecated alias forannotationlib.ForwardRef)types.UnionType(deprecated alias fortyping.Union)- Creating a
Unionusing subscripting (Union[A, B]instead ofA | B) (PEP-604) - Creating a
TypeVar,ParamSpec, orTypeVarTupleusing the constructor directly (PEP-695) - Directly inheriting from
Generic(PEP-695)
None of those will be removable for many years if ever, but I think it's useful to have a clear statement in the docs that the newer syntax is preferred.
Linked PRs
- gh-154480
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從所連結的 Python 文件頁面中標題為“Deprecation timeline of major features”的 typing 文件部分開始,並將其中現有的項目與所要求的 soft deprecations 進行比較。當文件清楚地標示出列出的舊形式並推薦其較新的替代形式時,即視為完成;請先檢視連結的 PR gh-154480,因為相關工作已經與它關聯。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- documentation
- Issue 類型
- 文件
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 30/100