CodeSampleX

Ejemplo

tzdata 2026.2: IANA_VERSION

Muestra verificada para pypi tzdata 2026.2: IANA_VERSION. El contrato se ejecutó en python 3.12 · linux alpine/x64 · docker y pasó.

sha256:fc14c0020a6b8e3deb8d91324c6fa15aad2a82371d3c74117e90aab4b021bcb6

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
2
Claves de firma que lo compilaron
1
Entorno declarado python linux 24 · ubuntu · glibc 2.39 x64 python python pip

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
python 3.12 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · python@1python:3.12-alpine@sha256:d09d15e60962…
2026-08-26
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-07

Caso

HOW
Objetivo
verify pkg:pypi/tzdata@2026.2
Paquetes
Símbolos
  • tzdata.IANA_VERSION
Entorno
python
Creado
2026-08-26T13:51:48Z

Contrato

  1. tzdata.IANA_VERSION exposes the IANA database release identifier matching format YYYY[a-z] and __version__ matching the package version 2026.2.
  2. tzdata provides the bundled zones resource file containing valid IANA timezone identifier names including UTC, America/New_York, Europe/London, and Asia/Tokyo.
  3. tzdata.zoneinfo package namespace contains compiled binary zoneinfo data files for time zone definitions.
  4. zoneinfo.ZoneInfo resolves timezone data provided by tzdata and computes correct UTC offsets for America/New_York (-05:00 in winter) and Asia/Tokyo (+09:00).
  5. zoneinfo.ZoneInfo raises ZoneInfoNotFoundError or KeyError when queried with an invalid timezone key.

Archivos

  • NOTES.md
  • PROMPT.md
  • csx.json
  • requirements.txt
  • spec.json
  • test/contract.py

Descargar el artefacto de código fuente (tar.gz)

Código fuente

NOTES.md
# tzdata IANA Time Zone Database for Python

This sample pins `tzdata` 2026.2 and verifies `tzdata.IANA_VERSION` and time zone data resources for Python's standard `zoneinfo` module.

