]> git.ipfire.org Git - thirdparty/fastapi/sqlmodel.git/commitdiff
🔧 Adopt Ruff for formatting (#679)
authorSebastián Ramírez <tiangolo@gmail.com>
Thu, 26 Oct 2023 14:32:26 +0000 (18:32 +0400)
committerGitHub <noreply@github.com>
Thu, 26 Oct 2023 14:32:26 +0000 (18:32 +0400)
.pre-commit-config.yaml
pyproject.toml
scripts/format.sh
scripts/lint.sh
tests/conftest.py

index 022ef24a0ff2d6180d706d9ca9e0f3dd4c7750a1..61aaf714117ca982856506dc410b4a36b6e859d5 100644 (file)
@@ -13,23 +13,13 @@ repos:
         -   --unsafe
     -   id: end-of-file-fixer
     -   id: trailing-whitespace
--   repo: https://github.com/asottile/pyupgrade
-    rev: v3.15.0
-    hooks:
-    -   id: pyupgrade
-        args:
-        - --py3-plus
-        - --keep-runtime-typing
--   repo: https://github.com/astral-sh/ruff-pre-commit
-    rev: v0.1.1
+-   repo: https://github.com/charliermarsh/ruff-pre-commit
+    rev: v0.1.2
     hooks:
     -   id: ruff
         args:
         - --fix
--   repo: https://github.com/psf/black
-    rev: 23.10.0
-    hooks:
-    -   id: black
+    -   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
index 181064e4eaae9a9b0fbe48d207101928d6c8b3f7..20188513c16fbd8028749d8d1703b329547135c0 100644 (file)
@@ -38,6 +38,7 @@ sqlalchemy2-stubs = {version = "*", allow-prereleases = true}
 [tool.poetry.group.dev.dependencies]
 pytest = "^7.0.1"
 mypy = "0.971"
+# Needed by the code generator using templates
 black = "^22.10.0"
 mkdocs-material = "9.1.21"
 pillow = "^9.3.0"
@@ -46,7 +47,7 @@ mdx-include = "^1.4.1"
 coverage = {extras = ["toml"], version = "^6.2"}
 fastapi = "^0.68.1"
 requests = "^2.26.0"
-ruff = "^0.1.1"
+ruff = "^0.1.2"
 
 [build-system]
 requires = ["poetry-core"]
@@ -87,11 +88,13 @@ select = [
     "I",  # isort
     "C",  # flake8-comprehensions
     "B",  # flake8-bugbear
+    "UP", # pyupgrade
 ]
 ignore = [
     "E501",  # line too long, handled by black
     "B008",  # do not perform function calls in argument defaults
     "C901",  # too complex
+    "W191", # indentation contains tabs
 ]
 
 [tool.ruff.per-file-ignores]
@@ -99,3 +102,7 @@ ignore = [
 
 [tool.ruff.isort]
 known-third-party = ["sqlmodel", "sqlalchemy", "pydantic", "fastapi"]
+
+[tool.ruff.pyupgrade]
+# Preserve types, even if a file imports `from __future__ import annotations`.
+keep-runtime-typing = true
index b6aebd10d46eb10d653800fd6f8fed17ca9970dc..70c12e579d34a4483411ace36fba07304bf4d545 100755 (executable)
@@ -2,4 +2,4 @@
 set -x
 
 ruff sqlmodel tests docs_src scripts --fix
-black sqlmodel tests docs_src scripts
+ruff format sqlmodel tests docs_src scripts
index b328e3d9ac19105c69a171076d117cfc2897160b..f66882239f04ad7353def9b765c425a536526b5c 100755 (executable)
@@ -5,4 +5,4 @@ set -x
 
 mypy sqlmodel
 ruff sqlmodel tests docs_src scripts
-black sqlmodel tests docs_src --check
+ruff format sqlmodel tests docs_src --check
index cd66420c883dfd5ee961500fb8d328e2c5c39157..2b8e5fc29e1c8a92371fd11ddc610a3131bd213b 100644 (file)
@@ -42,8 +42,7 @@ def coverage_run(*, module: str, cwd: Union[str, Path]) -> subprocess.CompletedP
             module,
         ],
         cwd=str(cwd),
-        stdout=subprocess.PIPE,
-        stderr=subprocess.PIPE,
+        capture_output=True,
         encoding="utf-8",
     )
     return result