Xpersona
P

python-dev

CLAWHUB · Unverified

Opinionated Python development setup with uv, ty, ruff, pytest, lefthook, and just. Use when creating a new Python project, writing or fixing pyproject.toml, or configuring linting, formatting, type checking, testing, git hooks, or CI. Skill: python-dev Owner: tenequm Summary: Opinionated Python development setup with uv, ty, ruff, pytest, lefthook, and just. Use when creating a new Python project, writing or fixing pyproject.toml, or configuring linting, formatting, type checking, testing, git hooks, or CI. Tags: latest:0.3.0 Version history: v0.3.0 | 2026-09-09T11:55:55.464Z | user Updated python-dev from 0.2.5 to 0.3.0. Changes: - modified CHANG

62
Rank
84
Safety
2.3k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 2.3K downloads reported by the source. Last updated 10/9/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s17bp3v1hm1dnkzey0c9tfh02183j0y5:python-dev
  1. Setup complexity is classified as HIGH. You must provision dedicated cloud infrastructure or an isolated VM. Do not run this directly on your local workstation.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-tenequm-python-dev/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

145,623 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

SKILL.md

---
name: python-dev
description: Opinionated Python development setup with uv, ty, ruff, pytest, lefthook, and just. Use when creating a new Python project, writing or fixing pyproject.toml, or configuring linting, formatting, type checking, testing, git hooks, or CI.
metadata:
  version: "0.3.0"
  categories: "development"
  topics: "python, uv, ruff, pytest, lefthook"
  upstream: "uv@0.12.11, ty@0.0.79, ruff@0.16.6, pytest@9.1.1, pytest-asyncio@1.4.0, lefthook@2.1.12"
  openclaw:
    homepage: https://github.com/tenequm/skills/tree/main/skills/python-dev
    emoji: "🐍"
---

# Python Development Setup

Opinionated, production-ready Python development stack. No choices to make - just use this.

## When to Use

- Starting a new Python project
- Modernizing an existing project (migrating from pip/poetry/mypy/black/flake8)
- Setting up linting, formatting, type checking, or testing
- Creating a Justfile for project commands
- Configuring pyproject.toml as the single source of truth

## The Stack

