CodeSampleX

Exemplo

pydantic-settings 2.14.2: pydantic_settings.SettingsConfigDict

Amostra verificada para pypi pydantic-settings 2.14.2: pydantic_settings.SettingsConfigDict. O contrato rodou em python 3.12 · linux alpine/x64 · docker e…

sha256:1807e23acdeed8b24c53e41a6eab635528d4b6ce7831a5ef502a991da54c10fd

Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu. Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas. MIT-0

Evidência de execução

O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.

Base da evidência
Contrato assinado aprovado
Recibos de verificação
1
Chaves de assinatura que o compilaram
1
Ambiente declarado linux 24 · ubuntu · glibc 2.39 x64 pip

Ambientes das execuções de verificação

Ambiente Contrato Etapas Execução
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-27

Caso

HOW
Objetivo
verify pydantic_settings.SettingsConfigDict in pkg:pypi/pydantic-settings@2.14.2
Pacotes
Símbolos
  • pydantic_settings.SettingsConfigDict
Criado
2026-08-27T19:32:23Z

Contrato

  1. SettingsConfigDict(env_prefix='APP_') prefixes environment variable lookup for settings fields
  2. SettingsConfigDict(env_nested_delimiter='__') parses nested model fields from delimited environment variables
  3. SettingsConfigDict(case_sensitive=True) requires exact case match for prefixed environment variables

Arquivos

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

Baixar o artefato de código-fonte (tar.gz)

Código-fonte

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 pydantic_settings.SettingsConfigDict in pkg:pypi/pydantic-settings@2.14.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:pypi/pydantic-settings@2.14.2
Demonstrate these symbols/APIs:
  - pydantic_settings.SettingsConfigDict

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:65ec818bbc2996c88557f293dbbd9a9f06fba70b23004d0d3ed172c054656f9d","contract":["SettingsConfigDict(env_prefix='APP_') prefixes environment variable lookup for settings fields","SettingsConfigDict(env_nested_delimiter='__') parses nested model fields from delimited environment variables","SettingsConfigDict(case_sensitive=True) requires exact case match for prefixed environment variables"],"goal":"verify pydantic_settings.SettingsConfigDict in pkg:pypi/pydantic-settings@2.14.2","kind":"HOW","packages":["pkg:pypi/pydantic-settings@2.14.2"],"schemaVersion":1,"symbols":["pydantic_settings.SettingsConfigDict"]},"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/pydantic-settings@2.14.2"],"schemaVersion":1,"subject":"pkg:pypi/pydantic-settings@2.14.2","symbols":["pydantic_settings.SettingsConfigDict"],"verifierAdapter":"python@1"}
requirements.txt
pydantic-settings==2.14.2
pydantic==2.13.4
pydantic-core==2.46.4
annotated-types==0.8.0
typing-extensions==4.15.0
typing-inspection==0.4.2
python-dotenv==1.2.2
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pydantic_settings.SettingsConfigDict in pkg:pypi/pydantic-settings@2.14.2",
  "kind": "HOW",
  "packages": [
    "pkg:pypi/pydantic-settings@2.14.2"
  ],
  "symbols": [
    "pydantic_settings.SettingsConfigDict"
  ]
}
test/contract.py
import os
from pydantic import BaseModel
from pydantic_settings import BaseSettings, SettingsConfigDict


class DatabaseConfig(BaseModel):
    host: str = "localhost"


class AppSettings(BaseSettings):
    model_config = SettingsConfigDict(
        env_prefix="APP_",
        env_nested_delimiter="__",
        case_sensitive=False,
    )
    host: str = "localhost"
    port: int = 8080
    database: DatabaseConfig = DatabaseConfig()


class StrictCaseSettings(BaseSettings):
    model_config = SettingsConfigDict(
        env_prefix="APP_",
        case_sensitive=True,
    )
    endpoint: str = "default_endpoint"


def main() -> None:
    tracked_keys = [
        "APP_HOST",
        "APP_PORT",
        "APP_DATABASE__HOST",
        "APP_ENDPOINT",
        "APP_endpoint",
        "HOST",
    ]
    saved_env = {k: os.environ.get(k) for k in tracked_keys}

    try:
        # Set environment variables
        os.environ["APP_HOST"] = "10.0.0.1"
        os.environ["APP_PORT"] = "9000"
        os.environ["APP_DATABASE__HOST"] = "db.internal"
        os.environ["HOST"] = "ignored.example.com"

        # 1. Test env_prefix and env_nested_delimiter
        settings = AppSettings()
        assert settings.host == "10.0.0.1", f"Expected '10.0.0.1', got '{settings.host}'"
        assert settings.port == 9000, f"Expected 9000, got {settings.port}"
        assert settings.database.host == "db.internal", f"Expected 'db.internal', got '{settings.database.host}'"

        # 2. Test case_sensitive=True
        os.environ["APP_ENDPOINT"] = "uppercase_val"
        strict_case = StrictCaseSettings()
        assert strict_case.endpoint == "default_endpoint", (
            f"Expected default 'default_endpoint' under case_sensitive=True, got '{strict_case.endpoint}'"
        )

        os.environ["APP_endpoint"] = "exact_val"
        strict_case_exact = StrictCaseSettings()
        assert strict_case_exact.endpoint == "exact_val", (
            f"Expected 'exact_val', got '{strict_case_exact.endpoint}'"
        )

    finally:
        for k, v in saved_env.items():
            if v is None:
                os.environ.pop(k, None)
            else:
                os.environ[k] = v


if __name__ == "__main__":
    main()

Seeder de origem

anônimo