Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop Python 3.8, set Python3.9 as the minimum version. #313

Merged
merged 4 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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][]:

Expand Down
6 changes: 4 additions & 2 deletions aiosqlite/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]):
Expand Down
20 changes: 5 additions & 15 deletions aiosqlite/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
18 changes: 5 additions & 13 deletions aiosqlite/cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -96,15 +88,15 @@ 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
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
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ skip_covered = true

[tool.mypy]
ignore_missing_imports = true
python_version = "3.9"

[[tool.mypy.overrides]]
module = "aiosqlite.tests.perf"
Expand Down