샘플
typing-extensions 4.16.0: typing_extensions.get_origin
검증된 샘플 — pypi typing-extensions 4.16.0: typing_extensions.get_origin. python 3.12 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다.
sha256:ed7dff04196d63e7c218654c0e25b976592cfef8be8730b2384eb4a47fc987d8
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
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 typing_extensions.get_origin in pkg:pypi/typing-extensions@4.16.0
- 심벌
-
- typing_extensions.get_origin
- 환경
- python
- 생성일
- 2026-09-05T22:00:01Z
컨트랙트
- get_origin extracts underlying class from parameterized generic collections including List, Dict, and Set
- get_origin identifies special typing constructs including Union, Literal, and Annotated
- get_origin extracts origin generic class from parameterized user-defined Generic classes
- get_origin returns None for unsubscripted types and non-generic objects
파일
- PROMPT.md
- csx.json
- pyproject.toml
- requirements.txt
- sample.py
- spec.json
- 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 typing_extensions.get_origin in pkg:pypi/typing-extensions@4.16.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:pypi/typing-extensions@4.16.0
Demonstrate these symbols/APIs:
- typing_extensions.get_origin
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:5c7649b78ca393498b683cdb9d484da1bfae992b870827162a94b2bce0f25878","contract":["get_origin extracts underlying class from parameterized generic collections including List, Dict, and Set","get_origin identifies special typing constructs including Union, Literal, and Annotated","get_origin extracts origin generic class from parameterized user-defined Generic classes","get_origin returns None for unsubscripted types and non-generic objects"],"goal":"verify typing_extensions.get_origin in pkg:pypi/typing-extensions@4.16.0","kind":"HOW","packages":["pkg:pypi/typing-extensions@4.16.0"],"schemaVersion":1,"symbols":["typing_extensions.get_origin"]},"contractCommand":["python","test/contract.py"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"pypi","language":"python","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"pip","runtime":"python","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/typing-extensions@4.16.0"],"schemaVersion":1,"subject":"pkg:pypi/typing-extensions@4.16.0","symbols":["typing_extensions.get_origin"],"verifierAdapter":"python@1"}
[project]
name = "verify-typing-extensions-get-origin"
version = "0.1.0"
dependencies = [
"typing-extensions==4.16.0",
]
typing-extensions==4.16.0
"""Demonstration of type introspection with typing_extensions.get_origin."""
from typing import Any, Dict, List, Optional, Set, Tuple, TypeVar, Union
from typing_extensions import Annotated, Generic, Literal, get_origin
T = TypeVar("T")
class Container(Generic[T]):
"""A generic container type for demonstrating get_origin on user-defined classes."""
def __init__(self, value: T) -> None:
self.value = value
def unpack_collection_origin(tp: Any) -> Optional[type]:
"""Extract and return the underlying collection class if tp is a parameterized collection."""
origin = get_origin(tp)
if origin in (list, dict, set, tuple):
return origin
return None
def is_special_form_type(tp: Any) -> bool:
"""Check whether tp is a special typing construct like Union, Literal, or Annotated."""
origin = get_origin(tp)
return origin in (Union, Literal, Annotated)
def get_custom_generic_origin(tp: Any) -> Optional[type]:
"""Return origin if tp is parameterized from Container or another user generic class."""
return get_origin(tp)
def is_unsubscripted_or_primitive(tp: Any) -> bool:
"""Return True if tp has no subscripted origin (e.g. primitive int, str, or raw list)."""
return get_origin(tp) is None
{
"schemaVersion": 1,
"goal": "verify typing_extensions.get_origin in pkg:pypi/typing-extensions@4.16.0",
"kind": "HOW",
"packages": [
"pkg:pypi/typing-extensions@4.16.0"
],
"symbols": [
"typing_extensions.get_origin"
]
}
"""Contract verification test for typing_extensions.get_origin in pkg:pypi/typing-extensions@4.16.0."""
import os
import sys
from typing import Dict, List, Optional, Set, Tuple, Union
# Ensure project root is on sys.path for local module imports
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from typing_extensions import Annotated, Literal, get_origin
from sample import (
Container,
get_custom_generic_origin,
is_special_form_type,
is_unsubscripted_or_primitive,
unpack_collection_origin,
)
def test_collection_generics_origin() -> None:
"""Assertion 1: get_origin extracts underlying class from parameterized generic collections including List, Dict, and Set."""
assert get_origin(List[int]) is list
assert get_origin(Dict[str, int]) is dict
assert get_origin(Set[float]) is set
assert get_origin(Tuple[int, ...]) is tuple
# Built-in generic aliases (PEP 585)
assert get_origin(list[int]) is list
assert get_origin(dict[str, int]) is dict
# Sample helper check
assert unpack_collection_origin(List[int]) is list
assert unpack_collection_origin(Dict[str, int]) is dict
assert unpack_collection_origin(Set[float]) is set
assert unpack_collection_origin(Tuple[int, ...]) is tuple
assert unpack_collection_origin(int) is None
def test_special_forms_origin() -> None:
"""Assertion 2: get_origin identifies special typing constructs including Union, Literal, and Annotated."""
assert get_origin(Union[int, str]) is Union
assert get_origin(Optional[int]) is Union
assert get_origin(Literal["read", "write"]) is Literal
assert get_origin(Annotated[int, "metadata"]) is Annotated
# Sample helper check
assert is_special_form_type(Union[int, str]) is True
assert is_special_form_type(Optional[int]) is True
assert is_special_form_type(Literal["a", "b"]) is True
assert is_special_form_type(Annotated[str, "doc"]) is True
assert is_special_form_type(List[int]) is False
def test_custom_generic_origin() -> None:
"""Assertion 3: get_origin extracts origin generic class from parameterized user-defined Generic classes."""
specialized = Container[int]
assert get_origin(specialized) is Container
assert get_custom_generic_origin(specialized) is Container
specialized_str = Container[str]
assert get_origin(specialized_str) is Container
assert get_custom_generic_origin(specialized_str) is Container
def test_unsubscripted_and_primitives_return_none() -> None:
"""Assertion 4: get_origin returns None for unsubscripted types and non-generic objects."""
assert get_origin(int) is None
assert get_origin(str) is None
assert get_origin(list) is None
assert get_origin(Container) is None
assert get_origin(object) is None
assert get_origin("not_a_type") is None
assert get_origin(123) is None
# Sample helper check
assert is_unsubscripted_or_primitive(int) is True
assert is_unsubscripted_or_primitive(str) is True
assert is_unsubscripted_or_primitive(list) is True
assert is_unsubscripted_or_primitive(Container) is True
assert is_unsubscripted_or_primitive(List[int]) is False
assert is_unsubscripted_or_primitive(Container[int]) is False
def main() -> None:
test_collection_generics_origin()
test_special_forms_origin()
test_custom_generic_origin()
test_unsubscripted_and_primitives_return_none()
print("All contract assertions passed.")
if __name__ == "__main__":
main()
오리진 시더
익명