Skip to content

Commit

Permalink
Drop Python 3.8, set Python3.9 as the minimum version. (#313)
Browse files Browse the repository at this point in the history
* run pyupgrade --py39-plus ...

* format and lint aiosqlite + tests

* bump Python in the CONTRIBUTING.md

* Enforce target python version for mypy

---------

Co-authored-by: stankudrow <[email protected]>
Co-authored-by: Amethyst Reese <[email protected]>
  • Loading branch information
3 people authored Feb 3, 2025
1 parent 883695f commit ca481c6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 31 deletions.
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

0 comments on commit ca481c6

Please sign in to comment.