Bump dependencies (#874)
* fix pytest-asynio bump to 0.19 * bump mypy * fix coverage of async fixtures
This commit is contained in:
@ -11,7 +11,7 @@ repos:
|
|||||||
exclude: ^(docs_src/|examples/|tests/)
|
exclude: ^(docs_src/|examples/|tests/)
|
||||||
args: [ '--max-line-length=88' ]
|
args: [ '--max-line-length=88' ]
|
||||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||||
rev: v0.961
|
rev: v0.982
|
||||||
hooks:
|
hooks:
|
||||||
- id: mypy
|
- id: mypy
|
||||||
exclude: ^(docs_src/|examples/)
|
exclude: ^(docs_src/|examples/)
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import string
|
import string
|
||||||
import sys
|
|
||||||
import uuid
|
import uuid
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from random import choices
|
from random import choices
|
||||||
@ -15,24 +14,18 @@ from typing import (
|
|||||||
overload,
|
overload,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
import ormar # noqa I101
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
from ormar.exceptions import ModelDefinitionError, RelationshipInstanceError
|
||||||
|
from ormar.fields.base import BaseField
|
||||||
|
from ormar.fields.referential_actions import ReferentialAction
|
||||||
from pydantic import BaseModel, create_model
|
from pydantic import BaseModel, create_model
|
||||||
from pydantic.typing import ForwardRef, evaluate_forwardref
|
from pydantic.typing import ForwardRef, evaluate_forwardref
|
||||||
|
|
||||||
import ormar # noqa I101
|
|
||||||
from ormar.exceptions import ModelDefinitionError, RelationshipInstanceError
|
|
||||||
from ormar.fields.referential_actions import ReferentialAction
|
|
||||||
from ormar.fields.base import BaseField
|
|
||||||
|
|
||||||
if TYPE_CHECKING: # pragma no cover
|
if TYPE_CHECKING: # pragma no cover
|
||||||
from ormar.models import Model, NewBaseModel, T
|
from ormar.models import Model, NewBaseModel, T
|
||||||
from ormar.fields import ManyToManyField
|
from ormar.fields import ManyToManyField
|
||||||
|
|
||||||
if sys.version_info < (3, 7):
|
|
||||||
ToType = Type["T"]
|
|
||||||
else:
|
|
||||||
ToType = Union[Type["T"], "ForwardRef"]
|
|
||||||
|
|
||||||
|
|
||||||
def create_dummy_instance(fk: Type["T"], pk: Any = None) -> "T":
|
def create_dummy_instance(fk: Type["T"], pk: Any = None) -> "T":
|
||||||
"""
|
"""
|
||||||
@ -205,7 +198,7 @@ def ForeignKey(to: ForwardRef, **kwargs: Any) -> "Model": # pragma: no cover
|
|||||||
|
|
||||||
|
|
||||||
def ForeignKey( # type: ignore # noqa CFQ002
|
def ForeignKey( # type: ignore # noqa CFQ002
|
||||||
to: "ToType",
|
to: Union[Type["T"], "ForwardRef"],
|
||||||
*,
|
*,
|
||||||
name: str = None,
|
name: str = None,
|
||||||
unique: bool = False,
|
unique: bool = False,
|
||||||
|
|||||||
830
poetry.lock
generated
830
poetry.lock
generated
File diff suppressed because it is too large
Load Diff
@ -74,7 +74,7 @@ python = "<3.8"
|
|||||||
pytest = "^7.1.3"
|
pytest = "^7.1.3"
|
||||||
pytest-cov = "^4.0.0"
|
pytest-cov = "^4.0.0"
|
||||||
codecov = "^2.1.12"
|
codecov = "^2.1.12"
|
||||||
pytest-asyncio = "^0.18.3"
|
pytest-asyncio = "^0.19.0"
|
||||||
fastapi = ">=0.70.1,<0.86"
|
fastapi = ">=0.70.1,<0.86"
|
||||||
flake8 = "^3.9.2"
|
flake8 = "^3.9.2"
|
||||||
flake8-black = "^0.3.3"
|
flake8-black = "^0.3.3"
|
||||||
@ -88,7 +88,7 @@ flake8-functions = "^0.0.7"
|
|||||||
flake8-expression-complexity = "^0.0.11"
|
flake8-expression-complexity = "^0.0.11"
|
||||||
|
|
||||||
# types
|
# types
|
||||||
mypy = "^0.971"
|
mypy = "^0.982"
|
||||||
types-ujson = "^5.5.0"
|
types-ujson = "^5.5.0"
|
||||||
types-PyMySQL = "^1.0.19"
|
types-PyMySQL = "^1.0.19"
|
||||||
types-ipaddress = "^1.0.1"
|
types-ipaddress = "^1.0.1"
|
||||||
|
|||||||
@ -3,6 +3,7 @@ from typing import List
|
|||||||
|
|
||||||
import databases
|
import databases
|
||||||
import pytest
|
import pytest
|
||||||
|
import pytest_asyncio
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from pydantic.typing import ForwardRef
|
from pydantic.typing import ForwardRef
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
@ -77,7 +78,7 @@ def create_test_database():
|
|||||||
metadata.drop_all(engine)
|
metadata.drop_all(engine)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="function")
|
@pytest_asyncio.fixture(scope="function")
|
||||||
async def cleanup():
|
async def cleanup():
|
||||||
yield
|
yield
|
||||||
async with db:
|
async with db:
|
||||||
|
|||||||
@ -67,15 +67,8 @@ class Teacher(ormar.Model):
|
|||||||
category: Optional[Category] = ormar.ForeignKey(Category, nullable=True)
|
category: Optional[Category] = ormar.ForeignKey(Category, nullable=True)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
|
||||||
def event_loop():
|
|
||||||
loop = asyncio.get_event_loop()
|
|
||||||
yield loop
|
|
||||||
loop.close()
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True, scope="module")
|
@pytest.fixture(autouse=True, scope="module")
|
||||||
async def create_test_database():
|
def create_test_database():
|
||||||
engine = sqlalchemy.create_engine(DATABASE_URL)
|
engine = sqlalchemy.create_engine(DATABASE_URL)
|
||||||
metadata.drop_all(engine)
|
metadata.drop_all(engine)
|
||||||
metadata.create_all(engine)
|
metadata.create_all(engine)
|
||||||
|
|||||||
@ -67,15 +67,8 @@ class Teacher(ormar.Model):
|
|||||||
category: Optional[Category] = ormar.ForeignKey(Category, nullable=True)
|
category: Optional[Category] = ormar.ForeignKey(Category, nullable=True)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
|
||||||
def event_loop():
|
|
||||||
loop = asyncio.get_event_loop()
|
|
||||||
yield loop
|
|
||||||
loop.close()
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True, scope="module")
|
@pytest.fixture(autouse=True, scope="module")
|
||||||
async def create_test_database():
|
def create_test_database():
|
||||||
engine = sqlalchemy.create_engine(DATABASE_URL)
|
engine = sqlalchemy.create_engine(DATABASE_URL)
|
||||||
metadata.drop_all(engine)
|
metadata.drop_all(engine)
|
||||||
metadata.create_all(engine)
|
metadata.create_all(engine)
|
||||||
|
|||||||
@ -2,6 +2,7 @@ from typing import Optional
|
|||||||
|
|
||||||
import databases
|
import databases
|
||||||
import pytest
|
import pytest
|
||||||
|
import pytest_asyncio
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from starlette.testclient import TestClient
|
from starlette.testclient import TestClient
|
||||||
@ -71,7 +72,7 @@ def create_test_database():
|
|||||||
metadata.drop_all(engine)
|
metadata.drop_all(engine)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture()
|
@pytest_asyncio.fixture
|
||||||
async def sample_data():
|
async def sample_data():
|
||||||
async with database:
|
async with database:
|
||||||
country = await Country(id=1, name="USA").save()
|
country = await Country(id=1, name="USA").save()
|
||||||
|
|||||||
@ -3,6 +3,7 @@ from string import ascii_uppercase
|
|||||||
|
|
||||||
import databases
|
import databases
|
||||||
import pytest
|
import pytest
|
||||||
|
import pytest_asyncio
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
|
|
||||||
@ -51,7 +52,7 @@ def create_test_database():
|
|||||||
metadata.drop_all(engine)
|
metadata.drop_all(engine)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="function")
|
@pytest_asyncio.fixture(scope="function")
|
||||||
async def cleanup():
|
async def cleanup():
|
||||||
yield
|
yield
|
||||||
async with database:
|
async with database:
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import decimal
|
|||||||
import databases
|
import databases
|
||||||
import pydantic
|
import pydantic
|
||||||
import pytest
|
import pytest
|
||||||
|
import pytest_asyncio
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
import typing
|
import typing
|
||||||
|
|
||||||
@ -63,15 +64,8 @@ class ExampleModel2(Model):
|
|||||||
test_string: str = ormar.String(max_length=250)
|
test_string: str = ormar.String(max_length=250)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
|
||||||
def event_loop():
|
|
||||||
loop = asyncio.get_event_loop()
|
|
||||||
yield loop
|
|
||||||
loop.close()
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True, scope="module")
|
@pytest.fixture(autouse=True, scope="module")
|
||||||
async def create_test_database():
|
def create_test_database():
|
||||||
engine = sqlalchemy.create_engine(DATABASE_URL)
|
engine = sqlalchemy.create_engine(DATABASE_URL)
|
||||||
metadata.create_all(engine)
|
metadata.create_all(engine)
|
||||||
yield
|
yield
|
||||||
|
|||||||
@ -27,15 +27,8 @@ class Product(ormar.Model):
|
|||||||
created: datetime = ormar.DateTime(server_default=func.now())
|
created: datetime = ormar.DateTime(server_default=func.now())
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
|
||||||
def event_loop():
|
|
||||||
loop = asyncio.get_event_loop()
|
|
||||||
yield loop
|
|
||||||
loop.close()
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True, scope="module")
|
@pytest.fixture(autouse=True, scope="module")
|
||||||
async def create_test_database():
|
def create_test_database():
|
||||||
engine = sqlalchemy.create_engine(DATABASE_URL)
|
engine = sqlalchemy.create_engine(DATABASE_URL)
|
||||||
metadata.drop_all(engine)
|
metadata.drop_all(engine)
|
||||||
metadata.create_all(engine)
|
metadata.create_all(engine)
|
||||||
|
|||||||
@ -2,6 +2,7 @@ from typing import Optional
|
|||||||
|
|
||||||
import databases
|
import databases
|
||||||
import pytest
|
import pytest
|
||||||
|
import pytest_asyncio
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
|
||||||
import ormar
|
import ormar
|
||||||
@ -46,7 +47,7 @@ def create_test_database():
|
|||||||
metadata.drop_all(engine)
|
metadata.drop_all(engine)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True, scope="function")
|
@pytest_asyncio.fixture(autouse=True, scope="function")
|
||||||
async def cleanup():
|
async def cleanup():
|
||||||
yield
|
yield
|
||||||
async with database:
|
async with database:
|
||||||
|
|||||||
@ -3,6 +3,7 @@ from uuid import UUID, uuid4
|
|||||||
|
|
||||||
import databases
|
import databases
|
||||||
import pytest
|
import pytest
|
||||||
|
import pytest_asyncio
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
|
||||||
import ormar
|
import ormar
|
||||||
@ -70,7 +71,7 @@ def create_test_database():
|
|||||||
metadata.drop_all(engine)
|
metadata.drop_all(engine)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True, scope="function")
|
@pytest_asyncio.fixture(autouse=True, scope="function")
|
||||||
async def cleanup():
|
async def cleanup():
|
||||||
yield
|
yield
|
||||||
async with database:
|
async with database:
|
||||||
|
|||||||
@ -2,6 +2,7 @@ from typing import Optional
|
|||||||
|
|
||||||
import databases
|
import databases
|
||||||
import pytest
|
import pytest
|
||||||
|
import pytest_asyncio
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
|
||||||
import ormar
|
import ormar
|
||||||
@ -47,7 +48,7 @@ def create_test_database():
|
|||||||
metadata.drop_all(engine)
|
metadata.drop_all(engine)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True, scope="function")
|
@pytest_asyncio.fixture(autouse=True, scope="function")
|
||||||
async def cleanup():
|
async def cleanup():
|
||||||
yield
|
yield
|
||||||
async with database:
|
async with database:
|
||||||
|
|||||||
@ -2,6 +2,7 @@ from typing import Optional
|
|||||||
|
|
||||||
import databases
|
import databases
|
||||||
import pytest
|
import pytest
|
||||||
|
import pytest_asyncio
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
|
||||||
import ormar
|
import ormar
|
||||||
@ -47,7 +48,7 @@ def create_test_database():
|
|||||||
metadata.drop_all(engine)
|
metadata.drop_all(engine)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True, scope="function")
|
@pytest_asyncio.fixture(autouse=True, scope="function")
|
||||||
async def cleanup():
|
async def cleanup():
|
||||||
yield
|
yield
|
||||||
async with database:
|
async with database:
|
||||||
|
|||||||
@ -67,15 +67,8 @@ class Post(ormar.Model):
|
|||||||
author: Optional[Author] = ormar.ForeignKey(Author)
|
author: Optional[Author] = ormar.ForeignKey(Author)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
|
||||||
def event_loop():
|
|
||||||
loop = asyncio.get_event_loop()
|
|
||||||
yield loop
|
|
||||||
loop.close()
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True, scope="module")
|
@pytest.fixture(autouse=True, scope="module")
|
||||||
async def create_test_database():
|
def create_test_database():
|
||||||
engine = sqlalchemy.create_engine(DATABASE_URL)
|
engine = sqlalchemy.create_engine(DATABASE_URL)
|
||||||
metadata.create_all(engine)
|
metadata.create_all(engine)
|
||||||
yield
|
yield
|
||||||
|
|||||||
@ -5,6 +5,7 @@ from typing import Optional, List
|
|||||||
import databases
|
import databases
|
||||||
import pydantic
|
import pydantic
|
||||||
import pytest
|
import pytest
|
||||||
|
import pytest_asyncio
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
|
||||||
import ormar
|
import ormar
|
||||||
@ -86,7 +87,7 @@ def event_loop():
|
|||||||
loop.close()
|
loop.close()
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True, scope="module")
|
@pytest_asyncio.fixture(autouse=True, scope="module")
|
||||||
async def sample_data(event_loop, create_test_database):
|
async def sample_data(event_loop, create_test_database):
|
||||||
async with database:
|
async with database:
|
||||||
nick1 = await NickNames.objects.create(name="Nippon", is_lame=False)
|
nick1 = await NickNames.objects.create(name="Nippon", is_lame=False)
|
||||||
|
|||||||
@ -3,6 +3,7 @@ from typing import List, Optional
|
|||||||
|
|
||||||
import databases
|
import databases
|
||||||
import pytest
|
import pytest
|
||||||
|
import pytest_asyncio
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
|
||||||
import ormar
|
import ormar
|
||||||
@ -69,7 +70,7 @@ def event_loop():
|
|||||||
loop.close()
|
loop.close()
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True, scope="module")
|
@pytest_asyncio.fixture(autouse=True, scope="module")
|
||||||
async def sample_data(event_loop, create_test_database):
|
async def sample_data(event_loop, create_test_database):
|
||||||
async with database:
|
async with database:
|
||||||
creator = await User(name="Anonymous").save()
|
creator = await User(name="Anonymous").save()
|
||||||
|
|||||||
@ -2,6 +2,7 @@ from typing import Optional
|
|||||||
|
|
||||||
import databases
|
import databases
|
||||||
import pytest
|
import pytest
|
||||||
|
import pytest_asyncio
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
|
||||||
import ormar
|
import ormar
|
||||||
@ -72,7 +73,7 @@ def create_test_database():
|
|||||||
metadata.drop_all(engine)
|
metadata.drop_all(engine)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="function")
|
@pytest_asyncio.fixture(scope="function")
|
||||||
async def cleanup():
|
async def cleanup():
|
||||||
yield
|
yield
|
||||||
async with database:
|
async with database:
|
||||||
|
|||||||
@ -3,6 +3,7 @@ from typing import List, Optional
|
|||||||
|
|
||||||
import databases
|
import databases
|
||||||
import pytest
|
import pytest
|
||||||
|
import pytest_asyncio
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
|
||||||
import ormar
|
import ormar
|
||||||
@ -53,7 +54,7 @@ def event_loop():
|
|||||||
loop.close()
|
loop.close()
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True, scope="module")
|
@pytest_asyncio.fixture(autouse=True, scope="module")
|
||||||
async def create_test_database():
|
async def create_test_database():
|
||||||
engine = sqlalchemy.create_engine(DATABASE_URL)
|
engine = sqlalchemy.create_engine(DATABASE_URL)
|
||||||
metadata.create_all(engine)
|
metadata.create_all(engine)
|
||||||
@ -61,7 +62,7 @@ async def create_test_database():
|
|||||||
metadata.drop_all(engine)
|
metadata.drop_all(engine)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="function")
|
@pytest_asyncio.fixture(scope="function")
|
||||||
async def cleanup():
|
async def cleanup():
|
||||||
yield
|
yield
|
||||||
async with database:
|
async with database:
|
||||||
|
|||||||
@ -2,6 +2,7 @@ from typing import List, Optional
|
|||||||
|
|
||||||
import databases
|
import databases
|
||||||
import pytest
|
import pytest
|
||||||
|
import pytest_asyncio
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
|
||||||
import ormar
|
import ormar
|
||||||
@ -52,7 +53,7 @@ def create_test_database():
|
|||||||
metadata.drop_all(engine)
|
metadata.drop_all(engine)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="function")
|
@pytest_asyncio.fixture(scope="function")
|
||||||
async def cleanup():
|
async def cleanup():
|
||||||
yield
|
yield
|
||||||
async with database:
|
async with database:
|
||||||
|
|||||||
@ -2,6 +2,7 @@ from typing import List, Optional
|
|||||||
|
|
||||||
import databases
|
import databases
|
||||||
import pytest
|
import pytest
|
||||||
|
import pytest_asyncio
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
|
||||||
import ormar
|
import ormar
|
||||||
@ -51,7 +52,7 @@ def create_test_database():
|
|||||||
metadata.drop_all(engine)
|
metadata.drop_all(engine)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="function")
|
@pytest_asyncio.fixture(scope="function")
|
||||||
async def cleanup():
|
async def cleanup():
|
||||||
yield
|
yield
|
||||||
async with database:
|
async with database:
|
||||||
|
|||||||
@ -3,6 +3,7 @@ from typing import Optional
|
|||||||
import databases
|
import databases
|
||||||
import pydantic
|
import pydantic
|
||||||
import pytest
|
import pytest
|
||||||
|
import pytest_asyncio
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
|
||||||
import ormar
|
import ormar
|
||||||
@ -66,7 +67,7 @@ def create_test_database():
|
|||||||
metadata.drop_all(engine)
|
metadata.drop_all(engine)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="function")
|
@pytest_asyncio.fixture(scope="function")
|
||||||
async def cleanup():
|
async def cleanup():
|
||||||
yield
|
yield
|
||||||
async with database:
|
async with database:
|
||||||
|
|||||||
@ -2,6 +2,7 @@ from typing import Optional
|
|||||||
|
|
||||||
import databases
|
import databases
|
||||||
import pytest
|
import pytest
|
||||||
|
import pytest_asyncio
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
|
||||||
import ormar
|
import ormar
|
||||||
@ -70,7 +71,7 @@ def create_test_database():
|
|||||||
metadata.drop_all(engine)
|
metadata.drop_all(engine)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True, scope="function")
|
@pytest_asyncio.fixture(autouse=True, scope="function")
|
||||||
async def cleanup():
|
async def cleanup():
|
||||||
yield
|
yield
|
||||||
async with database:
|
async with database:
|
||||||
|
|||||||
Reference in New Issue
Block a user