🔧 Adopt Ruff for formatting (#679)
This commit is contained in:
parent
8d14232538
commit
7fdfee10a5
@ -13,23 +13,13 @@ repos:
|
|||||||
- --unsafe
|
- --unsafe
|
||||||
- id: end-of-file-fixer
|
- id: end-of-file-fixer
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
- repo: https://github.com/asottile/pyupgrade
|
- repo: https://github.com/charliermarsh/ruff-pre-commit
|
||||||
rev: v3.15.0
|
rev: v0.1.2
|
||||||
hooks:
|
|
||||||
- id: pyupgrade
|
|
||||||
args:
|
|
||||||
- --py3-plus
|
|
||||||
- --keep-runtime-typing
|
|
||||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
||||||
rev: v0.1.1
|
|
||||||
hooks:
|
hooks:
|
||||||
- id: ruff
|
- id: ruff
|
||||||
args:
|
args:
|
||||||
- --fix
|
- --fix
|
||||||
- repo: https://github.com/psf/black
|
- id: ruff-format
|
||||||
rev: 23.10.0
|
|
||||||
hooks:
|
|
||||||
- id: black
|
|
||||||
ci:
|
ci:
|
||||||
autofix_commit_msg: 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
|
autofix_commit_msg: 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
|
||||||
autoupdate_commit_msg: ⬆ [pre-commit.ci] pre-commit autoupdate
|
autoupdate_commit_msg: ⬆ [pre-commit.ci] pre-commit autoupdate
|
||||||
|
@ -38,6 +38,7 @@ sqlalchemy2-stubs = {version = "*", allow-prereleases = true}
|
|||||||
[tool.poetry.group.dev.dependencies]
|
[tool.poetry.group.dev.dependencies]
|
||||||
pytest = "^7.0.1"
|
pytest = "^7.0.1"
|
||||||
mypy = "0.971"
|
mypy = "0.971"
|
||||||
|
# Needed by the code generator using templates
|
||||||
black = "^22.10.0"
|
black = "^22.10.0"
|
||||||
mkdocs-material = "9.1.21"
|
mkdocs-material = "9.1.21"
|
||||||
pillow = "^9.3.0"
|
pillow = "^9.3.0"
|
||||||
@ -46,7 +47,7 @@ mdx-include = "^1.4.1"
|
|||||||
coverage = {extras = ["toml"], version = "^6.2"}
|
coverage = {extras = ["toml"], version = "^6.2"}
|
||||||
fastapi = "^0.68.1"
|
fastapi = "^0.68.1"
|
||||||
requests = "^2.26.0"
|
requests = "^2.26.0"
|
||||||
ruff = "^0.1.1"
|
ruff = "^0.1.2"
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["poetry-core"]
|
requires = ["poetry-core"]
|
||||||
@ -87,11 +88,13 @@ select = [
|
|||||||
"I", # isort
|
"I", # isort
|
||||||
"C", # flake8-comprehensions
|
"C", # flake8-comprehensions
|
||||||
"B", # flake8-bugbear
|
"B", # flake8-bugbear
|
||||||
|
"UP", # pyupgrade
|
||||||
]
|
]
|
||||||
ignore = [
|
ignore = [
|
||||||
"E501", # line too long, handled by black
|
"E501", # line too long, handled by black
|
||||||
"B008", # do not perform function calls in argument defaults
|
"B008", # do not perform function calls in argument defaults
|
||||||
"C901", # too complex
|
"C901", # too complex
|
||||||
|
"W191", # indentation contains tabs
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.ruff.per-file-ignores]
|
[tool.ruff.per-file-ignores]
|
||||||
@ -99,3 +102,7 @@ ignore = [
|
|||||||
|
|
||||||
[tool.ruff.isort]
|
[tool.ruff.isort]
|
||||||
known-third-party = ["sqlmodel", "sqlalchemy", "pydantic", "fastapi"]
|
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
|
||||||
|
@ -2,4 +2,4 @@
|
|||||||
set -x
|
set -x
|
||||||
|
|
||||||
ruff sqlmodel tests docs_src scripts --fix
|
ruff sqlmodel tests docs_src scripts --fix
|
||||||
black sqlmodel tests docs_src scripts
|
ruff format sqlmodel tests docs_src scripts
|
||||||
|
@ -5,4 +5,4 @@ set -x
|
|||||||
|
|
||||||
mypy sqlmodel
|
mypy sqlmodel
|
||||||
ruff sqlmodel tests docs_src scripts
|
ruff sqlmodel tests docs_src scripts
|
||||||
black sqlmodel tests docs_src --check
|
ruff format sqlmodel tests docs_src --check
|
||||||
|
@ -42,8 +42,7 @@ def coverage_run(*, module: str, cwd: Union[str, Path]) -> subprocess.CompletedP
|
|||||||
module,
|
module,
|
||||||
],
|
],
|
||||||
cwd=str(cwd),
|
cwd=str(cwd),
|
||||||
stdout=subprocess.PIPE,
|
capture_output=True,
|
||||||
stderr=subprocess.PIPE,
|
|
||||||
encoding="utf-8",
|
encoding="utf-8",
|
||||||
)
|
)
|
||||||
return result
|
return result
|
||||||
|
Loading…
x
Reference in New Issue
Block a user