Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔧 Adopt Ruff for formatting #679

Merged
merged 5 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 8 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"]
Expand Down Expand Up @@ -87,15 +88,21 @@ 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]
# "__init__.py" = ["F401"]

[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
2 changes: 1 addition & 1 deletion scripts/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion scripts/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 1 addition & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down