diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 47e7792..0dc5b89 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,7 @@ ## Preparation -You'll need to have at least Python 3.8 available for testing. +You'll need to have at least Python 3.9 available for testing. You can do this with [pyenv][]: diff --git a/aiosqlite/context.py b/aiosqlite/context.py index 316845f..0e20045 100644 --- a/aiosqlite/context.py +++ b/aiosqlite/context.py @@ -2,15 +2,17 @@ # Licensed under the MIT license +from collections.abc import Coroutine, Generator +from contextlib import AbstractAsyncContextManager from functools import wraps -from typing import Any, AsyncContextManager, Callable, Coroutine, Generator, TypeVar +from typing import Any, Callable, TypeVar from .cursor import Cursor _T = TypeVar("_T") -class Result(AsyncContextManager[_T], Coroutine[Any, Any, _T]): +class Result(AbstractAsyncContextManager[_T], Coroutine[Any, Any, _T]): __slots__ = ("_coro", "_obj") def __init__(self, coro: Coroutine[Any, Any, _T]): diff --git a/aiosqlite/core.py b/aiosqlite/core.py index 61f5db7..61bab67 100644 --- a/aiosqlite/core.py +++ b/aiosqlite/core.py @@ -8,22 +8,12 @@ import asyncio import logging import sqlite3 +from collections.abc import AsyncIterator, Generator, Iterable from functools import partial from pathlib import Path from queue import Empty, Queue, SimpleQueue from threading import Thread -from typing import ( - Any, - AsyncIterator, - Callable, - Generator, - Iterable, - Literal, - Optional, - Tuple, - Type, - Union, -) +from typing import Any, Callable, Literal, Optional, Union from warnings import warn from .context import contextmanager @@ -63,7 +53,7 @@ def __init__( self._running = True self._connection: Optional[sqlite3.Connection] = None self._connector = connector - self._tx: SimpleQueue[Tuple[asyncio.Future, Callable[[], Any]]] = SimpleQueue() + self._tx: SimpleQueue[tuple[asyncio.Future, Callable[[], Any]]] = SimpleQueue() self._iter_chunk_size = iter_chunk_size if loop is not None: @@ -264,11 +254,11 @@ def isolation_level(self, value: IsolationLevel) -> None: self._conn.isolation_level = value @property - def row_factory(self) -> Optional[Type]: + def row_factory(self) -> Optional[type]: return self._conn.row_factory @row_factory.setter - def row_factory(self, factory: Optional[Type]) -> None: + def row_factory(self, factory: Optional[type]) -> None: self._conn.row_factory = factory @property diff --git a/aiosqlite/cursor.py b/aiosqlite/cursor.py index 197938f..a6794d9 100644 --- a/aiosqlite/cursor.py +++ b/aiosqlite/cursor.py @@ -2,16 +2,8 @@ # Licensed under the MIT license import sqlite3 -from typing import ( - Any, - AsyncIterator, - Callable, - Iterable, - Optional, - Tuple, - Type, - TYPE_CHECKING, -) +from collections.abc import AsyncIterator, Iterable +from typing import Any, Callable, Optional, TYPE_CHECKING if TYPE_CHECKING: from .core import Connection @@ -66,7 +58,7 @@ async def fetchone(self) -> Optional[sqlite3.Row]: async def fetchmany(self, size: Optional[int] = None) -> Iterable[sqlite3.Row]: """Fetch up to `cursor.arraysize` number of rows.""" - args: Tuple[int, ...] = () + args: tuple[int, ...] = () if size is not None: args = (size,) return await self._execute(self._cursor.fetchmany, *args) @@ -96,7 +88,7 @@ def arraysize(self, value: int) -> None: self._cursor.arraysize = value @property - def description(self) -> Tuple[Tuple[str, None, None, None, None, None, None], ...]: + def description(self) -> tuple[tuple[str, None, None, None, None, None, None], ...]: return self._cursor.description @property @@ -104,7 +96,7 @@ def row_factory(self) -> Optional[Callable[[sqlite3.Cursor, sqlite3.Row], object return self._cursor.row_factory @row_factory.setter - def row_factory(self, factory: Optional[Type]) -> None: + def row_factory(self, factory: Optional[type]) -> None: self._cursor.row_factory = factory @property diff --git a/pyproject.toml b/pyproject.toml index 5a942cf..c8d03b8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -69,6 +69,7 @@ skip_covered = true [tool.mypy] ignore_missing_imports = true +python_version = "3.9" [[tool.mypy.overrides]] module = "aiosqlite.tests.perf"