샘플
annotated-types 0.8.0: annotated_types.Ge, annotated_types.Gt, annotated_types.Interval
검증된 샘플 — pypi annotated-types 0.8.0: annotated_types.Ge, annotated_types.Gt, annotated_types.Interval. python 3.12 · linux alpine/x64 · docker에서 contract를…
sha256:92277298fc1a441aa9f4ff16fdc53a1e5b18176ddbf27e14d1fd26fd3aaf300c
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
python linux 24 · ubuntu · glibc 2.39 x64 python python pip
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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-28 |
케이스
HOW- 목표
- verify pkg:pypi/annotated-types@0.8.0
- 심벌
-
- annotated_types.Ge
- annotated_types.Gt
- annotated_types.Interval
- annotated_types.Le
- annotated_types.Len
- annotated_types.Lt
- annotated_types.Predicate
- 환경
- python
- 생성일
- 2026-08-28T04:01:42Z
컨트랙트
- Gt, Ge, Lt, and Le instantiate single-bound inequality constraints inheriting from BaseMetadata and storing their respective bound attributes.
- Interval groups upper and lower bounds into an iterable GroupedMetadata object that yields individual Gt, Ge, Lt, and Le constraint instances.
- Len expresses minimum and maximum collection length constraints and unpacks into MinLen and MaxLen instances when iterated.
- Predicate encapsulates callable validation predicates with customizable string representation and equality semantics.
- annotated-types constraint objects integrate with typing.Annotated for function signatures and class attributes, retrievable via typing.get_type_hints.
파일
- NOTES.md
- PROMPT.md
- csx.json
- requirements.txt
- spec.json
- test/contract.py
소스
# annotated-types constraint metadata and typing.Annotated integration
This sample pins `annotated-types` 0.8.0 and verifies core constraint metadata types: `Gt`, `Ge`, `Lt`, `Le`, `Interval`, `Len`, and `Predicate`.
The contract verifies:
- Single-bound inequality constraints (`Gt`, `Ge`, `Lt`, `Le`) inheriting from `BaseMetadata` with frozen immutability and attribute storage (`gt`, `ge`, `lt`, `le`).
- Multi-bound `Interval` implementing `GroupedMetadata` to unpack into single-bound constraints (`Gt`, `Ge`, `Lt`, `Le`) upon iteration.
- Collection sizing metadata `Len(min_length, max_length)` implementing `GroupedMetadata` to unpack into `MinLen` and `MaxLen`.
- Callable predicate metadata `Predicate(func)` holding validation functions with readable string representation (`repr`) and equality semantics.
- Integration with standard `typing.Annotated` for function parameter, return type, and class attribute annotations retrievable via `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 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.Ge
- annotated_types.Gt
- annotated_types.Interval
- annotated_types.Le
- annotated_types.Len
- annotated_types.Lt
- annotated_types.Predicate
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:dea4b69a255757ed79c331c52b4219b2242999d64d30280cf45d820c2a71fb6c","contract":["Gt, Ge, Lt, and Le instantiate single-bound inequality constraints inheriting from BaseMetadata and storing their respective bound attributes.","Interval groups upper and lower bounds into an iterable GroupedMetadata object that yields individual Gt, Ge, Lt, and Le constraint instances.","Len expresses minimum and maximum collection length constraints and unpacks into MinLen and MaxLen instances when iterated.","Predicate encapsulates callable validation predicates with customizable string representation and equality semantics.","annotated-types constraint objects integrate with typing.Annotated for function signatures and class attributes, retrievable via typing.get_type_hints."],"goal":"verify pkg:pypi/annotated-types@0.8.0","kind":"HOW","packages":["pkg:pypi/annotated-types@0.8.0"],"schemaVersion":1,"symbols":["annotated_types.Ge","annotated_types.Gt","annotated_types.Interval","annotated_types.Le","annotated_types.Len","annotated_types.Lt","annotated_types.Predicate"]},"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.Ge","annotated_types.Gt","annotated_types.Interval","annotated_types.Le","annotated_types.Len","annotated_types.Lt","annotated_types.Predicate"],"verifierAdapter":"python@1"}
annotated-types==0.8.0
{
"schemaVersion": 1,
"goal": "verify pkg:pypi/annotated-types@0.8.0",
"kind": "HOW",
"packages": [
"pkg:pypi/annotated-types@0.8.0"
],
"symbols": [
"annotated_types.Ge",
"annotated_types.Gt",
"annotated_types.Interval",
"annotated_types.Le",
"annotated_types.Len",
"annotated_types.Lt",
"annotated_types.Predicate"
]
}
from typing import Annotated, get_args, get_type_hints
import annotated_types
from annotated_types import (
BaseMetadata,
Ge,
GroupedMetadata,
Gt,
Interval,
Le,
Len,
Lt,
MaxLen,
MinLen,
Predicate,
)
# 1. Verify package version
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__}"
# 2. Verify single-bound inequality constraints (Gt, Ge, Lt, Le)
assert issubclass(Gt, BaseMetadata)
assert issubclass(Ge, BaseMetadata)
assert issubclass(Lt, BaseMetadata)
assert issubclass(Le, BaseMetadata)
gt10 = Gt(10)
ge0 = Ge(0)
lt100 = Lt(100)
le50 = Le(50)
assert gt10.gt == 10
assert ge0.ge == 0
assert lt100.lt == 100
assert le50.le == 50
assert gt10 == Gt(10)
assert gt10 != Gt(20)
assert hash(gt10) == hash(Gt(10))
assert ge0 == Ge(0)
assert ge0 != Ge(1)
assert lt100 == Lt(100)
assert lt100 != Lt(50)
assert le50 == Le(50)
assert le50 != Le(60)
# 3. Verify Interval and GroupedMetadata unpacking
iv_range = Interval(ge=1, lt=100)
assert isinstance(iv_range, GroupedMetadata)
assert iv_range.ge == 1
assert iv_range.lt == 100
assert iv_range.gt is None
assert iv_range.le is None
unpacked_iv = list(iv_range)
assert unpacked_iv == [Ge(1), Lt(100)]
iv_all = Interval(gt=0, ge=1, lt=10, le=9)
assert list(iv_all) == [Gt(0), Ge(1), Lt(10), Le(9)]
iv_empty = Interval()
assert list(iv_empty) == []
# 4. Verify Len constraint and MinLen/MaxLen unpacking
len_bounded = Len(min_length=2, max_length=20)
assert isinstance(len_bounded, GroupedMetadata)
assert len_bounded.min_length == 2
assert len_bounded.max_length == 20
assert list(len_bounded) == [MinLen(2), MaxLen(20)]
len_min_only = Len(min_length=5)
assert list(len_min_only) == [MinLen(5)]
len_default = Len()
assert len_default.min_length == 0
assert len_default.max_length is None
assert list(len_default) == []
# 5. Verify Predicate metadata and representation
pred_lower = Predicate(str.islower)
assert issubclass(Predicate, BaseMetadata)
assert pred_lower.func is str.islower
assert repr(pred_lower) == "Predicate(str.islower)"
assert pred_lower == Predicate(str.islower)
assert pred_lower != Predicate(str.isupper)
pred_custom = Predicate(lambda x: x % 2 == 0)
assert repr(pred_custom).startswith("Predicate(")
# 6. Verify integration with typing.Annotated and reflection
def process_data(
score: Annotated[int, Gt(0), Le(100)],
username: Annotated[str, Len(3, 30), Predicate(str.isalnum)],
ratio: Annotated[float, Interval(ge=0.0, le=1.0)],
) -> Annotated[bool, Predicate(bool)]:
return True
hints = get_type_hints(process_data, include_extras=True)
assert "score" in hints and "username" in hints and "ratio" in hints and "return" in hints
score_args = get_args(hints["score"])
assert score_args[0] is int
assert score_args[1] == Gt(0)
assert score_args[2] == Le(100)
user_args = get_args(hints["username"])
assert user_args[0] is str
assert user_args[1] == Len(3, 30)
assert user_args[2] == Predicate(str.isalnum)
ratio_args = get_args(hints["ratio"])
assert ratio_args[0] is float
assert ratio_args[1] == Interval(ge=0.0, le=1.0)
return_args = get_args(hints["return"])
assert return_args[0] is bool
assert return_args[1] == Predicate(bool)
class Record:
item_count: Annotated[int, Ge(1), Lt(1000)]
record_hints = get_type_hints(Record, include_extras=True)
count_args = get_args(record_hints["item_count"])
assert count_args[0] is int
assert count_args[1] == Ge(1)
assert count_args[2] == Lt(1000)
print("CONTRACT PASS: pkg:pypi/annotated-types@0.8.0 verified offline")
오리진 시더
익명