Skip to content

Commit

Permalink
Stop importing deprecated typing classes (#698)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamsorcerer committed Apr 28, 2023
1 parent 66b3328 commit e36ad48
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 15 deletions.
4 changes: 2 additions & 2 deletions aiohttp_admin/backends/sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import logging
import operator
import sys
from collections.abc import Sequence
from collections.abc import Callable, Coroutine, Iterator, Sequence
from types import MappingProxyType
from typing import Any, Callable, Coroutine, Iterator, Literal, Optional, TypeVar, Union
from typing import Any, Literal, Optional, TypeVar, Union

import sqlalchemy as sa
from aiohttp import web
Expand Down
4 changes: 2 additions & 2 deletions aiohttp_admin/security.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
from collections.abc import Collection
from collections.abc import Collection, Mapping, Sequence
from enum import Enum
from typing import Mapping, Optional, Sequence, Union
from typing import Optional, Union

from aiohttp import web
from aiohttp_security import AbstractAuthorizationPolicy, SessionIdentityPolicy
Expand Down
5 changes: 3 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Awaitable, Callable, Optional, Type
from collections.abc import Awaitable, Callable
from typing import Optional
from unittest.mock import AsyncMock, create_autospec

import pytest
Expand All @@ -15,7 +16,7 @@


@pytest.fixture
def base() -> Type[DeclarativeBase]:
def base() -> type[DeclarativeBase]:
class Base(DeclarativeBase):
"""Base model."""

Expand Down
15 changes: 8 additions & 7 deletions tests/test_backends_sqlalchemy.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
from collections.abc import Awaitable, Callable
from datetime import date, datetime
from typing import Awaitable, Callable, Type, Union
from typing import Union

import pytest
import sqlalchemy as sa
Expand All @@ -16,7 +17,7 @@
_Login = Callable[[TestClient], Awaitable[dict[str, str]]]


def test_pk(base: Type[DeclarativeBase], mock_engine: AsyncEngine) -> None:
def test_pk(base: type[DeclarativeBase], mock_engine: AsyncEngine) -> None:
class TestModel(base): # type: ignore[misc,valid-type]
__tablename__ = "dummy"
id: Mapped[int] = mapped_column(primary_key=True)
Expand Down Expand Up @@ -59,7 +60,7 @@ def test_table(mock_engine: AsyncEngine) -> None:
}


def test_fk(base: Type[DeclarativeBase], mock_engine: AsyncEngine) -> None:
def test_fk(base: type[DeclarativeBase], mock_engine: AsyncEngine) -> None:
class TestModel(base): # type: ignore[misc,valid-type]
__tablename__ = "dummy"
id: Mapped[int] = mapped_column(primary_key=True)
Expand All @@ -78,7 +79,7 @@ class TestChildModel(base): # type: ignore[misc,valid-type]
"validators": [("required",)]}}


def test_relationship(base: Type[DeclarativeBase], mock_engine: AsyncEngine) -> None:
def test_relationship(base: type[DeclarativeBase], mock_engine: AsyncEngine) -> None:
class TestMany(base): # type: ignore[misc,valid-type]
__tablename__ = "many"
id: Mapped[int] = mapped_column(primary_key=True)
Expand All @@ -98,7 +99,7 @@ class TestOne(base): # type: ignore[misc,valid-type]
assert "ones" not in r.inputs


def test_check_constraints(base: Type[DeclarativeBase], mock_engine: AsyncEngine) -> None:
def test_check_constraints(base: type[DeclarativeBase], mock_engine: AsyncEngine) -> None:
class TestCC(base): # type: ignore[misc,valid-type]
__tablename__ = "test"
pk: Mapped[int] = mapped_column(primary_key=True)
Expand Down Expand Up @@ -139,7 +140,7 @@ class TestCC(base): # type: ignore[misc,valid-type]
assert f["regex"]["validators"] == [("required",), ("regex", "abc.*")]


async def test_nonid_pk(base: Type[DeclarativeBase], mock_engine: AsyncEngine) -> None:
async def test_nonid_pk(base: type[DeclarativeBase], mock_engine: AsyncEngine) -> None:
class TestModel(base): # type: ignore[misc,valid-type]
__tablename__ = "test"
num: Mapped[int] = mapped_column(primary_key=True)
Expand All @@ -160,7 +161,7 @@ class TestModel(base): # type: ignore[misc,valid-type]
}


async def test_id_nonpk(base: Type[DeclarativeBase], mock_engine: AsyncEngine) -> None:
async def test_id_nonpk(base: type[DeclarativeBase], mock_engine: AsyncEngine) -> None:
class NotPK(base): # type: ignore[misc,valid-type]
__tablename__ = "notpk"
name: Mapped[str] = mapped_column(primary_key=True)
Expand Down
3 changes: 2 additions & 1 deletion tests/test_security.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
from typing import Awaitable, Callable, Optional
from collections.abc import Awaitable, Callable
from typing import Optional
from unittest import mock

from aiohttp.test_utils import TestClient
Expand Down
2 changes: 1 addition & 1 deletion tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
import re
from typing import Awaitable, Callable
from collections.abc import Awaitable, Callable

import sqlalchemy as sa
from aiohttp.test_utils import TestClient
Expand Down

0 comments on commit e36ad48

Please sign in to comment.