Skip to content

Instantly share code, notes, and snippets.

@riandoza
Last active March 19, 2025 17:16
Show Gist options
  • Save riandoza/16cdb2c845630c51d16a74ec1f98bd00 to your computer and use it in GitHub Desktop.
Save riandoza/16cdb2c845630c51d16a74ec1f98bd00 to your computer and use it in GitHub Desktop.
My Ruff configuration
cache-dir = "~/.cache/ruff"
# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".mypy_cache",
".nox",
".pants.d",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
".vscode",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
".env",
"vendor",
"site-packages",
]
src = ["src", "test", "app"]
# Same as Black.
line-length = 120
indent-width = 4
# Assume Python 3.8
target-version = "py311"
include = ["*.py"]
extend-include = ["*.ipynb"]
ignore-init-module-imports = true
select = ["E4", "E7", "E9", "F", "B", "Q"]
[lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
ignore = ["E501", "F401", "F841", "D417", "SIM108", "UP009"]
extend-select = [
# pycodestyle
"E",
# Pyflakes
"F",
# pyupgrade
"UP",
# flake8-bugbear
"B",
# flake8-simplify
"SIM",
# isort
"I",
]
extend-safe-fixes = ["F601"]
extend-unsafe-fixes = ["UP034"]
# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = ["B", "F401"]
# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
[lint.per-file-ignores]
"__init__.py" = ["E402"]
"**/{tests,docs,tools,dist}/*" = ["E402"]
[format]
# Like Black, use double quotes for strings.
quote-style = "double"
indent-style = "space"
# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false
# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"
[isort]
order-by-type = true
known-local-folder = ["src"]
force-wrap-aliases = true
case-sensitive = true
combine-as-imports = true
single-line-exclusions = ["os", "json"]
[pep8-naming]
# Allow Pydantic's `@validator` decorator to trigger class method treatment.
classmethod-decorators = ["pydantic.validator"]
# extend-ignore-names = ["callMethod"]
[flake8-annotations]
allow-star-arg-any = true
# ignore-fully-untyped = true
mypy-init-return = true
suppress-dummy-args = true
suppress-none-returning = true
[flake8-bandit]
check-typed-exception = false
[flake8-bugbear]
# Allow default arguments like, e.g., `data: List[str] = fastapi.Query(None)`.
extend-immutable-calls = ["fastapi.Depends", "fastapi.Query"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment