diff --git a/.coveragerc b/.coveragerc index d2f27fd81..c54526d72 100644 --- a/.coveragerc +++ b/.coveragerc @@ -2,6 +2,7 @@ source = ormar, tests omit = ./tests/test.db, *py.typed* data_file = .coverage +concurrency = greenlet [report] omit = ./tests/test.db, *py.typed* diff --git a/Makefile b/Makefile index 5513ab725..c230e1068 100644 --- a/Makefile +++ b/Makefile @@ -31,6 +31,6 @@ lint: poetry run python -m ruff check . --fix fmt: - poetry run python -m black . + poetry run python -m ruff format . pre-commit: fmt lint type_check \ No newline at end of file diff --git a/benchmarks/conftest.py b/benchmarks/conftest.py index 3aaff36d8..54a344406 100644 --- a/benchmarks/conftest.py +++ b/benchmarks/conftest.py @@ -4,12 +4,13 @@ import time import nest_asyncio -import ormar import pytest import pytest_asyncio from tests.lifespan import init_tests from tests.settings import create_config +import ormar + base_ormar_config = create_config() nest_asyncio.apply() pytestmark = pytest.mark.asyncio diff --git a/docs/contributing.md b/docs/contributing.md index 2bf798212..e182d097d 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -37,9 +37,10 @@ git checkout -b my-new-feature-branch # make your changes... # 4. Formatting and linting -# ormar uses black for formatting, flake8 for linting and mypy for type hints check +# ormar uses ruff for formatting and linting and mypy for type hints check # run all of the following as all those calls will be run on travis after every push -black ormar tests +ruff format ormar tests +ruff check ormar tests flake8 ormar mypy ormar tests diff --git a/docs/models/index.md b/docs/models/index.md index 80268131d..7561bae07 100644 --- a/docs/models/index.md +++ b/docs/models/index.md @@ -9,7 +9,7 @@ They are being managed in the background and you do not have to create them on y To build an ormar model you simply need to inherit a `ormar.Model` class. -```Python hl_lines="9" +```Python hl_lines="10" --8<-- "../docs_src/models/docs001.py" ``` @@ -23,7 +23,7 @@ Each table **has to** have a primary key column, which you specify by setting `p Only one primary key column is allowed. -```Python hl_lines="15-17" +```Python hl_lines="16-18" --8<-- "../docs_src/models/docs001.py" ``` @@ -60,7 +60,7 @@ you should get back exactly same value in `response`.). !!!warning pydantic fields have to be always **Optional** and it cannot be changed (otherwise db load validation would fail) -```Python hl_lines="19" +```Python hl_lines="20" --8<-- "../docs_src/models/docs014.py" ``` @@ -139,7 +139,7 @@ If for whatever reason you prefer to change the name in the database but keep th with specifying `name` parameter during Field declaration Here you have a sample model with changed names -```Python hl_lines="18-21" +```Python hl_lines="19-22" --8<-- "../docs_src/models/docs008.py" ``` @@ -149,7 +149,7 @@ Note that you can also change the ForeignKey column name ``` But for now you cannot change the ManyToMany column names as they go through other Model anyway. -```Python hl_lines="43" +```Python hl_lines="44" --8<-- "../docs_src/models/docs010.py" ``` @@ -193,13 +193,13 @@ book = await Book.objects.first_or_404(name="123") Note that for better IDE support and mypy checks you can provide type hints. -```Python hl_lines="15-17" +```Python hl_lines="16-18" --8<-- "../docs_src/models/docs001.py" ``` Note that type hints are **optional** so perfectly valid `ormar` code can look like this: -```Python hl_lines="15-17" +```Python hl_lines="16-18" --8<-- "../docs_src/models/docs012.py" ``` @@ -222,7 +222,7 @@ One is `DatabaseConnection` instance created with your database url in [sqlalche Created instance needs to be passed to every `Model` with `ormar_config` object `database` parameter. -```Python hl_lines="3 5 11" +```Python hl_lines="4 6 12" --8<-- "../docs_src/models/docs001.py" ``` @@ -236,7 +236,7 @@ Second dependency is sqlalchemy `MetaData` instance. Created instance needs to be passed to every `Model` with `ormar_config` object `metadata` parameter. -```Python hl_lines="2 6 12" +```Python hl_lines="1 7 13" --8<-- "../docs_src/models/docs001.py" ``` @@ -251,7 +251,7 @@ To ease the config management, the `OrmarConfig` class provide `copy` method. So instead of providing the same parameters over and over again for all models you should create a base object and use its copy in all models. -```Python hl_lines="9-12 19 28" +```Python hl_lines="10-13 20 29" --8<-- "../docs_src/models/docs013.py" ``` @@ -281,7 +281,7 @@ Right now only `IndexColumns`, `UniqueColumns` and `CheckColumns` constraints ar You can set this parameter by providing `ormar_config` object `constraints` argument. -```Python hl_lines="13-16" +```Python hl_lines="14-17" --8<-- "../docs_src/models/docs006.py" ``` @@ -294,7 +294,7 @@ You can set this parameter by providing `ormar_config` object `constraints` argu You can set this parameter by providing `ormar_config` object `constraints` argument. -```Python hl_lines="13-16" +```Python hl_lines="14-17" --8<-- "../docs_src/models/docs017.py" ``` @@ -307,7 +307,7 @@ You can set this parameter by providing `ormar_config` object `constraints` argu You can set this parameter by providing `ormar_config` object `constraints` argument. -```Python hl_lines="15-20" +```Python hl_lines="16-21" --8<-- "../docs_src/models/docs018.py" ``` @@ -334,7 +334,7 @@ model_config = ConfigDict(validate_assignment=True, ser_json_bytes="base64") ``` So to overwrite setting or provide your own a sample model can look like following: -```Python hl_lines="16" +```Python hl_lines="17" --8<-- "../docs_src/models/docs016.py" ``` @@ -415,7 +415,7 @@ There are two ways to create and persist the `Model` instance in the database. 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. -```Python hl_lines="29-30" +```Python hl_lines="30-31" --8<-- "../docs_src/models/docs007.py" ``` @@ -425,7 +425,7 @@ For creating multiple objects at once a `bulk_create()` QuerySet's method is ava Each model has a `QuerySet` initialised as `objects` parameter -```Python hl_lines="32" +```Python hl_lines="33" --8<-- "../docs_src/models/docs007.py" ``` diff --git a/docs/models/internals.md b/docs/models/internals.md index 2e5f45cf9..56a4ace84 100644 --- a/docs/models/internals.md +++ b/docs/models/internals.md @@ -8,7 +8,7 @@ All `Model` classes inherit from `pydantic.BaseModel` so you can access all norm For example to list pydantic model fields you can: -```Python hl_lines="20" +```Python hl_lines="21" --8<-- "../docs_src/models/docs003.py" ``` @@ -24,7 +24,7 @@ To access auto created sqlalchemy table you can use `Model.ormar_config.table` p For example to list table columns you can: -```Python hl_lines="24" +```Python hl_lines="25" --8<-- "../docs_src/models/docs004.py" ``` @@ -40,7 +40,7 @@ To access ormar `Fields` you can use `Model.ormar_config.model_fields` parameter For example to list table model fields you can: -```Python hl_lines="22" +```Python hl_lines="23" --8<-- "../docs_src/models/docs005.py" ``` diff --git a/docs/mypy.md b/docs/mypy.md index d1f13f005..94ea6afd8 100644 --- a/docs/mypy.md +++ b/docs/mypy.md @@ -2,7 +2,7 @@ To provide better errors check you should use mypy with pydantic [plugin][plugin Please use notation introduced in version 0.4.0. -```Python hl_lines="15-17" +```Python hl_lines="16-18" --8<-- "../docs_src/models/docs012.py" ``` @@ -10,7 +10,7 @@ Note that above example is not using the type hints, so further operations with Preferred notation should look liked this: -```Python hl_lines="15-17" +```Python hl_lines="16-18" --8<-- "../docs_src/models/docs001.py" ``` diff --git a/docs/queries/create.md b/docs/queries/create.md index 71c66f8fd..60951f433 100644 --- a/docs/queries/create.md +++ b/docs/queries/create.md @@ -109,7 +109,7 @@ assert album == album2 Updates the model, or in case there is no match in database creates a new one. -```Python hl_lines="43-51" +```Python hl_lines="44-52" --8<-- "../docs_src/queries/docs003.py" ``` @@ -125,7 +125,7 @@ Allows you to create multiple objects at once. A valid list of `Model` objects needs to be passed. -```python hl_lines="29-35" +```python hl_lines="30-37" --8<-- "../docs_src/queries/docs004.py" ``` diff --git a/docs/queries/delete.md b/docs/queries/delete.md index 161d3c31c..c3ebb5b95 100644 --- a/docs/queries/delete.md +++ b/docs/queries/delete.md @@ -26,7 +26,7 @@ If you do not provide this flag or a filter a `QueryDefinitionError` will be rai Return number of rows deleted. -```python hl_lines="43-47" +```python hl_lines="44-48" --8<-- "../docs_src/queries/docs005.py" ``` diff --git a/docs/queries/update.md b/docs/queries/update.md index 265fbe456..fe45429bb 100644 --- a/docs/queries/update.md +++ b/docs/queries/update.md @@ -29,7 +29,7 @@ If you do not provide this flag or a filter a `QueryDefinitionError` will be rai Return number of rows updated. -```Python hl_lines="45-47" +```Python hl_lines="46-48" --8<-- "../docs_src/queries/docs002.py" ``` @@ -44,7 +44,7 @@ Return number of rows updated. Updates the model, or in case there is no match in database creates a new one. -```Python hl_lines="43-51" +```Python hl_lines="44-52" --8<-- "../docs_src/queries/docs003.py" ``` diff --git a/docs/relations/foreign-key.md b/docs/relations/foreign-key.md index 5ac1629df..ad37afc3c 100644 --- a/docs/relations/foreign-key.md +++ b/docs/relations/foreign-key.md @@ -14,7 +14,7 @@ Sqlalchemy column and type are automatically taken from target `Model`. To define a relation add `ForeignKey` field that points to related `Model`. -```Python hl_lines="30" +```Python hl_lines="31" --8<-- "../docs_src/fields/docs003.py" ``` @@ -24,7 +24,7 @@ To define a relation add `ForeignKey` field that points to related `Model`. By default it's child (source) `Model` name + s, like courses in snippet below: -```Python hl_lines="33 40" +```Python hl_lines="34 41" --8<-- "../docs_src/fields/docs001.py" ``` @@ -173,7 +173,7 @@ To read which methods of QuerySet are available read below [querysetproxy][query You can overwrite related model field name by providing `related_name` parameter like below: -```Python hl_lines="27-29 35" +```Python hl_lines="28-30 36" --8<-- "../docs_src/fields/docs002.py" ``` diff --git a/docs/relations/index.md b/docs/relations/index.md index 8155c5229..db0ed3a21 100644 --- a/docs/relations/index.md +++ b/docs/relations/index.md @@ -13,7 +13,7 @@ To read more about methods, possibilities, definition etc. please read the subse To define many-to-one relation use `ForeignKey` field. -```Python hl_lines="26" +```Python hl_lines="27" --8<-- "../docs_src/relations/docs003.py" ``` diff --git a/docs/relations/many-to-many.md b/docs/relations/many-to-many.md index 464889916..e3a81945e 100644 --- a/docs/relations/many-to-many.md +++ b/docs/relations/many-to-many.md @@ -9,7 +9,7 @@ Sqlalchemy column and Type are automatically taken from target `Model`. ## Defining Models -```Python hl_lines="34" +```Python hl_lines="35" --8<-- "../docs_src/relations/docs002.py" ``` @@ -139,7 +139,7 @@ assert len(categories) == 1 Optionally if you want to add additional fields you can explicitly create and pass the through model class. -```Python hl_lines="19-24 32" +```Python hl_lines="20-25 33" --8<-- "../docs_src/relations/docs004.py" ``` @@ -232,7 +232,7 @@ so it's useful only when additional fields are provided on `Through` model. In a sample model setup as following: -```Python hl_lines="19-24 32" +```Python hl_lines="20-25 33" --8<-- "../docs_src/relations/docs004.py" ``` diff --git a/docs/relations/queryset-proxy.md b/docs/relations/queryset-proxy.md index a1358a8f4..8a914eba4 100644 --- a/docs/relations/queryset-proxy.md +++ b/docs/relations/queryset-proxy.md @@ -127,7 +127,7 @@ provided Through model. Given sample like this: -```Python hl_lines="19-24 32" +```Python hl_lines="20-25 33" --8<-- "../docs_src/relations/docs004.py" ``` @@ -174,7 +174,7 @@ Updates the related model with provided keyword arguments, return number of upda Note that for `ManyToMany` relations update can also accept an argument with through field name and a dictionary of fields. -```Python hl_lines="19-24 32" +```Python hl_lines="20-25 33" --8<-- "../docs_src/relations/docs004.py" ``` diff --git a/docs/signals.md b/docs/signals.md index 1daed005d..eb209d368 100644 --- a/docs/signals.md +++ b/docs/signals.md @@ -34,7 +34,7 @@ You can for example define a trigger that will set `album.is_best_seller` status Import `pre_update` decorator, for list of currently available decorators/ signals check below. -```Python hl_lines="6" +```Python hl_lines="7" --8<-- "../docs_src/signals/docs002.py" ``` @@ -54,7 +54,7 @@ for which you want to run the signal receiver. Currently there is no way to set signal for all models at once without explicitly passing them all into registration of receiver. -```Python hl_lines="30-33" +```Python hl_lines="31-34" --8<-- "../docs_src/signals/docs002.py" ``` @@ -65,7 +65,7 @@ Currently there is no way to set signal for all models at once without explicitl Note that our newly created function has instance and class of the instance so you can easily run database queries inside your receivers if you want to. -```Python hl_lines="43-50" +```Python hl_lines="44-51" --8<-- "../docs_src/signals/docs002.py" ``` diff --git a/docs_src/aggregations/docs001.py b/docs_src/aggregations/docs001.py index 9db9c240b..9db54ef3d 100644 --- a/docs_src/aggregations/docs001.py +++ b/docs_src/aggregations/docs001.py @@ -1,7 +1,8 @@ from typing import Optional -import ormar import sqlalchemy + +import ormar from ormar import DatabaseConnection DATABASE_URL = "sqlite+aiosqlite:///aggregations_docs001.db" @@ -24,7 +25,6 @@ class Author(ormar.Model): class Book(ormar.Model): - ormar_config = base_ormar_config.copy( tablename="books", order_by=["year", "-ranking"] ) diff --git a/docs_src/fastapi/docs001.py b/docs_src/fastapi/docs001.py index 47118f465..d82214220 100644 --- a/docs_src/fastapi/docs001.py +++ b/docs_src/fastapi/docs001.py @@ -1,10 +1,11 @@ from typing import Optional -import ormar from fastapi import FastAPI from tests.lifespan import lifespan from tests.settings import create_config +import ormar + base_ormar_config = create_config() app = FastAPI(lifespan=lifespan(base_ormar_config)) diff --git a/docs_src/fastapi/mypy/docs001.py b/docs_src/fastapi/mypy/docs001.py index 11d1dad89..33c0adffa 100644 --- a/docs_src/fastapi/mypy/docs001.py +++ b/docs_src/fastapi/mypy/docs001.py @@ -1,5 +1,6 @@ -import ormar import sqlalchemy + +import ormar from ormar import DatabaseConnection database = DatabaseConnection("sqlite+aiosqlite:///db.sqlite") diff --git a/docs_src/fields/docs001.py b/docs_src/fields/docs001.py index 30a324ba2..1c5e7543f 100644 --- a/docs_src/fields/docs001.py +++ b/docs_src/fields/docs001.py @@ -1,9 +1,10 @@ import asyncio from typing import Optional -import ormar import sqlalchemy from examples import create_drop_database + +import ormar from ormar import DatabaseConnection DATABASE_URL = "sqlite+aiosqlite:///fields_docs001.db" diff --git a/docs_src/fields/docs002.py b/docs_src/fields/docs002.py index 7822ad652..cde9a8c20 100644 --- a/docs_src/fields/docs002.py +++ b/docs_src/fields/docs002.py @@ -1,7 +1,8 @@ from typing import Optional -import ormar import sqlalchemy + +import ormar from ormar import DatabaseConnection DATABASE_URL = "sqlite+aiosqlite:///fields_docs002.db" diff --git a/docs_src/fields/docs003.py b/docs_src/fields/docs003.py index c9c590564..1593377e4 100644 --- a/docs_src/fields/docs003.py +++ b/docs_src/fields/docs003.py @@ -1,7 +1,8 @@ from typing import Optional -import ormar import sqlalchemy + +import ormar from ormar import DatabaseConnection database = DatabaseConnection("sqlite+aiosqlite:///db.sqlite") diff --git a/docs_src/fields/docs004.py b/docs_src/fields/docs004.py index 8500b8d69..9e611b246 100644 --- a/docs_src/fields/docs004.py +++ b/docs_src/fields/docs004.py @@ -1,16 +1,16 @@ from datetime import datetime -import ormar import sqlalchemy -from ormar import DatabaseConnection from sqlalchemy import func, text +import ormar +from ormar import DatabaseConnection + database = DatabaseConnection("sqlite+aiosqlite:///fields_docs004.db") metadata = sqlalchemy.MetaData() class Product(ormar.Model): - ormar_config = ormar.OrmarConfig( database=database, metadata=metadata, tablename="product" ) diff --git a/docs_src/models/docs001.py b/docs_src/models/docs001.py index c57bdba22..538f2f87c 100644 --- a/docs_src/models/docs001.py +++ b/docs_src/models/docs001.py @@ -1,5 +1,6 @@ -import ormar import sqlalchemy + +import ormar from ormar import DatabaseConnection database = DatabaseConnection("sqlite+aiosqlite:///db.sqlite") diff --git a/docs_src/models/docs002.py b/docs_src/models/docs002.py index 145b788b4..2b759a62f 100644 --- a/docs_src/models/docs002.py +++ b/docs_src/models/docs002.py @@ -1,5 +1,6 @@ -import ormar import sqlalchemy + +import ormar from ormar import DatabaseConnection database = DatabaseConnection("sqlite+aiosqlite:///db.sqlite") @@ -7,7 +8,6 @@ class Course(ormar.Model): - ormar_config = ormar.OrmarConfig( database=database, metadata=metadata, diff --git a/docs_src/models/docs003.py b/docs_src/models/docs003.py index 53f93cb57..c7d66a5b9 100644 --- a/docs_src/models/docs003.py +++ b/docs_src/models/docs003.py @@ -1,5 +1,6 @@ -import ormar import sqlalchemy + +import ormar from ormar import DatabaseConnection database = DatabaseConnection("sqlite+aiosqlite:///db.sqlite") diff --git a/docs_src/models/docs004.py b/docs_src/models/docs004.py index 00951b697..1ce8c427e 100644 --- a/docs_src/models/docs004.py +++ b/docs_src/models/docs004.py @@ -1,5 +1,6 @@ -import ormar import sqlalchemy + +import ormar from ormar import DatabaseConnection DATABASE_URL = "sqlite+aiosqlite:///models_docs004.db" diff --git a/docs_src/models/docs005.py b/docs_src/models/docs005.py index 82e11eb1a..42b24b19c 100644 --- a/docs_src/models/docs005.py +++ b/docs_src/models/docs005.py @@ -1,7 +1,8 @@ import pprint -import ormar import sqlalchemy + +import ormar from ormar import DatabaseConnection database = DatabaseConnection("sqlite+aiosqlite:///db.sqlite") diff --git a/docs_src/models/docs006.py b/docs_src/models/docs006.py index 7a8877467..6d8207ed1 100644 --- a/docs_src/models/docs006.py +++ b/docs_src/models/docs006.py @@ -1,5 +1,6 @@ -import ormar import sqlalchemy + +import ormar from ormar import DatabaseConnection database = DatabaseConnection("sqlite+aiosqlite:///db.sqlite") diff --git a/docs_src/models/docs007.py b/docs_src/models/docs007.py index fc3e5f86e..a7b09f3dc 100644 --- a/docs_src/models/docs007.py +++ b/docs_src/models/docs007.py @@ -1,8 +1,9 @@ import asyncio -import ormar import sqlalchemy from examples import create_drop_database + +import ormar from ormar import DatabaseConnection DATABASE_URL = "sqlite+aiosqlite:///models_docs007.db" diff --git a/docs_src/models/docs008.py b/docs_src/models/docs008.py index dbcc0a971..50a70d983 100644 --- a/docs_src/models/docs008.py +++ b/docs_src/models/docs008.py @@ -1,5 +1,6 @@ -import ormar import sqlalchemy + +import ormar from ormar import DatabaseConnection DATABASE_URl = "sqlite+aiosqlite:///models_docs008.db" diff --git a/docs_src/models/docs009.py b/docs_src/models/docs009.py index 2b7834808..0cfcc95ac 100644 --- a/docs_src/models/docs009.py +++ b/docs_src/models/docs009.py @@ -1,7 +1,8 @@ from typing import Optional -import ormar import sqlalchemy + +import ormar from ormar import DatabaseConnection database = DatabaseConnection( @@ -24,7 +25,6 @@ class Artist(ormar.Model): class Album(ormar.Model): - ormar_config = ormar.OrmarConfig( database=database, metadata=metadata, diff --git a/docs_src/models/docs010.py b/docs_src/models/docs010.py index 73f7ee0cd..c387fb192 100644 --- a/docs_src/models/docs010.py +++ b/docs_src/models/docs010.py @@ -1,5 +1,6 @@ -import ormar import sqlalchemy + +import ormar from ormar import DatabaseConnection DATABASE_URl = "sqlite+aiosqlite:///models_docs010.db" diff --git a/docs_src/models/docs012.py b/docs_src/models/docs012.py index 11d1dad89..33c0adffa 100644 --- a/docs_src/models/docs012.py +++ b/docs_src/models/docs012.py @@ -1,5 +1,6 @@ -import ormar import sqlalchemy + +import ormar from ormar import DatabaseConnection database = DatabaseConnection("sqlite+aiosqlite:///db.sqlite") diff --git a/docs_src/models/docs013.py b/docs_src/models/docs013.py index 2d3f454fa..0981800aa 100644 --- a/docs_src/models/docs013.py +++ b/docs_src/models/docs013.py @@ -1,7 +1,8 @@ from typing import Optional -import ormar import sqlalchemy + +import ormar from ormar import DatabaseConnection DATABASE_URL = "sqlite+aiosqlite:///models_docs013.db" diff --git a/docs_src/models/docs014.py b/docs_src/models/docs014.py index 6ee8fba27..c805f05ec 100644 --- a/docs_src/models/docs014.py +++ b/docs_src/models/docs014.py @@ -1,6 +1,7 @@ -import ormar import pydantic import sqlalchemy + +import ormar from ormar import DatabaseConnection database = DatabaseConnection("sqlite+aiosqlite:///db.sqlite") diff --git a/docs_src/models/docs015.py b/docs_src/models/docs015.py index aed94a31a..41a290244 100644 --- a/docs_src/models/docs015.py +++ b/docs_src/models/docs015.py @@ -1,5 +1,6 @@ -import ormar import sqlalchemy + +import ormar from ormar import DatabaseConnection database = DatabaseConnection("sqlite+aiosqlite:///db.sqlite") diff --git a/docs_src/models/docs016.py b/docs_src/models/docs016.py index 4c563ef6e..1cd334b0f 100644 --- a/docs_src/models/docs016.py +++ b/docs_src/models/docs016.py @@ -1,6 +1,7 @@ -import ormar import pydantic import sqlalchemy + +import ormar from ormar import DatabaseConnection database = DatabaseConnection("sqlite+aiosqlite:///db.sqlite") diff --git a/docs_src/models/docs017.py b/docs_src/models/docs017.py index fe62d9d06..867b94fdc 100644 --- a/docs_src/models/docs017.py +++ b/docs_src/models/docs017.py @@ -1,5 +1,6 @@ -import ormar import sqlalchemy + +import ormar from ormar import DatabaseConnection database = DatabaseConnection("sqlite+aiosqlite:///db.sqlite") diff --git a/docs_src/models/docs018.py b/docs_src/models/docs018.py index fd2b3bdc8..bfa37a249 100644 --- a/docs_src/models/docs018.py +++ b/docs_src/models/docs018.py @@ -1,7 +1,8 @@ import datetime -import ormar import sqlalchemy + +import ormar from ormar import DatabaseConnection database = DatabaseConnection("sqlite+aiosqlite:///db.sqlite") diff --git a/docs_src/queries/docs001.py b/docs_src/queries/docs001.py index 6aae985dc..a4aa061e4 100644 --- a/docs_src/queries/docs001.py +++ b/docs_src/queries/docs001.py @@ -1,7 +1,8 @@ from typing import Optional -import ormar import sqlalchemy + +import ormar from ormar import DatabaseConnection DATABASE_URL = "sqlite+aiosqlite:///queries_docs001.db" diff --git a/docs_src/queries/docs002.py b/docs_src/queries/docs002.py index 681275d4c..75cec9650 100644 --- a/docs_src/queries/docs002.py +++ b/docs_src/queries/docs002.py @@ -1,8 +1,9 @@ import asyncio -import ormar import sqlalchemy from examples import create_drop_database + +import ormar from ormar import DatabaseConnection DATABASE_URL = "sqlite+aiosqlite:///queries_docs002.db" diff --git a/docs_src/queries/docs003.py b/docs_src/queries/docs003.py index 0eedf5cb4..5880e6ecf 100644 --- a/docs_src/queries/docs003.py +++ b/docs_src/queries/docs003.py @@ -1,8 +1,9 @@ import asyncio -import ormar import sqlalchemy from examples import create_drop_database + +import ormar from ormar import DatabaseConnection DATABASE_URL = "sqlite+aiosqlite:///queries_docs003.db" diff --git a/docs_src/queries/docs004.py b/docs_src/queries/docs004.py index 91a81abce..c78f69608 100644 --- a/docs_src/queries/docs004.py +++ b/docs_src/queries/docs004.py @@ -1,8 +1,9 @@ import asyncio -import ormar import sqlalchemy from examples import create_drop_database + +import ormar from ormar import DatabaseConnection DATABASE_URL = "sqlite+aiosqlite:///queries_docs004.db" diff --git a/docs_src/queries/docs005.py b/docs_src/queries/docs005.py index d59e2ef8a..8a8576fc2 100644 --- a/docs_src/queries/docs005.py +++ b/docs_src/queries/docs005.py @@ -1,8 +1,9 @@ import asyncio -import ormar import sqlalchemy from examples import create_drop_database + +import ormar from ormar import DatabaseConnection DATABASE_URL = "sqlite+aiosqlite:///queries_docs005.db" diff --git a/docs_src/queries/docs006.py b/docs_src/queries/docs006.py index 80590b09e..2dec4d4bf 100644 --- a/docs_src/queries/docs006.py +++ b/docs_src/queries/docs006.py @@ -1,8 +1,9 @@ import asyncio -import ormar import sqlalchemy from examples import create_drop_database + +import ormar from ormar import DatabaseConnection DATABASE_URL = "sqlite+aiosqlite:///queries_docs006.db" diff --git a/docs_src/queries/docs007.py b/docs_src/queries/docs007.py index 723410aee..5fc3e5b0f 100644 --- a/docs_src/queries/docs007.py +++ b/docs_src/queries/docs007.py @@ -1,8 +1,9 @@ import asyncio -import ormar import sqlalchemy from examples import create_drop_database + +import ormar from ormar import DatabaseConnection DATABASE_URL = "sqlite+aiosqlite:///queries_docs007.db" diff --git a/docs_src/queries/docs008.py b/docs_src/queries/docs008.py index c925ecb8a..831af4a75 100644 --- a/docs_src/queries/docs008.py +++ b/docs_src/queries/docs008.py @@ -1,11 +1,12 @@ import asyncio -import ormar import sqlalchemy from examples import create_drop_database -from ormar import DatabaseConnection from pydantic import ValidationError +import ormar +from ormar import DatabaseConnection + DATABASE_URL = "sqlite+aiosqlite:///queries_docs008.db" database = DatabaseConnection(DATABASE_URL) @@ -106,9 +107,11 @@ async def run_query(): # cannot exclude mandatory model columns - # manufacturer__name in this example - note usage of dict/set this time try: - await Car.objects.select_related("manufacturer").exclude_fields( - {"manufacturer": {"name"}} - ).all() + await ( + Car.objects.select_related("manufacturer") + .exclude_fields({"manufacturer": {"name"}}) + .all() + ) except ValidationError: # will raise pydantic ValidationError as company.name is required pass diff --git a/docs_src/queries/docs009.py b/docs_src/queries/docs009.py index 4f674af72..543880035 100644 --- a/docs_src/queries/docs009.py +++ b/docs_src/queries/docs009.py @@ -1,8 +1,9 @@ import asyncio -import ormar import sqlalchemy from examples import create_drop_database + +import ormar from ormar import DatabaseConnection DATABASE_URL = "sqlite+aiosqlite:///queries_docs009.db" @@ -39,36 +40,48 @@ class Car(ormar.Model): @create_drop_database(base_config=ormar_base_config) async def run_query(): # 1. like in example above - await Car.objects.select_related("manufacturer").fields( - ["id", "name", "manufacturer__name"] - ).all() + await ( + Car.objects.select_related("manufacturer") + .fields(["id", "name", "manufacturer__name"]) + .all() + ) # 2. to mark a field as required use ellipsis - await Car.objects.select_related("manufacturer").fields( - {"id": ..., "name": ..., "manufacturer": {"name": ...}} - ).all() + await ( + Car.objects.select_related("manufacturer") + .fields({"id": ..., "name": ..., "manufacturer": {"name": ...}}) + .all() + ) # 3. to include whole nested model use ellipsis - await Car.objects.select_related("manufacturer").fields( - {"id": ..., "name": ..., "manufacturer": ...} - ).all() + await ( + Car.objects.select_related("manufacturer") + .fields({"id": ..., "name": ..., "manufacturer": ...}) + .all() + ) # 4. to specify fields at last nesting level you can also use set # - equivalent to 2. above - await Car.objects.select_related("manufacturer").fields( - {"id": ..., "name": ..., "manufacturer": {"name"}} - ).all() + await ( + Car.objects.select_related("manufacturer") + .fields({"id": ..., "name": ..., "manufacturer": {"name"}}) + .all() + ) # 5. of course set can have multiple fields - await Car.objects.select_related("manufacturer").fields( - {"id": ..., "name": ..., "manufacturer": {"name", "founded"}} - ).all() + await ( + Car.objects.select_related("manufacturer") + .fields({"id": ..., "name": ..., "manufacturer": {"name", "founded"}}) + .all() + ) # 6. you can include all nested fields, # but it will be equivalent of 3. above which is shorter - await Car.objects.select_related("manufacturer").fields( - {"id": ..., "name": ..., "manufacturer": {"id", "name", "founded"}} - ).all() + await ( + Car.objects.select_related("manufacturer") + .fields({"id": ..., "name": ..., "manufacturer": {"id", "name", "founded"}}) + .all() + ) asyncio.run(run_query()) diff --git a/docs_src/relations/docs001.py b/docs_src/relations/docs001.py index ea8cc9b34..96b501b65 100644 --- a/docs_src/relations/docs001.py +++ b/docs_src/relations/docs001.py @@ -1,7 +1,8 @@ from typing import Optional, Union -import ormar import sqlalchemy + +import ormar from ormar import DatabaseConnection database = DatabaseConnection("sqlite+aiosqlite:///db.sqlite") diff --git a/docs_src/relations/docs003.py b/docs_src/relations/docs003.py index 1055d52c6..58917eec3 100644 --- a/docs_src/relations/docs003.py +++ b/docs_src/relations/docs003.py @@ -1,7 +1,8 @@ from typing import Optional, Union -import ormar import sqlalchemy + +import ormar from ormar import DatabaseConnection DATABASE_URL = "sqlite+aiosqlite:///relations_docs003.db" diff --git a/docs_src/relations/docs004.py b/docs_src/relations/docs004.py index 97b06dab3..247a2d2b9 100644 --- a/docs_src/relations/docs004.py +++ b/docs_src/relations/docs004.py @@ -1,5 +1,6 @@ -import ormar import sqlalchemy + +import ormar from ormar import DatabaseConnection DATABASE_URL = "sqlite+aiosqlite:///relations_docs004.db" diff --git a/docs_src/select_columns/docs001.py b/docs_src/select_columns/docs001.py index ebd5c0a99..87e135127 100644 --- a/docs_src/select_columns/docs001.py +++ b/docs_src/select_columns/docs001.py @@ -1,8 +1,9 @@ import asyncio -import ormar import sqlalchemy from examples import create_drop_database + +import ormar from ormar import DatabaseConnection DATABASE_URL = "sqlite+aiosqlite:///select_columns_docs001.db" diff --git a/docs_src/signals/docs002.py b/docs_src/signals/docs002.py index 27fd7ac07..02b7d894b 100644 --- a/docs_src/signals/docs002.py +++ b/docs_src/signals/docs002.py @@ -1,8 +1,9 @@ import asyncio -import ormar import sqlalchemy from examples import create_drop_database + +import ormar from ormar import DatabaseConnection, pre_update DATABASE_URL = "sqlite+aiosqlite:///signals_docs002.db" diff --git a/examples/script_from_readme.py b/examples/script_from_readme.py index 63702c6bc..775dcdeb7 100644 --- a/examples/script_from_readme.py +++ b/examples/script_from_readme.py @@ -1,9 +1,10 @@ from typing import Optional -import ormar import pydantic import sqlalchemy +import ormar + DATABASE_URL = "sqlite+aiosqlite:///db.sqlite" diff --git a/ormar/fields/base.py b/ormar/fields/base.py index 8e9328eb5..4e0fa3a0d 100644 --- a/ormar/fields/base.py +++ b/ormar/fields/base.py @@ -308,7 +308,7 @@ def _get_encrypted_column(self, name: str) -> sqlalchemy.Column: """ if self.primary_key or self.is_relation: raise ModelDefinitionError( - "Primary key field and relations fields" "cannot be encrypted!" + "Primary key field and relations fields cannot be encrypted!" ) column: sqlalchemy.Column = sqlalchemy.Column( self.db_alias or name, diff --git a/ormar/fields/many_to_many.py b/ormar/fields/many_to_many.py index 81fb89dbf..924e79d76 100644 --- a/ormar/fields/many_to_many.py +++ b/ormar/fields/many_to_many.py @@ -142,7 +142,8 @@ def ManyToMany( # type: ignore column_type = None else: __type__, column_type, pk_only_model = populate_m2m_params_based_on_to_model( - to=to, nullable=nullable # type: ignore + to=to, # type: ignore + nullable=nullable, ) namespace = dict( __type__=__type__, diff --git a/ormar/fields/model_fields.py b/ormar/fields/model_fields.py index f6b589480..6d67daf9c 100644 --- a/ormar/fields/model_fields.py +++ b/ormar/fields/model_fields.py @@ -119,7 +119,7 @@ def __new__(cls, *args: Any, **kwargs: Any) -> Self: # type: ignore encrypt_secret=encrypt_secret, encrypt_backend=encrypt_backend, encrypt_custom_backend=encrypt_custom_backend, - **kwargs + **kwargs, ) Field = type(cls.__name__, cls._bases, {}) return Field(**namespace) @@ -160,7 +160,7 @@ def __new__( # type: ignore # noqa CFQ002 max_length: int, min_length: Optional[int] = None, regex: Optional[str] = None, - **kwargs: Any + **kwargs: Any, ) -> Self: # type: ignore kwargs = { **kwargs, @@ -213,7 +213,7 @@ def __new__( # type: ignore minimum: Optional[int] = None, maximum: Optional[int] = None, multiple_of: Optional[int] = None, - **kwargs: Any + **kwargs: Any, ) -> Self: autoincrement = kwargs.pop("autoincrement", None) autoincrement = ( @@ -294,7 +294,7 @@ def __new__( # type: ignore minimum: Optional[float] = None, maximum: Optional[float] = None, multiple_of: Optional[int] = None, - **kwargs: Any + **kwargs: Any, ) -> Self: kwargs = { **kwargs, @@ -521,7 +521,7 @@ def __new__( # type: ignore minimum: Optional[int] = None, maximum: Optional[int] = None, multiple_of: Optional[int] = None, - **kwargs: Any + **kwargs: Any, ) -> Self: autoincrement = kwargs.pop("autoincrement", None) autoincrement = ( @@ -569,7 +569,7 @@ def __new__( # type: ignore minimum: Optional[int] = None, maximum: Optional[int] = None, multiple_of: Optional[int] = None, - **kwargs: Any + **kwargs: Any, ) -> Self: autoincrement = kwargs.pop("autoincrement", None) autoincrement = ( @@ -621,7 +621,7 @@ def __new__( # type: ignore # noqa CFQ002 scale: Optional[int] = None, max_digits: Optional[int] = None, decimal_places: Optional[int] = None, - **kwargs: Any + **kwargs: Any, ) -> Self: kwargs = { **kwargs, diff --git a/ormar/fields/sqlalchemy_encrypted.py b/ormar/fields/sqlalchemy_encrypted.py index 06cc7b696..097a37a45 100644 --- a/ormar/fields/sqlalchemy_encrypted.py +++ b/ormar/fields/sqlalchemy_encrypted.py @@ -145,7 +145,7 @@ def __init__( type_ = self._field_type.__type__ if type_ is None: # pragma: nocover raise ModelDefinitionError( - f"Improperly configured field " f"{self._field_type.name}" + f"Improperly configured field {self._field_type.name}" ) self.type_: Any = type_ diff --git a/ormar/fields/through_field.py b/ormar/fields/through_field.py index 640fdb899..97fea536d 100644 --- a/ormar/fields/through_field.py +++ b/ormar/fields/through_field.py @@ -20,7 +20,7 @@ def Through( # noqa CFQ002 *, name: Optional[str] = None, related_name: Optional[str] = None, - **kwargs: Any + **kwargs: Any, ) -> Any: """ Despite a name it's a function that returns constructed ThroughField. diff --git a/ormar/models/helpers/models.py b/ormar/models/helpers/models.py index 27b756018..acd894a92 100644 --- a/ormar/models/helpers/models.py +++ b/ormar/models/helpers/models.py @@ -1,5 +1,4 @@ import itertools -import sqlite3 from typing import TYPE_CHECKING, Any, ForwardRef import pydantic diff --git a/ormar/models/helpers/pydantic.py b/ormar/models/helpers/pydantic.py index 9d0b083fe..bb0eadfad 100644 --- a/ormar/models/helpers/pydantic.py +++ b/ormar/models/helpers/pydantic.py @@ -30,7 +30,8 @@ def create_pydantic_field( :type model_field: ManyToManyField class """ model_field.through.model_fields[field_name] = FieldInfo.from_annotated_attribute( - annotation=Optional[model], default=None # type: ignore + annotation=Optional[model], # type: ignore + default=None, ) model_field.through.model_rebuild( force=True, _types_namespace={model_field.owner.__name__: model_field.owner} diff --git a/ormar/models/helpers/sqlalchemy.py b/ormar/models/helpers/sqlalchemy.py index 5ffcde8c7..55fc297b1 100644 --- a/ormar/models/helpers/sqlalchemy.py +++ b/ormar/models/helpers/sqlalchemy.py @@ -300,7 +300,7 @@ def set_constraint_names(config: "OrmarConfig") -> None: if isinstance(constraint, sqlalchemy.UniqueConstraint) and not constraint.name: constraint.name = ( f"uc_{config.tablename}_" - f'{"_".join([str(col) for col in constraint._pending_colargs])}' + f"{'_'.join([str(col) for col in constraint._pending_colargs])}" ) elif ( isinstance(constraint, sqlalchemy.Index) @@ -308,7 +308,7 @@ def set_constraint_names(config: "OrmarConfig") -> None: ): constraint.name = ( f"ix_{config.tablename}_" - f'{"_".join([col for col in constraint._pending_colargs])}' + f"{'_'.join([col for col in constraint._pending_colargs])}" ) elif isinstance(constraint, sqlalchemy.CheckConstraint) and not constraint.name: sql_condition: str = str(constraint.sqltext).replace(" ", "_") diff --git a/ormar/models/mixins/pydantic_mixin.py b/ormar/models/mixins/pydantic_mixin.py index 3ed018455..d3cf0ced3 100644 --- a/ormar/models/mixins/pydantic_mixin.py +++ b/ormar/models/mixins/pydantic_mixin.py @@ -178,6 +178,6 @@ def copy_selected_validators_type( for field_name in decorator.info.fields if field_name in fields ] - getattr(model.__pydantic_decorators__, validator_type)[ - name - ] = copied_decorator + getattr(model.__pydantic_decorators__, validator_type)[name] = ( + copied_decorator + ) diff --git a/ormar/models/newbasemodel.py b/ormar/models/newbasemodel.py index f589637ad..06ad46c6b 100644 --- a/ormar/models/newbasemodel.py +++ b/ormar/models/newbasemodel.py @@ -133,7 +133,8 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # type: ignore if not pk_only: new_kwargs = self.serialize_nested_models_json_fields(new_kwargs) self.__pydantic_validator__.validate_python( - new_kwargs, self_instance=self # type: ignore + new_kwargs, + self_instance=self, # type: ignore ) else: fields_set = {self.ormar_config.pkname} diff --git a/ormar/models/ormar_config.py b/ormar/models/ormar_config.py index 20fa2c28d..8d6a2525d 100644 --- a/ormar/models/ormar_config.py +++ b/ormar/models/ormar_config.py @@ -14,7 +14,6 @@ class OrmarConfig: - if TYPE_CHECKING: # pragma: no cover pkname: str metadata: sqlalchemy.MetaData diff --git a/ormar/queryset/actions/order_action.py b/ormar/queryset/actions/order_action.py index af9601964..ca614d1e4 100644 --- a/ormar/queryset/actions/order_action.py +++ b/ormar/queryset/actions/order_action.py @@ -52,7 +52,7 @@ def get_field_name_text(self) -> str: :rtype: sqlalchemy.sql.elements.TextClause """ prefix = f"{self.table_prefix}_" if self.table_prefix else "" - return f"{prefix}{self.table}" f".{self.field_alias}" + return f"{prefix}{self.table}.{self.field_alias}" def get_min_or_max(self) -> sqlalchemy.sql.expression.TextClause: """ @@ -67,9 +67,9 @@ def get_min_or_max(self) -> sqlalchemy.sql.expression.TextClause: prefix = f"{self.table_prefix}_" if self.table_prefix else "" if self.direction == "": function = "min" if not self.is_postgres_bool else "bool_or" - return text(f"{function}({prefix}{self.table}" f".{self.field_alias})") + return text(f"{function}({prefix}{self.table}.{self.field_alias})") function = "max" if not self.is_postgres_bool else "bool_or" - return text(f"{function}({prefix}{self.table}" f".{self.field_alias}) desc") + return text(f"{function}({prefix}{self.table}.{self.field_alias}) desc") def get_text_clause(self) -> sqlalchemy.sql.expression.TextClause: """ diff --git a/ormar/queryset/clause.py b/ormar/queryset/clause.py index acf8b40a8..45c8df98b 100644 --- a/ormar/queryset/clause.py +++ b/ormar/queryset/clause.py @@ -172,7 +172,7 @@ class Prefix: @property def alias_key(self) -> str: source_model_name = self.source_model.get_name() - return f"{source_model_name}_" f"{self.relation_str}" + return f"{source_model_name}_{self.relation_str}" class QueryClause: diff --git a/ormar/queryset/join.py b/ormar/queryset/join.py index a5492512a..9f43da3b8 100644 --- a/ormar/queryset/join.py +++ b/ormar/queryset/join.py @@ -305,7 +305,9 @@ def _process_join(self) -> None: # noqa: CFQ002 self.next_alias, self.to_table ) self.select_from = sqlalchemy.sql.outerjoin( - self.select_from, target_table, on_clause # type: ignore + self.select_from, # type: ignore + target_table, + on_clause, ) self._get_order_bys() @@ -318,7 +320,9 @@ def _process_join(self) -> None: # noqa: CFQ002 ) self.columns.extend( self.alias_manager.prefixed_columns( # type: ignore - self.next_alias, target_table, self_related_fields # type: ignore + self.next_alias, + target_table, # type: ignore + self_related_fields, ) ) self.used_aliases.append(self.next_alias) @@ -339,7 +343,7 @@ def _verify_allowed_order_field(self, order_by: str) -> None: parts = order_by.split("__") if len(parts) > 2 or parts[0] != self.target_field.through.get_name(): raise ModelDefinitionError( - "You can order the relation only " "by related or link table columns!" + "You can order the relation only by related or link table columns!" ) def _get_alias_and_model(self, order_by: str) -> tuple[str, type["Model"]]: diff --git a/ormar/queryset/queryset.py b/ormar/queryset/queryset.py index 232392285..d302027c8 100644 --- a/ormar/queryset/queryset.py +++ b/ormar/queryset/queryset.py @@ -1253,5 +1253,6 @@ async def bulk_update( # noqa: CCR001 await cast( type["Model"], self.model_cls ).ormar_config.signals.post_bulk_update.send( - sender=self.model_cls, instances=objects # type: ignore + sender=self.model_cls, # type: ignore + instances=objects, ) diff --git a/ormar/relations/querysetproxy.py b/ormar/relations/querysetproxy.py index ee727800d..bf48a8d41 100644 --- a/ormar/relations/querysetproxy.py +++ b/ormar/relations/querysetproxy.py @@ -507,7 +507,8 @@ async def update(self, each: bool = False, **kwargs: Any) -> int: await child.update(**kwargs) # type: ignore if self.type_ == ormar.RelationType.MULTIPLE and through_kwargs: await self.update_through_instance( - child=child, **through_kwargs # type: ignore + child=child, + **through_kwargs, # type: ignore ) return len(children) @@ -593,9 +594,7 @@ def filter( # noqa: A003, A001 relation=self.relation, type_=self.type_, to=self.to, qryset=queryset ) - def exclude( - self, *args: Any, **kwargs: Any - ) -> "QuerysetProxy[T]": # noqa: A003, A001 + def exclude(self, *args: Any, **kwargs: Any) -> "QuerysetProxy[T]": # noqa: A003, A001 """ Works exactly the same as filter and all modifiers (suffixes) are the same, but returns a *not* condition. diff --git a/poetry.lock b/poetry.lock index acb4989bf..c16761123 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 2.2.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.3.2 and should not be changed by hand. [[package]] name = "aiomysql" @@ -7,7 +7,7 @@ description = "MySQL driver for asyncio." optional = true python-versions = ">=3.9" groups = ["main"] -markers = "extra == \"all\" or extra == \"mysql\"" +markers = "extra == \"mysql\" or extra == \"all\"" files = [ {file = "aiomysql-0.3.2-py3-none-any.whl", hash = "sha256:c82c5ba04137d7afd5c693a258bea8ead2aad77101668044143a991e04632eb2"}, {file = "aiomysql-0.3.2.tar.gz", hash = "sha256:72d15ef5cfc34c03468eb41e1b90adb9fd9347b0b589114bd23ead569a02ac1a"}, @@ -47,7 +47,7 @@ description = "asyncio bridge to the standard sqlite3 module" optional = true python-versions = ">=3.9" groups = ["main"] -markers = "extra == \"all\" or extra == \"sqlite\"" +markers = "extra == \"sqlite\" or extra == \"all\"" files = [ {file = "aiosqlite-0.22.1-py3-none-any.whl", hash = "sha256:21c002eb13823fad740196c5a2e9d8e62f6243bd9e7e4a1f87fb5e44ecb4fceb"}, {file = "aiosqlite-0.22.1.tar.gz", hash = "sha256:043e0bd78d32888c0a9ca90fc788b38796843360c855a7262a532813133a0650"}, @@ -126,7 +126,7 @@ description = "Timeout context manager for asyncio programs" optional = true python-versions = ">=3.7" groups = ["main"] -markers = "(extra == \"all\" or extra == \"postgres\" or extra == \"postgresql\") and python_version < \"3.11.0\" or extra == \"aiopg\" or extra == \"all\"" +markers = "(extra == \"postgresql\" or extra == \"postgres\" or extra == \"all\") and python_version < \"3.11.0\" or extra == \"aiopg\" or extra == \"all\"" files = [ {file = "async-timeout-4.0.3.tar.gz", hash = "sha256:4640d96be84d82d02ed59ea2b7105a0f7b33abe8703703cd0ab0bf87c427522f"}, {file = "async_timeout-4.0.3-py3-none-any.whl", hash = "sha256:7405140ff1230c310e51dc27b3145b9092d659ce68ff733fb0cefe3ee42be028"}, @@ -139,7 +139,7 @@ description = "An asyncio PostgreSQL driver" optional = true python-versions = ">=3.9.0" groups = ["main"] -markers = "extra == \"all\" or extra == \"postgres\" or extra == \"postgresql\"" +markers = "extra == \"postgresql\" or extra == \"postgres\" or extra == \"all\"" files = [ {file = "asyncpg-0.31.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:831712dd3cf117eec68575a9b50da711893fd63ebe277fc155ecae1c6c9f0f61"}, {file = "asyncpg-0.31.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:0b17c89312c2f4ccea222a3a6571f7df65d4ba2c0e803339bfc7bed46a96d3be"}, @@ -221,6 +221,19 @@ files = [ [package.extras] dev = ["freezegun (>=1.0,<2.0)", "pytest (>=6.0)", "pytest-cov"] +[[package]] +name = "backports-asyncio-runner" +version = "1.2.0" +description = "Backport of asyncio.Runner, a context manager that controls event loop life cycle." +optional = false +python-versions = "<3.11,>=3.8" +groups = ["dev"] +markers = "python_version < \"3.11\"" +files = [ + {file = "backports_asyncio_runner-1.2.0-py3-none-any.whl", hash = "sha256:0da0a936a8aeb554eccb426dc55af3ba63bcdc69fa1a600b5bb305413a4477b5"}, + {file = "backports_asyncio_runner-1.2.0.tar.gz", hash = "sha256:a5aa7b2b7d8f8bfcaa2b57313f70792df84e32a2a746f585213373f900b42162"}, +] + [[package]] name = "backrefs" version = "6.1" @@ -241,59 +254,6 @@ files = [ [package.extras] extras = ["regex"] -[[package]] -name = "black" -version = "26.1.0" -description = "The uncompromising code formatter." -optional = false -python-versions = ">=3.10" -groups = ["dev"] -files = [ - {file = "black-26.1.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:ca699710dece84e3ebf6e92ee15f5b8f72870ef984bf944a57a777a48357c168"}, - {file = "black-26.1.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:5e8e75dabb6eb83d064b0db46392b25cabb6e784ea624219736e8985a6b3675d"}, - {file = "black-26.1.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:eb07665d9a907a1a645ee41a0df8a25ffac8ad9c26cdb557b7b88eeeeec934e0"}, - {file = "black-26.1.0-cp310-cp310-win_amd64.whl", hash = "sha256:7ed300200918147c963c87700ccf9966dceaefbbb7277450a8d646fc5646bf24"}, - {file = "black-26.1.0-cp310-cp310-win_arm64.whl", hash = "sha256:c5b7713daea9bf943f79f8c3b46f361cc5229e0e604dcef6a8bb6d1c37d9df89"}, - {file = "black-26.1.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:3cee1487a9e4c640dc7467aaa543d6c0097c391dc8ac74eb313f2fbf9d7a7cb5"}, - {file = "black-26.1.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:d62d14ca31c92adf561ebb2e5f2741bf8dea28aef6deb400d49cca011d186c68"}, - {file = "black-26.1.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:fb1dafbbaa3b1ee8b4550a84425aac8874e5f390200f5502cf3aee4a2acb2f14"}, - {file = "black-26.1.0-cp311-cp311-win_amd64.whl", hash = "sha256:101540cb2a77c680f4f80e628ae98bd2bd8812fb9d72ade4f8995c5ff019e82c"}, - {file = "black-26.1.0-cp311-cp311-win_arm64.whl", hash = "sha256:6f3977a16e347f1b115662be07daa93137259c711e526402aa444d7a88fdc9d4"}, - {file = "black-26.1.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:6eeca41e70b5f5c84f2f913af857cf2ce17410847e1d54642e658e078da6544f"}, - {file = "black-26.1.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:dd39eef053e58e60204f2cdf059e2442e2eb08f15989eefe259870f89614c8b6"}, - {file = "black-26.1.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:9459ad0d6cd483eacad4c6566b0f8e42af5e8b583cee917d90ffaa3778420a0a"}, - {file = "black-26.1.0-cp312-cp312-win_amd64.whl", hash = "sha256:a19915ec61f3a8746e8b10adbac4a577c6ba9851fa4a9e9fbfbcf319887a5791"}, - {file = "black-26.1.0-cp312-cp312-win_arm64.whl", hash = "sha256:643d27fb5facc167c0b1b59d0315f2674a6e950341aed0fc05cf307d22bf4954"}, - {file = "black-26.1.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:ba1d768fbfb6930fc93b0ecc32a43d8861ded16f47a40f14afa9bb04ab93d304"}, - {file = "black-26.1.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:2b807c240b64609cb0e80d2200a35b23c7df82259f80bef1b2c96eb422b4aac9"}, - {file = "black-26.1.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1de0f7d01cc894066a1153b738145b194414cc6eeaad8ef4397ac9abacf40f6b"}, - {file = "black-26.1.0-cp313-cp313-win_amd64.whl", hash = "sha256:91a68ae46bf07868963671e4d05611b179c2313301bd756a89ad4e3b3db2325b"}, - {file = "black-26.1.0-cp313-cp313-win_arm64.whl", hash = "sha256:be5e2fe860b9bd9edbf676d5b60a9282994c03fbbd40fe8f5e75d194f96064ca"}, - {file = "black-26.1.0-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:9dc8c71656a79ca49b8d3e2ce8103210c9481c57798b48deeb3a8bb02db5f115"}, - {file = "black-26.1.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:b22b3810451abe359a964cc88121d57f7bce482b53a066de0f1584988ca36e79"}, - {file = "black-26.1.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:53c62883b3f999f14e5d30b5a79bd437236658ad45b2f853906c7cbe79de00af"}, - {file = "black-26.1.0-cp314-cp314-win_amd64.whl", hash = "sha256:f016baaadc423dc960cdddf9acae679e71ee02c4c341f78f3179d7e4819c095f"}, - {file = "black-26.1.0-cp314-cp314-win_arm64.whl", hash = "sha256:66912475200b67ef5a0ab665011964bf924745103f51977a78b4fb92a9fc1bf0"}, - {file = "black-26.1.0-py3-none-any.whl", hash = "sha256:1054e8e47ebd686e078c0bb0eaf31e6ce69c966058d122f2c0c950311f9f3ede"}, - {file = "black-26.1.0.tar.gz", hash = "sha256:d294ac3340eef9c9eb5d29288e96dc719ff269a88e27b396340459dd85da4c58"}, -] - -[package.dependencies] -click = ">=8.0.0" -mypy-extensions = ">=0.4.3" -packaging = ">=22.0" -pathspec = ">=1.0.0" -platformdirs = ">=2" -pytokens = ">=0.3.0" -tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} -typing-extensions = {version = ">=4.0.1", markers = "python_version < \"3.11\""} - -[package.extras] -colorama = ["colorama (>=0.4.3)"] -d = ["aiohttp (>=3.10)"] -jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] -uvloop = ["uvloop (>=0.15.2)"] - [[package]] name = "certifi" version = "2024.8.30" @@ -399,7 +359,7 @@ files = [ {file = "cffi-2.0.0-cp39-cp39-win_amd64.whl", hash = "sha256:b882b3df248017dba09d6b16defe9b5c407fe32fc7c65a9c69798e6175601be9"}, {file = "cffi-2.0.0.tar.gz", hash = "sha256:44d1b5909021139fe36001ae048dbdde8214afa20200eda0f64c068cac5d5529"}, ] -markers = {main = "platform_python_implementation != \"PyPy\" and (extra == \"all\" or extra == \"crypto\")"} +markers = {main = "platform_python_implementation != \"PyPy\" and (extra == \"crypto\" or extra == \"all\")"} [package.dependencies] pycparser = {version = "*", markers = "implementation_name != \"PyPy\""} @@ -689,7 +649,7 @@ description = "cryptography is a package which provides cryptographic recipes an optional = true python-versions = "!=3.9.0,!=3.9.1,>=3.8" groups = ["main"] -markers = "extra == \"all\" or extra == \"crypto\"" +markers = "extra == \"crypto\" or extra == \"all\"" files = [ {file = "cryptography-46.0.5-cp311-abi3-macosx_10_9_universal2.whl", hash = "sha256:351695ada9ea9618b3500b490ad54c739860883df6c1f555e088eaf25b1bbaad"}, {file = "cryptography-46.0.5-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:c18ff11e86df2e28854939acde2d003f7984f721eba450b56a200ad90eeb0e6b"}, @@ -1741,7 +1701,7 @@ description = "Fast, correct Python JSON library supporting dataclasses, datetim optional = true python-versions = ">=3.10" groups = ["main"] -markers = "extra == \"all\" or extra == \"orjson\"" +markers = "extra == \"orjson\" or extra == \"all\"" files = [ {file = "orjson-3.11.7-cp310-cp310-macosx_10_15_x86_64.macosx_11_0_arm64.macosx_10_15_universal2.whl", hash = "sha256:a02c833f38f36546ba65a452127633afce4cf0dd7296b753d3bb54e55e5c0174"}, {file = "orjson-3.11.7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b63c6e6738d7c3470ad01601e23376aa511e50e1f3931395b9f9c722406d1a67"}, @@ -1924,7 +1884,7 @@ description = "psycopg2 - Python-PostgreSQL Database Adapter" optional = true python-versions = ">=3.9" groups = ["main"] -markers = "extra == \"aiopg\" or extra == \"all\" or extra == \"postgres\" or extra == \"postgresql\"" +markers = "extra == \"aiopg\" or extra == \"all\" or extra == \"postgresql\" or extra == \"postgres\"" files = [ {file = "psycopg2-binary-2.9.11.tar.gz", hash = "sha256:b6aed9e096bf63f9e75edf2581aa9a7e7186d97ab5c177aa6c87797cd591236c"}, {file = "psycopg2_binary-2.9.11-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d6fe6b47d0b42ce1c9f1fa3e35bb365011ca22e39db37074458f27921dca40f2"}, @@ -2018,7 +1978,7 @@ files = [ {file = "pycparser-2.22-py3-none-any.whl", hash = "sha256:c3702b6d3dd8c7abc1afa565d7e63d53a1d0bd86cdc24edd75470f4de499cfcc"}, {file = "pycparser-2.22.tar.gz", hash = "sha256:491c8be9c040f5390f5bf44a5b07752bd07f56edf992381b05c701439eec10f6"}, ] -markers = {main = "platform_python_implementation != \"PyPy\" and (extra == \"all\" or extra == \"crypto\") and implementation_name != \"PyPy\"", dev = "implementation_name != \"PyPy\""} +markers = {main = "platform_python_implementation != \"PyPy\" and (extra == \"crypto\" or extra == \"all\") and implementation_name != \"PyPy\"", dev = "implementation_name != \"PyPy\""} [[package]] name = "pydantic" @@ -2242,7 +2202,7 @@ description = "Pure Python MySQL Driver" optional = true python-versions = ">=3.8" groups = ["main"] -markers = "extra == \"all\" or extra == \"mysql\"" +markers = "extra == \"mysql\" or extra == \"all\"" files = [ {file = "pymysql-1.1.2-py3-none-any.whl", hash = "sha256:e6b1d89711dd51f8f74b1631fe08f039e7d76cf67a42a323d3178f0f25762ed9"}, {file = "pymysql-1.1.2.tar.gz", hash = "sha256:4961d3e165614ae65014e361811a724e2044ad3ea3739de9903ae7c21f539f03"}, @@ -2293,21 +2253,23 @@ dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "requests [[package]] name = "pytest-asyncio" -version = "0.23.8" +version = "1.3.0" description = "Pytest support for asyncio" optional = false -python-versions = ">=3.8" +python-versions = ">=3.10" groups = ["dev"] files = [ - {file = "pytest_asyncio-0.23.8-py3-none-any.whl", hash = "sha256:50265d892689a5faefb84df80819d1ecef566eb3549cf915dfb33569359d1ce2"}, - {file = "pytest_asyncio-0.23.8.tar.gz", hash = "sha256:759b10b33a6dc61cce40a8bd5205e302978bbbcc00e279a8b61d9a6a3c82e4d3"}, + {file = "pytest_asyncio-1.3.0-py3-none-any.whl", hash = "sha256:611e26147c7f77640e6d0a92a38ed17c3e9848063698d5c93d5aa7aa11cebff5"}, + {file = "pytest_asyncio-1.3.0.tar.gz", hash = "sha256:d7f52f36d231b80ee124cd216ffb19369aa168fc10095013c6b014a34d3ee9e5"}, ] [package.dependencies] -pytest = ">=7.0.0,<9" +backports-asyncio-runner = {version = ">=1.1,<2", markers = "python_version < \"3.11\""} +pytest = ">=8.2,<10" +typing-extensions = {version = ">=4.12", markers = "python_version < \"3.13\""} [package.extras] -docs = ["sphinx (>=5.3)", "sphinx-rtd-theme (>=1.0)"] +docs = ["sphinx (>=5.3)", "sphinx-rtd-theme (>=1)"] testing = ["coverage (>=6.2)", "hypothesis (>=5.7.1)"] [[package]] @@ -2400,21 +2362,6 @@ files = [ [package.dependencies] six = ">=1.5" -[[package]] -name = "pytokens" -version = "0.3.0" -description = "A Fast, spec compliant Python 3.14+ tokenizer that runs on older Pythons." -optional = false -python-versions = ">=3.8" -groups = ["dev"] -files = [ - {file = "pytokens-0.3.0-py3-none-any.whl", hash = "sha256:95b2b5eaf832e469d141a378872480ede3f251a5a5041b8ec6e581d3ac71bbf3"}, - {file = "pytokens-0.3.0.tar.gz", hash = "sha256:2f932b14ed08de5fcf0b391ace2642f858f1394c0857202959000b68ed7a458a"}, -] - -[package.extras] -dev = ["black", "build", "mypy", "pytest", "pytest-cov", "setuptools", "tox", "twine", "wheel"] - [[package]] name = "pyyaml" version = "6.0.2" @@ -3129,4 +3076,4 @@ sqlite = ["aiosqlite"] [metadata] lock-version = "2.1" python-versions = "^3.10.0" -content-hash = "c676c15b601a53122a556662fd3099b3054ece06f3464ac69eda7b5c9be1f299" +content-hash = "c760557c0c749295223d68bc7ba1326d735fa7f1063c52f2b032138971c8ec4f" diff --git a/pyproject.toml b/pyproject.toml index b9999cc4d..cd1a324b7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -84,14 +84,12 @@ all = [ [tool.poetry.group.dev.dependencies] # Testing -pytest = ">=7.4.4,<9.0.0" +pytest = ">=8.2,<10.0" pytest-cov = ">=7,<8" codecov = "^2.1.13" -pytest-asyncio = ">=0.21,<0.24" +pytest-asyncio = ">=1.1.0,<2.0" fastapi = ">=0.125.0" - -black = ">=24.1,<27.0" ruff = ">=0.5.1,<0.15.3" setuptools = ">=78.1.1,<83.0.0" @@ -137,6 +135,11 @@ email-validator = "^2.1.1" requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" +[tool.pytest.ini_options] +asyncio_mode = "strict" +asyncio_default_fixture_loop_scope = "module" +asyncio_default_test_loop_scope = "module" + [tool.mypy] # TODO: Enable mypy plugin after pydantic release supporting toml file disallow_untyped_calls = true @@ -163,7 +166,16 @@ disable_ending_comma_heuristic = true split_arguments_when_comma_terminated = true [tool.ruff] -select = ["E", "F", "I"] -ignore = ["E402"] line-length = 88 src = ["ormar", "tests"] + +[tool.ruff.lint] +select = ["E", "F", "I"] +ignore = ["E402"] + +[tool.ruff.format] +indent-style = "space" +docstring-code-format = true + +[tool.ruff.lint.isort] +known-first-party = ["ormar"] \ No newline at end of file diff --git a/tests/lifespan.py b/tests/lifespan.py index f2f3763f9..3b8c53142 100644 --- a/tests/lifespan.py +++ b/tests/lifespan.py @@ -4,10 +4,10 @@ import pytest_asyncio import sqlalchemy from fastapi import FastAPI -from ormar import OrmarConfig from sqlalchemy import text from sqlalchemy.ext.asyncio import create_async_engine +from ormar import OrmarConfig from tests.settings import ASYNC_DATABASE_URL diff --git a/tests/settings.py b/tests/settings.py index b792a3a8d..1532707f5 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -1,10 +1,11 @@ import os -import ormar import sqlalchemy -from ormar.databases.connection import DatabaseConnection from sqlalchemy.ext.asyncio import create_async_engine +import ormar +from ormar.databases.connection import DatabaseConnection + def convert_to_async_url(url: str) -> str: # pragma: nocover """Convert database URL to async driver version.""" diff --git a/tests/test_completion.py b/tests/test_completion.py index ffe5ac993..fce23bf9d 100644 --- a/tests/test_completion.py +++ b/tests/test_completion.py @@ -1,5 +1,4 @@ import ormar - from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_databases/test_concurent_transactions.py b/tests/test_databases/test_concurent_transactions.py index 717c482e7..4f81b1598 100644 --- a/tests/test_databases/test_concurent_transactions.py +++ b/tests/test_databases/test_concurent_transactions.py @@ -1,9 +1,9 @@ import asyncio import sys -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_databases/test_connection.py b/tests/test_databases/test_connection.py index 6a078ab4b..3602216f0 100644 --- a/tests/test_databases/test_connection.py +++ b/tests/test_databases/test_connection.py @@ -1,8 +1,8 @@ -import ormar import pytest -from ormar.databases.connection import DatabaseConnection from sqlalchemy import text +import ormar +from ormar.databases.connection import DatabaseConnection from tests.lifespan import init_tests from tests.settings import ASYNC_DATABASE_URL, DATABASE_URL, create_config diff --git a/tests/test_databases/test_transaction_as_fixture.py b/tests/test_databases/test_transaction_as_fixture.py index 52be0d935..4d3b4bbd1 100644 --- a/tests/test_databases/test_transaction_as_fixture.py +++ b/tests/test_databases/test_transaction_as_fixture.py @@ -1,6 +1,6 @@ -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_deferred/test_forward_cross_refs.py b/tests/test_deferred/test_forward_cross_refs.py index cd361682e..26cb372c5 100644 --- a/tests/test_deferred/test_forward_cross_refs.py +++ b/tests/test_deferred/test_forward_cross_refs.py @@ -1,9 +1,9 @@ # type: ignore from typing import ForwardRef, Optional -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_deferred/test_forward_refs.py b/tests/test_deferred/test_forward_refs.py index 4fc2d8b53..8707fc254 100644 --- a/tests/test_deferred/test_forward_refs.py +++ b/tests/test_deferred/test_forward_refs.py @@ -1,12 +1,12 @@ # type: ignore from typing import ForwardRef, Optional -import ormar import pytest import pytest_asyncio import sqlalchemy as sa -from ormar.exceptions import ModelError +import ormar +from ormar.exceptions import ModelError from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_deferred/test_more_same_table_joins.py b/tests/test_deferred/test_more_same_table_joins.py index fc89f4094..2f24a70f5 100644 --- a/tests/test_deferred/test_more_same_table_joins.py +++ b/tests/test_deferred/test_more_same_table_joins.py @@ -1,8 +1,8 @@ from typing import Optional -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_deferred/test_same_table_joins.py b/tests/test_deferred/test_same_table_joins.py index 2b0c9f89d..73538ea58 100644 --- a/tests/test_deferred/test_same_table_joins.py +++ b/tests/test_deferred/test_same_table_joins.py @@ -1,8 +1,8 @@ from typing import Optional -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_encryption/test_encrypted_columns.py b/tests/test_encryption/test_encrypted_columns.py index 5a685065a..024cf91f2 100644 --- a/tests/test_encryption/test_encrypted_columns.py +++ b/tests/test_encryption/test_encrypted_columns.py @@ -6,11 +6,11 @@ import uuid from typing import Any, Optional -import ormar import pytest + +import ormar from ormar import ModelDefinitionError, NoMatch from ormar.fields.sqlalchemy_encrypted import EncryptedString - from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_exclude_include_dict/test_complex_relation_tree_performance.py b/tests/test_exclude_include_dict/test_complex_relation_tree_performance.py index fd48bbd62..da324d7ed 100644 --- a/tests/test_exclude_include_dict/test_complex_relation_tree_performance.py +++ b/tests/test_exclude_include_dict/test_complex_relation_tree_performance.py @@ -1,10 +1,10 @@ from datetime import datetime from typing import Optional, Union -import ormar as orm import pydantic import pytest +import ormar as orm from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_exclude_include_dict/test_dumping_model_to_dict.py b/tests/test_exclude_include_dict/test_dumping_model_to_dict.py index e4cf6f6ab..d53b7ba78 100644 --- a/tests/test_exclude_include_dict/test_dumping_model_to_dict.py +++ b/tests/test_exclude_include_dict/test_dumping_model_to_dict.py @@ -1,8 +1,8 @@ from typing import Optional -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_exclude_include_dict/test_excludable_items.py b/tests/test_exclude_include_dict/test_excludable_items.py index 044d86a5f..30593dcb9 100644 --- a/tests/test_exclude_include_dict/test_excludable_items.py +++ b/tests/test_exclude_include_dict/test_excludable_items.py @@ -2,7 +2,6 @@ import ormar from ormar.models.excludable import ExcludableItems - from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_exclude_include_dict/test_excluding_fields_in_fastapi.py b/tests/test_exclude_include_dict/test_excluding_fields_in_fastapi.py index e13fba6f6..e88eb6db2 100644 --- a/tests/test_exclude_include_dict/test_excluding_fields_in_fastapi.py +++ b/tests/test_exclude_include_dict/test_excluding_fields_in_fastapi.py @@ -3,16 +3,16 @@ import string from typing import Optional -import ormar import pydantic import pytest import sqlalchemy from asgi_lifespan import LifespanManager from fastapi import FastAPI from httpx import ASGITransport, AsyncClient -from ormar import post_save from pydantic import ConfigDict, computed_field +import ormar +from ormar import post_save from tests.lifespan import init_tests, lifespan from tests.settings import create_config diff --git a/tests/test_exclude_include_dict/test_excluding_fields_with_default.py b/tests/test_exclude_include_dict/test_excluding_fields_with_default.py index 6fe2c1a57..8ebe360ad 100644 --- a/tests/test_exclude_include_dict/test_excluding_fields_with_default.py +++ b/tests/test_exclude_include_dict/test_excluding_fields_with_default.py @@ -1,9 +1,9 @@ import random from typing import Optional -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_exclude_include_dict/test_excluding_subset_of_columns.py b/tests/test_exclude_include_dict/test_excluding_subset_of_columns.py index 8940d071d..a9f043f29 100644 --- a/tests/test_exclude_include_dict/test_excluding_subset_of_columns.py +++ b/tests/test_exclude_include_dict/test_excluding_subset_of_columns.py @@ -1,9 +1,9 @@ from typing import Optional -import ormar import pydantic import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config @@ -161,9 +161,11 @@ async def test_selecting_subset(): with pytest.raises(pydantic.ValidationError): # cannot exclude mandatory model columns - company__name in this example - await Car.objects.select_related("manufacturer").exclude_fields( - ["manufacturer__name"] - ).all() + await ( + Car.objects.select_related("manufacturer") + .exclude_fields(["manufacturer__name"]) + .all() + ) @pytest.mark.asyncio diff --git a/tests/test_exclude_include_dict/test_pydantic_dict_params.py b/tests/test_exclude_include_dict/test_pydantic_dict_params.py index 8df38c313..3fd1376d5 100644 --- a/tests/test_exclude_include_dict/test_pydantic_dict_params.py +++ b/tests/test_exclude_include_dict/test_pydantic_dict_params.py @@ -1,8 +1,8 @@ from typing import Optional -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_fastapi/test_binary_fields.py b/tests/test_fastapi/test_binary_fields.py index cb553aca1..6a97823a3 100644 --- a/tests/test_fastapi/test_binary_fields.py +++ b/tests/test_fastapi/test_binary_fields.py @@ -2,12 +2,12 @@ import uuid from enum import Enum -import ormar import pytest from asgi_lifespan import LifespanManager from fastapi import FastAPI from httpx import ASGITransport, AsyncClient +import ormar from tests.lifespan import init_tests, lifespan from tests.settings import create_config diff --git a/tests/test_fastapi/test_docs_with_multiple_relations_to_one.py b/tests/test_fastapi/test_docs_with_multiple_relations_to_one.py index 0cdd0fe9e..9aa43b58f 100644 --- a/tests/test_fastapi/test_docs_with_multiple_relations_to_one.py +++ b/tests/test_fastapi/test_docs_with_multiple_relations_to_one.py @@ -1,12 +1,12 @@ from typing import Optional from uuid import UUID, uuid4 -import ormar import pytest from asgi_lifespan import LifespanManager from fastapi import FastAPI from httpx import ASGITransport, AsyncClient +import ormar from tests.lifespan import init_tests, lifespan from tests.settings import create_config diff --git a/tests/test_fastapi/test_enum_schema.py b/tests/test_fastapi/test_enum_schema.py index da1f7c027..011bc17cd 100644 --- a/tests/test_fastapi/test_enum_schema.py +++ b/tests/test_fastapi/test_enum_schema.py @@ -1,7 +1,6 @@ from enum import Enum import ormar - from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_fastapi/test_excludes_with_get_pydantic.py b/tests/test_fastapi/test_excludes_with_get_pydantic.py index cbd20976c..6b0948393 100644 --- a/tests/test_fastapi/test_excludes_with_get_pydantic.py +++ b/tests/test_fastapi/test_excludes_with_get_pydantic.py @@ -1,11 +1,11 @@ from typing import ForwardRef, Optional -import ormar import pytest from asgi_lifespan import LifespanManager from fastapi import FastAPI from httpx import ASGITransport, AsyncClient +import ormar from tests.lifespan import init_tests, lifespan from tests.settings import create_config diff --git a/tests/test_fastapi/test_excluding_fields.py b/tests/test_fastapi/test_excluding_fields.py index 89228b900..d8a186165 100644 --- a/tests/test_fastapi/test_excluding_fields.py +++ b/tests/test_fastapi/test_excluding_fields.py @@ -1,9 +1,9 @@ -import ormar import pytest from asgi_lifespan import LifespanManager from fastapi import FastAPI from httpx import ASGITransport, AsyncClient +import ormar from tests.lifespan import init_tests, lifespan from tests.settings import create_config diff --git a/tests/test_fastapi/test_extra_ignore_parameter.py b/tests/test_fastapi/test_extra_ignore_parameter.py index bcfc63366..8bea3392b 100644 --- a/tests/test_fastapi/test_extra_ignore_parameter.py +++ b/tests/test_fastapi/test_extra_ignore_parameter.py @@ -1,10 +1,10 @@ -import ormar import pytest from asgi_lifespan import LifespanManager from fastapi import FastAPI from httpx import ASGITransport, AsyncClient -from ormar import Extra +import ormar +from ormar import Extra from tests.lifespan import init_tests, lifespan from tests.settings import create_config diff --git a/tests/test_fastapi/test_fastapi_docs.py b/tests/test_fastapi/test_fastapi_docs.py index ce0f36de3..be38241f0 100644 --- a/tests/test_fastapi/test_fastapi_docs.py +++ b/tests/test_fastapi/test_fastapi_docs.py @@ -1,7 +1,6 @@ import datetime from typing import Optional, Union -import ormar import pydantic import pytest from asgi_lifespan import LifespanManager @@ -9,6 +8,7 @@ from httpx import ASGITransport, AsyncClient from pydantic import Field +import ormar from tests.lifespan import init_tests, lifespan from tests.settings import create_config diff --git a/tests/test_fastapi/test_fastapi_usage.py b/tests/test_fastapi/test_fastapi_usage.py index 14d0f6f76..076f41604 100644 --- a/tests/test_fastapi/test_fastapi_usage.py +++ b/tests/test_fastapi/test_fastapi_usage.py @@ -1,11 +1,11 @@ from typing import Optional -import ormar import pytest from asgi_lifespan import LifespanManager from fastapi import FastAPI from httpx import ASGITransport, AsyncClient +import ormar from tests.lifespan import init_tests, lifespan from tests.settings import create_config diff --git a/tests/test_fastapi/test_inheritance_concrete_fastapi.py b/tests/test_fastapi/test_inheritance_concrete_fastapi.py index 857e11c8e..971e46dab 100644 --- a/tests/test_fastapi/test_inheritance_concrete_fastapi.py +++ b/tests/test_fastapi/test_inheritance_concrete_fastapi.py @@ -1,14 +1,14 @@ import datetime from typing import Optional -import ormar import pytest from asgi_lifespan import LifespanManager from fastapi import FastAPI from httpx import ASGITransport, AsyncClient -from ormar.relations.relation_proxy import RelationProxy from pydantic import computed_field +import ormar +from ormar.relations.relation_proxy import RelationProxy from tests.lifespan import init_tests, lifespan from tests.settings import create_config diff --git a/tests/test_fastapi/test_inheritance_mixins_fastapi.py b/tests/test_fastapi/test_inheritance_mixins_fastapi.py index 88614e0dc..40227b174 100644 --- a/tests/test_fastapi/test_inheritance_mixins_fastapi.py +++ b/tests/test_fastapi/test_inheritance_mixins_fastapi.py @@ -1,12 +1,12 @@ import datetime from typing import Optional -import ormar import pytest from asgi_lifespan import LifespanManager from fastapi import FastAPI from httpx import ASGITransport, AsyncClient +import ormar from tests.lifespan import init_tests, lifespan from tests.settings import create_config diff --git a/tests/test_fastapi/test_json_field_fastapi.py b/tests/test_fastapi/test_json_field_fastapi.py index 4c3b93e88..00bf148d8 100644 --- a/tests/test_fastapi/test_json_field_fastapi.py +++ b/tests/test_fastapi/test_json_field_fastapi.py @@ -2,13 +2,13 @@ import uuid from typing import Optional -import ormar import pydantic import pytest from asgi_lifespan import LifespanManager from fastapi import FastAPI from httpx import ASGITransport, AsyncClient +import ormar from tests.lifespan import init_tests, lifespan from tests.settings import create_config diff --git a/tests/test_fastapi/test_m2m_forwardref.py b/tests/test_fastapi/test_m2m_forwardref.py index 459eb10f7..54c6f95ce 100644 --- a/tests/test_fastapi/test_m2m_forwardref.py +++ b/tests/test_fastapi/test_m2m_forwardref.py @@ -1,12 +1,12 @@ from typing import ForwardRef, Optional -import ormar import pytest from asgi_lifespan import LifespanManager from fastapi import FastAPI from httpx import ASGITransport, AsyncClient from starlette import status +import ormar from tests.lifespan import init_tests, lifespan from tests.settings import create_config diff --git a/tests/test_fastapi/test_more_reallife_fastapi.py b/tests/test_fastapi/test_more_reallife_fastapi.py index 4c2c3adcf..e957319e7 100644 --- a/tests/test_fastapi/test_more_reallife_fastapi.py +++ b/tests/test_fastapi/test_more_reallife_fastapi.py @@ -1,11 +1,11 @@ from typing import Optional -import ormar import pytest from asgi_lifespan import LifespanManager from fastapi import FastAPI from httpx import ASGITransport, AsyncClient +import ormar from tests.lifespan import init_tests, lifespan from tests.settings import create_config diff --git a/tests/test_fastapi/test_nested_saving.py b/tests/test_fastapi/test_nested_saving.py index cbe1cd66a..43af631f6 100644 --- a/tests/test_fastapi/test_nested_saving.py +++ b/tests/test_fastapi/test_nested_saving.py @@ -1,12 +1,12 @@ from typing import Any, Optional, Union, cast -import ormar import pytest from asgi_lifespan import LifespanManager from fastapi import FastAPI from httpx import ASGITransport, AsyncClient -from ormar.queryset.utils import translate_list_to_dict +import ormar +from ormar.queryset.utils import translate_list_to_dict from tests.lifespan import init_tests, lifespan from tests.settings import create_config diff --git a/tests/test_fastapi/test_recursion_error.py b/tests/test_fastapi/test_recursion_error.py index e3e19cc96..1b997e733 100644 --- a/tests/test_fastapi/test_recursion_error.py +++ b/tests/test_fastapi/test_recursion_error.py @@ -2,13 +2,13 @@ from datetime import datetime from typing import Optional -import ormar import pytest from asgi_lifespan import LifespanManager from fastapi import Depends, FastAPI from httpx import ASGITransport, AsyncClient from pydantic import BaseModel, Json +import ormar from tests.lifespan import init_tests, lifespan from tests.settings import create_config diff --git a/tests/test_fastapi/test_relations_with_nested_defaults.py b/tests/test_fastapi/test_relations_with_nested_defaults.py index 7805d7fbc..6f0869ef3 100644 --- a/tests/test_fastapi/test_relations_with_nested_defaults.py +++ b/tests/test_fastapi/test_relations_with_nested_defaults.py @@ -1,12 +1,12 @@ from typing import Optional -import ormar import pytest import pytest_asyncio from asgi_lifespan import LifespanManager from fastapi import FastAPI from httpx import ASGITransport, AsyncClient +import ormar from tests.lifespan import init_tests, lifespan from tests.settings import create_config @@ -105,7 +105,7 @@ async def test_related_with_defaults(sample_data): { "author": {"id": 1}, "id": 1, - "title": "Bug caused by " "default value", + "title": "Bug caused by default value", "year": 2021, } ], diff --git a/tests/test_fastapi/test_schema_not_allowed_params.py b/tests/test_fastapi/test_schema_not_allowed_params.py index 5147f9128..59ea1ba61 100644 --- a/tests/test_fastapi/test_schema_not_allowed_params.py +++ b/tests/test_fastapi/test_schema_not_allowed_params.py @@ -1,5 +1,4 @@ import ormar - from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_fastapi/test_skip_reverse_models.py b/tests/test_fastapi/test_skip_reverse_models.py index 565d9b431..7c273e77a 100644 --- a/tests/test_fastapi/test_skip_reverse_models.py +++ b/tests/test_fastapi/test_skip_reverse_models.py @@ -1,11 +1,11 @@ from typing import Optional -import ormar import pytest from asgi_lifespan import LifespanManager from fastapi import FastAPI from httpx import ASGITransport, AsyncClient +import ormar from tests.lifespan import init_tests, lifespan from tests.settings import create_config diff --git a/tests/test_fastapi/test_wekref_exclusion.py b/tests/test_fastapi/test_wekref_exclusion.py index 411fffffc..200e9be40 100644 --- a/tests/test_fastapi/test_wekref_exclusion.py +++ b/tests/test_fastapi/test_wekref_exclusion.py @@ -1,13 +1,13 @@ from typing import Optional from uuid import UUID, uuid4 -import ormar import pydantic import pytest from asgi_lifespan import LifespanManager from fastapi import FastAPI from httpx import ASGITransport, AsyncClient +import ormar from tests.lifespan import init_tests, lifespan from tests.settings import create_config diff --git a/tests/test_inheritance_and_pydantic_generation/test_geting_pydantic_models.py b/tests/test_inheritance_and_pydantic_generation/test_geting_pydantic_models.py index 99e22212e..2bfb0fd0e 100644 --- a/tests/test_inheritance_and_pydantic_generation/test_geting_pydantic_models.py +++ b/tests/test_inheritance_and_pydantic_generation/test_geting_pydantic_models.py @@ -1,9 +1,9 @@ from typing import ForwardRef, Optional -import ormar import pydantic from pydantic_core import PydanticUndefined +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_inheritance_and_pydantic_generation/test_inheritance_concrete.py b/tests/test_inheritance_and_pydantic_generation/test_inheritance_concrete.py index 06085ab70..93427f146 100644 --- a/tests/test_inheritance_and_pydantic_generation/test_inheritance_concrete.py +++ b/tests/test_inheritance_and_pydantic_generation/test_inheritance_concrete.py @@ -2,17 +2,17 @@ from collections import Counter from typing import Optional -import ormar -import ormar.fields.constraints import pydantic import pytest import sqlalchemy as sa +from pydantic import computed_field + +import ormar +import ormar.fields.constraints from ormar import ModelDefinitionError from ormar.exceptions import ModelError from ormar.models.metaclass import get_constraint_copy from ormar.relations.relation_proxy import RelationProxy -from pydantic import computed_field - from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_inheritance_and_pydantic_generation/test_inheritance_mixins.py b/tests/test_inheritance_and_pydantic_generation/test_inheritance_mixins.py index 9e6a92da0..143b5c5e1 100644 --- a/tests/test_inheritance_and_pydantic_generation/test_inheritance_mixins.py +++ b/tests/test_inheritance_and_pydantic_generation/test_inheritance_mixins.py @@ -1,10 +1,10 @@ import datetime from typing import Optional -import ormar import pytest import sqlalchemy as sa +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_inheritance_and_pydantic_generation/test_inheritance_of_property_fields.py b/tests/test_inheritance_and_pydantic_generation/test_inheritance_of_property_fields.py index 6b87cef3f..1b96afbf2 100644 --- a/tests/test_inheritance_and_pydantic_generation/test_inheritance_of_property_fields.py +++ b/tests/test_inheritance_and_pydantic_generation/test_inheritance_of_property_fields.py @@ -1,6 +1,6 @@ -import ormar from pydantic import computed_field +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_inheritance_and_pydantic_generation/test_inheritance_with_default.py b/tests/test_inheritance_and_pydantic_generation/test_inheritance_with_default.py index bd93e79e0..28df0674a 100644 --- a/tests/test_inheritance_and_pydantic_generation/test_inheritance_with_default.py +++ b/tests/test_inheritance_and_pydantic_generation/test_inheritance_with_default.py @@ -1,9 +1,9 @@ import datetime import uuid -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_inheritance_and_pydantic_generation/test_inherited_class_is_not_abstract_by_default.py b/tests/test_inheritance_and_pydantic_generation/test_inherited_class_is_not_abstract_by_default.py index d6757ac33..eec1ed16f 100644 --- a/tests/test_inheritance_and_pydantic_generation/test_inherited_class_is_not_abstract_by_default.py +++ b/tests/test_inheritance_and_pydantic_generation/test_inherited_class_is_not_abstract_by_default.py @@ -1,9 +1,9 @@ import datetime from typing import Optional -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_inheritance_and_pydantic_generation/test_nested_models_pydantic.py b/tests/test_inheritance_and_pydantic_generation/test_nested_models_pydantic.py index b73698f70..ff781b83f 100644 --- a/tests/test_inheritance_and_pydantic_generation/test_nested_models_pydantic.py +++ b/tests/test_inheritance_and_pydantic_generation/test_nested_models_pydantic.py @@ -1,5 +1,4 @@ import ormar - from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_inheritance_and_pydantic_generation/test_pydantic_fields_order.py b/tests/test_inheritance_and_pydantic_generation/test_pydantic_fields_order.py index 58bf96c94..f4ed0482c 100644 --- a/tests/test_inheritance_and_pydantic_generation/test_pydantic_fields_order.py +++ b/tests/test_inheritance_and_pydantic_generation/test_pydantic_fields_order.py @@ -1,5 +1,4 @@ import ormar - from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_inheritance_and_pydantic_generation/test_validators_are_inherited.py b/tests/test_inheritance_and_pydantic_generation/test_validators_are_inherited.py index e6f1b5e7d..b7ff51cfd 100644 --- a/tests/test_inheritance_and_pydantic_generation/test_validators_are_inherited.py +++ b/tests/test_inheritance_and_pydantic_generation/test_validators_are_inherited.py @@ -1,9 +1,9 @@ import enum -import ormar import pytest from pydantic import ValidationError, field_validator +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_inheritance_and_pydantic_generation/test_validators_in_generated_pydantic.py b/tests/test_inheritance_and_pydantic_generation/test_validators_in_generated_pydantic.py index b8fce0dd3..85532e11a 100644 --- a/tests/test_inheritance_and_pydantic_generation/test_validators_in_generated_pydantic.py +++ b/tests/test_inheritance_and_pydantic_generation/test_validators_in_generated_pydantic.py @@ -1,9 +1,9 @@ import enum -import ormar import pytest from pydantic import ValidationError, field_validator +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_meta_constraints/test_check_constraints.py b/tests/test_meta_constraints/test_check_constraints.py index 02a6ca34a..eb108728c 100644 --- a/tests/test_meta_constraints/test_check_constraints.py +++ b/tests/test_meta_constraints/test_check_constraints.py @@ -1,7 +1,7 @@ -import ormar.fields.constraints import pytest import sqlalchemy +import ormar.fields.constraints from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_meta_constraints/test_index_constraints.py b/tests/test_meta_constraints/test_index_constraints.py index e3a21908a..d54e52d17 100644 --- a/tests/test_meta_constraints/test_index_constraints.py +++ b/tests/test_meta_constraints/test_index_constraints.py @@ -1,6 +1,6 @@ -import ormar.fields.constraints import pytest +import ormar.fields.constraints from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_meta_constraints/test_unique_constraints.py b/tests/test_meta_constraints/test_unique_constraints.py index 94ba8ef47..1c386ed28 100644 --- a/tests/test_meta_constraints/test_unique_constraints.py +++ b/tests/test_meta_constraints/test_unique_constraints.py @@ -1,7 +1,7 @@ -import ormar.fields.constraints import pytest import sqlalchemy +import ormar.fields.constraints from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_definition/pks_and_fks/test_non_integer_pkey.py b/tests/test_model_definition/pks_and_fks/test_non_integer_pkey.py index 9512caefb..0f2730bd2 100644 --- a/tests/test_model_definition/pks_and_fks/test_non_integer_pkey.py +++ b/tests/test_model_definition/pks_and_fks/test_non_integer_pkey.py @@ -1,10 +1,10 @@ import random -import ormar import pytest import sqlalchemy -from ormar.databases.connection import DatabaseConnection +import ormar +from ormar.databases.connection import DatabaseConnection from tests.settings import ASYNC_DATABASE_URL, DATABASE_URL database = DatabaseConnection(ASYNC_DATABASE_URL) diff --git a/tests/test_model_definition/pks_and_fks/test_saving_string_pks.py b/tests/test_model_definition/pks_and_fks/test_saving_string_pks.py index ad7b3df1b..76e7b144b 100644 --- a/tests/test_model_definition/pks_and_fks/test_saving_string_pks.py +++ b/tests/test_model_definition/pks_and_fks/test_saving_string_pks.py @@ -1,14 +1,14 @@ from random import choice from string import ascii_uppercase -import ormar import pytest import pytest_asyncio import sqlalchemy -from ormar import Float, String -from ormar.databases.connection import DatabaseConnection from sqlalchemy import create_engine +import ormar +from ormar import Float, String +from ormar.databases.connection import DatabaseConnection from tests.settings import ASYNC_DATABASE_URL, DATABASE_URL database = DatabaseConnection(ASYNC_DATABASE_URL) diff --git a/tests/test_model_definition/pks_and_fks/test_uuid_fks.py b/tests/test_model_definition/pks_and_fks/test_uuid_fks.py index a573ffcd0..56a7dcc4a 100644 --- a/tests/test_model_definition/pks_and_fks/test_uuid_fks.py +++ b/tests/test_model_definition/pks_and_fks/test_uuid_fks.py @@ -1,11 +1,11 @@ import uuid -import ormar import pytest import sqlalchemy -from ormar.databases.connection import DatabaseConnection from sqlalchemy import create_engine +import ormar +from ormar.databases.connection import DatabaseConnection from tests.settings import ASYNC_DATABASE_URL, DATABASE_URL metadata = sqlalchemy.MetaData() diff --git a/tests/test_model_definition/test_aliases.py b/tests/test_model_definition/test_aliases.py index 2f119ff3e..c1648292a 100644 --- a/tests/test_model_definition/test_aliases.py +++ b/tests/test_model_definition/test_aliases.py @@ -1,8 +1,8 @@ from typing import Optional -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_definition/test_columns.py b/tests/test_model_definition/test_columns.py index 58ba55311..5a30f582b 100644 --- a/tests/test_model_definition/test_columns.py +++ b/tests/test_model_definition/test_columns.py @@ -2,11 +2,11 @@ from enum import Enum from typing import Optional -import ormar import pydantic import pytest -from ormar import ModelDefinitionError +import ormar +from ormar import ModelDefinitionError from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_definition/test_create_uses_init_for_consistency.py b/tests/test_model_definition/test_create_uses_init_for_consistency.py index 80cd7729f..1806c6ee1 100644 --- a/tests/test_model_definition/test_create_uses_init_for_consistency.py +++ b/tests/test_model_definition/test_create_uses_init_for_consistency.py @@ -1,10 +1,10 @@ import uuid from typing import ClassVar -import ormar import pytest from pydantic import model_validator +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_definition/test_dates_with_timezone.py b/tests/test_model_definition/test_dates_with_timezone.py index 42917ecee..3f187ffe2 100644 --- a/tests/test_model_definition/test_dates_with_timezone.py +++ b/tests/test_model_definition/test_dates_with_timezone.py @@ -1,8 +1,8 @@ from datetime import date, datetime, time, timedelta, timezone -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_definition/test_equality_and_hash.py b/tests/test_model_definition/test_equality_and_hash.py index f5b3cd335..48725999a 100644 --- a/tests/test_model_definition/test_equality_and_hash.py +++ b/tests/test_model_definition/test_equality_and_hash.py @@ -1,7 +1,7 @@ # type: ignore -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_definition/test_extra_ignore_parameter.py b/tests/test_model_definition/test_extra_ignore_parameter.py index 733faf2b4..eed4df2b5 100644 --- a/tests/test_model_definition/test_extra_ignore_parameter.py +++ b/tests/test_model_definition/test_extra_ignore_parameter.py @@ -1,6 +1,5 @@ import ormar from ormar import Extra - from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_definition/test_field_quoting.py b/tests/test_model_definition/test_field_quoting.py index c903334fb..52606d955 100644 --- a/tests/test_model_definition/test_field_quoting.py +++ b/tests/test_model_definition/test_field_quoting.py @@ -1,8 +1,8 @@ from typing import Optional -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_definition/test_fields_access.py b/tests/test_model_definition/test_fields_access.py index bfcc52f8b..4b63f31ee 100644 --- a/tests/test_model_definition/test_fields_access.py +++ b/tests/test_model_definition/test_fields_access.py @@ -1,7 +1,7 @@ -import ormar import pytest -from ormar import BaseField +import ormar +from ormar import BaseField from tests.lifespan import init_tests from tests.settings import create_config @@ -135,7 +135,7 @@ def test_combining_groups_together(): assert len(group._nested_groups) == 2 assert str( group.get_text_clause().compile(compile_kwargs={"literal_binds": True}) - ) == ("NOT ((product.name = 'Test') AND" " (product.rating >= 3.0))") + ) == ("NOT ((product.name = 'Test') AND (product.rating >= 3.0))") group = ((Product.name == "Test") & (Product.rating >= 3.0)) | ( Product.category.name << (["Toys", "Books"]) diff --git a/tests/test_model_definition/test_foreign_key_value_used_for_related_model.py b/tests/test_model_definition/test_foreign_key_value_used_for_related_model.py index 6f0e9b7b4..21976d805 100644 --- a/tests/test_model_definition/test_foreign_key_value_used_for_related_model.py +++ b/tests/test_model_definition/test_foreign_key_value_used_for_related_model.py @@ -1,9 +1,9 @@ import uuid from typing import Optional -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_definition/test_iterate.py b/tests/test_model_definition/test_iterate.py index 31e64ffd9..c6b806270 100644 --- a/tests/test_model_definition/test_iterate.py +++ b/tests/test_model_definition/test_iterate.py @@ -1,9 +1,9 @@ import uuid -import ormar import pytest -from ormar.exceptions import QueryDefinitionError +import ormar +from ormar.exceptions import QueryDefinitionError from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_definition/test_json_fields.py b/tests/test_model_definition/test_json_fields.py index 49c6a19f3..9a38e50f3 100644 --- a/tests/test_model_definition/test_json_fields.py +++ b/tests/test_model_definition/test_json_fields.py @@ -1,6 +1,6 @@ -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_definition/test_model_construct.py b/tests/test_model_definition/test_model_construct.py index 4ccd96913..de4facf73 100644 --- a/tests/test_model_definition/test_model_construct.py +++ b/tests/test_model_definition/test_model_construct.py @@ -1,8 +1,8 @@ from typing import Optional -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_definition/test_model_definition.py b/tests/test_model_definition/test_model_definition.py index 9056d0ec6..e6edc2c91 100644 --- a/tests/test_model_definition/test_model_definition.py +++ b/tests/test_model_definition/test_model_definition.py @@ -3,13 +3,13 @@ import decimal import typing -import ormar import pydantic import pytest import sqlalchemy + +import ormar from ormar.exceptions import ModelDefinitionError from ormar.models import Model - from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_definition/test_models.py b/tests/test_model_definition/test_models.py index d994e5cc7..e754f39a9 100644 --- a/tests/test_model_definition/test_models.py +++ b/tests/test_model_definition/test_models.py @@ -6,12 +6,12 @@ from enum import Enum from typing import Optional -import ormar import pydantic import pytest import sqlalchemy -from ormar.exceptions import ModelError, NoMatch, QueryDefinitionError +import ormar +from ormar.exceptions import ModelError, NoMatch, QueryDefinitionError from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_definition/test_models_are_pickable.py b/tests/test_model_definition/test_models_are_pickable.py index 4ce741548..26d00216c 100644 --- a/tests/test_model_definition/test_models_are_pickable.py +++ b/tests/test_model_definition/test_models_are_pickable.py @@ -1,9 +1,9 @@ import pickle from typing import Optional -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_definition/test_overwriting_pydantic_field_type.py b/tests/test_model_definition/test_overwriting_pydantic_field_type.py index d170c6e7f..a2aad6f1b 100644 --- a/tests/test_model_definition/test_overwriting_pydantic_field_type.py +++ b/tests/test_model_definition/test_overwriting_pydantic_field_type.py @@ -1,10 +1,10 @@ from typing import Optional -import ormar import pydantic import pytest from pydantic import Json, PositiveInt, ValidationError +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_definition/test_overwriting_sql_nullable.py b/tests/test_model_definition/test_overwriting_sql_nullable.py index 27c8c5fee..9473fa89e 100644 --- a/tests/test_model_definition/test_overwriting_sql_nullable.py +++ b/tests/test_model_definition/test_overwriting_sql_nullable.py @@ -1,10 +1,10 @@ from typing import Optional -import ormar import pytest import sqlalchemy from sqlalchemy import text +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_definition/test_pk_field_is_always_not_null.py b/tests/test_model_definition/test_pk_field_is_always_not_null.py index 5d9c5e408..dcfb48a02 100644 --- a/tests/test_model_definition/test_pk_field_is_always_not_null.py +++ b/tests/test_model_definition/test_pk_field_is_always_not_null.py @@ -1,7 +1,6 @@ from typing import Optional import ormar - from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_definition/test_properties.py b/tests/test_model_definition/test_properties.py index 863f09387..c403101d7 100644 --- a/tests/test_model_definition/test_properties.py +++ b/tests/test_model_definition/test_properties.py @@ -1,8 +1,8 @@ # type: ignore -import ormar import pytest from pydantic import PydanticUserError, computed_field +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_definition/test_pydantic_fields.py b/tests/test_model_definition/test_pydantic_fields.py index 8fec91c35..a40ec0108 100644 --- a/tests/test_model_definition/test_pydantic_fields.py +++ b/tests/test_model_definition/test_pydantic_fields.py @@ -1,11 +1,11 @@ import random from typing import Optional -import ormar import pytest from pydantic import BaseModel, Field, HttpUrl from pydantic_extra_types.payment import PaymentCardNumber +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_definition/test_pydantic_only_fields.py b/tests/test_model_definition/test_pydantic_only_fields.py index 9dffa5a27..617287665 100644 --- a/tests/test_model_definition/test_pydantic_only_fields.py +++ b/tests/test_model_definition/test_pydantic_only_fields.py @@ -1,10 +1,10 @@ import datetime -import ormar import pydantic import pytest from pydantic import computed_field +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_definition/test_pydantic_private_attributes.py b/tests/test_model_definition/test_pydantic_private_attributes.py index 3ee1d26b4..a95dfb6a8 100644 --- a/tests/test_model_definition/test_pydantic_private_attributes.py +++ b/tests/test_model_definition/test_pydantic_private_attributes.py @@ -1,6 +1,6 @@ -import ormar from pydantic import PrivateAttr +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_definition/test_save_status.py b/tests/test_model_definition/test_save_status.py index 652bb7e19..4bc49bd53 100644 --- a/tests/test_model_definition/test_save_status.py +++ b/tests/test_model_definition/test_save_status.py @@ -1,9 +1,9 @@ from typing import Optional -import ormar import pytest -from ormar.exceptions import ModelPersistenceError +import ormar +from ormar.exceptions import ModelPersistenceError from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_definition/test_saving_nullable_fields.py b/tests/test_model_definition/test_saving_nullable_fields.py index 456781405..1c1220ac6 100644 --- a/tests/test_model_definition/test_saving_nullable_fields.py +++ b/tests/test_model_definition/test_saving_nullable_fields.py @@ -1,8 +1,8 @@ from typing import Optional -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_definition/test_server_default.py b/tests/test_model_definition/test_server_default.py index a181d7905..125dcf33d 100644 --- a/tests/test_model_definition/test_server_default.py +++ b/tests/test_model_definition/test_server_default.py @@ -1,10 +1,10 @@ import time from datetime import datetime -import ormar import pytest from sqlalchemy import func, text +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_definition/test_setting_comments_in_db.py b/tests/test_model_definition/test_setting_comments_in_db.py index 30bc33693..8f91fac96 100644 --- a/tests/test_model_definition/test_setting_comments_in_db.py +++ b/tests/test_model_definition/test_setting_comments_in_db.py @@ -1,7 +1,7 @@ -import ormar import pytest -from ormar.models import Model +import ormar +from ormar.models import Model from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_definition/test_through_model_relation_setup_on_clone.py b/tests/test_model_definition/test_through_model_relation_setup_on_clone.py index c075f7202..5aaed1631 100644 --- a/tests/test_model_definition/test_through_model_relation_setup_on_clone.py +++ b/tests/test_model_definition/test_through_model_relation_setup_on_clone.py @@ -1,6 +1,6 @@ -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_methods/test_excludes_in_load_all.py b/tests/test_model_methods/test_excludes_in_load_all.py index 6b9b08744..d5f32916d 100644 --- a/tests/test_model_methods/test_excludes_in_load_all.py +++ b/tests/test_model_methods/test_excludes_in_load_all.py @@ -1,8 +1,8 @@ import uuid -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_methods/test_load_all.py b/tests/test_model_methods/test_load_all.py index cfceb58d1..dfaa36af9 100644 --- a/tests/test_model_methods/test_load_all.py +++ b/tests/test_model_methods/test_load_all.py @@ -1,8 +1,8 @@ from typing import Optional -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_methods/test_populate_default_values.py b/tests/test_model_methods/test_populate_default_values.py index 8675f6794..cc5d7c82b 100644 --- a/tests/test_model_methods/test_populate_default_values.py +++ b/tests/test_model_methods/test_populate_default_values.py @@ -1,6 +1,6 @@ -import ormar from sqlalchemy import text +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_methods/test_save_related.py b/tests/test_model_methods/test_save_related.py index d9cc47914..c8300f626 100644 --- a/tests/test_model_methods/test_save_related.py +++ b/tests/test_model_methods/test_save_related.py @@ -1,8 +1,8 @@ from typing import Optional -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_methods/test_save_related_from_dict.py b/tests/test_model_methods/test_save_related_from_dict.py index 31c218ddb..3339e1dfd 100644 --- a/tests/test_model_methods/test_save_related_from_dict.py +++ b/tests/test_model_methods/test_save_related_from_dict.py @@ -1,8 +1,8 @@ from typing import Optional -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_methods/test_save_related_pk_only.py b/tests/test_model_methods/test_save_related_pk_only.py index 426c1cef6..92f0e80b8 100644 --- a/tests/test_model_methods/test_save_related_pk_only.py +++ b/tests/test_model_methods/test_save_related_pk_only.py @@ -1,6 +1,6 @@ -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_methods/test_save_related_uuid.py b/tests/test_model_methods/test_save_related_uuid.py index 5b425c680..c8f1b0037 100644 --- a/tests/test_model_methods/test_save_related_uuid.py +++ b/tests/test_model_methods/test_save_related_uuid.py @@ -1,9 +1,9 @@ import uuid from typing import Optional -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_methods/test_update.py b/tests/test_model_methods/test_update.py index f2cbd3398..fef903121 100644 --- a/tests/test_model_methods/test_update.py +++ b/tests/test_model_methods/test_update.py @@ -1,8 +1,8 @@ from typing import Optional -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_model_methods/test_upsert.py b/tests/test_model_methods/test_upsert.py index 249054ce5..4b50115f7 100644 --- a/tests/test_model_methods/test_upsert.py +++ b/tests/test_model_methods/test_upsert.py @@ -1,8 +1,8 @@ from typing import Optional -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_ordering/test_default_model_order.py b/tests/test_ordering/test_default_model_order.py index f74ff4817..344b0839d 100644 --- a/tests/test_ordering/test_default_model_order.py +++ b/tests/test_ordering/test_default_model_order.py @@ -1,9 +1,9 @@ from typing import Optional -import ormar import pytest import pytest_asyncio +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_ordering/test_default_relation_order.py b/tests/test_ordering/test_default_relation_order.py index a28d7f923..31984eea3 100644 --- a/tests/test_ordering/test_default_relation_order.py +++ b/tests/test_ordering/test_default_relation_order.py @@ -1,10 +1,10 @@ from typing import Optional from uuid import UUID, uuid4 -import ormar import pytest import pytest_asyncio +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_ordering/test_default_through_relation_order.py b/tests/test_ordering/test_default_through_relation_order.py index 0833bd30d..02a06f9d3 100644 --- a/tests/test_ordering/test_default_through_relation_order.py +++ b/tests/test_ordering/test_default_through_relation_order.py @@ -1,8 +1,9 @@ from typing import Any, Optional, cast from uuid import UUID, uuid4 -import ormar import pytest + +import ormar from ormar import ( Model, ModelDefinitionError, @@ -11,7 +12,6 @@ pre_save, pre_update, ) - from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_ordering/test_proper_order_of_sorting_apply.py b/tests/test_ordering/test_proper_order_of_sorting_apply.py index 4e6a83137..9fee6f8cb 100644 --- a/tests/test_ordering/test_proper_order_of_sorting_apply.py +++ b/tests/test_ordering/test_proper_order_of_sorting_apply.py @@ -1,9 +1,9 @@ from typing import Optional -import ormar import pytest import pytest_asyncio +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_queries/test_adding_related.py b/tests/test_queries/test_adding_related.py index 84a3f226b..6ab3b1ec0 100644 --- a/tests/test_queries/test_adding_related.py +++ b/tests/test_queries/test_adding_related.py @@ -1,8 +1,8 @@ from typing import Optional -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_queries/test_aggr_functions.py b/tests/test_queries/test_aggr_functions.py index f6b1963a6..accd36cdc 100644 --- a/tests/test_queries/test_aggr_functions.py +++ b/tests/test_queries/test_aggr_functions.py @@ -1,10 +1,10 @@ from typing import Optional -import ormar import pytest import pytest_asyncio -from ormar.exceptions import QueryDefinitionError +import ormar +from ormar.exceptions import QueryDefinitionError from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_queries/test_deep_relations_select_all.py b/tests/test_queries/test_deep_relations_select_all.py index 8e8eabc61..3b71cfad4 100644 --- a/tests/test_queries/test_deep_relations_select_all.py +++ b/tests/test_queries/test_deep_relations_select_all.py @@ -1,7 +1,7 @@ -import ormar import pytest from sqlalchemy import func +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_queries/test_filter_groups.py b/tests/test_queries/test_filter_groups.py index fe416c6f6..5a154382c 100644 --- a/tests/test_queries/test_filter_groups.py +++ b/tests/test_queries/test_filter_groups.py @@ -1,7 +1,6 @@ from typing import Optional import ormar - from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_queries/test_indirect_relations_to_self.py b/tests/test_queries/test_indirect_relations_to_self.py index ca0e9a884..05f75e6fc 100644 --- a/tests/test_queries/test_indirect_relations_to_self.py +++ b/tests/test_queries/test_indirect_relations_to_self.py @@ -1,8 +1,8 @@ from datetime import datetime -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_queries/test_isnull_filter.py b/tests/test_queries/test_isnull_filter.py index 483943167..e3bdf06b3 100644 --- a/tests/test_queries/test_isnull_filter.py +++ b/tests/test_queries/test_isnull_filter.py @@ -1,8 +1,8 @@ from typing import Optional -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_queries/test_nested_reverse_relations.py b/tests/test_queries/test_nested_reverse_relations.py index 0c8069f4f..d9a074ea2 100644 --- a/tests/test_queries/test_nested_reverse_relations.py +++ b/tests/test_queries/test_nested_reverse_relations.py @@ -1,8 +1,8 @@ from typing import Optional -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_queries/test_non_relation_fields_not_merged.py b/tests/test_queries/test_non_relation_fields_not_merged.py index 84500cb78..02654d966 100644 --- a/tests/test_queries/test_non_relation_fields_not_merged.py +++ b/tests/test_queries/test_non_relation_fields_not_merged.py @@ -1,8 +1,8 @@ from typing import Optional -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_queries/test_or_filters.py b/tests/test_queries/test_or_filters.py index 838b168d7..366f78bf5 100644 --- a/tests/test_queries/test_or_filters.py +++ b/tests/test_queries/test_or_filters.py @@ -1,9 +1,9 @@ from typing import Optional -import ormar import pytest -from ormar.exceptions import QueryDefinitionError +import ormar +from ormar.exceptions import QueryDefinitionError from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_queries/test_order_by.py b/tests/test_queries/test_order_by.py index a7ffa9cb6..924f47379 100644 --- a/tests/test_queries/test_order_by.py +++ b/tests/test_queries/test_order_by.py @@ -1,8 +1,8 @@ from typing import Optional -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_queries/test_pagination.py b/tests/test_queries/test_pagination.py index 790945b28..b72031f5b 100644 --- a/tests/test_queries/test_pagination.py +++ b/tests/test_queries/test_pagination.py @@ -1,7 +1,7 @@ -import ormar import pytest -from ormar.exceptions import QueryDefinitionError +import ormar +from ormar.exceptions import QueryDefinitionError from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_queries/test_queryproxy_on_m2m_models.py b/tests/test_queries/test_queryproxy_on_m2m_models.py index d292fe242..b4ec39a64 100644 --- a/tests/test_queries/test_queryproxy_on_m2m_models.py +++ b/tests/test_queries/test_queryproxy_on_m2m_models.py @@ -1,9 +1,9 @@ from typing import Optional, Union -import ormar import pytest -from ormar.exceptions import QueryDefinitionError +import ormar +from ormar.exceptions import QueryDefinitionError from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_queries/test_queryset_level_methods.py b/tests/test_queries/test_queryset_level_methods.py index 5cb534904..b7cda2313 100644 --- a/tests/test_queries/test_queryset_level_methods.py +++ b/tests/test_queries/test_queryset_level_methods.py @@ -1,17 +1,17 @@ from enum import Enum from typing import Optional -import ormar import pydantic import pytest +from pydantic import Json + +import ormar from ormar import QuerySet from ormar.exceptions import ( ModelListEmptyError, ModelPersistenceError, QueryDefinitionError, ) -from pydantic import Json - from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_queries/test_quoting_table_names_in_on_join_clause.py b/tests/test_queries/test_quoting_table_names_in_on_join_clause.py index 53e7c708f..2a5be7dc6 100644 --- a/tests/test_queries/test_quoting_table_names_in_on_join_clause.py +++ b/tests/test_queries/test_quoting_table_names_in_on_join_clause.py @@ -2,9 +2,9 @@ import uuid from typing import Optional, Union -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_queries/test_reserved_sql_keywords_escaped.py b/tests/test_queries/test_reserved_sql_keywords_escaped.py index e82034381..37969739e 100644 --- a/tests/test_queries/test_reserved_sql_keywords_escaped.py +++ b/tests/test_queries/test_reserved_sql_keywords_escaped.py @@ -1,8 +1,8 @@ from typing import Optional -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_queries/test_reverse_fk_queryset.py b/tests/test_queries/test_reverse_fk_queryset.py index aaaf2614b..5847d2268 100644 --- a/tests/test_queries/test_reverse_fk_queryset.py +++ b/tests/test_queries/test_reverse_fk_queryset.py @@ -1,9 +1,9 @@ from typing import Optional -import ormar import pytest -from ormar import NoMatch +import ormar +from ormar import NoMatch from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_queries/test_selecting_subset_of_columns.py b/tests/test_queries/test_selecting_subset_of_columns.py index f78d98193..748335963 100644 --- a/tests/test_queries/test_selecting_subset_of_columns.py +++ b/tests/test_queries/test_selecting_subset_of_columns.py @@ -1,11 +1,11 @@ import itertools from typing import Optional -import ormar import pydantic import pytest import pytest_asyncio +import ormar from tests.lifespan import init_tests from tests.settings import create_config @@ -198,9 +198,11 @@ async def test_selecting_subset(): with pytest.raises(pydantic.ValidationError): # cannot exclude mandatory model columns - company__name in this example - await Car.objects.select_related("manufacturer").fields( - ["id", "name", "manufacturer__founded"] - ).all() + await ( + Car.objects.select_related("manufacturer") + .fields(["id", "name", "manufacturer__founded"]) + .all() + ) @pytest.mark.asyncio diff --git a/tests/test_queries/test_values_and_values_list.py b/tests/test_queries/test_values_and_values_list.py index 4983fcf07..95d9bfdb7 100644 --- a/tests/test_queries/test_values_and_values_list.py +++ b/tests/test_queries/test_values_and_values_list.py @@ -1,10 +1,10 @@ from typing import Optional -import ormar import pytest import pytest_asyncio -from ormar.exceptions import QueryDefinitionError +import ormar +from ormar.exceptions import QueryDefinitionError from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_relations/test_cascades.py b/tests/test_relations/test_cascades.py index 22c079aeb..f299f22f9 100644 --- a/tests/test_relations/test_cascades.py +++ b/tests/test_relations/test_cascades.py @@ -1,9 +1,9 @@ from typing import Optional -import ormar import pytest import pytest_asyncio +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_relations/test_customizing_through_model_relation_names.py b/tests/test_relations/test_customizing_through_model_relation_names.py index d75290623..b1308feb6 100644 --- a/tests/test_relations/test_customizing_through_model_relation_names.py +++ b/tests/test_relations/test_customizing_through_model_relation_names.py @@ -1,6 +1,6 @@ -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_relations/test_database_fk_creation.py b/tests/test_relations/test_database_fk_creation.py index 7d7033573..935321d17 100644 --- a/tests/test_relations/test_database_fk_creation.py +++ b/tests/test_relations/test_database_fk_creation.py @@ -1,10 +1,10 @@ from typing import Optional -import ormar import pytest import sqlalchemy -from ormar.fields.foreign_key import validate_referential_action +import ormar +from ormar.fields.foreign_key import validate_referential_action from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_relations/test_foreign_keys.py b/tests/test_relations/test_foreign_keys.py index 753118209..d98505ee6 100644 --- a/tests/test_relations/test_foreign_keys.py +++ b/tests/test_relations/test_foreign_keys.py @@ -1,9 +1,9 @@ from typing import Optional -import ormar import pytest -from ormar.exceptions import MultipleMatches, NoMatch, RelationshipInstanceError +import ormar +from ormar.exceptions import MultipleMatches, NoMatch, RelationshipInstanceError from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_relations/test_m2m_through_fields.py b/tests/test_relations/test_m2m_through_fields.py index ad49f64fe..998d83691 100644 --- a/tests/test_relations/test_m2m_through_fields.py +++ b/tests/test_relations/test_m2m_through_fields.py @@ -1,8 +1,8 @@ from typing import Any, ForwardRef, Optional -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_relations/test_many_to_many.py b/tests/test_relations/test_many_to_many.py index 902df2dfb..31cd82213 100644 --- a/tests/test_relations/test_many_to_many.py +++ b/tests/test_relations/test_many_to_many.py @@ -1,10 +1,10 @@ from typing import Optional -import ormar import pytest import pytest_asyncio -from ormar.exceptions import ModelPersistenceError, NoMatch, RelationshipInstanceError +import ormar +from ormar.exceptions import ModelPersistenceError, NoMatch, RelationshipInstanceError from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_relations/test_postgress_select_related_with_limit.py b/tests/test_relations/test_postgress_select_related_with_limit.py index 14ff84964..d2592a408 100644 --- a/tests/test_relations/test_postgress_select_related_with_limit.py +++ b/tests/test_relations/test_postgress_select_related_with_limit.py @@ -4,9 +4,9 @@ from enum import Enum from typing import Optional -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_relations/test_prefetch_related.py b/tests/test_relations/test_prefetch_related.py index 996ded70f..30b1736fb 100644 --- a/tests/test_relations/test_prefetch_related.py +++ b/tests/test_relations/test_prefetch_related.py @@ -1,8 +1,8 @@ from typing import Optional -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_relations/test_prefetch_related_multiple_models_relation.py b/tests/test_relations/test_prefetch_related_multiple_models_relation.py index 2e726f984..21c0d803e 100644 --- a/tests/test_relations/test_prefetch_related_multiple_models_relation.py +++ b/tests/test_relations/test_prefetch_related_multiple_models_relation.py @@ -1,8 +1,8 @@ from typing import Optional -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_relations/test_prefetch_related_with_same_models.py b/tests/test_relations/test_prefetch_related_with_same_models.py index cbec28a23..642fe1d9f 100644 --- a/tests/test_relations/test_prefetch_related_with_same_models.py +++ b/tests/test_relations/test_prefetch_related_with_same_models.py @@ -1,11 +1,11 @@ from random import randint from typing import ForwardRef, Optional -import ormar import pytest from faker import Faker -from ormar.relations.relation_proxy import RelationProxy +import ormar +from ormar.relations.relation_proxy import RelationProxy from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_relations/test_python_style_relations.py b/tests/test_relations/test_python_style_relations.py index c74bed52f..fc9b14fca 100644 --- a/tests/test_relations/test_python_style_relations.py +++ b/tests/test_relations/test_python_style_relations.py @@ -1,9 +1,9 @@ from typing import Optional -import ormar import pytest import pytest_asyncio +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_relations/test_relations_default_exception.py b/tests/test_relations/test_relations_default_exception.py index f7d71458b..e5af3dc94 100644 --- a/tests/test_relations/test_relations_default_exception.py +++ b/tests/test_relations/test_relations_default_exception.py @@ -1,10 +1,10 @@ # type: ignore from typing import Optional -import ormar import pytest -from ormar.exceptions import ModelDefinitionError +import ormar +from ormar.exceptions import ModelDefinitionError from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_relations/test_replacing_models_with_copy.py b/tests/test_relations/test_replacing_models_with_copy.py index 6464b1543..f97b61b24 100644 --- a/tests/test_relations/test_replacing_models_with_copy.py +++ b/tests/test_relations/test_replacing_models_with_copy.py @@ -1,8 +1,8 @@ from typing import Any, Optional, Union -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_relations/test_reverse_relation_preserves_validator.py b/tests/test_relations/test_reverse_relation_preserves_validator.py index 7e8ad8594..a1f774e62 100644 --- a/tests/test_relations/test_reverse_relation_preserves_validator.py +++ b/tests/test_relations/test_reverse_relation_preserves_validator.py @@ -1,9 +1,9 @@ from typing import Optional, Union -import ormar import pytest_asyncio from pydantic import field_validator +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_relations/test_saving_related.py b/tests/test_relations/test_saving_related.py index 24668b905..2c6cc57ba 100644 --- a/tests/test_relations/test_saving_related.py +++ b/tests/test_relations/test_saving_related.py @@ -1,9 +1,9 @@ from typing import Union -import ormar import pytest -from ormar.exceptions import ModelPersistenceError +import ormar +from ormar.exceptions import ModelPersistenceError from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_relations/test_select_related_with_limit.py b/tests/test_relations/test_select_related_with_limit.py index 333e3fe96..b4703ee7f 100644 --- a/tests/test_relations/test_select_related_with_limit.py +++ b/tests/test_relations/test_select_related_with_limit.py @@ -1,8 +1,8 @@ from typing import Optional -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_relations/test_select_related_with_m2m_and_pk_name_set.py b/tests/test_relations/test_select_related_with_m2m_and_pk_name_set.py index 99ef9db20..1837ffab3 100644 --- a/tests/test_relations/test_select_related_with_m2m_and_pk_name_set.py +++ b/tests/test_relations/test_select_related_with_m2m_and_pk_name_set.py @@ -2,11 +2,11 @@ from datetime import date from typing import Optional, Union -import ormar import pytest import sqlalchemy -from ormar import ModelDefinitionError +import ormar +from ormar import ModelDefinitionError from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_relations/test_selecting_proper_table_prefix.py b/tests/test_relations/test_selecting_proper_table_prefix.py index fbc8b735c..3a8543dbc 100644 --- a/tests/test_relations/test_selecting_proper_table_prefix.py +++ b/tests/test_relations/test_selecting_proper_table_prefix.py @@ -1,8 +1,8 @@ from typing import Optional -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_relations/test_skipping_reverse.py b/tests/test_relations/test_skipping_reverse.py index 30d46a671..4a7fd9b0b 100644 --- a/tests/test_relations/test_skipping_reverse.py +++ b/tests/test_relations/test_skipping_reverse.py @@ -1,9 +1,9 @@ from typing import Optional -import ormar import pytest import pytest_asyncio +import ormar from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_relations/test_through_relations_fail.py b/tests/test_relations/test_through_relations_fail.py index 16694485c..54ba61e83 100644 --- a/tests/test_relations/test_through_relations_fail.py +++ b/tests/test_relations/test_through_relations_fail.py @@ -1,10 +1,10 @@ from typing import Optional +import pytest + # type: ignore import ormar -import pytest from ormar import ModelDefinitionError - from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_relations/test_weakref_checking.py b/tests/test_relations/test_weakref_checking.py index 2af76200a..b7dbb3a2f 100644 --- a/tests/test_relations/test_weakref_checking.py +++ b/tests/test_relations/test_weakref_checking.py @@ -1,5 +1,4 @@ import ormar - from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_signals/test_signals.py b/tests/test_signals/test_signals.py index c5aacefd8..050e1d3b2 100644 --- a/tests/test_signals/test_signals.py +++ b/tests/test_signals/test_signals.py @@ -1,8 +1,9 @@ from typing import Optional -import ormar import pydantic import pytest + +import ormar from ormar import ( post_bulk_update, post_delete, @@ -14,7 +15,6 @@ ) from ormar.exceptions import SignalDefinitionError from ormar.signals import SignalEmitter - from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_signals/test_signals_for_relations.py b/tests/test_signals/test_signals_for_relations.py index 4b421ab54..c95871188 100644 --- a/tests/test_signals/test_signals_for_relations.py +++ b/tests/test_signals/test_signals_for_relations.py @@ -1,15 +1,15 @@ from typing import Optional -import ormar import pydantic import pytest + +import ormar from ormar import ( post_relation_add, post_relation_remove, pre_relation_add, pre_relation_remove, ) - from tests.lifespan import init_tests from tests.settings import create_config diff --git a/tests/test_types.py b/tests/test_types.py index 1523cf113..9cc9ce439 100644 --- a/tests/test_types.py +++ b/tests/test_types.py @@ -1,11 +1,11 @@ from typing import Optional -import ormar import pytest import sqlalchemy + +import ormar from ormar.databases.connection import DatabaseConnection from ormar.models.ormar_config import OrmarConfig - from tests.settings import ASYNC_DATABASE_URL, DATABASE_URL database = DatabaseConnection(ASYNC_DATABASE_URL) diff --git a/tests/test_utils/test_models_helpers.py b/tests/test_utils/test_models_helpers.py index 221869081..098d1c2ec 100644 --- a/tests/test_utils/test_models_helpers.py +++ b/tests/test_utils/test_models_helpers.py @@ -20,4 +20,3 @@ def test_group_related_list(): def test_replace_models_with_copy_returns_plain_type(): assert replace_models_with_copy(int) is int - diff --git a/tests/test_utils/test_queryset_utils.py b/tests/test_utils/test_queryset_utils.py index 6998a1ba8..bd71c7d2e 100644 --- a/tests/test_utils/test_queryset_utils.py +++ b/tests/test_utils/test_queryset_utils.py @@ -4,7 +4,6 @@ update, update_dict_from_list, ) - from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_vulnerabilities/test_aggregated_functions.py b/tests/test_vulnerabilities/test_aggregated_functions.py index 5c0f67d92..96a842340 100644 --- a/tests/test_vulnerabilities/test_aggregated_functions.py +++ b/tests/test_vulnerabilities/test_aggregated_functions.py @@ -1,8 +1,8 @@ from typing import Optional -import ormar import pytest +import ormar from tests.lifespan import init_tests from tests.settings import create_config