Sample
typing-extensions 4.16.0: typing_extensions.get_type_hints
Verified sample for pypi typing-extensions 4.16.0: typing_extensions.get_type_hints. The contract ran on python 3.12 · linux debian/x64 · docker and passed.
sha256:25be1b8c402ce3ec5f8dd6c464f47158cf6de4db3dff26eeae0f3305c3660640
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_type_hints in pkg:pypi/typing-extensions@4.16.0
- Packages
- Symbols
-
- typing_extensions.get_type_hints
- Environment
- python
- Created
- 2026-09-05T23:35:27Z
Contract
- get_type_hints resolves function parameter and return type annotations into concrete types.
- get_type_hints evaluates forward references defined as string literals using globalns and localns.
- get_type_hints unwraps Annotated metadata by default, returning the underlying type.
- get_type_hints preserves Annotated metadata when include_extras=True.
- get_type_hints resolves inherited class attributes across class inheritance hierarchy.
- get_type_hints raises TypeError for objects that cannot have type annotations.
Files
- NOTES.md
- PROMPT.md
- csx.json
- requirements.txt
- spec.json
- test/contract.py
Source
# typing_extensions.get_type_hints API contract
This sample pins `typing-extensions` 4.16.0 and verifies `typing_extensions.get_type_hints` for type annotation evaluation and introspection.
The contract verifies:
- `get_type_hints` resolves function parameter and return type annotations into concrete types.
- `get_type_hints` evaluates forward references defined as string literals using globalns and localns.
- `get_type_hints` unwraps Annotated metadata by default (`include_extras=False`), returning the underlying type.
- `get_type_hints` preserves Annotated metadata when `include_extras=True`.
- `get_type_hints` resolves inherited class attributes across class inheritance hierarchy.
- `get_type_hints` raises TypeError for objects that cannot have type annotations and returns empty dict for unannotated objects.
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_type_hints 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_type_hints
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:734381c2a515ff0d1210280bd6ba0cc83ae0f7644a53be893d0607247ea3e42d","contract":["get_type_hints resolves function parameter and return type annotations into concrete types.","get_type_hints evaluates forward references defined as string literals using globalns and localns.","get_type_hints unwraps Annotated metadata by default, returning the underlying type.","get_type_hints preserves Annotated metadata when include_extras=True.","get_type_hints resolves inherited class attributes across class inheritance hierarchy.","get_type_hints raises TypeError for objects that cannot have type annotations."],"goal":"verify typing_extensions.get_type_hints in pkg:pypi/typing-extensions@4.16.0","kind":"HOW","packages":["pkg:pypi/typing-extensions@4.16.0"],"schemaVersion":1,"symbols":["typing_extensions.get_type_hints"]},"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/typing-extensions@4.16.0"],"schemaVersion":1,"subject":"pkg:pypi/typing-extensions@4.16.0","symbols":["typing_extensions.get_type_hints"],"verifierAdapter":"python@1"}
typing-extensions==4.16.0
{
"schemaVersion": 1,
"goal": "verify typing_extensions.get_type_hints in pkg:pypi/typing-extensions@4.16.0",
"kind": "HOW",
"packages": [
"pkg:pypi/typing-extensions@4.16.0"
],
"symbols": [
"typing_extensions.get_type_hints"
]
}
from typing import Annotated, Optional, get_args, get_origin
from typing_extensions import get_type_hints
# 1. Resolves function parameter and return type annotations into concrete types
def calculate_area(length: int, width: float) -> float:
return float(length * width)
fn_hints = get_type_hints(calculate_area)
assert fn_hints == {"length": int, "width": float, "return": float}, f"Unexpected function hints: {fn_hints}"
# 2. Evaluates forward references defined as string literals using globalns and localns
class Node:
pass
def traverse(node: "Node", depth: "CustomInt") -> "Optional[Node]":
return node if depth > 0 else None
local_env = {"CustomInt": int}
fwd_hints = get_type_hints(traverse, localns=local_env)
assert fwd_hints["node"] is Node, f"Expected Node, got {fwd_hints['node']}"
assert fwd_hints["depth"] is int, f"Expected int, got {fwd_hints['depth']}"
assert fwd_hints["return"] == Optional[Node], f"Expected Optional[Node], got {fwd_hints['return']}"
# 3. Unwraps Annotated metadata by default, returning the underlying type
def process_data(value: Annotated[int, "metadata", 42]) -> Annotated[str, "result"]:
return str(value)
unwrapped_hints = get_type_hints(process_data, include_extras=False)
assert unwrapped_hints["value"] is int, f"Expected unwrapped int, got {unwrapped_hints['value']}"
assert unwrapped_hints["return"] is str, f"Expected unwrapped str, got {unwrapped_hints['return']}"
# 4. Preserves Annotated metadata when include_extras=True
extras_hints = get_type_hints(process_data, include_extras=True)
assert get_origin(extras_hints["value"]) is Annotated
assert get_args(extras_hints["value"]) == (int, "metadata", 42)
assert get_origin(extras_hints["return"]) is Annotated
assert get_args(extras_hints["return"]) == (str, "result")
# 5. Resolves inherited class attributes across class inheritance hierarchy
class BaseEntity:
id: int
name: str
class Account(BaseEntity):
balance: float
class PremiumAccount(Account):
tier: str
class_hints = get_type_hints(PremiumAccount)
assert class_hints == {
"id": int,
"name": str,
"balance": float,
"tier": str,
}, f"Unexpected class inheritance hints: {class_hints}"
# 6. Raises TypeError for objects that cannot have type annotations
try:
get_type_hints(12345)
raise AssertionError("get_type_hints on integer must raise TypeError")
except TypeError:
pass
try:
get_type_hints("invalid_object")
raise AssertionError("get_type_hints on string must raise TypeError")
except TypeError:
pass
def no_annotations(x, y):
return x + y
assert get_type_hints(no_annotations) == {}, "Unannotated function must return empty dictionary"
print("CONTRACT PASS: pkg:pypi/typing-extensions@4.16.0 verified offline")
Origin Seeder
anonymous