Пример
iniconfig 2.3.0: Section
Проверенный пример — pypi iniconfig 2.3.0: Section. Контракт выполнен на python 3.12 · linux debian/x64 · docker и пройден: IniConfig parses INI…
sha256:3ea3239c818d3c99cbc79786fcae2e8ac2d6d67892198168930b51289b1701db
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 1
- Ключи подписи, собравшие его
- 1
Заявленная среда
linux 24 · ubuntu · glibc 2.39 x64 pip
Среды запусков проверки
| Окружение | Контракт | Этапы | Запуск |
|---|---|---|---|
| python 3.12 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · python@1python:3.12-slim@sha256:09f7da3bc104… |
2026-09-01 |
Кейс
HOW- Цель
- verify iniconfig.Section in pkg:pypi/iniconfig@2.3.0
- Пакеты
- Символы
-
- iniconfig.Section
- Создан
- 2026-09-01T21:58:06Z
Контракт
- IniConfig parses INI configuration data and exposes sections as SectionWrapper objects.
- SectionWrapper provides dictionary-like key access and iteration over key-value pairs.
- SectionWrapper.get supports typed conversion callables and default fallback values.
- SectionWrapper.lineof returns source line numbers for options in the section.
Файлы
- PROMPT.md
- csx.json
- requirements.txt
- spec.json
- src/example.py
- test/contract.py
Исходный код
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify iniconfig.Section in pkg:pypi/iniconfig@2.3.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:pypi/iniconfig@2.3.0
Demonstrate these symbols/APIs:
- iniconfig.Section
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:b8c75fb09febc1629bdbd0e263abe91a8446320bc61808ab62429eb4503c4844","contract":["IniConfig parses INI configuration data and exposes sections as SectionWrapper objects.","SectionWrapper provides dictionary-like key access and iteration over key-value pairs.","SectionWrapper.get supports typed conversion callables and default fallback values.","SectionWrapper.lineof returns source line numbers for options in the section."],"goal":"verify iniconfig.Section in pkg:pypi/iniconfig@2.3.0","kind":"HOW","packages":["pkg:pypi/iniconfig@2.3.0"],"schemaVersion":1,"symbols":["iniconfig.Section"]},"contractCommand":["python","test/contract.py"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"pypi","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"pip","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/iniconfig@2.3.0"],"schemaVersion":1,"subject":"pkg:pypi/iniconfig@2.3.0","symbols":["iniconfig.Section"],"verifierAdapter":"python@1"}
iniconfig==2.3.0
{
"schemaVersion": 1,
"goal": "verify iniconfig.Section in pkg:pypi/iniconfig@2.3.0",
"kind": "HOW",
"packages": [
"pkg:pypi/iniconfig@2.3.0"
],
"symbols": [
"iniconfig.Section"
]
}
"""Demonstration of INI section inspection and data conversion with iniconfig."""
import iniconfig
def parse_and_print_sections(ini_text: str) -> None:
"""Parse INI text and inspect section objects."""
ini = iniconfig.IniConfig("config.ini", ini_text)
for section in ini:
print(f"Section: {section.name}")
for key, value in section.items():
lineno = section.lineof(key)
print(f" line {lineno}: {key} = {value}")
if __name__ == "__main__":
sample_ini = """# Application settings
[web]
host = 127.0.0.1
port = 8080
debug = true
[cache]
enabled = false
ttl = 300
"""
parse_and_print_sections(sample_ini)
"""Contract test for iniconfig.Section in pkg:pypi/iniconfig@2.3.0."""
import sys
import iniconfig
def test_section_wrapper_behavior():
ini_content = """# Service configuration
[service]
host = 127.0.0.1
port = 9000
timeout = 30
debug = true
[database]
engine = sqlite
pool_size = 5
"""
ini = iniconfig.IniConfig("config.ini", ini_content)
# 1. Section retrieval and indexing
assert "service" in ini
assert "database" in ini
assert "missing" not in ini
service_sec = ini["service"]
assert isinstance(service_sec, iniconfig.SectionWrapper)
assert service_sec.name == "service"
assert service_sec.config is ini
# 2. Key access and iteration
assert service_sec["host"] == "127.0.0.1"
assert service_sec["port"] == "9000"
assert list(service_sec) == ["host", "port", "timeout", "debug"]
assert list(service_sec.items()) == [
("host", "127.0.0.1"),
("port", "9000"),
("timeout", "30"),
("debug", "true"),
]
# 3. Typed conversion and default fallbacks via get()
assert service_sec.get("port", convert=int) == 9000
assert service_sec.get("timeout", convert=int) == 30
assert service_sec.get("debug", convert=lambda v: v.strip().lower() == "true") is True
assert service_sec.get("absent_key", default="fallback") == "fallback"
assert service_sec.get("absent_key", default=500, convert=int) == 500
assert service_sec.get("absent_key") is None
# 4. Source line tracking via SectionWrapper.lineof
assert service_sec.lineof("host") == 3
assert service_sec.lineof("port") == 4
assert service_sec.lineof("timeout") == 5
assert service_sec.lineof("debug") == 6
assert service_sec.lineof("nonexistent") is None
# 5. Iteration over IniConfig produces SectionWrapper objects in file order
sections = list(ini)
assert len(sections) == 2
assert [s.name for s in sections] == ["service", "database"]
assert all(isinstance(s, iniconfig.SectionWrapper) for s in sections)
db_sec = ini["database"]
assert db_sec.name == "database"
assert db_sec.get("pool_size", convert=int) == 5
def main():
test_section_wrapper_behavior()
print("CONTRACT PASS: iniconfig.Section verified successfully")
return 0
if __name__ == "__main__":
sys.exit(main())
Исходный сидер
аноним