mirror of
https://github.com/langgenius/dify.git
synced 2026-04-05 16:50:39 +08:00
chore(api): align Python support with 3.12 (#34419)
Co-authored-by: Asuka Minato <i@asukaminato.eu.org>
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user