Skip to content

Commit 0c9787b

Browse files
committed
build: 🛠 Convert everything to use ruff and just
1 parent bf8529f commit 0c9787b

File tree

13 files changed

+83
-164
lines changed

13 files changed

+83
-164
lines changed

‎.flake8

Lines changed: 0 additions & 29 deletions
This file was deleted.

‎.github/workflows/flake8-mypy.yml renamed to ‎.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
run: |
1414
python -m pip install --upgrade poetry
1515
poetry install -E fastapi
16-
- name: Lint with flake8
16+
- name: Lint with ruff & mypy
1717
run: |
18-
poetry run flake8 pydantic_async_validation tests
18+
poetry run ruff check pydantic_async_validation tests
1919
poetry run mypy pydantic_async_validation

‎.pre-commit-config.yaml

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,11 @@ repos:
77
- id: check-merge-conflict
88
- id: check-docstring-first
99
- id: debug-statements
10-
- repo: https://github.com/PyCQA/flake8
11-
rev: 6.0.0
10+
- repo: https://github.com/astral-sh/ruff-pre-commit
11+
rev: v0.0.284
1212
hooks:
13-
- id: flake8
14-
args: ["--config=.flake8"]
15-
additional_dependencies:
16-
- flake8-builtins
17-
- flake8-annotations
18-
- flake8-commas
19-
- flake8-isort
20-
- flake8-print
21-
- flake8-debugger
22-
- repo: https://github.com/pycqa/isort
23-
rev: 5.12.0
24-
hooks:
25-
- id: isort
26-
- repo: https://github.com/asottile/pyupgrade
27-
rev: v3.9.0
28-
hooks:
29-
- id: pyupgrade
30-
args: ["--py38-plus"]
31-
- repo: https://github.com/asottile/add-trailing-comma
32-
rev: v3.0.0
33-
hooks:
34-
- id: add-trailing-comma
35-
args: ["--py36-plus"]
13+
- id: ruff
14+
args: [--fix, --exit-non-zero-on-fix]
3615
- repo: https://github.com/Lucas-C/pre-commit-hooks-safety
3716
rev: v1.3.1
3817
hooks:

‎build/Taskfile

Lines changed: 0 additions & 60 deletions
This file was deleted.

‎justfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
install-pre-commit:
2+
#!/usr/bin/env bash
3+
if ( which pre-commit > /dev/null 2>&1 )
4+
then
5+
pre-commit install --install-hooks
6+
else
7+
echo "-----------------------------------------------------------------"
8+
echo "pre-commit is not installed - cannot enable pre-commit hooks!"
9+
echo "Recommendation: Install pre-commit ('brew install pre-commit')."
10+
echo "-----------------------------------------------------------------"
11+
fi
12+
13+
install: install-pre-commit (poetry "install")
14+
15+
update: (poetry "install")
16+
17+
poetry *args:
18+
poetry {{args}}
19+
20+
test *args: (poetry "run" "pytest" "--cov=pydantic_async_validation" "--cov-report" "term-missing:skip-covered" args)
21+
22+
test-all: (poetry "run" "tox")
23+
24+
ruff *args: (poetry "run" "ruff" "check" "pydantic_async_validation" "tests" args)
25+
26+
mypy *args: (poetry "run" "mypy" "pydantic_async_validation" args)
27+
28+
lint: ruff mypy
29+
30+
publish: (poetry "publish" "--build")

‎pydantic_async_validation/fastapi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ def ensure_request_validation_errors() -> Generator[None, None, None]:
2828
try:
2929
yield
3030
except ValidationError as O_o:
31-
raise RequestValidationError(errors=O_o.errors())
31+
raise RequestValidationError(errors=O_o.errors()) from O_o

‎pydantic_async_validation/metaclasses.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import TYPE_CHECKING, Any, List, Optional, Tuple
22

3-
from pydantic._internal._model_construction import ModelMetaclass # noqa
3+
from pydantic._internal._model_construction import ModelMetaclass
44