| Tool | Role | Replaces |
|------|------|----------|
| [uv](https://docs.astral.sh/uv/) 0.12+ | Package manager, Python versions, runner | pip, poetry, pyenv, virtualenv |
| [ty](https://docs.astral.sh/ty/) (beta) | Type checker (Astral, Rust) | mypy, pyright |
| [ruff](https://docs.astral.sh/ruff/) | Linter + formatter | flake8, black, isort, pyupgrade |
| [pytest](https://docs.pytest.org/) | Testing | unittest |
| [just](https://just.systems/) | Command runner | make |
| [lefthook](https://lefthook.dev/) 2.1+ | Git hooks (single binary, parallel) | pre-commit |

> **Note on ty**: ty is in beta (0.0.x) - no stable API, and inference can change between any
> two versions, so pin it. Pydantic is no longer a fair complaint: ty has shipped a dedicated
> library-support track for it since 0.0.57 (constructors, `model_config`, `BaseSettings`,
> `RootModel`, strict vs lax). Django and SQLAlchemy still have no such support and remain the
> likely source of false positives. Before swapping the whole checker, reach for
> `[tool.ty.analysis] replace-imports-with-any = ["sqlalchemy.**"]`, which silences one bad
> dependency instead of all of them. If you do need rock-solid checking today, swap `ty` for
> `pyright` and keep the rest of the stack unchanged.

## Quick Start: New Project

```bash
# 1. Create project with src layout (uv 0.12+ packages by default; --package is redundant)
uv init my-project
cd my-project

# 2. Pin Python version
uv python pin 3.13

# 3. Add dev dependencies
uv add --dev ruff ty pytest pytest-asyncio lefthook

# 4. Create Justfile and lefthook.yml (see templates below)
# 5. Configure pyproject.toml (see template below)
# 6. Install git hooks
uv run lefthook install

# 7. Run checks
just check
```

## pyproject.toml Template

This is the single config file. Copy this and adjust `[project]` fields.

```toml
[project]
name = "my-project"
version = "0.1.0"
description = "Project description"
readme = "README.md"
requires-python = ">=3.13"
lice

_meta.json

{
  "ownerId": "kn76gpsgjw5chv0xvzbzcb8cxn81x46r",
  "slug": "python-dev",
  "version": "0.3.0",
  "publishedAt": 1788954955464
}

references/justfile-reference.md

# Justfile Reference

`just` is a command runner for project-specific recipes. Replaces Makefile for non-build tasks.

**Manual**: https://just.systems/man/en/ | **GitHub**: https://github.com/casey/just

## Installation

```bash
brew install just       # macOS
cargo install just      # Via Rust
```

## Core Syntax

```just
# This comment shows in `just --list`
recipe-name:
    command1
    command2
```

Each line runs in a **separate shell** by default. Use `&&` to chain commands in one shell.

Suppress command echoing with `@`:

```just
@hello:
    echo "Hello"
# Output: Hello (not: echo "Hello" \n Hello)
```

## Variables

```just
# Simple assignment
version := "1.0.0"

# Backtick (evaluated at parse time)
git_hash := `git rev-parse --short HEAD`

# Environment variable with default
port := env("PORT", "8000")

# Use in recipes
build:
    @echo "Building {{version}} ({{git_hash}})"
```

## Parameters

```just
# Required
build target:
    @echo "Building {{target}}"

# With default
test suite="unit":
    @echo "Running {{suite}} tests"

# Variadic (one or more)
backup +FILES:
    scp {{FILES}} server:

# Variadic (zero or more)
commit MESSAGE *FLAGS:
    git commit {{FLAGS}} -m "{{MESSAGE}}"

# Exported as env var
serve $PORT="8000":
    python -m http.server $PORT
```

## Dependencies

```just
# Run before (prior dependency)
build:
    @echo "Building..."

test: build
    @echo "Testing..."

# Run after (subsequent dependency)
deploy: build && notify cleanup
    @echo "Deploying..."

# With arguments
default: (test "unit")

test suite:
    @echo "Running {{suite}} tests"
```

## Settings

```just
# Load .env file
set dotenv-load

# Export all variables as env vars
set export

# Suppress command echoing globally
set quiet

# Use bash
set shell := ["bash", "-uc"]
```

## Recipe Attributes

```just
# Group in `just --list`
[group('testing')]
test:
    uv run pytest

[group('quality')]
check:
    uv run ty check

# Require confirmation
[confirm("Reset database?")]
db-reset:
    dropdb myapp && createdb myapp

# Platform-specific
[linux]
install:
    sudo apt install libfoo-dev

[macos]
install:
    brew install libfoo

# Private (hidden from list)
[private]
_helper:
    echo "internal"

# Documentation override
[doc("Run type checking and linting")]
check:
    uv run ty check
    uv run ruff check
    uv run ruff format --check
```

## Shebang Recipes

For multi-line scripts in any language:

```just
analyze:
    #!/usr/bin/env python3
    import json
    with open("data.json") as f:
        data = json.load(f)
    print(f"Found {len(data)} records")

# With uv inline script deps
check-api:
    #!/usr/bin/env -S uv run --script
    # /// script
    # dependencies = ["httpx"]
    # ///
    import httpx
    r = httpx.get("https://api.example.com/health")
    print(f"Status: {r.status_code}")

# Bash with strict mode
deploy:
    #!/usr/bin/env -S bash -euo pipefail
    echo "Deploying..."
    git push origin main
```

Use `#!/usr/bin/env -S` with `-S

references/pytest-reference.md

# pytest Reference

Modern Python testing with pytest and key plugins.

**Docs**: https://docs.pytest.org/en/stable/ | **GitHub**: https://github.com/pytest-dev/pytest | **Tracked line**: pytest 9.x

> **Heads up (8 -> 9)**: pytest 9.0 adds native `[tool.pytest]` TOML configuration (alongside the still-supported `[tool.pytest.ini_options]`), built-in subtests, and stricter mode. It drops Python 3.9 and turns previously-deprecated behaviours into errors. pytest 8.4 already failed (instead of warn-skipping) async tests without an asyncio plugin and made `yield` in tests an error. pytest 9.0.3 fixes CVE-2025-71176 in temp-directory creation - upgrade if you are on 9.0.0/9.0.1/9.0.2.

## Installation

```bash
uv add --dev pytest pytest-asyncio pytest-cov pytest-mock
```

## Running Tests

```bash
uv run pytest                          # Run all tests
uv run pytest tests/test_models.py     # Specific file
uv run pytest tests/test_models.py::test_create  # Specific test
uv run pytest -x                       # Stop on first failure
uv run pytest -x --pdb                 # Drop into debugger on failure
uv run pytest -k "test_user"           # Match test names
uv run pytest -m "not slow"            # Skip marked tests
uv run pytest -v                       # Verbose output
uv run pytest --tb=short               # Short tracebacks
uv run pytest -n auto                  # Parallel (needs pytest-xdist)
```

## pyproject.toml Configuration

```toml
[tool.pytest.ini_options]
testpaths = ["tests"]
python_files = ["test_*.py"]
python_classes = ["Test*"]
python_functions = ["test_*"]
asyncio_mode = "auto"                  # pytest-asyncio: auto-detect async tests
# pytest 9.0 silently ignored --strict-markers/--strict-config given via addopts.
# The ini keys work on 9.0 and 9.1 alike; `strict` is the shorthand for all four
# strictness axes (config, markers, xfail, parametrization ids).
strict = true
addopts = ["-ra"]                      # Show summary for all non-passing tests

markers = [
    "slow: marks tests as slow (deselect with '-m \"not slow\"')",
    "integration: integration tests",
]

filterwarnings = [
    "error",                           # Treat warnings as errors
    "ignore::DeprecationWarning:some_lib",  # Selectively ignore
]
```

### Coverage Config

```toml
[tool.coverage.run]
source = ["src"]
branch = true
omit = ["*/tests/*", "*/__pycache__/*"]

[tool.coverage.report]
exclude_lines = [
    "pragma: no cover",
    "def __repr__",
    "raise NotImplementedError",
    "if __name__ == .__main__.:",
    "if TYPE_CHECKING:",
]
fail_under = 80
```

## Key Plugins

### pytest-asyncio (1.0+)

With `asyncio_mode = "auto"` in config, no decorators needed:

```python
# Async tests - just write async def
async def test_fetch_data():
    result = await my_async_function()
    assert result == expected

# Async fixtures
@pytest.fixture
async def async_client():
    async with SomeAsyncClient() as client:
        yield client

# For a custom event loop 

references/ruff-reference.md

# ruff Reference

Extremely fast Python linter and formatter, written in Rust. Replaces flake8, black, isort, pyupgrade.

**Docs**: https://docs.astral.sh/ruff/ | **GitHub**: https://github.com/astral-sh/ruff | **Tracked line**: ruff 0.16.x

> **Heads up**: ruff **0.16 is the big one** - the default rule set went from 59 to 413 rules, 18 opinionated `E`/`F` rules were dropped from that default set, and `ruff format` now formats Python blocks inside Markdown by default. A `select` list replaces the defaults, so prefer `extend-select`/`ignore`. 0.16 also adds line-level `ruff: ignore` comments and `--add-ignore`, and `format --check` gained the linter's `--output-format github`. Earlier: 0.14 moved the default target Python to 3.14; 0.15 shipped the 2026 formatter style guide and block-level suppressions. Pinning `target-version` in `pyproject.toml` keeps formatter output reproducible across upgrades.

## Usage

```bash
# Lint
uv run ruff check .              # Check for errors
uv run ruff check --fix .        # Auto-fix
uv run ruff check --diff .       # Show what would change

# Format
uv run ruff format .             # Format code
uv run ruff format --check .     # Check without changing

# Combined (lint + format in one go)
uv run ruff check --fix && uv run ruff format

# Info
ruff rule E501                   # Explain a rule
ruff rule --all                  # List all rules
```

## pyproject.toml Configuration

### Core Settings

```toml
[tool.ruff]
target-version = "py313"
line-length = 100
indent-width = 4

exclude = [
    ".git",
    ".venv",
    "__pycache__",
    "build",
    "dist",
    "*.egg-info",
]
```

### Lint Rules

```toml
[tool.ruff.lint]
# Ruff 0.16 enables 413 rules by default (up from 59), and dropped 18 opinionated
# E/F rules from that set. Writing a `select` list REPLACES the default set, so
# `select = ["E","F","I","UP"]` now yields a weaker linter than no config at all.
# Start from the defaults and narrow with `ignore`, or widen with `extend-select`.
ignore = [
    "E501",   # line too long - formatter handles it
    "UP007",  # X | Y unions - Optional[X] is more readable
    "UP006",  # type vs Type - both valid
]

# Allow auto-fix for all enabled rules
fixable = ["ALL"]
unfixable = []
```

### Extended Rule Sets (add when needed)

Use `extend-select`, not `select` - it adds to ruff 0.16's default set instead of replacing it.
Some of these are already on by default (a mutable-default arg raises `B006` with no config at
all), while `S`, `T20` and `ERA` are not.

```toml
[tool.ruff.lint]
extend-select = [
    "B",   # flake8-bugbear - common bugs and design problems (partly default in 0.16)
    "SIM", # flake8-simplify - simplification suggestions
    "RUF", # ruff-specific rules
    "S",   # flake8-bandit - security issues
    "PTH", # flake8-use-pathlib - prefer pathlib over os.path
    "T20", # flake8-print - no print() in production code
    "ERA", # eradicate - commented-out code detection
]
```

### Per-File Ignore

Sponsored

Ads related to python-dev and adjacent AI workflows.