サンプル
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
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
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")
オリジンシーダー
匿名