Pular para o conteúdo
Skillpedia
Código em geral14 mil · #11334

modern-python-toolchain

O que ela faz

Esta skill configura ferramentas modernas para um projeto Python. Ela é para desenvolvedores que estão começando um novo projeto Python ou organizando um ambiente bagunçado.

Quando usar

  • ✓Quando você começar um novo projeto Python e quiser ferramentas rápidas e padronizadas.
  • ✓Quando quiser configurar a análise e a formatação de código Python.
  • ✓Quando precisar instalar ou configurar o uv para os seus pacotes Python.

Link da skill

https://github.com/XiaomiMiMo/MiMo-Code/blob/main/packages/cli/src/skill/builtin/.bundle/modern-python-toolchain/SKILL.md

Copie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.

Como usar

O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.

Mensagem pronta para colar

Use esta skill para me ajudar: https://github.com/XiaomiMiMo/MiMo-Code/blob/main/packages/cli/src/skill/builtin/.bundle/modern-python-toolchain/SKILL.md Leia o arquivo SKILL.md desse link e siga as instruções dele na minha tarefa.
Quer que a sua IA encontre skills como esta sozinha?Instale o MCP grátis do Skillpedia: uma linha, e ela pesquisa entre 15.000+ skills antes de cada tarefa.Instalar em 1 minuto →

Exemplo do que pedir para a IA

“Quero configurar um novo projeto Python com gerenciamento rápido de pacotes, análise de código e verificação de tipos.”

5 skills novas por semana. 1 minuto de leitura.

Como funciona

O agente instala o uv, fixa uma versão do Python e adiciona o ruff e o pyright com configurações que combinam com o projeto. Depois usa essas ferramentas para gerenciar os pacotes e verificar o código.

Conteúdo técnico (SKILL.md original)

Texto original do autor, em inglês, direto do GitHub.

Modern Python Toolchain

A guide for setting up Python projects with modern, fast tooling: uv (package/project manager), ruff (linter/formatter), and pyright (type checker).

Installing uv

uv is an extremely fast Python package and project manager. It replaces pip, pip-tools, pipx, pyenv, virtualenv, poetry, etc.

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

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

# Homebrew (macOS)
brew install uv

After installation, restart your shell or run source $HOME/.local/bin/env (the installer prints the exact command).

For detailed information: https://docs.astral.sh/uv/


uv basics

Python version

Pin a single Python minor version. The recommended default is 3.12 (broadest ecosystem support — PyTorch, CUDA images, downstream libraries). Python 3.14 is the latest stable; prefer it for new projects unless you depend on packages that haven't added 3.14 support yet.

# pyproject.toml
requires-python = "==3.12.*"

Install Python via uv (no system Python needed):

uv python install 3.12

Creating a new project

uv init                       # Create new project with pyproject.toml
uv init -p 3.12               # Specify Python version

Common commands

uv add requests               # Add dependency
uv add --dev ruff "pyright[nodejs]"  # Add dev dependencies
uv remove requests            # Remove dependency
uv sync                       # Install from lockfile
uv run COMMAND                # Run command in project environment
uv run script.py              # Run a script
uv run python -c "..."        # Run Python one-liner
uvx TOOL ARGS                 # Run a tool without installing it

Rules

  • Never use pip in uv projects — always uv add for packages.
  • Never run python script.py directly — always uv run script.py to ensure the correct environment. For one-liners use uv run python -c "...".
  • Don't manually manage environments with python -m venv or source .venv/bin/activate — uv handles this automatically.
  • uvx runs tools from PyPI by package name without installing them permanently.

Project types

For library projects (uv init --lib) or packaged apps (uv init --package), uv_build is used as the default build backend automatically:

[build-system]
# auto-generated by uv init; version bound tracks your installed uv (here: 0.11.28)
requires = ["uv_build>=0.11.28,<0.12.0"]
build-backend = "uv_build"

For application projects with an entry point:

[project.scripts]
myapp = "myapp.__main__:main"

If the project does not use src layout, just run uv run main.py.


ruff

Ruff is an extremely fast Python linter and code formatter. It replaces Flake8, isort, Black, pyupgrade, autoflake, and more.

For detailed information: https://docs.astral.sh/ruff/

When to use

Always use ruff for Python linting and formatting. Prefer uv run ruff when ruff is a dev dependency; otherwise fall back to uvx ruff.

Configuration

Add to pyproject.toml:

[tool.ruff.lint]
extend-select = [
    "UP",  # pyupgrade
    "I",   # isort
]

Do not enable the full E category or other formatter-conflicting rules (E1xx, E501, W191, Q, COM); ruff format owns layout.

Post-edit workflow

After modifying Python code, run both:

uv run ruff check --fix path/to/changed_file.py
uv run ruff format path/to/changed_file.py

Use --diff to preview changes without applying.


pyright

Pyright is a fast type checker for Python. Only use it when the project lists it as a dev dependency or explicitly uses type checking.

Install with the nodejs extra so Node.js is bundled automatically (no system node required):

uv add --dev "pyright[nodejs]"

Run type checking:

uv run pyright path/to/changed_file.py    # check specific files
uv run pyright src/                        # check all code

Usually only check the files you modified. For broad changes (base classes, shared types), check the full tree.


Coding style

Type annotations

Use modern Python 3.12+ syntax:

# Good — builtin generics, union syntax
def fetch(url: str, timeout: float = 30.0) -> list[dict[str, str | None]]:
    ...

# Bad — legacy typing imports
from typing import List, Dict, Optional
def fetch(url: str, tim
Perguntas frequentes

Qual versão do Python ela sugere?

A skill recomenda fixar uma versão secundária do Python e sugere a 3.12 como padrão amplo.

O uv substitui o pip?

A skill diz que o uv pode substituir ferramentas como pip, virtualenv e poetry no trabalho com projetos.

Para que servem o ruff e o pyright?

O ruff analisa e formata o código, e o pyright verifica os tipos.

Detalhes

Descrição original do autor

Modern Python project setup with uv, ruff, and pyright. Use when initializing a new Python project, configuring the Python environment, setting up linting/formatting, or when a project needs uv (the fast Python package manager). Trigger on: 'set up Python', 'new Python project', 'configure uv', 'install uv', 'ruff', 'pyright', 'Python linting', 'Python formatting', or when a task requires Python and no pyproject.toml exists yet.

repo: XiaomiMiMo/MiMo-Code

Popularidade

Estrelas no GitHub
14 mil
Posição no ranking
#11334
Licença
MIT
Atualizada em
02/11/2026

Essa skill é útil?

0

Entre para votar.

Comentários

  • …

Mais skills deste repositório

Skills parecidas