pyproject.toml Configuration
ThePyprojectConfigFile manages the pyproject.toml file - the central configuration for Python projects.
Overview
Manages pyproject.toml with:- Project metadata (name, version, description, authors)
- Dependencies (runtime and dev)
- Build system configuration (uv)
- Tool configurations (ruff, ty, pytest, bandit, rumdl)
- CLI entry points
- Python version requirements
Inheritance
Inherits from:TomlConfigFile (which extends DictConfigFile)
What this means:
- TOML format using tomlkit (preserves formatting and comments)
- Subset validation (user can add, not remove)
- Intelligent merging of configurations
- Dependency normalization on dump
File Location
Path:pyproject.toml (project root)
Extension: .toml - TOML configuration file.
Configuration Sections
Project Metadata
Keywords
pyrig generates an emptykeywords list as a placeholder. You should fill this with 5-8 relevant search terms that help users discover your project on PyPI.
Best Practices:
- Use 5-8 keywords (optimal for discoverability)
- Include primary use cases and features
- Use hyphenated compound terms (e.g., “task-runner”, “cli-framework”)
- Mix broad terms (e.g., “automation”) with specific ones (e.g., “ci-cd”)
- Avoid redundancy with classifiers (don’t repeat “python”, “testing” if already in classifiers)
- Focus on what users would actually search for
PYPI_TOKEN to your repository secrets.
Example for a web framework:
CLI Entry Points
uv run my-app <command> or just my-app <command> after activating the project’s virtual environment.
Dependencies
dependencies: Required for package to run (read from existing pyproject.toml, normalized and sorted)dev: Only needed for development (testing, linting, etc.)- Each tool’s dev dependencies are auto-added individually (e.g., ruff, pytest, mkdocs). If you replace a tool, its deps are swapped automatically
Build System
Ruff (Linter & Formatter)
select = ["ALL"]: Maximum code quality enforcement- Minimal ignores: Only conflicts and practical exceptions
fixable = ["ALL"]: Auto-fix onruff check --fixS101in tests: Pytest requires assert statements- Google convention: Consistent docstring format
ty (Type Checker)
Pytest (Test Runner)
testpaths: Where to find tests--cov=my_app: Measure code coverage--cov-report=term-missing: Show uncovered lines--cov-fail-under=90: Require 90% coverage minimum
Bandit (Security Scanner)
- Security scanning for common vulnerabilities
- Allow assert in tests (required by pytest)
- Ignore dotfiles (e.g., .scratch.py)
rumdl (Markdown Linter)
Dynamic Configuration
Several values are determined automatically:Current directory name
Git repo owner from remote URL or
git config user.nameGit repo owner from remote URL or
git config user.nameAuto-detected from LICENSE file using spdx-matcher library
Existing value or
>=3.12 (default)Generated from
requires-python + OS Independent + Typing :: TypedEmpty list (user should fill with 5-8 search terms for PyPI)
Auto-generated from git remote (Homepage, Documentation, Source, Issues, Changelog)
Package name → pyrig CLI entry point
Package name (hyphens → underscores)
Dependency Management
Normalization
When generating and dumping, pyrig normalizes dependencies:- Removes version specifiers for comparison
- Merges user deps with tool dev deps (during config generation)
- Sorts and deduplicates
- Preserves user-specified versions
Standard Dev Dependencies
Pyrig automatically adds dev dependencies declared by each tool (viaTool.dev_dependencies()). If you replace a tool, its deps are swapped automatically. Override dev_dependencies() in your tool subclass to customize what dev dependencies are added for your project.
Usage
Automatic Creation
Adding Dependencies
Updating Configuration
Edit pyproject.toml manually, then:Best Practices
- Don’t remove pyrig settings: You can add, but don’t remove required configs
- Use uv for dependencies: Don’t manually edit dependency lists
- Keep coverage high: 90% minimum enforced by pytest
- Follow strict typing: ty strict mode catches bugs early
- Let ruff auto-fix: Run
uv run ruff check --fixbefore committing