CodeSampleX

Beispiel

fastapi 0.141.1: UploadFile

Verifiziertes Beispiel für pypi fastapi 0.141.1: UploadFile. Der Vertrag lief auf python 3.12 · linux alpine/x64 · docker und bestand.

sha256:cf2d0328c62fc1b71b532045cc7dae579eeba8d5e6e5f016f0fb73813ca0278e

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung linux 24 · ubuntu · glibc 2.39 x64 pip

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
python 3.12 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · python@1python:3.12-alpine@sha256:d09d15e60962…
2026-08-28

Fall

HOW
Ziel
verify fastapi.UploadFile in pkg:pypi/fastapi@0.141.1
Pakete
Symbole
  • fastapi.UploadFile
Erstellt
2026-08-28T04:18:01Z

Contract

  1. assert UploadFile initializes with file stream filename size and headers
  2. assert UploadFile async read returns binary payload data from underlying file
  3. assert UploadFile async seek repositions stream and enables partial reads
  4. assert UploadFile async write writes data to file stream and updates contents
  5. assert UploadFile async close closes underlying file stream without errors

Dateien

  • PROMPT.md
  • csx.json
  • pyproject.toml
  • requirements.txt
  • spec.json
  • test/contract.py

Quellartefakt herunterladen (tar.gz)

Quelltext

PROMPT.md
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 fastapi.UploadFile in pkg:pypi/fastapi@0.141.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:pypi/fastapi@0.141.1
Demonstrate these symbols/APIs:
  - fastapi.UploadFile

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.
csx.json
{"case":{"caseId":"case:sha256:ad1eb15b88d2d784e6d6250bb7f1734f76766e606926eced75db3855f02ab3dc","contract":["assert UploadFile initializes with file stream filename size and headers","assert UploadFile async read returns binary payload data from underlying file","assert UploadFile async seek repositions stream and enables partial reads","assert UploadFile async write writes data to file stream and updates contents","assert UploadFile async close closes underlying file stream without errors"],"goal":"verify fastapi.UploadFile in pkg:pypi/fastapi@0.141.1","kind":"HOW","packages":["pkg:pypi/fastapi@0.141.1"],"schemaVersion":1,"symbols":["fastapi.UploadFile"]},"contractCommand":["python","test/contract.py"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"pypi","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"pip","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/fastapi@0.141.1"],"schemaVersion":1,"subject":"pkg:pypi/fastapi@0.141.1","symbols":["fastapi.UploadFile"],"verifierAdapter":"python@1"}
pyproject.toml
[project]
name = "verify-fastapi-uploadfile"
version = "0.1.0"
dependencies = [
    "fastapi==0.141.1",
]
requirements.txt
annotated-doc==0.0.5
annotated-types==0.8.0
anyio==4.14.2
fastapi==0.141.1
idna==3.19
pydantic==2.13.4
pydantic-core==2.46.4
starlette==1.6.0
typing-extensions==4.16.0
typing-inspection==0.4.4
spec.json
{
  "schemaVersion": 1,
  "goal": "verify fastapi.UploadFile in pkg:pypi/fastapi@0.141.1",
  "kind": "HOW",
  "packages": [
    "pkg:pypi/fastapi@0.141.1"
  ],
  "symbols": [
    "fastapi.UploadFile"
  ]
}
test/contract.py
import asyncio
import io
from fastapi import UploadFile


def test_upload_file_init():
    payload = b"Hello, FastAPI UploadFile contract test."
    stream = io.BytesIO(payload)
    upload = UploadFile(
        file=stream,
        filename="contract_test.txt",
        size=len(payload),
        headers={"content-type": "text/plain"},
    )
    assert upload.filename == "contract_test.txt"
    assert upload.size == len(payload)
    assert upload.content_type == "text/plain"
    assert upload.headers.get("content-type") == "text/plain"


async def test_upload_file_async_operations():
    payload = b"Hello, FastAPI UploadFile contract test."
    stream = io.BytesIO(payload)
    upload = UploadFile(
        file=stream,
        filename="contract_test.txt",
        size=len(payload),
        headers={"content-type": "text/plain"},
    )

    # assert UploadFile async read returns binary payload data from underlying file
    content = await upload.read()
    assert content == payload

    # assert UploadFile async seek repositions stream and enables partial reads
    await upload.seek(7)
    partial = await upload.read(7)
    assert partial == b"FastAPI"

    # assert UploadFile async write writes data to file stream and updates contents
    await upload.seek(0)
    await upload.write(b"GREETINGS")
    await upload.seek(0)
    read_back = await upload.read(9)
    assert read_back == b"GREETINGS"

    # assert UploadFile async close closes underlying file stream without errors
    await upload.close()


def main():
    test_upload_file_init()
    asyncio.run(test_upload_file_async_operations())
    print("All contract assertions passed.")


if __name__ == "__main__":
    main()

Ursprungs-Seeder

anonym