Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit 0f7d713

Browse files
authored
chore: replace isort, black, pyupgrade and autoflake with ruff (#615)
1 parent 56b48ba commit 0f7d713

14 files changed

+111
-210
lines changed

.pre-commit-config.yaml

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,43 +9,17 @@ repos:
99
- id: mixed-line-ending
1010
args: ["--fix=lf"]
1111

12-
- repo: https://github.com/pycqa/isort
13-
rev: "6.0.0"
12+
- repo: https://github.com/astral-sh/ruff-pre-commit
13+
# Ruff version.
14+
rev: v0.12.1
1415
hooks:
15-
- id: isort
16-
args:
17-
[
18-
"--profile",
19-
"black",
20-
"--multi-line=3",
21-
"--trailing-comma",
22-
"--force-grid-wrap=0",
23-
"--use-parentheses",
24-
"--line-width=88",
25-
]
26-
27-
- repo: https://github.com/PyCQA/autoflake.git
28-
rev: v2.3.1
29-
hooks:
30-
- id: autoflake
31-
args:
32-
[
33-
"--in-place",
34-
"--remove-all-unused-imports",
35-
"--ignore-init-module-imports",
36-
]
37-
38-
- repo: https://github.com/psf/black
39-
rev: "24.4.0"
40-
hooks:
41-
- id: black
42-
args: [--line-length, "90"]
43-
44-
- repo: https://github.com/asottile/pyupgrade
45-
rev: v3.15.2
46-
hooks:
47-
- id: pyupgrade
48-
args: ["--py37-plus", "--keep-runtime-typing"]
16+
# Run the linter.
17+
- id: ruff
18+
types_or: [ python, pyi ]
19+
args: [ --fix ]
20+
# Run the formatter.
21+
- id: ruff-format
22+
types_or: [ python, pyi ]
4923

5024
- repo: https://github.com/commitizen-tools/commitizen
5125
rev: v3.22.0

poetry.lock

Lines changed: 30 additions & 142 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

postgrest/_async/request_builder.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,9 @@ async def execute(self) -> Optional[SingleAPIResponse[_ReturnT]]:
149149

150150

151151
# ignoring type checking as a workaround for https://github.com/python/mypy/issues/9319
152-
class AsyncFilterRequestBuilder(BaseFilterRequestBuilder[_ReturnT], AsyncQueryRequestBuilder[_ReturnT]): # type: ignore
152+
class AsyncFilterRequestBuilder(
153+
BaseFilterRequestBuilder[_ReturnT], AsyncQueryRequestBuilder[_ReturnT]
154+
): # type: ignore
153155
def __init__(
154156
self,
155157
session: AsyncClient,
@@ -189,7 +191,9 @@ def __init__(
189191

190192

191193
# ignoring type checking as a workaround for https://github.com/python/mypy/issues/9319
192-
class AsyncSelectRequestBuilder(BaseSelectRequestBuilder[_ReturnT], AsyncQueryRequestBuilder[_ReturnT]): # type: ignore
194+
class AsyncSelectRequestBuilder(
195+
BaseSelectRequestBuilder[_ReturnT], AsyncQueryRequestBuilder[_ReturnT]
196+
): # type: ignore
193197
def __init__(
194198
self,
195199
session: AsyncClient,

postgrest/_sync/request_builder.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,9 @@ def execute(self) -> Optional[SingleAPIResponse[_ReturnT]]:
149149

150150

151151
# ignoring type checking as a workaround for https://github.com/python/mypy/issues/9319
152-
class SyncFilterRequestBuilder(BaseFilterRequestBuilder[_ReturnT], SyncQueryRequestBuilder[_ReturnT]): # type: ignore
152+
class SyncFilterRequestBuilder(
153+
BaseFilterRequestBuilder[_ReturnT], SyncQueryRequestBuilder[_ReturnT]
154+
): # type: ignore
153155
def __init__(
154156
self,
155157
session: Client,
@@ -189,7 +191,9 @@ def __init__(
189191

190192

191193
# ignoring type checking as a workaround for https://github.com/python/mypy/issues/9319
192-
class SyncSelectRequestBuilder(BaseSelectRequestBuilder[_ReturnT], SyncQueryRequestBuilder[_ReturnT]): # type: ignore
194+
class SyncSelectRequestBuilder(
195+
BaseSelectRequestBuilder[_ReturnT], SyncQueryRequestBuilder[_ReturnT]
196+
): # type: ignore
193197
def __init__(
194198
self,
195199
session: Client,

postgrest/base_request_builder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ def limit(self: Self, size: int, *, foreign_table: Optional[str] = None) -> Self
609609
)
610610
return self
611611

612-
def offset(self: _FilterT, size: int) -> _FilterT:
612+
def offset(self: Self, size: int) -> Self:
613613
"""Set the starting row index returned by a query.
614614
Args:
615615
size: The number of the row to start at

pyproject.toml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,14 @@ deprecation = "^2.1.0"
2424
pydantic = ">=1.9,<3.0"
2525
strenum = {version = "^0.4.9", python = "<3.11"}
2626

27-
[tool.poetry.dev-dependencies]
27+
[tool.poetry.group.dev.dependencies]
2828
pytest = "^8.4.1"
29-
flake8 = "^7.3.0"
30-
black = "^25.1"
31-
isort = "^6.0.1"
3229
pre-commit = "^4.2.0"
3330
pytest-cov = "^6.2.1"
3431
pytest-depends = "^1.0.1"
3532
pytest-asyncio = "^1.0.0"
3633
unasync-cli = { git = "https://github.com/supabase-community/unasync-cli.git", branch = "main" }
34+
ruff = "^0.12.1"
3735

3836
[tool.poetry.group.docs]
3937
optional = true
@@ -42,6 +40,28 @@ optional = true
4240
sphinx = "^7.1.2"
4341
furo = ">=2023.9.10,<2025.0.0"
4442

43+
[tool.ruff.lint]
44+
select = [
45+
# pycodestyle
46+
"E",
47+
# Pyflakes
48+
"F",
49+
# pyupgrade
50+
"UP",
51+
# flake8-bugbear
52+
# "B",
53+
# flake8-simplify
54+
# "SIM",
55+
# isort
56+
"I",
57+
]
58+
ignore = ["F401", "F403", "F841", "E712", "E501", "E402", "UP006", "UP035"]
59+
# isort.required-imports = ["from __future__ import annotations"]
60+
61+
[tool.ruff.lint.pyupgrade]
62+
# Preserve types, even if a file imports `from __future__ import annotations`.
63+
keep-runtime-typing = true
64+
4565
[tool.pytest.ini_options]
4666
asyncio_mode = "auto"
4767
filterwarnings = [

0 commit comments

Comments
 (0)