From ec9893acf383a27fb668823822c15cce49c0fada Mon Sep 17 00:00:00 2001 From: Alberto Donato Date: Wed, 30 Oct 2024 13:05:59 +0100 Subject: [PATCH] require Python 3.11 --- .github/workflows/ci.yml | 2 -- pyproject.toml | 3 +-- query_exporter/db.py | 7 ++++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 688b58f..46ffa78 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,6 @@ jobs: strategy: matrix: python-version: - - "3.10" - "3.11" - "3.12" - "3.13" @@ -59,7 +58,6 @@ jobs: strategy: matrix: python-version: - - "3.10" - "3.11" - "3.12" - "3.13" diff --git a/pyproject.toml b/pyproject.toml index 84b903a..64ed3f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ maintainers = [ authors = [ { name = "Alberto Donato", email = "alberto.donato@gmail.com" }, ] -requires-python = ">=3.10" +requires-python = ">=3.11" classifiers = [ "Development Status :: 5 - Production/Stable", "Framework :: AsyncIO", @@ -29,7 +29,6 @@ classifiers = [ "License :: OSI Approved :: GNU General Public License (GPL)", "Operating System :: OS Independent", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", diff --git a/query_exporter/db.py b/query_exporter/db.py index 2c791e0..7406818 100644 --- a/query_exporter/db.py +++ b/query_exporter/db.py @@ -18,6 +18,7 @@ from typing import ( Any, NamedTuple, + Self, cast, ) @@ -165,7 +166,7 @@ class QueryResults(NamedTuple): latency: float | None = None @classmethod - async def from_results(cls, results: AsyncResultProxy) -> "QueryResults": + async def from_results(cls, results: AsyncResultProxy) -> Self: """Return a QueryResults from results for a query.""" timestamp = time() conn_info = results._result_proxy.connection.info @@ -298,7 +299,7 @@ def __init__( self._setup_query_latency_tracking() - async def __aenter__(self) -> "DataBase": + async def __aenter__(self) -> Self: await self.connect() return self @@ -352,7 +353,7 @@ async def execute(self, query: Query) -> MetricResults: try: result = await self._execute_query(query) return query.results(await QueryResults.from_results(result)) - except asyncio.TimeoutError: + except TimeoutError: raise self._query_timeout_error( query.name, cast(QueryTimeout, query.timeout) )