55
from pydantic_async_validation.constants import (
66
ASYNC_FIELD_VALIDATOR_CONFIG_KEY,

‎pydantic_async_validation/utils.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def generic_field_validator_wrapper(
4949
args -= {'kwargs'}
5050

5151
if not args.issubset(all_field_validator_kwargs):
52-
raise PydanticUserError( # noqa
52+
raise PydanticUserError(
5353
f'Invalid signature for validator {validator_func}: {sig}, '
5454
f'should be: '
5555
f'(self, value, field, config), '
@@ -62,31 +62,31 @@ def generic_field_validator_wrapper(
6262
self, value=value, field=field, config=config,
6363
)
6464
if args == set():
65-
return lambda self, value, field, config: validator_func(
65+
return lambda self, value, field, config: validator_func( # noqa: ARG005
6666
self,
6767
)
6868
if args == {'value'}:
69-
return lambda self, value, field, config: validator_func(
69+
return lambda self, value, field, config: validator_func( # noqa: ARG005
7070
self, value=value,
7171
)
7272
if args == {'field'}:
73-
return lambda self, value, field, config: validator_func(
73+
return lambda self, value, field, config: validator_func( # noqa: ARG005
7474
self, field=field,
7575
)
7676
if args == {'value', 'field'}:
77-
return lambda self, value, field, config: validator_func(
77+
return lambda self, value, field, config: validator_func( # noqa: ARG005
7878
self, value=value, field=field,
7979
)
8080
if args == {'config'}:
81-
return lambda self, value, field, config: validator_func(
81+
return lambda self, value, field, config: validator_func( # noqa: ARG005
8282
self, config=config,
8383
)
8484
if args == {'value', 'config'}:
85-
return lambda self, value, field, config: validator_func(
85+
return lambda self, value, field, config: validator_func( # noqa: ARG005
8686
self, value=value, config=config,
8787
)
8888
if args == {'field', 'config'}:
89-
return lambda self, value, field, config: validator_func(
89+
return lambda self, value, field, config: validator_func( # noqa: ARG005
9090
self, field=field, config=config,
9191
)
9292

@@ -139,7 +139,7 @@ def generic_model_validator_wrapper(
139139
args -= {'kwargs'}
140140

141141
if not args.issubset(all_model_validator_kwargs):
142-
raise PydanticUserError( # noqa
142+
raise PydanticUserError(
143143
f'Invalid signature for validator {validator_func}: {sig}, '
144144
f'should be: '
145145
f'(self, config), '
@@ -152,7 +152,7 @@ def generic_model_validator_wrapper(
152152
self, config=config,
153153
)
154154
if args == set():
155-
return lambda self, config: validator_func(
155+
return lambda self, config: validator_func( # noqa: ARG005
156156
self,
157157
)
158158

‎pydantic_async_validation/validators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
if TYPE_CHECKING: # pragma: no cover
1010
from inspect import Signature # noqa
1111

12-
from pydantic.main import BaseConfig # noqa
13-
from pydantic.types import ModelOrDc # noqa
12+
from pydantic.main import BaseConfig
13+
from pydantic.types import ModelOrDc
1414

1515
ValidatorCallable = Callable[
1616
[

‎pyproject.toml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,23 @@ fastapi = ["fastapi"]
1818

1919
[tool.poetry.group.dev.dependencies]
2020
pytest = ">=7.1.2,<8.0.0"
21-
isort = "^5.10.1"
22-
mypy = ">=0.971,<2.0"
23-
flake8 = ">=5.0.4,<7.0.0"
24-
flake8-builtins = ">=1.5.3,<3.0.0"
25-
flake8-annotations = ">=2.9.1,<4.0.0"
26-
flake8-commas = "^2.1.0"
27-
flake8-isort = ">=4.2,<7.0"
28-
flake8-print = "^5.0.0"
29-
flake8-debugger = "^4.1.2"
3021
pytest-cov = ">=3,<5"
31-
tox = ">=3.26,<5.0"
3222
pytest-asyncio = "^0.21.1"
23+
mypy = ">=0.971,<2.0"
24+
tox = ">=3.26,<5.0"
3325
httpx = "^0.24.1"
26+
ruff = "^0.0.284"
27+
28+
[tool.ruff]
29+
select = ["F","E","W","C","I","N","UP","ANN","S","B","A","COM","C4","T20","PT","ARG","TD","RUF"]
30+
line-length = 115
31+
target-version = "py38"
32+
ignore = ["A001","A002","A003","ANN101","ANN102","ANN401","C901","N8","B008","F405","F821"]
3433

35-
[tool.isort]
36-
multi_line_output = 3
37-
include_trailing_comma = true
38-
line_length = 115
34+
[tool.ruff.per-file-ignores]
35+
"__init__.py" = ["F401"]
36+
"conftest.py" = ["S101","ANN","F401"]
37+
"test_*.py" = ["S101","ANN","F401"]
3938

4039
[build-system]
4140
requires = ["poetry-core"]

0 commit comments

Comments
 (0)