`utcnow` deprecation note is misleading
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 36k
- PR 合并指标
- PR 指标待抓取
描述
Documentation
Currently, the deprecation notice for datetime.utcnow() reads:
Deprecated since version 3.12: Use
datetime.now()withUTCinstead.
Unfortunately, applying this suggestion verbatim can easily break user code – especially when applying it to libraries. (See for example https://foss.heptapod.net/openpyxl/openpyxl/-/issues/2051). These datetime-related TypeErrors are easy to introduce, and fairly hard to fix. I suggest to amend the deprecation notice:
Deprecated since version 3.12: Use
datetime.now(UTC)instead. Please note that this will return an aware datetime object. If you need to remain compatible, usedatetime.now(UTC).replace(tzinfo=None).
Maybe someone can come up with a better wording.
Linked PRs
- gh-118571
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
查看链接的 datetime 页面中关于 datetime.datetime.utcnow() 的文档,并将拟议措辞与 PR gh-118571 进行比较。当 deprecation note 明确警告 datetime.now(UTC) 返回一个 aware datetime,并说明兼容性选项 replace(tzinfo=None),或采用已达成一致的更好措辞时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- documentation
- Issue 类型
- 文档
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 25/100