샘플
sqlalchemy 2.0.51: orm.decl_api.DeclarativeMeta
검증된 샘플 — pypi sqlalchemy 2.0.51: orm.decl_api.DeclarativeMeta. python 3.12 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다.
sha256:b08edda3b630d70e54e4f7d9e318ab08ad5abe49bce03277fa4d81790d7ffa49
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
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-06 |
케이스
HOW- 목표
- verify sqlalchemy.orm.decl_api.DeclarativeMeta in pkg:pypi/sqlalchemy@2.0.51
- 심벌
-
- sqlalchemy.orm.decl_api.DeclarativeMeta
- 환경
- python
- 생성일
- 2026-09-06T12:26:35Z
컨트랙트
- Base classes produced by declarative_base() have DeclarativeMeta as their metaclass, and models subclassing the base are instances of DeclarativeMeta.
- Custom declarative base classes can be defined directly using metaclass=DeclarativeMeta when configured with registry and __abstract__ = True.
- Defining a class directly with metaclass=DeclarativeMeta without providing a registry raises InvalidRequestError.
- Classes instantiated through DeclarativeMeta initialize table metadata and map columns to their underlying Table representation.
- Custom metaclasses subclassing DeclarativeMeta can hook into model initialization while remaining DeclarativeMeta instances.
파일
- NOTES.md
- PROMPT.md
- csx.json
- requirements.txt
- spec.json
- test/contract.py
소스
# sqlalchemy DeclarativeMeta API
This sample pins `sqlalchemy` 2.0.51 and verifies `sqlalchemy.orm.decl_api.DeclarativeMeta` for declarative class mapping and metaclass customization.
The contract verifies:
- Base classes produced by declarative_base() have DeclarativeMeta as their metaclass, and models subclassing the base are instances of DeclarativeMeta.
- Custom declarative base classes can be defined directly using metaclass=DeclarativeMeta when configured with registry and __abstract__ = True.
- Defining a class directly with metaclass=DeclarativeMeta without providing a registry raises InvalidRequestError.
- Classes instantiated through DeclarativeMeta initialize table metadata and map columns to their underlying Table representation.
- Custom metaclasses subclassing DeclarativeMeta can hook into model initialization while remaining DeclarativeMeta instances.
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 sqlalchemy.orm.decl_api.DeclarativeMeta in pkg:pypi/sqlalchemy@2.0.51
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:pypi/sqlalchemy@2.0.51
Demonstrate these symbols/APIs:
- sqlalchemy.orm.decl_api.DeclarativeMeta
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:3d4494d60557564e170000656eb13fab1bf2d88a3abdf5fbd13c327b4e8f13cf","contract":["Base classes produced by declarative_base() have DeclarativeMeta as their metaclass, and models subclassing the base are instances of DeclarativeMeta.","Custom declarative base classes can be defined directly using metaclass=DeclarativeMeta when configured with registry and __abstract__ = True.","Defining a class directly with metaclass=DeclarativeMeta without providing a registry raises InvalidRequestError.","Classes instantiated through DeclarativeMeta initialize table metadata and map columns to their underlying Table representation.","Custom metaclasses subclassing DeclarativeMeta can hook into model initialization while remaining DeclarativeMeta instances."],"goal":"verify sqlalchemy.orm.decl_api.DeclarativeMeta in pkg:pypi/sqlalchemy@2.0.51","kind":"HOW","packages":["pkg:pypi/sqlalchemy@2.0.51"],"schemaVersion":1,"symbols":["sqlalchemy.orm.decl_api.DeclarativeMeta"]},"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/sqlalchemy@2.0.51"],"schemaVersion":1,"subject":"pkg:pypi/sqlalchemy@2.0.51","symbols":["sqlalchemy.orm.decl_api.DeclarativeMeta"],"verifierAdapter":"python@1"}
sqlalchemy==2.0.51
{
"schemaVersion": 1,
"goal": "verify sqlalchemy.orm.decl_api.DeclarativeMeta in pkg:pypi/sqlalchemy@2.0.51",
"kind": "HOW",
"packages": [
"pkg:pypi/sqlalchemy@2.0.51"
],
"symbols": [
"sqlalchemy.orm.decl_api.DeclarativeMeta"
]
}
import sqlalchemy
from sqlalchemy.orm.decl_api import DeclarativeMeta
from sqlalchemy.orm import declarative_base, registry
from sqlalchemy import Column, Integer, String
from sqlalchemy.exc import InvalidRequestError
# 1. Base created by declarative_base() has DeclarativeMeta metaclass, as do its subclasses
Base = declarative_base()
assert isinstance(Base, DeclarativeMeta)
assert type(Base) is DeclarativeMeta
class User(Base):
__tablename__ = "users"
id = Column(Integer, primary_key=True)
name = Column(String(50))
assert isinstance(User, DeclarativeMeta)
assert type(User) is DeclarativeMeta
assert hasattr(User, "__table__")
assert User.__table__.name == "users"
# 2. Custom declarative base using metaclass=DeclarativeMeta directly with registry and __abstract__
reg = registry()
class CustomBase(metaclass=DeclarativeMeta):
__abstract__ = True
registry = reg
metadata = reg.metadata
class Item(CustomBase):
__tablename__ = "items"
id = Column(Integer, primary_key=True)
description = Column(String(100))
assert isinstance(Item, DeclarativeMeta)
assert Item.__table__.name == "items"
assert Item in reg.mappers or reg._class_registry.get("Item") is Item
assert "items" in reg.metadata.tables
# 3. Defining a class directly with metaclass=DeclarativeMeta without registry raises InvalidRequestError
try:
class InvalidClass(metaclass=DeclarativeMeta):
pass
assert False, "Expected InvalidRequestError when creating DeclarativeMeta class without registry"
except InvalidRequestError as exc:
assert "Declarative base class has no 'registry' attribute" in str(exc)
# 4. Classes instantiated through DeclarativeMeta initialize table metadata and map columns
assert "id" in User.__table__.c
assert "name" in User.__table__.c
assert User.__table__.primary_key.columns.contains_column(User.__table__.c.id)
# 5. Custom metaclass subclassing DeclarativeMeta can hook into model initialization
class CustomMeta(DeclarativeMeta):
def __init__(cls, classname, bases, dict_):
super().__init__(classname, bases, dict_)
cls._meta_custom_initialized = True
CustomBaseWithMeta = declarative_base(metaclass=CustomMeta)
class Product(CustomBaseWithMeta):
__tablename__ = "products"
id = Column(Integer, primary_key=True)
assert isinstance(Product, DeclarativeMeta)
assert isinstance(Product, CustomMeta)
assert getattr(Product, "_meta_custom_initialized", False) is True
print("CONTRACT PASS: sqlalchemy.orm.decl_api.DeclarativeMeta verified offline")
오리진 시더
익명