Skip to content

Instantly share code, notes, and snippets.

@rubenhortas
Last active August 18, 2026 16:08
Show Gist options
  • Select an option

  • Save rubenhortas/b5006ce4cb208c8a96d44bbc9ee4c3df to your computer and use it in GitHub Desktop.

Select an option

Save rubenhortas/b5006ce4cb208c8a96d44bbc9ee4c3df to your computer and use it in GitHub Desktop.
Ruff settings for Python projects
# File: ruff.toml
#
# Description: Configuration for Ruff (linter/formatter).
#
# Usage Options:
# 1. PROJECT: Place in the root directory of your Python project to apply these settings locally to that specific project.
#
# 2. GLOBAL FALLBACK: Place in your global configuration directory to apply as a system-wide default for all projects:
# - Linux/macOS: ~/.config/ruff/ruff.toml
# - Windows: %USERPROFILE%\.config\ruff\ruff.toml
#
line-length = 120
[lint]
select = [
"E", # pycodestyle errors
"F", # Pyflakes
"I", # isort
"UP", # pyupgrade
"ANN", # flake8-annotations
"B", # flake8-bugbear
"S", # flake8-bandit (security)
"SIM", # flake8-simplify
"RUF", # Ruff-specific rules
"N", # PEP8 naming
"W", # Pycodestyle warnings (style issues)
"FLY", # Flynt – f-string conversion suggestions
"SLOT", # Flake8-slots – suggests use of __slots__ where appropriate
"PERF", # Perflint
]
extend-select = [
"TID", # Flake8-tidy-imports
"BLE", # Flake8-blind-except
"TRY", # Tryceratops
"PIE", # Flake8-pie
"PTH", # flake8-use-pathlib
"C4", # flake8-comprehensions
"INP", # Flake8-no-pep420
"TC", # Flake8-type-checking
"ARG", # Flake8-unused-arguments
"LOG", # flake8-logging
"G", # Flake8-logging-format
"TD", # Flake8-todos
"FIX", # Flake8-fixme
]
ignore = [
"E501", # Line too long (handled by formatter)
"BLE001", # Blind exception
"COM812", # Formatter conflict prevention
"ISC001", # Formatter conflict prevention
]
[lint.isort]
combine-as-imports = true
force-single-line = false
detect-same-package = true
[format]
quote-style = "double"
indent-style = "space"
# File: settings.toml
# Location: ~/.config/ruff/settings.toml (Linux/macOS) or %USERPROFILE%\.config\ruff\settings.toml (Windows)
# Description: Global fallback configuration for Ruff.
# This applies to all Python projects on your machine unless overridden by a project-specific config.
line-length = 120
[lint]
select = [
"E", # pycodestyle errors
"F", # Pyflakes
"I", # isort
"UP", # pyupgrade
"ANN", # flake8-annotations
"B", # flake8-bugbear
"S", # flake8-bandit (security)
"SIM", # flake8-simplify
"RUF", # Ruff-specific rules
"N", # PEP8 naming
"W", # Pycodestyle warnings (style issues)
"FLY", # Flynt – f-string conversion suggestions
"SLOT", # Flake8-slots – suggests use of __slots__ where appropriate
"PERF", # Perflint
]
extend-select = [
"TID", # Flake8-tidy-imports
"BLE", # Flake8-blind-except
"TRY", # Tryceratops
"PIE", # Flake8-pie
"PTH", # flake8-use-pathlib
"C4", # flake8-comprehensions
"INP", # Flake8-no-pep420
"TC", # Flake8-type-checking
"ARG", # Flake8-unused-arguments
"LOG", # flake8-logging
"G", # Flake8-logging-format
"TD", # Flake8-todos
"FIX", # Flake8-fixme
]
ignore = [
"E501", # Line too long (handled by formatter)
"BLE001", # Blind exception
"COM812", # Formatter conflict prevention
"ISC001", # Formatter conflict prevention
]
[format]
quote-style = "double"
indent-style = "space"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment