diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..984c6ca --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,25 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +default_language_version: + python: python3.10 +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-added-large-files + - id: check-toml + - id: check-yaml + args: + - --unsafe + - id: end-of-file-fixer + - id: trailing-whitespace +- repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.2.2 + hooks: + - id: ruff + args: + - --fix + - id: ruff-format +ci: + autofix_commit_msg: 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks + autoupdate_commit_msg: ⬆ [pre-commit.ci] pre-commit autoupdate diff --git a/src/backend/.flake8 b/src/backend/.flake8 deleted file mode 100644 index 710dc9c..0000000 --- a/src/backend/.flake8 +++ /dev/null @@ -1,3 +0,0 @@ -[flake8] -max-line-length = 88 -exclude = .git,__pycache__,__init__.py,.mypy_cache,.pytest_cache diff --git a/src/backend/mypy.ini b/src/backend/mypy.ini deleted file mode 100644 index 9813db0..0000000 --- a/src/backend/mypy.ini +++ /dev/null @@ -1,4 +0,0 @@ -[mypy] -plugins = pydantic.mypy, sqlmypy -ignore_missing_imports = True -disallow_untyped_defs = True diff --git a/src/backend/pyproject.toml b/src/backend/pyproject.toml index e151784..7e10822 100644 --- a/src/backend/pyproject.toml +++ b/src/backend/pyproject.toml @@ -27,13 +27,11 @@ sqlmodel = "^0.0.16" bcrypt = "4.0.1" [tool.poetry.group.dev.dependencies] -mypy = "^1.7.0" -black = "^23.11.0" -isort = "^5.12.0" -autoflake = "^2.2.1" -flake8 = "^6.1.0" pytest = "^7.4.3" pytest-cov = "^4.1.0" +mypy = "^1.8.0" +ruff = "^0.2.2" +pre-commit = "^3.6.2" [tool.isort] multi_line_output = 3 @@ -43,3 +41,30 @@ line_length = 88 [build-system] requires = ["poetry>=0.12"] build-backend = "poetry.masonry.api" + +[tool.mypy] +strict = true + +[tool.ruff] +target-version = "py310" + +[tool.ruff.lint] +select = [ + "E", # pycodestyle errors + "W", # pycodestyle warnings + "F", # pyflakes + "I", # isort + "B", # flake8-bugbear + "C4", # flake8-comprehensions + "UP", # pyupgrade +] +ignore = [ + "E501", # line too long, handled by black + "B008", # do not perform function calls in argument defaults + "W191", # indentation contains tabs + "B904", # Allow raising exceptions without from e, for HTTPException +] + +[tool.ruff.lint.pyupgrade] +# Preserve types, even if a file imports `from __future__ import annotations`. +keep-runtime-typing = true