From 2d470ee41805294614223f86eddf017115ce8eca Mon Sep 17 00:00:00 2001 From: jaakko Date: Tue, 14 Apr 2026 12:28:35 +0300 Subject: [PATCH] =?UTF-8?q?CodeBench:=20deprecated-patterns.md=20+=20inlin?= =?UTF-8?q?e=20deprecated-s=C3=A4=C3=A4nn=C3=B6t=20promptissa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lisätty SQLAlchemy 2.0, Pydantic v2, FastAPI ja Python deprecated → modern patterniparit. Uusimmat dokumentaatiot tarkistettu 2026-04-14. --- kipina-codebench/prompts/code.md | 8 +++++ .../prompts/deprecated-patterns.md | 31 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 kipina-codebench/prompts/deprecated-patterns.md diff --git a/kipina-codebench/prompts/code.md b/kipina-codebench/prompts/code.md index 1f2c7d2..521ea69 100644 --- a/kipina-codebench/prompts/code.md +++ b/kipina-codebench/prompts/code.md @@ -25,6 +25,14 @@ OUTPUT FORMAT — use these exact markers to separate files: DOCUMENTATION — every file must have a one-line module docstring. Classes get a one-line docstring. Keep it zensical: say what it IS, not what it does. No filler. +NEVER USE DEPRECATED PATTERNS: +- ✗ declarative_base() → ✓ class Base(DeclarativeBase): pass +- ✗ Column(Type) → ✓ Mapped[type] = mapped_column(Type) +- ✗ class Config: orm_mode = True → ✓ model_config = ConfigDict(from_attributes=True) +- ✗ .dict() → ✓ .model_dump() +- ✗ Optional[str] → ✓ str | None +- ✗ session.query(Model).all() → ✓ session.execute(select(Model)).scalars().all() + RULES: - Follow the REFERENCE IMPLEMENTATION patterns exactly - SQLAlchemy 2.0: DeclarativeBase + Mapped + mapped_column (not Column()) diff --git a/kipina-codebench/prompts/deprecated-patterns.md b/kipina-codebench/prompts/deprecated-patterns.md new file mode 100644 index 0000000..c9694a9 --- /dev/null +++ b/kipina-codebench/prompts/deprecated-patterns.md @@ -0,0 +1,31 @@ +DEPRECATED PATTERNS — do NOT generate these. Use the modern alternative. + +SQLAlchemy: + ✗ from sqlalchemy.ext.declarative import declarative_base → ✓ from sqlalchemy.orm import DeclarativeBase + ✗ Base = declarative_base() → ✓ class Base(DeclarativeBase): pass + ✗ Column(Integer, primary_key=True) → ✓ Mapped[int] = mapped_column(primary_key=True) + ✗ Column(String(255)) → ✓ Mapped[str] = mapped_column(String(255)) + ✗ session.query(User).filter_by(name="x").all() → ✓ session.execute(select(User).filter_by(name="x")).scalars().all() + ✗ session.query(User).get(5) → ✓ session.get(User, 5) + ✗ MetaData(bind=engine) → ✓ metadata.create_all(engine) + +Pydantic: + ✗ class Config: orm_mode = True → ✓ model_config = ConfigDict(from_attributes=True) + ✗ .dict() → ✓ .model_dump() + ✗ .json() → ✓ .model_dump_json() + ✗ parse_obj() → ✓ model_validate() + ✗ @validator → ✓ @field_validator + ✗ @root_validator → ✓ @model_validator + ✗ Optional[str] (auto-None in v1) → ✓ str | None = None (explicit default in v2) + ✗ ConstrainedInt → ✓ Annotated[int, Field(ge=0)] + +FastAPI: + ✗ status_code=201 → ✓ status_code=status.HTTP_201_CREATED (readable) + ✗ Manual exception strings → ✓ HTTPException(status_code=404, detail="Not found") + ✗ .dict() in handlers → ✓ .model_dump() (Pydantic v2) + +Python: + ✗ Optional[str] → ✓ str | None (PEP 604, Python 3.10+) + ✗ List[str] → ✓ list[str] (PEP 585, Python 3.9+) + ✗ Dict[str, int] → ✓ dict[str, int] + ✗ Tuple[int, ...] → ✓ tuple[int, ...]