Master Code
On The Go

Learn. Practice. Build.

Home › Code Snippets › Python Snippets › Modern Toolchain

Python Snippet

Python uv & Ruff — The Modern Toolchain

Replace pip, Poetry, black, flake8, and isort with two blazing-fast Rust tools.

Last updated: October 2026

Quick answer: Install uv for dependency management and virtual environments — it replaces pip, pip-tools, pipx, Poetry, pyenv, and virtualenv. Install ruff for linting and formatting — it replaces flake8, black, isort, and pyupgrade. Both are written in Rust and run 10-100x faster than the tools they replace.

🎬 Interactive Live Demo

Click through the tabs to see common uv and ruff workflows with their real output.

💡 Each tab shows the real command and its actual output. Note the sub-second timings.

1

Install uv

Install uv with a single command:

# macOS / Linux
curl -LsSf https://astral.sh/uv/install.sh | sh

# Windows (PowerShell)
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"

# Or via pip (any platform)
pip install uv

# Verify
uv --version

uv is a single static binary. No Python required to install it — it manages Python versions itself.

2

Create a Project with uv

# New project
uv init myproject
cd myproject

# Or bootstrap in current folder
uv init

# Install a specific Python version (no pyenv needed)
uv python install 3.12

This creates:

  • pyproject.toml — project metadata and dependencies
  • .python-version — pinned Python version
  • README.md and a starter hello.py
3

Manage Dependencies

# Add packages (updates pyproject.toml + uv.lock + venv)
uv add fastapi uvicorn
uv add --dev pytest ruff

# Remove a package
uv remove fastapi

# Sync from lock file (like npm ci)
uv sync

# Run a script in the project's environment
uv run python app.py
uv run ruff check .

Replaces: pip install, pip-compile, poetry add, virtualenv, and manual source .venv/bin/activate.

4

Install Ruff

# Add as a dev dependency
uv add --dev ruff

# Or install standalone
curl -LsSf https://astral.sh/ruff/install.sh | sh

Ruff is a single binary that replaces six tools. It runs 10-100x faster than flake8 + black combined.

5

Configure Ruff in pyproject.toml

[tool.ruff]
line-length = 88
target-version = "py312"

[tool.ruff.lint]
# Enable: pycodestyle, pyflakes, isort, bugbear, pyupgrade, simplify
select = ["E", "F", "I", "B", "UP", "SIM"]

ignore = ["E501"]  # line too long (let formatter handle)

[tool.ruff.lint.per-file-ignores]
"tests/*" = ["S101"]  # allow assert in tests

[tool.ruff.format]
quote-style = "double"
indent-style = "space"

All configuration in one place. No separate .flake8, .isort.cfg, or .black files.

6

Run Linting and Formatting

# Check for issues
uv run ruff check .

# Check and auto-fix
uv run ruff check . --fix

# Format (drop-in black replacement)
uv run ruff format .

# Preview changes without writing
uv run ruff format . --diff

# Check everything in one pass
uv run ruff check . && uv run ruff format --check .

💡 Pre-commit hook: Add ruff to .pre-commit-config.yaml so formatting happens automatically before each commit.

🎯 The Toolchain It Replaces

Old Tool Replaced By Speedup
pip uv 10-100x
pip-tools uv 50x
poetry uv 10-50x
pyenv uv N/A
virtualenv uv 10-100x
flake8 ruff 50-100x
black ruff format 30x
isort ruff 100x
pyupgrade ruff 100x

Nine tools replaced by two. Both are maintained by Astral.

⚠️ Common Mistakes

❓ Frequently Asked Questions

What is uv in Python?

uv is an extremely fast Python package installer and resolver written in Rust. It replaces pip, pip-tools, pipx, poetry, pyenv, and virtualenv in a single tool. It is 10-100x faster than pip.

What is Ruff?

Ruff is an extremely fast Python linter and formatter written in Rust. It replaces flake8, black, isort, pyupgrade, autoflake, and more. It runs 10-100x faster than the tools it replaces.

Should I switch from pip and Poetry to uv?

Yes, for most new projects. uv is faster, uses less disk space, and handles both dependency management and virtual environments. It is now the recommended tool by many Python teams.

Should I switch from black and flake8 to Ruff?

Yes. Ruff combines both tools with a single configuration in pyproject.toml. It is dramatically faster and produces equivalent or better results.

Is uv production-ready?

Yes. uv is used by many production teams and is actively maintained by Astral. It has been adopted widely in 2024-2026 as the standard Python toolchain.

🎯 You've Completed the Python Snippet Cluster!

You now have 5 Python snippets. Each one links to the others, creating a strong topical cluster for Python developers.

← All Python Snippets