chore(api): align Python support with 3.12 (#34419)

Co-authored-by: Asuka Minato <i@asukaminato.eu.org>
This commit is contained in:
99
2026-04-02 13:07:32 +08:00
committed by GitHub
parent cb9ee5903a
commit 8f9dbf269e
97 changed files with 410 additions and 1441 deletions

View File

@@ -12,7 +12,7 @@ import os
from collections.abc import Generator
from contextlib import contextmanager
from pathlib import Path
from typing import Protocol, TypeVar
from typing import Protocol
import psycopg2
import pytest
@@ -48,11 +48,8 @@ class _CloserProtocol(Protocol):
pass
_Closer = TypeVar("_Closer", bound=_CloserProtocol)
@contextmanager
def _auto_close(closer: _Closer) -> Generator[_Closer, None, None]:
def _auto_close[T: _CloserProtocol](closer: T) -> Generator[T, None, None]:
yield closer
closer.close()

View File

@@ -1,6 +1,6 @@
from collections.abc import Callable, Iterable
from enum import StrEnum
from typing import Any, NamedTuple, TypeVar
from typing import Any, NamedTuple
import pytest
import sqlalchemy as sa
@@ -58,10 +58,7 @@ class _ColumnTest(_Base):
long_value: Mapped[_EnumWithLongValue] = mapped_column(EnumText(enum_class=_EnumWithLongValue), nullable=False)
_T = TypeVar("_T")
def _first(it: Iterable[_T]) -> _T:
def _first[T](it: Iterable[T]) -> T:
ls = list(it)
if not ls:
raise ValueError("List is empty")