Dagger
Search

python

Provides lint, test, format check, security scan, and Docker image build
functions for Python projects. Uses ruff for linting/formatting,
pytest for testing, and bandit for security scanning.

Installation

dagger install github.com/stuttgart-things/dagger/python@v0.86.0

Entrypoint

Return Type
Python
Example
dagger -m github.com/stuttgart-things/dagger/python@2dc146fd7c32848394ea4b5e5b7e66b920035233 call \
func (m *MyModule) Example() *dagger.Python  {
	return dag.
			Python()
}
@function
def example() -> dagger.Python:
	return (
		dag.python()
	)
@func()
example(): Python {
	return dag
		.python()
}

Types

Python 🔗

buildAndPushImage() 🔗

BuildAndPushImage builds and pushes a Docker image to a registry

Return Type
String !
Arguments
NameTypeDefault ValueDescription
srcDirectory !-Build context directory
imageRefString !-Full image reference (e.g., ghcr.io/org/image:tag)
tokenSecret !-Registry authentication token
dockerfileString "Dockerfile"No description provided
versionString "dev"No description provided
commitString "unknown"No description provided
dateString "unknown"No description provided
registryUrlString "ghcr.io"No description provided
usernameString ""No description provided
Example
dagger -m github.com/stuttgart-things/dagger/python@2dc146fd7c32848394ea4b5e5b7e66b920035233 call \
 build-and-push-image --src DIR_PATH --image-ref string --token env:MYSECRET
func (m *MyModule) Example(ctx context.Context, src *dagger.Directory, imageRef string, token *dagger.Secret) string  {
	return dag.
			Python().
			BuildAndPushImage(ctx, src, imageRef, token)
}
@function
async def example(src: dagger.Directory, image_ref: str, token: dagger.Secret) -> str:
	return await (
		dag.python()
		.build_and_push_image(src, image_ref, token)
	)
@func()
async example(src: Directory, imageRef: string, token: Secret): Promise<string> {
	return dag
		.python()
		.buildAndPushImage(src, imageRef, token)
}

buildImage() 🔗

BuildImage builds a Docker image from a Dockerfile

Return Type
Container !
Arguments
NameTypeDefault ValueDescription
srcDirectory !-Build context directory (must contain Dockerfile)
dockerfileString "Dockerfile"No description provided
versionString "dev"No description provided
commitString "unknown"No description provided
dateString "unknown"No description provided
Example
dagger -m github.com/stuttgart-things/dagger/python@2dc146fd7c32848394ea4b5e5b7e66b920035233 call \
 build-image --src DIR_PATH
func (m *MyModule) Example(src *dagger.Directory) *dagger.Container  {
	return dag.
			Python().
			BuildImage(src)
}
@function
def example(src: dagger.Directory) -> dagger.Container:
	return (
		dag.python()
		.build_image(src)
	)
@func()
example(src: Directory): Container {
	return dag
		.python()
		.buildImage(src)
}

formatCheck() 🔗

FormatCheck runs ruff format check (non-modifying) on Python source code

Return Type
String !
Arguments
NameTypeDefault ValueDescription
srcDirectory !-Python source directory
pythonVersionString "3.12-slim"No description provided
ruffVersionString "0.8.6"No description provided
pathsString "src/,tests/"Comma-separated list of paths to check
Example
dagger -m github.com/stuttgart-things/dagger/python@2dc146fd7c32848394ea4b5e5b7e66b920035233 call \
 format-check --src DIR_PATH
func (m *MyModule) Example(ctx context.Context, src *dagger.Directory) string  {
	return dag.
			Python().
			FormatCheck(ctx, src)
}
@function
async def example(src: dagger.Directory) -> str:
	return await (
		dag.python()
		.format_check(src)
	)
@func()
async example(src: Directory): Promise<string> {
	return dag
		.python()
		.formatCheck(src)
}

lint() 🔗

Lint runs ruff linter on Python source code

Return Type
String !
Arguments
NameTypeDefault ValueDescription
srcDirectory !-Python source directory
pythonVersionString "3.12-slim"No description provided
ruffVersionString "0.8.6"No description provided
pathsString "src/,tests/"Comma-separated list of paths to lint
Example
dagger -m github.com/stuttgart-things/dagger/python@2dc146fd7c32848394ea4b5e5b7e66b920035233 call \
 lint --src DIR_PATH
func (m *MyModule) Example(ctx context.Context, src *dagger.Directory) string  {
	return dag.
			Python().
			Lint(ctx, src)
}
@function
async def example(src: dagger.Directory) -> str:
	return await (
		dag.python()
		.lint(src)
	)
@func()
async example(src: Directory): Promise<string> {
	return dag
		.python()
		.lint(src)
}

securityScan() 🔗

SecurityScan runs bandit Python security scanner

Return Type
String !
Arguments
NameTypeDefault ValueDescription
srcDirectory !-Python source directory
pythonVersionString "3.12-slim"No description provided
banditVersionString "1.8.3"No description provided
scanPathString "src/"Path to scan
Example
dagger -m github.com/stuttgart-things/dagger/python@2dc146fd7c32848394ea4b5e5b7e66b920035233 call \
 security-scan --src DIR_PATH
func (m *MyModule) Example(ctx context.Context, src *dagger.Directory) string  {
	return dag.
			Python().
			SecurityScan(ctx, src)
}
@function
async def example(src: dagger.Directory) -> str:
	return await (
		dag.python()
		.security_scan(src)
	)
@func()
async example(src: Directory): Promise<string> {
	return dag
		.python()
		.securityScan(src)
}

test() 🔗

Test runs pytest on the Python source code

Return Type
String !
Arguments
NameTypeDefault ValueDescription
srcDirectory !-Python source directory
pythonVersionString "3.12-slim"No description provided
testPathString "tests/"Path to test directory
installExtraString ""Extra pip install specifier (e.g., ".[dev]" or "-r requirements-dev.txt")
Example
dagger -m github.com/stuttgart-things/dagger/python@2dc146fd7c32848394ea4b5e5b7e66b920035233 call \
 test --src DIR_PATH
func (m *MyModule) Example(ctx context.Context, src *dagger.Directory) string  {
	return dag.
			Python().
			Test(ctx, src)
}
@function
async def example(src: dagger.Directory) -> str:
	return await (
		dag.python()
		.test(src)
	)
@func()
async example(src: Directory): Promise<string> {
	return dag
		.python()
		.test(src)
}

testWithCoverage() 🔗

TestWithCoverage runs pytest with coverage reporting

Return Type
String !
Arguments
NameTypeDefault ValueDescription
srcDirectory !-Python source directory
pythonVersionString "3.12-slim"No description provided
testPathString "tests/"Path to test directory
installExtraString ""Extra pip install specifier
coveragePathString "src/"Source path for coverage measurement
Example
dagger -m github.com/stuttgart-things/dagger/python@2dc146fd7c32848394ea4b5e5b7e66b920035233 call \
 test-with-coverage --src DIR_PATH
func (m *MyModule) Example(ctx context.Context, src *dagger.Directory) string  {
	return dag.
			Python().
			TestWithCoverage(ctx, src)
}
@function
async def example(src: dagger.Directory) -> str:
	return await (
		dag.python()
		.test_with_coverage(src)
	)
@func()
async example(src: Directory): Promise<string> {
	return dag
		.python()
		.testWithCoverage(src)
}