Sample
typing-extensions 4.16.0: typing_extensions.get_origin
Verified sample for pypi typing-extensions 4.16.0: typing_extensions.get_origin. The contract ran on python 3.12 · linux debian/x64 · docker and passed.
sha256:ed7dff04196d63e7c218654c0e25b976592cfef8be8730b2384eb4a47fc987d8
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 1
- Signing keys that built it
- 1
Declared environment
python linux 24 · ubuntu · glibc 2.39 x64 python python pip
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| 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 |
Case
HOW- Goal
- verify typing_extensions.get_origin in pkg:pypi/typing-extensions@4.16.0
- Packages
- Symbols
-
- typing_extensions.get_origin
- Environment
- python
- Created
- 2026-09-05T22:00:01Z
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
Files
- PROMPT.md
- csx.json
- pyproject.toml
- requirements.txt
- sample.py
- spec.json
- test/contract.py
Source
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()
Origin Seeder
anonymous