CodeSampleX

샘플

ruff 0.16.1

검증된 샘플 — pypi ruff 0.16.1. python 3.12 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: ruff.find_ruff_bin returns the path to the executable ruff binary

sha256:2f8326ad8222f1d437bd11fc630bf19ac2bf4cde500a80accfb4937ea7af7d69

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 python linux 24 · ubuntu · glibc 2.39 x64 python python pip

검증 실행 환경

환경 컨트랙트 단계 실행일
python 3.12 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · python@1
2026-08-20

케이스

HOW
목표
verify pkg:pypi/ruff@0.16.1
패키지
환경
python
생성일
2026-08-20T02:56:27Z

컨트랙트

  1. ruff.find_ruff_bin returns the path to the executable ruff binary
  2. ruff binary formats python source code via standard input

파일

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

소스 아티팩트 내려받기 (tar.gz)

소스

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 pkg:pypi/ruff@0.16.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:pypi/ruff@0.16.1

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:3cbc7b4db0673d3497018002cd3f86008c6c34e3aa8e7477b7b1e4e2eaf9c3a2","contract":["ruff.find_ruff_bin returns the path to the executable ruff binary","ruff binary formats python source code via standard input"],"goal":"verify pkg:pypi/ruff@0.16.1","kind":"HOW","packages":["pkg:pypi/ruff@0.16.1"],"schemaVersion":1},"contractCommand":["python","test/contract.py"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"pypi","language":"python","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"pip","runtime":"python","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/ruff@0.16.1"],"schemaVersion":1,"verifierAdapter":"python@1"}
requirements.txt
ruff==0.16.1
sample.py
"""Sample demonstrating finding and running the ruff binary using the ruff package."""

import os
import subprocess
from typing import Tuple
import ruff


def get_ruff_binary_path() -> str:
    """Return the absolute path to the ruff executable."""
    bin_path = ruff.find_ruff_bin()
    if not os.path.exists(bin_path):
        raise FileNotFoundError(f"ruff binary not found at {bin_path}")
    return bin_path


def format_source_code(source: str) -> str:
    """Format Python source code using the ruff executable via stdin."""
    bin_path = get_ruff_binary_path()
    result = subprocess.run(
        [bin_path, "format", "--stdin-filename", "example.py", "-"],
        input=source,
        capture_output=True,
        text=True,
        check=True,
    )
    return result.stdout


def check_source_code(source: str) -> Tuple[int, str]:
    """Run ruff linter check on Python source code via stdin."""
    bin_path = get_ruff_binary_path()
    result = subprocess.run(
        [bin_path, "check", "--stdin-filename", "example.py", "-"],
        input=source,
        capture_output=True,
        text=True,
    )
    return result.returncode, result.stdout


def main() -> None:
    bin_path = get_ruff_binary_path()
    print(f"Located ruff binary at: {bin_path}")

    unformatted = "x = [ 1,   2,  3]\n"
    formatted = format_source_code(unformatted)
    print("Formatted result:")
    print(formatted)


if __name__ == "__main__":
    main()
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:pypi/ruff@0.16.1",
  "kind": "HOW",
  "packages": [
    "pkg:pypi/ruff@0.16.1"
  ]
}
test/contract.py
"""Contract verification test for ruff."""

import os
import sys

# Ensure project root is on sys.path for local module imports
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

import ruff
from sample import format_source_code, get_ruff_binary_path


def test_find_ruff_bin() -> None:
    # Assertion 1: ruff.find_ruff_bin returns the path to the executable ruff binary
    bin_path = ruff.find_ruff_bin()
    assert isinstance(bin_path, str), f"Expected str, got {type(bin_path)}"
    assert os.path.exists(bin_path), f"ruff binary does not exist at {bin_path}"
    assert os.path.isabs(bin_path), f"ruff binary path is not absolute: {bin_path}"

    helper_path = get_ruff_binary_path()
    assert helper_path == bin_path


def test_format_source_code() -> None:
    # Assertion 2: ruff binary formats python source code via standard input
    unformatted = "items = [ 1,   2,   3 ]\n"
    expected = "items = [1, 2, 3]\n"
    formatted = format_source_code(unformatted)
    assert formatted == expected, f"Expected {expected!r}, got {formatted!r}"


def main() -> None:
    test_find_ruff_bin()
    test_format_source_code()
    print("Contract verification passed successfully.")


if __name__ == "__main__":
    main()

오리진 시더

익명