Skip to content

Commit e36ad48

Browse files
Stop importing deprecated typing classes (#698)
1 parent 66b3328 commit e36ad48

6 files changed

Lines changed: 18 additions & 15 deletions

File tree

aiohttp_admin/backends/sqlalchemy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import logging
44
import operator
55
import sys
6-
from collections.abc import Sequence
6+
from collections.abc import Callable, Coroutine, Iterator, Sequence
77
from types import MappingProxyType
8-
from typing import Any, Callable, Coroutine, Iterator, Literal, Optional, TypeVar, Union
8+
from typing import Any, Literal, Optional, TypeVar, Union
99

1010
import sqlalchemy as sa
1111
from aiohttp import web

aiohttp_admin/security.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import json
2-
from collections.abc import Collection
2+
from collections.abc import Collection, Mapping, Sequence
33
from enum import Enum
4-
from typing import Mapping, Optional, Sequence, Union
4+
from typing import Optional, Union
55

66
from aiohttp import web
77
from aiohttp_security import AbstractAuthorizationPolicy, SessionIdentityPolicy

tests/conftest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Awaitable, Callable, Optional, Type
1+
from collections.abc import Awaitable, Callable
2+
from typing import Optional
23
from unittest.mock import AsyncMock, create_autospec
34

45
import pytest
@@ -15,7 +16,7 @@
1516

1617

1718
@pytest.fixture
18-
def base() -> Type[DeclarativeBase]:
19+
def base() -> type[DeclarativeBase]:
1920
class Base(DeclarativeBase):
2021
"""Base model."""
2122

tests/test_backends_sqlalchemy.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import json
2+
from collections.abc import Awaitable, Callable
23
from datetime import date, datetime
3-
from typing import Awaitable, Callable, Type, Union
4+
from typing import Union
45

56
import pytest
67
import sqlalchemy as sa
@@ -16,7 +17,7 @@
1617
_Login = Callable[[TestClient], Awaitable[dict[str, str]]]
1718

1819

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

6162

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

8081

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

100101

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

141142

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

162163

163-
async def test_id_nonpk(base: Type[DeclarativeBase], mock_engine: AsyncEngine) -> None:
164+
async def test_id_nonpk(base: type[DeclarativeBase], mock_engine: AsyncEngine) -> None:
164165
class NotPK(base): # type: ignore[misc,valid-type]
165166
__tablename__ = "notpk"
166167
name: Mapped[str] = mapped_column(primary_key=True)

tests/test_security.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
2-
from typing import Awaitable, Callable, Optional
2+
from collections.abc import Awaitable, Callable
3+
from typing import Optional
34
from unittest import mock
45

56
from aiohttp.test_utils import TestClient

tests/test_views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import json
22
import re
3-
from typing import Awaitable, Callable
3+
from collections.abc import Awaitable, Callable
44

55
import sqlalchemy as sa
66
from aiohttp.test_utils import TestClient

0 commit comments

Comments
 (0)