샘플
annotated-types 0.8.0: annotated_types
검증된 샘플 — pypi annotated-types 0.8.0: annotated_types. python 3.12 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: annotated_types exports __version__…
sha256:04ba10211605f46af1937c43b32b441fa5506bdd609a27a62844ec22d0826558
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
python linux 24 · ubuntu · glibc 2.39 x64 python python 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-05 |
케이스
HOW- 목표
- verify annotated_types in pkg:pypi/annotated-types@0.8.0
- 심벌
-
- annotated_types
- 환경
- python
- 생성일
- 2026-09-05T22:49:19Z
컨트랙트
- annotated_types exports __version__ 0.8.0 and core metadata protocols including BaseMetadata and GroupedMetadata.
- GroupedMetadata enforces protocol implementation requiring subclasses to define __iter__ or raise TypeError upon subclassing.
- MultipleOf, Timezone, and Unit provide frozen constraint metadata inheriting from BaseMetadata with equality and hash semantics.
- Predefined predicate type aliases such as LowerCase, UpperCase, IsDigits, and IsFinite wrap Predicate with standard validation functions.
- annotated_types metadata integrates with typing.Annotated for parameter and return type reflection retrievable via typing.get_type_hints.
파일
- NOTES.md
- PROMPT.md
- csx.json
- requirements.txt
- spec.json
- test/contract.py
소스
# annotated-types core protocols, constraints, and typing.Annotated reflection
This sample pins `annotated-types` 0.8.0 and verifies core protocols, constraints, and documentation metadata: `BaseMetadata`, `GroupedMetadata`, `MultipleOf`, `Timezone`, `Unit`, `doc`/`DocInfo`, and predefined predicate type aliases (`LowerCase`, `UpperCase`, `IsDigits`, `IsFinite`, etc.).
The contract verifies:
- Top-level package version and exports (`__version__ == '0.8.0'`, `__all__`, `BaseMetadata`, `GroupedMetadata`).
- Protocol enforcement for `GroupedMetadata` ensuring subclasses define `__iter__` or raise `TypeError`.
- Frozen constraint metadata (`MultipleOf`, `Timezone`, `Unit`) inheriting from `BaseMetadata` with equality, hash, and attribute semantics.
- Timezone awareness metadata accepting `None` (naive), `...` (aware), `datetime.timezone` objects, or strings.
- Documentation metadata `doc` / `Doc` / `DocInfo` storing description strings under PEP 727.
- Standard predicate type aliases wrapping `Predicate` with standard validation functions.
- Offline reflection with standard `typing.Annotated`, `typing.get_type_hints(..., include_extras=True)`, and `typing.get_args(...)`.
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 annotated_types in pkg:pypi/annotated-types@0.8.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:pypi/annotated-types@0.8.0
Demonstrate these symbols/APIs:
- annotated_types
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:08ffb6cc3fd984cd4938df43433c4fc5f56d3bae4e6d559571ea953f18ecbf8c","contract":["annotated_types exports __version__ 0.8.0 and core metadata protocols including BaseMetadata and GroupedMetadata.","GroupedMetadata enforces protocol implementation requiring subclasses to define __iter__ or raise TypeError upon subclassing.","MultipleOf, Timezone, and Unit provide frozen constraint metadata inheriting from BaseMetadata with equality and hash semantics.","Predefined predicate type aliases such as LowerCase, UpperCase, IsDigits, and IsFinite wrap Predicate with standard validation functions.","annotated_types metadata integrates with typing.Annotated for parameter and return type reflection retrievable via typing.get_type_hints."],"goal":"verify annotated_types in pkg:pypi/annotated-types@0.8.0","kind":"HOW","packages":["pkg:pypi/annotated-types@0.8.0"],"schemaVersion":1,"symbols":["annotated_types"]},"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/annotated-types@0.8.0"],"schemaVersion":1,"subject":"pkg:pypi/annotated-types@0.8.0","symbols":["annotated_types"],"verifierAdapter":"python@1"}
annotated-types==0.8.0
{
"schemaVersion": 1,
"goal": "verify annotated_types in pkg:pypi/annotated-types@0.8.0",
"kind": "HOW",
"packages": [
"pkg:pypi/annotated-types@0.8.0"
],
"symbols": [
"annotated_types"
]
}
import math
from datetime import datetime, timezone
from typing import Annotated, get_args, get_type_hints
import annotated_types
from annotated_types import (
BaseMetadata,
Doc,
DocInfo,
GroupedMetadata,
IsAscii,
IsDigits,
IsFinite,
IsInfinite,
IsNan,
IsNotFinite,
IsNotInfinite,
IsNotNan,
LowerCase,
MultipleOf,
Predicate,
Timezone,
Unit,
UpperCase,
doc,
)
# 1. Package metadata and top-level exports
assert hasattr(annotated_types, "__version__"), "annotated_types must define __version__"
assert annotated_types.__version__ == "0.8.0", f"Expected version 0.8.0, got {annotated_types.__version__}"
assert "BaseMetadata" in annotated_types.__all__
assert "GroupedMetadata" in annotated_types.__all__
assert "MultipleOf" in annotated_types.__all__
assert "Timezone" in annotated_types.__all__
assert "doc" in annotated_types.__all__
assert "DocInfo" in annotated_types.__all__
assert "LowerCase" in annotated_types.__all__
assert "UpperCase" in annotated_types.__all__
assert "IsDigits" in annotated_types.__all__
assert "IsFinite" in annotated_types.__all__
assert hasattr(annotated_types, "Unit")
# 2. BaseMetadata & GroupedMetadata protocol enforcement
assert hasattr(BaseMetadata, "__slots__")
base_instance = BaseMetadata()
assert isinstance(base_instance, BaseMetadata)
class CustomGroup(GroupedMetadata):
def __init__(self, *items):
self.items = items
def __iter__(self):
return iter(self.items)
cg = CustomGroup(base_instance)
assert isinstance(cg, GroupedMetadata)
assert cg.__is_annotated_types_grouped_metadata__ is True
assert list(cg) == [base_instance]
try:
class IncompleteGroup(GroupedMetadata):
pass
assert False, "Should have raised TypeError for missing __iter__"
except TypeError as exc:
assert "Can't subclass GroupedMetadata without implementing __iter__" in str(exc)
# 3. MultipleOf constraint
assert issubclass(MultipleOf, BaseMetadata)
mo5 = MultipleOf(5)
assert mo5.multiple_of == 5
assert mo5 == MultipleOf(5)
assert mo5 != MultipleOf(10)
assert hash(mo5) == hash(MultipleOf(5))
# 4. Timezone constraint (aware, naive, tzinfo, string)
assert issubclass(Timezone, BaseMetadata)
tz_naive = Timezone(None)
tz_aware = Timezone(...)
tz_utc = Timezone(timezone.utc)
tz_str = Timezone("UTC")
assert tz_naive.tz is None
assert tz_aware.tz is ...
assert tz_utc.tz == timezone.utc
assert tz_str.tz == "UTC"
assert tz_utc == Timezone(timezone.utc)
assert tz_naive != tz_aware
# 5. Unit constraint
assert issubclass(Unit, BaseMetadata)
unit_meter = Unit("m")
assert unit_meter.unit == "m"
assert unit_meter == Unit("m")
assert unit_meter != Unit("kg")
assert hash(unit_meter) == hash(Unit("m"))
# 6. Documentation metadata (doc / Doc / DocInfo)
d = doc("Field documentation")
assert isinstance(d, Doc)
assert isinstance(d, DocInfo)
assert d.documentation == "Field documentation"
assert d == Doc("Field documentation")
assert d != Doc("Different text")
# 7. Predefined predicate aliases
lower_args = get_args(LowerCase)
assert len(lower_args) == 2
assert isinstance(lower_args[1], Predicate)
assert lower_args[1].func is str.islower
upper_args = get_args(UpperCase)
assert isinstance(upper_args[1], Predicate)
assert upper_args[1].func is str.isupper
digits_args = get_args(IsDigits)
assert isinstance(digits_args[1], Predicate)
assert digits_args[1].func is str.isdigit
ascii_args = get_args(IsAscii)
assert isinstance(ascii_args[1], Predicate)
assert ascii_args[1].func is str.isascii
finite_args = get_args(IsFinite)
assert isinstance(finite_args[1], Predicate)
assert finite_args[1].func is math.isfinite
not_finite_args = get_args(IsNotFinite)
assert isinstance(not_finite_args[1], Predicate)
assert not_finite_args[1].func(float("inf")) is True
assert not_finite_args[1].func(1.0) is False
nan_args = get_args(IsNan)
assert isinstance(nan_args[1], Predicate)
assert nan_args[1].func is math.isnan
not_nan_args = get_args(IsNotNan)
assert isinstance(not_nan_args[1], Predicate)
assert not_nan_args[1].func(float("nan")) is False
assert not_nan_args[1].func(1.0) is True
inf_args = get_args(IsInfinite)
assert isinstance(inf_args[1], Predicate)
assert inf_args[1].func is math.isinf
not_inf_args = get_args(IsNotInfinite)
assert isinstance(not_inf_args[1], Predicate)
assert not_inf_args[1].func(float("inf")) is False
assert not_inf_args[1].func(1.0) is True
# 8. Integration with typing.Annotated reflection
def validate_entry(
username: LowerCase,
step: Annotated[int, MultipleOf(10)],
timestamp: Annotated[datetime, Timezone(timezone.utc)],
altitude: Annotated[float, Unit("m")],
note: Annotated[str, doc("Optional description")],
) -> Annotated[float, Predicate(math.isfinite)]:
return altitude
hints = get_type_hints(validate_entry, include_extras=True)
assert "username" in hints
assert "step" in hints
assert "timestamp" in hints
assert "altitude" in hints
assert "note" in hints
assert "return" in hints
assert MultipleOf(10) in get_args(hints["step"])
assert Timezone(timezone.utc) in get_args(hints["timestamp"])
assert Unit("m") in get_args(hints["altitude"])
assert doc("Optional description") in get_args(hints["note"])
assert Predicate(math.isfinite) in get_args(hints["return"])
print("CONTRACT PASS: pkg:pypi/annotated-types@0.8.0 verified offline")
오리진 시더
익명