Przejdź do treści
Biblioteka skilli
Programowanie · Integracja z narzędziem

ruff

/ruff

Opisuje linter i formatter Pythona Ruff: konfigurację w pyproject.toml, wybór reguł, automatyczne poprawki oraz integrację z edytorami i CI.

Licencja
MIT
Ostatnia zmiana repozytorium
21.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
1
Przestarzałość

Brak sygnałów. Repozytorium zmienione 21.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Opisuje linter i formatter Pythona Ruff: konfigurację w pyproject.toml, wybór reguł, automatyczne poprawki oraz integrację z edytorami i CI.

Wyzwalacze z opisu

ruffruff checkruff formatpython lintingpyproject.toml lintingisort alternativeblack alternativeflake8 replacement
Oryginalny opis (EN)

Ruff Python linter and formatter. Covers configuration in pyproject.toml, rule selection, auto-fix, and integration with editors and CI. Use when configuring or troubleshooting Python code quality tooling. USE WHEN: user mentions "ruff", "ruff check", "ruff format", "python linting", "pyproject.toml linting", "isort alternative", "black alternative", "flake8 replacement", "python formatter" DO NOT USE FOR: ESLint/Prettier (JavaScript), mypy type checking

Jak działa

  1. Installation
  2. CLI Usage
  3. pyproject.toml Configuration
  4. Common Rule Sets
  5. Frequently Needed Rules
  6. Integration with pyproject.toml (full example for Python 3.10+ project)
  7. Pre-commit Integration
  8. CI/CD (GitHub Actions)
  9. Ruff vs Legacy Tools
  10. Quick Fixes Reference
Sekcje z nagłówków SKILL.md, w oryginale · 196 linii, 703 słów
Podgląd SKILL.md
---
name: ruff
description: |
  Ruff Python linter and formatter. Covers configuration in pyproject.toml,
  rule selection, auto-fix, and integration with editors and CI.
  Use when configuring or troubleshooting Python code quality tooling.

  USE WHEN: user mentions "ruff", "ruff check", "ruff format", "python linting",
  "pyproject.toml linting", "isort alternative", "black alternative",
  "flake8 replacement", "python formatter"

  DO NOT USE FOR: ESLint/Prettier (JavaScript), mypy type checking
allowed-tools: Read, Grep, Glob, Write, Edit
---
# Ruff: Python Linter & Formatter

## Installation

```bash
pip install ruff>=0.4.0
# or
uv add --dev ruff
```

## CLI Usage

```bash
# Lint
ruff check .                    # check all Python files
ruff check src/ tests/          # specific directories
ruff check --fix .              # auto-fix fixable issues
ruff check --fix --unsafe-fixes . # also apply unsafe fixes

# Format
ruff format .                   # format all files
ruff format --check .           # check only (no write)
ruff format --diff .            # show diff

# Combined (typical workflow)
ruff check --fix . && ruff format .

# Check single file
ruff check src/main.py
```

## pyproject.toml Configuration

```toml
[tool.ruff]
line-length = 100
target-version = "py310"
# Directories to exclude
exclude = [
    ".git", ".venv", "__pycache__", "dist", "build",
    "*.egg-info", ".mypy_cache",
]

[tool.ruff.lint]
# Rule sets to enable
select = [
    "E",   # pycodestyle errors
    "W",   # pycodestyle warnings
    "F",   # pyflakes (undefined names, unused imports)
    "I",   # isort (import ordering)
    "B",   # bugbear (common bugs)
    "C4",  # flake8-comprehensions
    "UP",  # pyupgrade (modern Python syntax)
    "S",   # bandit (security)
    "RUF", # Ruff-specific rules
]

# Rules to ignore globally
ignore = [
    "E501",  # line too long (handled by formatter)
    "S101",  # assert statements (fine in tests)
    "B008",  # do not perform function calls in default args
]

# Per-file ignores
[tool.ruff.lint.per-file-ignores]
"tests/**/*.py" = ["S101", "S105", "S106"]  # allow assert + hardcoded passwords in tests
"scripts/**/*.py" = ["S603", "S607"]         # allow subprocess in scripts

[tool.ruff.lint.isort]
known-first-party = ["driftwire", "mypackage"]
force-sort-within-sections = true

[tool.ruff.format]
quote-style = "double"
indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "auto"
```

## Common Rule Sets

