python

Structure Python projects with pyproject.toml, pytest, ruff, and mypy.

Updated Feb 21, 2024
One-click install
npx skills add https://github.com/zhongjis/nix-config --skill python-zhongjis
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: python
Source: https://github.com/zhongjis/nix-config/tree/main/modules/home-manager/features/ai-tools/common/skills/general/python
Command: npx skills add https://github.com/zhongjis/nix-config --skill python-zhongjis

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pytest, ruff, mypy, uv, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill streamlines Python development by providing a robust structure for projects, automating testing with pytest, and enforcing code quality through ruff and mypy.

Core Features & Use Cases

  • Project Scaffolding: Sets up a standard Python project structure with pyproject.toml.
  • Code Quality Enforcement: Integrates ruff for formatting and linting, and mypy for static type checking.
  • Automated Testing: Facilitates running tests with pytest, including fixtures and parametrization.
  • Use Case: When starting a new Python project, use this Skill to quickly set up a well-organized structure that includes testing and quality checks from the outset.

Quick Start

Use the python skill to set up a new project with pyproject.toml, src directory, and tests.

Frequently Asked Questions about python

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up a Python project structure with pyproject.toml?▼

To set up a Python project, configure pyproject.toml alongside a standard src directory and tests folder. This scaffolding establishes a well-organized structure integrating dependency management and execution via uv from the outset.

What is the best way to enforce Python code quality with ruff and mypy?▼

Enforcing Python code quality involves using ruff for automated formatting and linting, alongside mypy for strict static type checking. This combination ensures type-hinted code adheres to robust structural standards throughout development.

How do I run automated tests with pytest in a Python project?▼

Running automated tests with pytest involves executing test files within your project's tests directory. The setup facilitates standard pytest features including fixtures and parametrization to validate your type-hinted code.

Does this Python development workflow support dependency management with uv?▼

Yes, this Python development workflow fully supports uv for dependency management and command execution. It integrates uv directly into the pyproject.toml setup to streamline environment configuration and script running.

Why do I need type checking when writing type-hinted Python code?▼

Type checking is needed when writing type-hinted Python code to enforce static analysis via mypy. It catches potential type-related bugs early before execution, ensuring the structured project maintains strict code quality.