python-linting-ruff

Python Linting with Ruff

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "python-linting-ruff" with this command: npx skills add franciscosanchezn/easyfactu-es/franciscosanchezn-easyfactu-es-python-linting-ruff

Python Linting with Ruff

Configure and use Ruff as the primary linter and formatter for Python projects. Ruff is an extremely fast Python linter and formatter written in Rust that replaces flake8, isort, pyupgrade, and many other tools.

When to Use This Skill

  • Setting up linting for new Python projects

  • Migrating from flake8/pylint/isort to Ruff

  • Configuring pyproject.toml for code quality

  • Fixing linting errors and warnings

  • Integrating linting into CI/CD pipelines

Standard Ruff Configuration

Add this configuration to pyproject.toml :

[tool.ruff] line-length = 120 target-version = "py311" lint.select = [ "A", # flake8-builtins "B", # flake8-bugbear "C4", # flake8-comprehensions "E", # pycodestyle - errors "F", # pyflakes "I", # isort "RUF", # ruff specific rules "S", # flake8-bandit (security) "UP", # pyupgrade "W", # pycodestyle - warnings ] lint.ignore = ["S603", "A005"] extend-exclude = ["src/generated/*"]

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

[tool.ruff.lint.isort] known-first-party = ["orchestrator"]

Rule Categories Explained

Rule Set Purpose Examples

A

Prevents shadowing Python builtins id , list , type as variable names

B

Catches likely bugs and design issues Mutable default arguments, except: without type

C4

Improves comprehension usage Unnecessary list() calls, better dict comprehensions

E

PEP 8 style errors Line length, whitespace issues

F

Pyflakes errors Undefined names, unused imports

I

Import sorting (isort replacement) Alphabetical, grouped imports

RUF

Ruff-specific rules Python-specific improvements

S

Security issues (bandit replacement) Hardcoded passwords, SQL injection

UP

Python upgrade suggestions Modern syntax, deprecated features

W

PEP 8 style warnings Trailing whitespace, blank lines

Common Ignored Rules

Rule Reason

S603

subprocess call without shell=True - often needed

A005

Module shadowing built-in - sometimes unavoidable

S101

Use of assert - allowed in tests only

Workflow Commands

Check for Issues

Check all files

uv run ruff check src/

Check specific file

uv run ruff check src/orchestrator/main.py

Show all issues with explanations

uv run ruff check src/ --explain

Auto-fix Issues

Fix auto-fixable issues

uv run ruff check src/ --fix

Fix and show what changed

uv run ruff check src/ --fix --diff

Fix unsafe fixes too (review changes!)

uv run ruff check src/ --fix --unsafe-fixes

Format Code

Format all files

uv run ruff format src/

Check formatting without changing

uv run ruff format src/ --check

Show formatting diff

uv run ruff format src/ --diff

Integration with Other Tools

Pyright (Type Checking)

[tool.pyright] reportMissingImports = true reportMissingTypeStubs = false pythonVersion = "3.12" venvPath = "." venv = ".venv"

Rope (Refactoring)

[tool.rope] py_version = "3.10" ignored_resources = [ ".pyc", "~", ".ropeproject", ".hg", ".svn", "_svn", ".git", ".tox", ".venv", "venv", "node_modules", ]

Codespell (Spell Checking)

[tool.codespell] count = true quiet-level = 3 ignore-words-list = "basf,BASF,NotIn" skip = "src/generated/**,package-lock.json,*.svg,CHANGELOG.md"

CI/CD Integration

GitHub Actions Workflow

name: Lint

on: [push, pull_request]

jobs: lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: astral-sh/setup-uv@v3 - run: uv sync - run: uv run ruff check src/ - run: uv run ruff format src/ --check

Pre-commit Hook

.pre-commit-config.yaml

repos:

Adding Ruff to a Project

Install Ruff as dev dependency

uv add ruff --dev

Add configuration to pyproject.toml (See Standard Ruff Configuration above)

Run initial check

uv run ruff check src/

Fix auto-fixable issues

uv run ruff check src/ --fix

Format code

uv run ruff format src/

Troubleshooting

Too Many Errors Initially

Start with fewer rules and add more over time:

[tool.ruff] lint.select = ["E", "F", "I"] # Start minimal

Conflicting with Black

Ruff format is compatible with Black. If using both, let Ruff format handle everything:

Remove black, use ruff format

uv remove black

Import Sorting Issues

Configure first-party packages:

[tool.ruff.lint.isort] known-first-party = ["orchestrator", "mypackage"]

Resources

  • Ruff Documentation

  • Ruff Rules Reference

  • Ruff Configuration

  • Ruff vs Other Linters

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

openclaw-version-monitor

监控 OpenClaw GitHub 版本更新,获取最新版本发布说明,翻译成中文, 并推送到 Telegram 和 Feishu。用于:(1) 定时检查版本更新 (2) 推送版本更新通知 (3) 生成中文版发布说明

Archived SourceRecently Updated
Coding

ask-claude

Delegate a task to Claude Code CLI and immediately report the result back in chat. Supports persistent sessions with full context memory. Safe execution: no data exfiltration, no external calls, file operations confined to workspace. Use when the user asks to run Claude, delegate a coding task, continue a previous Claude session, or any task benefiting from Claude Code's tools (file editing, code analysis, bash, etc.).

Archived SourceRecently Updated
Coding

ai-dating

This skill enables dating and matchmaking workflows. Use it when a user asks to make friends, find a partner, run matchmaking, or provide dating preferences/profile updates. The skill should execute `dating-cli` commands to complete profile setup, task creation/update, match checking, contact reveal, and review.

Archived SourceRecently Updated
Coding

clawhub-rate-limited-publisher

Queue and publish local skills to ClawHub with a strict 5-per-hour cap using the local clawhub CLI and host scheduler.

Archived SourceRecently Updated