| Set | Code | What It Checks |
|-----|------|----------------|
| pycodestyle | E, W | PEP 8 style (spacing, indentation) |
| pyflakes | F | Undefined/unused names, imports |
| isort | I | Import order and grouping |
| bugbear | B | Common Python bugs and anti-patterns |
| pyupgrade | UP | Upgrade to modern Python syntax |
| flake8-comprehensions | C4 | Unnecessary comprehensions |
| bandit | S | Security vulnerabilities |
| flake8-simplify | SIM | Code simplification |
| McCabe complexity | C90 | Function complexity |
| Ruff-specific | RUF | Ruff's own rules |

## Frequently Needed Rules

```toml
# Ignore specific rules
[tool.ruff.lint]
ignore = [
    "E501",   # line length (let formatter handle it)
    "S101",   # assert usage
    "S603",   # subprocess without shell=True
    "S607",   # subprocess partial executable path
    "B904",   # raise ... from err (too strict sometimes)
    "UP007",  # use X | Y instead of Optional[X] (if on Python <3.10)
]
```

## Integration with pyproject.toml (full example for Python 3.10+ project)

```toml
[project]
name = "driftwire"
version = "0.1.0"
requires-python = ">=3.10"

[project.optional-dependencies]
dev = ["ruff>=0.4.0", "pytest>=8.0.0"]

[tool.ruff]
line-length = 100
target-version = "py310"

[tool.ruff.lint]
select = ["E", "W", "F", "I", "B", "C4", "UP", "RUF"]
ignore = ["E501", "B008"]

[tool.ruff.lint.per-file-ignores]
"tests/**/*.py" = ["S101"]

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

## Pre-commit Integration

```yaml
# .pre-commit-config.yaml
repos:
  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.4.0
    hooks:
      - id: ruff
        args: [--fix]
      - id: ruff-format
```

## CI/CD (GitHub Actions)

```yaml
- name: Lint with ruff
  run: |
    pip install ruff
    ruff check . --output-format=github
    ruff format --check .
```

## Ruff vs Legacy Tools

| Old Tool | Ruff Equivalent | Notes |
|----------|----------------|-------|
| flake8 | `ruff check` | 10-100x faster |
| isort | `ruff check --select I` | Built-in |
| black | `ruff format` | Compatible formatting |
| bandit | `ruff check --select S` | Subset of bandit rules |
| pyupgrade | `ruff check --select UP` | Built-in |
| autoflake | `ruff check --select F401 --fix` | Remove unused imports |

## Quick Fixes Reference

```bash
# Remove unused imports
ruff check --select F401 --fix .

# Sort imports
ruff check --select I --fix .

# Upgrade old-style type hints (Optional[X] -> X | None)
ruff check --select UP007 --fix .

# All auto-fixable issues
ruff check --fix .
```

## noqa Comments

```python
import os  # noqa: F401          # ignore specific rule on this line
import sys  # noqa                # ignore all rules on this line

def f(x=datetime.now()):  # noqa: B008  # allow function call in default
    pass
```

Wersje

RepozytoriumWynikLicencja
Ta strona · claude-dev-suite/claude-dev-suite100MIT
TerminalSkills/skills100Apache-2.0

Migawka bazy z 28.10.2026 · wersja paczki ef5bf3c667f2 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100python-project-setup
    Konfiguruje projekty Python z pyproject.toml, lintingiem ruff, formatowaniem, sprawdzaniem typów mypy lub pyright, testami pytest i hookami pre-commit.
  • 90modern-python
    Konfiguruje nowoczesne projekty Python z uv, ruff, ty i pytest: pyproject.toml, linting, typowanie i pre-commit.
  • 100python-code-quality
    Dba o jakość kodu Python z ruff i ty: linting, formatowanie, sprawdzanie typów i styl kodu.
  • 95setting-up-python-libraries
    Zakłada profesjonalne biblioteki Pythona: pyproject.toml, uv, ruff, pytest, pre-commit i GitHub Actions.
  • 100python-conventions
    Wymusza konwencje narzędziowe Pythona dla uv, ty, Ruff, pytest i pyproject.toml przy pracy z plikami .py i konfiguracją projektu.
  • 95python-tooling
    Porządkuje narzędzia projektu Python: pyproject.toml, menedżery pakietów, środowiska, ruff, mypy i entry pointy.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.