The contract verifies:
- `tzdata.IANA_VERSION` exposes the IANA database release string (e.g. `'2026b'`) and `tzdata.__version__` matches `'2026.2'`.
- `tzdata` provides the `zones` resource file listing all valid IANA time zone identifiers.
- `tzdata.zoneinfo` package namespace contains compiled binary zoneinfo data files for major time zones.
- `zoneinfo.ZoneInfo` resolves timezone names and computes accurate UTC offsets.
- Invalid timezone names raise `ZoneInfoNotFoundError` or `KeyError`.
PROMPT.md
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 pkg:pypi/tzdata@2026.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:pypi/tzdata@2026.2
Demonstrate these symbols/APIs:
  - tzdata.IANA_VERSION

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.
csx.json
{"case":{"caseId":"case:sha256:099eddd72c69f4fc57b5409e9476791a024bc371698212fdf305384c206740d4","contract":["tzdata.IANA_VERSION exposes the IANA database release identifier matching format YYYY[a-z] and __version__ matching the package version 2026.2.","tzdata provides the bundled zones resource file containing valid IANA timezone identifier names including UTC, America/New_York, Europe/London, and Asia/Tokyo.","tzdata.zoneinfo package namespace contains compiled binary zoneinfo data files for time zone definitions.","zoneinfo.ZoneInfo resolves timezone data provided by tzdata and computes correct UTC offsets for America/New_York (-05:00 in winter) and Asia/Tokyo (+09:00).","zoneinfo.ZoneInfo raises ZoneInfoNotFoundError or KeyError when queried with an invalid timezone key."],"goal":"verify pkg:pypi/tzdata@2026.2","kind":"HOW","packages":["pkg:pypi/tzdata@2026.2"],"schemaVersion":1,"symbols":["tzdata.IANA_VERSION"]},"contractCommand":["python","test/contract.py"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"pypi","executionContext":"python","language":"python","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"pip","runtime":"python","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/tzdata@2026.2"],"schemaVersion":1,"subject":"pkg:pypi/tzdata@2026.2","symbols":["tzdata.IANA_VERSION"],"verifierAdapter":"python@1"}
requirements.txt
tzdata==2026.2
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:pypi/tzdata@2026.2",
  "kind": "HOW",
  "packages": [
    "pkg:pypi/tzdata@2026.2"
  ],
  "symbols": [
    "tzdata.IANA_VERSION"
  ]
}
test/contract.py
import datetime
import importlib.resources
import re
import zoneinfo
import tzdata

# 1. Verify IANA_VERSION and __version__ attributes
assert hasattr(tzdata, "IANA_VERSION"), "tzdata must define IANA_VERSION"
assert isinstance(tzdata.IANA_VERSION, str), f"Expected str for IANA_VERSION, got {type(tzdata.IANA_VERSION)}"
assert re.match(r"^\d{4}[a-z]$", tzdata.IANA_VERSION), f"Unexpected IANA_VERSION format: {tzdata.IANA_VERSION}"
assert hasattr(tzdata, "__version__"), "tzdata must define __version__"
assert tzdata.__version__ == "2026.2", f"Expected __version__ 2026.2, got {tzdata.__version__}"

# 2. Verify tzdata package resource: zones listing file
zones_resource = importlib.resources.files("tzdata").joinpath("zones")
assert zones_resource.is_file(), "tzdata/zones resource file must exist and be a file"
zones_content = zones_resource.read_text(encoding="utf-8")
zones_list = [line.strip() for line in zones_content.splitlines() if line.strip()]
assert len(zones_list) >= 500, f"Expected at least 500 timezone entries, got {len(zones_list)}"
assert "UTC" in zones_list, "UTC must be listed in zones"
assert "America/New_York" in zones_list, "America/New_York must be listed in zones"
assert "Europe/London" in zones_list, "Europe/London must be listed in zones"
assert "Asia/Tokyo" in zones_list, "Asia/Tokyo must be listed in zones"

# 3. Verify tzdata.zoneinfo binary timezone data files exist
zi_resource = importlib.resources.files("tzdata.zoneinfo")
assert zi_resource.joinpath("UTC").is_file(), "tzdata.zoneinfo UTC file must exist"
assert zi_resource.joinpath("America", "New_York").is_file(), "tzdata.zoneinfo America/New_York file must exist"
assert zi_resource.joinpath("Europe", "London").is_file(), "tzdata.zoneinfo Europe/London file must exist"
assert zi_resource.joinpath("Asia", "Tokyo").is_file(), "tzdata.zoneinfo Asia/Tokyo file must exist"

# 4. Verify standard library zoneinfo.ZoneInfo resolution using tzdata
zi_ny = zoneinfo.ZoneInfo("America/New_York")
assert zi_ny.key == "America/New_York"
dt_utc_jan = datetime.datetime(2026, 1, 15, 12, 0, 0, tzinfo=datetime.timezone.utc)
dt_ny_jan = dt_utc_jan.astimezone(zi_ny)
assert dt_ny_jan.utcoffset() == datetime.timedelta(hours=-5), f"Expected -05:00 UTC offset, got {dt_ny_jan.utcoffset()}"

zi_tokyo = zoneinfo.ZoneInfo("Asia/Tokyo")
dt_tokyo = dt_utc_jan.astimezone(zi_tokyo)
assert dt_tokyo.utcoffset() == datetime.timedelta(hours=9), f"Expected +09:00 UTC offset, got {dt_tokyo.utcoffset()}"

# 5. Verify non-existent timezone key raises ZoneInfoNotFoundError
try:
    zoneinfo.ZoneInfo("Invalid/NonExistent_Zone_12345")
    raise AssertionError("Expected ZoneInfoNotFoundError for non-existent timezone key")
except (zoneinfo.ZoneInfoNotFoundError, KeyError):
    pass

print("CONTRACT PASS: pkg:pypi/tzdata@2026.2 verified offline")

Seeder de origen

anónimo