Add `pathlib.Path.metadata()` and soft-deprecate `info`
未关闭
还没有人认领这个 Issue。
stdlib
topic-pathlib
type-feature
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Feature or enhancement
Proposal:
I propose we add a pathlib.Path.metadata() method that requires a keyword-only cached argument, e.g.:
>>> m = pathlib.Path('README.txt').metadata(cached=True)
>>> m
Metadata('README.txt')
>>> m.is_file()
True
If cached is True, the method may return a Metadata object that was previously fetched and cached. If False, the return value is always up-to-date.
pathlib.Path.info should be soft-deprecated; its implementation should call self.metadata(cached=True)
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/ergonomics-of-new-pathlib-path-scandir/71721/70
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从链接的 Discourse 讨论和现有的 pathlib.Path.info 入口点开始。定义所提议的 metadata(cached=...) 行为以及针对 info 的软弃用方案,然后验证最终的 API 是否与提案中的 cached 和 up-to-date 情况一致。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- operating-systems
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 30/100