Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Kornia Kornia Pyproject Config

From Leeroopedia


Knowledge Sources
Domains Infrastructure, Build_System
Last Updated 2026-02-09 15:00 GMT

Overview

This is the central project configuration file (pyproject.toml) for the Kornia library, defining build system, package metadata, dependencies, linting rules, testing configuration, and code coverage settings.

Description

The pyproject.toml file at the repository root is the single source of configuration for the Kornia project. It uses hatchling as the build backend and defines the package metadata (name, description, authors, license, Python version requirements, classifiers). Core dependencies are kornia_rs>=0.1.9, packaging, and torch>=2.0.0. Optional dependency groups include dev (testing and development tools) and docs (Sphinx and documentation plugins). The file configures ruff for linting with extensive rule selection and per-file ignores, pytest with custom markers (grad, jit, nn, slow) and CLI options for device/dtype/optimizer testing, coverage with branch coverage and 84% minimum threshold, and codespell for spell checking. It also includes uv index configuration for PyTorch CUDA wheels, and ty (type checker) configuration with extensive rule suppressions for TorchScript compatibility.

Usage

This file is consumed by the build system (hatch/pip), linter (ruff), test runner (pytest), coverage tool, and other development tools. It is not imported by application code.

Code Reference

Source Location

Key Sections

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "kornia"
description = "Open Source Differentiable Computer Vision Library for PyTorch"
requires-python = ">=3.11"
license = { text = "Apache-2.0" }
dependencies = ["kornia_rs>=0.1.9", "packaging", "torch>=2.0.0"]

[tool.hatch.version]
path = "kornia/__init__.py"

[tool.ruff]
target-version = "py311"
line-length = 120

[tool.pytest.ini_options]
addopts = "--color=yes -v"
testpaths = ["tests"]

[tool.coverage.report]
fail_under = 84

I/O Contract

Package Metadata

Field Value
Name kornia
License Apache-2.0
Python >=3.11
Supported Python 3.11, 3.12, 3.13
Author Edgar Riba (edgar@kornia.org)

Core Dependencies

Package Version Constraint Purpose
kornia_rs >=0.1.9 Rust-based image I/O and utilities.
packaging (any) Version parsing utilities.
torch >=2.0.0 PyTorch deep learning framework.

Optional Dependencies

[dev] - Development/testing: coverage, diffusers, ivy, numpy, onnx, onnxruntime, pillow, pre-commit, pytest, ruff, setuptools, transformers.

[docs] - Documentation: furo, kornia_moons, matplotlib, opencv-python, sphinx, various sphinx extensions.

Tool Configuration

Ruff (Linter)

Setting Value Description
target-version py311 Minimum Python version for rules.
line-length 120 Maximum line length.
select AIR, ASYNC, B, BLE, C4, C90, D, E, F, ... Enabled rule categories.
pydocstyle.convention google Google-style docstrings.
pylint.max-args 30 Maximum function arguments.
pylint.max-branches 21 Maximum branch complexity.

Pytest

Setting Value Description
addopts --color=yes -v Default pytest options.
testpaths ["tests"] Test directory.
markers grad, jit, nn, slow Custom test markers.

Coverage

Setting Value Description
branch true Enable branch coverage.
source ["kornia/"] Source directory to measure.
fail_under 84 Minimum coverage percentage.

Usage Examples

# Install the package
# pip install .

# Install with dev dependencies
# pip install ".[dev]"

# Install with docs dependencies
# pip install ".[docs]"

# Run linter
# ruff check kornia/

# Run tests
# pytest tests/

# Run tests with specific device/dtype
# KORNIA_TEST_DEVICE=cuda KORNIA_TEST_DTYPE=float32 pytest

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment