Skip to content

Commit 7fdfee1

Browse files
authored
🔧 Adopt Ruff for formatting (#679)
1 parent 8d14232 commit 7fdfee1

File tree

5 files changed

+14
-18
lines changed

5 files changed

+14
-18
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,13 @@ repos:
1313
- --unsafe
1414
- id: end-of-file-fixer
1515
- id: trailing-whitespace
16-
- repo: https://github.com/asottile/pyupgrade
17-
rev: v3.15.0
18-
hooks:
19-
- id: pyupgrade
20-
args:
21-
- --py3-plus
22-
- --keep-runtime-typing
23-
- repo: https://github.com/astral-sh/ruff-pre-commit
24-
rev: v0.1.1
16+
- repo: https://github.com/charliermarsh/ruff-pre-commit
17+
rev: v0.1.2
2518
hooks:
2619
- id: ruff
2720
args:
2821
- --fix
29-
- repo: https://github.com/psf/black
30-
rev: 23.10.0
31-
hooks:
32-
- id: black
22+
- id: ruff-format
3323
ci:
3424
autofix_commit_msg: 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
3525
autoupdate_commit_msg: ⬆ [pre-commit.ci] pre-commit autoupdate

pyproject.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ sqlalchemy2-stubs = {version = "*", allow-prereleases = true}
3838
[tool.poetry.group.dev.dependencies]
3939
pytest = "^7.0.1"
4040
mypy = "0.971"
41+
# Needed by the code generator using templates
4142
black = "^22.10.0"
4243
mkdocs-material = "9.1.21"
4344
pillow = "^9.3.0"
@@ -46,7 +47,7 @@ mdx-include = "^1.4.1"
4647
coverage = {extras = ["toml"], version = "^6.2"}
4748
fastapi = "^0.68.1"
4849
requests = "^2.26.0"
49-
ruff = "^0.1.1"
50+
ruff = "^0.1.2"
5051

5152
[build-system]
5253
requires = ["poetry-core"]
@@ -87,15 +88,21 @@ select = [
8788
"I", # isort
8889
"C", # flake8-comprehensions
8990
"B", # flake8-bugbear
91+
"UP", # pyupgrade
9092
]
9193
ignore = [
9294
"E501", # line too long, handled by black
9395
"B008", # do not perform function calls in argument defaults
9496
"C901", # too complex
97+
"W191", # indentation contains tabs
9598
]
9699

97100
[tool.ruff.per-file-ignores]
98101
# "__init__.py" = ["F401"]
99102

100103
[tool.ruff.isort]
101104
known-third-party = ["sqlmodel", "sqlalchemy", "pydantic", "fastapi"]
105+
106+
[tool.ruff.pyupgrade]
107+
# Preserve types, even if a file imports `from __future__ import annotations`.
108+
keep-runtime-typing = true

scripts/format.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
set -x
33

44
ruff sqlmodel tests docs_src scripts --fix
5-
black sqlmodel tests docs_src scripts
5+
ruff format sqlmodel tests docs_src scripts

scripts/lint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ set -x
55

66
mypy sqlmodel
77
ruff sqlmodel tests docs_src scripts
8-
black sqlmodel tests docs_src --check
8+
ruff format sqlmodel tests docs_src --check

tests/conftest.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ def coverage_run(*, module: str, cwd: Union[str, Path]) -> subprocess.CompletedP
4242
module,
4343
],
4444
cwd=str(cwd),
45-
stdout=subprocess.PIPE,
46-
stderr=subprocess.PIPE,
45+
capture_output=True,
4746
encoding="utf-8",
4847
)
4948
return result

0 commit comments

Comments
 (0)