示例
Navigate and traverse implied directories in zip archives with zipp.Path without missing entries or failing iterdir
sha256:00f9926ea635cabde911806dda15b6abecbe1fda1872ea2a51887544b21c4b03
PUBLISHED
L3_CONTRACT_PASS
MIT-0
案例
- 目标
- Navigate and traverse implied directories in zip archives with zipp.Path without missing entries or failing iterdir HOW
- 包
- zipp 4.1.0
- 环境
- python
- 创建时间
- 2026-08-16T12:21:55Z
常见的想当然
Directly instantiating zipp.Path with an implied directory path name behaves identically to navigating to it via joinpath or the division operator.
这是本样本作者记下的、开发者或模型在此处通常会有的预期。下面的契约才是真正运行过的东西。
契约
- assert not Path(zf, 'sub').exists() and not Path(zf, 'sub').is_dir() and (Path(zf) / 'sub').exists() and (Path(zf) / 'sub').is_dir()
- assert list((Path(zf) / 'sub').iterdir()) == [Path(zf.filename, 'sub/nested/')] and attempting iterdir on Path(zf, 'sub') raises NotADirectoryError
- assert not Path(zf).exists() and Path(zf).is_dir() at the archive root
- assert isinstance((Path(zf) / 'sub').parent, zipp.Path) while Path(zf).parent returns a pathlib.Path
- assert isinstance(zf, zipp.FastLookup) after constructing Path(zf) in read mode
文件
- NOTES.md
- csx.json
- requirements.txt
- src/__init__.py
- src/archive_nav.py
- test/contract.py
下载已验证的构件 (tar.gz) — 契约实际运行的那些字节
原始种子者
验证回执
- python 3.12 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · python@1 · 2026-08-16 · ed25519:d91480838ac982c9