python

package
v0.1.156 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasUVRuntime

func HasUVRuntime() bool

HasUVRuntime checks if the uv Python package manager is available.

func RunPythonLint

func RunPythonLint(ctx context.Context, sourceDir string) (string, error)

RunPythonLint runs ruff check and returns the output.

func SetPythonRuntimeContext

func SetPythonRuntimeContext(runtimeContext *basev0.RuntimeContext) *basev0.RuntimeContext

SetPythonRuntimeContext determines the runtime context based on the requested context and available Python toolchain (uv).

Types

type PythonAgentSettings

type PythonAgentSettings struct {
	PythonVersion string `yaml:"python-version"`
	SourceDir     string `yaml:"source-dir"`
}

PythonAgentSettings holds settings common to all Python service agents.

func (*PythonAgentSettings) PythonSourceDir

func (s *PythonAgentSettings) PythonSourceDir() string

PythonSourceDir returns the configured source directory. Python convention: source is at the service root (not a subdirectory).

type TestEvent

type TestEvent struct {
	Action string // "pass" | "fail" | "skip"
	Test   string // test node id (e.g. "tests/test_admin.py::test_version")
}

TestEvent is a single per-test signal extracted from pytest's verbose output. Mirrors the go-side TestEvent shape so consumers can drive a uniform UI across both languages.

type TestOptions

type TestOptions struct {
	// OnEvent, when non-nil, is called for each per-test result line as
	// pytest emits it. Lets the agent forward live progress to the TUI
	// without waiting for the full summary at the end.
	OnEvent func(TestEvent)

	// CacheDir, when non-empty, persists the raw pytest output to
	// <CacheDir>/last-test.txt for post-mortem debugging.
	CacheDir string
}

TestOptions controls pytest invocation. Currently just a streaming hook — we may add Coverage / Verbose flags later mirroring the Go runner's TestOptions.

type TestSummary

type TestSummary struct {
	Run      int32
	Passed   int32
	Failed   int32
	Skipped  int32
	Coverage float32
	Failures []string
}

TestSummary holds the parsed results of a pytest run.

func ParsePytestVerbose

func ParsePytestVerbose(output string) *TestSummary

ParsePytestVerbose parses the verbose text output from pytest -v --tb=short.

func RunPythonTests

func RunPythonTests(ctx context.Context, sourceDir string, envVars []*resources.EnvironmentVariable, opts ...TestOptions) (*TestSummary, error)

RunPythonTests runs pytest and returns parsed results. With opts.OnEvent the per-test stream is also pushed to the callback in real time. With opts.CacheDir the full raw output is dumped to <CacheDir>/last-test.txt for post-mortem inspection.

func (*TestSummary) SummaryLine

func (s *TestSummary) SummaryLine() string

SummaryLine formats a one-line summary string.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL