diff --git a/.flake8 b/.flake8 deleted file mode 100644 index f2ee178..0000000 --- a/.flake8 +++ /dev/null @@ -1,4 +0,0 @@ -[flake8] -max-line-length = 88 -extend-ignore = E203 -exclude = **/migrations/* diff --git a/.isort.cfg b/.isort.cfg deleted file mode 100644 index 95d98f5..0000000 --- a/.isort.cfg +++ /dev/null @@ -1,7 +0,0 @@ -[settings] -profile=black -line_length=88 -known_first_party=hhub -known_third_party=django,pytest -skip=migrations -include_trailing_comma=true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3ca50df..374d02d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,4 @@ repos: - - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.3.0 hooks: @@ -11,22 +10,11 @@ repos: - id: name-tests-test - id: requirements-txt-fixer - id: trailing-whitespace - -- repo: https://github.com/python/black - rev: "22.6.0" +- repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.1.4 hooks: - - id: black - language_version: python3.9 - -- repo: https://github.com/pycqa/isort - rev: 5.11.5 - hooks: - - id: isort - name: isort (python) - -- repo: https://github.com/pycqa/flake8 - rev: 4.0.1 - hooks: - - id: flake8 - language_version: "python3" - exclude: migrations + # Run the linter. + - id: ruff + # Run the formatter. + - id: ruff-format diff --git a/README.md b/README.md index 4f97d2b..8836251 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # hhub [![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv) +[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) ![Github CI](https://github.com/gbdev/homebrewhub/actions/workflows/ci.yaml/badge.svg) This repository provides the source code of the [Homebrew Hub backend](https://hh3.gbdev.io/api), which powers [Homebrew Hub](https://hh.gbdev.io), the largest digital collection of Game Boy and Game Boy Color homebrews, playable natively in your browser. diff --git a/pyproject.toml b/pyproject.toml index e3d71f3..3d5c0e4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,4 +1,78 @@ -[tool.black] +[tool.ruff] +# Exclude a variety of commonly ignored directories. +exclude = [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".git-rewrite", + ".hg", + ".ipynb_checkpoints", + ".mypy_cache", + ".nox", + ".pants.d", + ".pyenv", + ".pytest_cache", + ".pytype", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + ".vscode", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "site-packages", + "venv", +] + +# Same as Black. line-length = 88 -target-version = ['py39'] -exclude = '(\.git|env|database|database-gba|_build|build|dist|.*\/migrations\/.*)' +indent-width = 4 + +# Assume Python 3.12 +target-version = "py312" + +[tool.ruff.lint] +# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. +# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or +# McCabe complexity (`C901`) by default. +select = ["E4", "E7", "E9", "F"] +ignore = [] + +# Allow fix for all enabled rules (when `--fix`) is provided. +fixable = ["ALL"] +unfixable = [] + +# Allow unused variables when underscore-prefixed. +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" + +[tool.ruff.format] +# Like Black, use double quotes for strings. +quote-style = "double" + +# Like Black, indent with spaces, rather than tabs. +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" + +# Enable auto-formatting of code examples in docstrings. Markdown, +# reStructuredText code/literal blocks and doctests are all supported. +# +# This is currently disabled by default, but it is planned for this +# to be opt-out in the future. +docstring-code-format = false + +# Set the line length limit used when formatting code snippets in +# docstrings. +# +# This only has an effect when the `docstring-code-format` setting is +# enabled. +docstring-code-line-length = "dynamic"