Skip to content

Commit 8340862

Browse files
authored
bump pytest-asyncio and pytest, use ruff for formatting too, fix ordering of ormar in files (#1561)
* bump pytest-asyncio and pytest, use ruff for formatting too, fix ordering of ormar in files * add pytest options to fix coverage on python 3.10 * switch coverage to using greenlet to fix coverage on python 3.10
1 parent 900f9c4 commit 8340862

210 files changed

Lines changed: 429 additions & 420 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.coveragerc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
source = ormar, tests
33
omit = ./tests/test.db, *py.typed*
44
data_file = .coverage
5+
concurrency = greenlet
56

67
[report]
78
omit = ./tests/test.db, *py.typed*

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ lint:
3131
poetry run python -m ruff check . --fix
3232

3333
fmt:
34-
poetry run python -m black .
34+
poetry run python -m ruff format .
3535

3636
pre-commit: fmt lint type_check

benchmarks/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
import time
55

66
import nest_asyncio
7-
import ormar
87
import pytest
98
import pytest_asyncio
109
from tests.lifespan import init_tests
1110
from tests.settings import create_config
1211

12+
import ormar
13+
1314
base_ormar_config = create_config()
1415
nest_asyncio.apply()
1516
pytestmark = pytest.mark.asyncio

docs/contributing.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ git checkout -b my-new-feature-branch
3737
# make your changes...
3838

3939
# 4. Formatting and linting
40-
# ormar uses black for formatting, flake8 for linting and mypy for type hints check
40+
# ormar uses ruff for formatting and linting and mypy for type hints check
4141
# run all of the following as all those calls will be run on travis after every push
42-
black ormar tests
42+
ruff format ormar tests
43+
ruff check ormar tests
4344
flake8 ormar
4445
mypy ormar tests
4546

docs/models/index.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ They are being managed in the background and you do not have to create them on y
99

1010
To build an ormar model you simply need to inherit a `ormar.Model` class.
1111

12-
```Python hl_lines="9"
12+
```Python hl_lines="10"
1313
--8<-- "../docs_src/models/docs001.py"
1414
```
1515

@@ -23,7 +23,7 @@ Each table **has to** have a primary key column, which you specify by setting `p
2323

2424
Only one primary key column is allowed.
2525

26-
```Python hl_lines="15-17"
26+
```Python hl_lines="16-18"
2727
--8<-- "../docs_src/models/docs001.py"
2828
```
2929

@@ -60,7 +60,7 @@ you should get back exactly same value in `response`.).
6060
!!!warning
6161
pydantic fields have to be always **Optional** and it cannot be changed (otherwise db load validation would fail)
6262

63-
```Python hl_lines="19"
63+
```Python hl_lines="20"
6464
--8<-- "../docs_src/models/docs014.py"
6565
```
6666

@@ -139,7 +139,7 @@ If for whatever reason you prefer to change the name in the database but keep th
139139
with specifying `name` parameter during Field declaration
140140

141141
Here you have a sample model with changed names
142-
```Python hl_lines="18-21"
142+
```Python hl_lines="19-22"
143143
--8<-- "../docs_src/models/docs008.py"
144144
```
145145

@@ -149,7 +149,7 @@ Note that you can also change the ForeignKey column name
149149
```
150150

151151
But for now you cannot change the ManyToMany column names as they go through other Model anyway.
152-
```Python hl_lines="43"
152+
```Python hl_lines="44"
153153
--8<-- "../docs_src/models/docs010.py"
154154
```
155155

@@ -193,13 +193,13 @@ book = await Book.objects.first_or_404(name="123")
193193

194194
Note that for better IDE support and mypy checks you can provide type hints.
195195

196-
```Python hl_lines="15-17"
196+
```Python hl_lines="16-18"
197197
--8<-- "../docs_src/models/docs001.py"
198198
```
199199

200200
Note that type hints are **optional** so perfectly valid `ormar` code can look like this:
201201

202-
```Python hl_lines="15-17"
202+
```Python hl_lines="16-18"
203203
--8<-- "../docs_src/models/docs012.py"
204204
```
205205

@@ -222,7 +222,7 @@ One is `DatabaseConnection` instance created with your database url in [sqlalche
222222

223223
Created instance needs to be passed to every `Model` with `ormar_config` object `database` parameter.
224224

225-
```Python hl_lines="3 5 11"
225+
```Python hl_lines="4 6 12"
226226
--8<-- "../docs_src/models/docs001.py"
227227
```
228228

@@ -236,7 +236,7 @@ Second dependency is sqlalchemy `MetaData` instance.
236236

237237
Created instance needs to be passed to every `Model` with `ormar_config` object `metadata` parameter.
238238

239-
```Python hl_lines="2 6 12"
239+
```Python hl_lines="1 7 13"
240240
--8<-- "../docs_src/models/docs001.py"
241241
```
242242

@@ -251,7 +251,7 @@ To ease the config management, the `OrmarConfig` class provide `copy` method.
251251
So instead of providing the same parameters over and over again for all models
252252
you should create a base object and use its copy in all models.
253253

254-
```Python hl_lines="9-12 19 28"
254+
```Python hl_lines="10-13 20 29"
255255
--8<-- "../docs_src/models/docs013.py"
256256
```
257257

@@ -281,7 +281,7 @@ Right now only `IndexColumns`, `UniqueColumns` and `CheckColumns` constraints ar
281281

282282
You can set this parameter by providing `ormar_config` object `constraints` argument.
283283

284-
```Python hl_lines="13-16"
284+
```Python hl_lines="14-17"
285285
--8<-- "../docs_src/models/docs006.py"
286286
```
287287

@@ -294,7 +294,7 @@ You can set this parameter by providing `ormar_config` object `constraints` argu
294294

295295
You can set this parameter by providing `ormar_config` object `constraints` argument.
296296

297-
```Python hl_lines="13-16"
297+
```Python hl_lines="14-17"
298298
--8<-- "../docs_src/models/docs017.py"
299299
```
300300

@@ -307,7 +307,7 @@ You can set this parameter by providing `ormar_config` object `constraints` argu
307307

308308
You can set this parameter by providing `ormar_config` object `constraints` argument.
309309

310-
```Python hl_lines="15-20"
310+
```Python hl_lines="16-21"
311311
--8<-- "../docs_src/models/docs018.py"
312312
```
313313

@@ -334,7 +334,7 @@ model_config = ConfigDict(validate_assignment=True, ser_json_bytes="base64")
334334
```
335335

336336
So to overwrite setting or provide your own a sample model can look like following:
337-
```Python hl_lines="16"
337+
```Python hl_lines="17"
338338
--8<-- "../docs_src/models/docs016.py"
339339
```
340340

@@ -415,7 +415,7 @@ There are two ways to create and persist the `Model` instance in the database.
415415

416416
If you plan to modify the instance in the later execution of your program you can initiate your `Model` as a normal class and later await a `save()` call.
417417

418-
```Python hl_lines="29-30"
418+
```Python hl_lines="30-31"
419419
--8<-- "../docs_src/models/docs007.py"
420420
```
421421

@@ -425,7 +425,7 @@ For creating multiple objects at once a `bulk_create()` QuerySet's method is ava
425425

426426
Each model has a `QuerySet` initialised as `objects` parameter
427427

428-
```Python hl_lines="32"
428+
```Python hl_lines="33"
429429
--8<-- "../docs_src/models/docs007.py"
430430
```
431431

docs/models/internals.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ All `Model` classes inherit from `pydantic.BaseModel` so you can access all norm
88

99
For example to list pydantic model fields you can:
1010

11-
```Python hl_lines="20"
11+
```Python hl_lines="21"
1212
--8<-- "../docs_src/models/docs003.py"
1313
```
1414

@@ -24,7 +24,7 @@ To access auto created sqlalchemy table you can use `Model.ormar_config.table` p
2424

2525
For example to list table columns you can:
2626

27-
```Python hl_lines="24"
27+
```Python hl_lines="25"
2828
--8<-- "../docs_src/models/docs004.py"
2929
```
3030

@@ -40,7 +40,7 @@ To access ormar `Fields` you can use `Model.ormar_config.model_fields` parameter
4040

4141
For example to list table model fields you can:
4242

43-
```Python hl_lines="22"
43+
```Python hl_lines="23"
4444
--8<-- "../docs_src/models/docs005.py"
4545
```
4646

docs/mypy.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ To provide better errors check you should use mypy with pydantic [plugin][plugin
22

33
Please use notation introduced in version 0.4.0.
44

5-
```Python hl_lines="15-17"
5+
```Python hl_lines="16-18"
66
--8<-- "../docs_src/models/docs012.py"
77
```
88

99
Note that above example is not using the type hints, so further operations with mypy might fail, depending on the context.
1010

1111
Preferred notation should look liked this:
1212

13-
```Python hl_lines="15-17"
13+
```Python hl_lines="16-18"
1414
--8<-- "../docs_src/models/docs001.py"
1515
```
1616

docs/queries/create.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ assert album == album2
109109

110110
Updates the model, or in case there is no match in database creates a new one.
111111

112-
```Python hl_lines="43-51"
112+
```Python hl_lines="44-52"
113113
--8<-- "../docs_src/queries/docs003.py"
114114
```
115115

@@ -125,7 +125,7 @@ Allows you to create multiple objects at once.
125125

126126
A valid list of `Model` objects needs to be passed.
127127

128-
```python hl_lines="29-35"
128+
```python hl_lines="30-37"
129129
--8<-- "../docs_src/queries/docs004.py"
130130
```
131131

docs/queries/delete.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ If you do not provide this flag or a filter a `QueryDefinitionError` will be rai
2626

2727
Return number of rows deleted.
2828

29-
```python hl_lines="43-47"
29+
```python hl_lines="44-48"
3030
--8<-- "../docs_src/queries/docs005.py"
3131
```
3232

docs/queries/update.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ If you do not provide this flag or a filter a `QueryDefinitionError` will be rai
2929

3030
Return number of rows updated.
3131

32-
```Python hl_lines="45-47"
32+
```Python hl_lines="46-48"
3333
--8<-- "../docs_src/queries/docs002.py"
3434
```
3535

@@ -44,7 +44,7 @@ Return number of rows updated.
4444

4545
Updates the model, or in case there is no match in database creates a new one.
4646

47-
```Python hl_lines="43-51"
47+
```Python hl_lines="44-52"
4848
--8<-- "../docs_src/queries/docs003.py"
4949
```
5050

0 commit comments

Comments
 (0)