first commit

This commit is contained in:
linkitapps
2026-09-14 23:22:10 +09:00
commit 9f9c8fb69b
4207 changed files with 1333187 additions and 0 deletions
@@ -0,0 +1,66 @@
"""
compatibility functions for different Python versions
"""
# Copyright (C) 2021 The Psycopg Team
from __future__ import annotations
import sys
from typing import Any, Iterator
if sys.version_info >= (3, 11):
from typing import LiteralString, Self
else:
from typing_extensions import LiteralString, Self
if sys.version_info >= (3, 12):
_asyncio_run_snippet = (
"running 'asyncio.run(...,"
" loop_factory=asyncio.SelectorEventLoop(selectors.SelectSelector()))'"
)
else:
_asyncio_run_snippet = (
"setting 'asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())'"
)
if sys.version_info >= (3, 13):
from typing import TypeVar
else:
from typing_extensions import TypeVar
if sys.version_info >= (3, 14):
from string.templatelib import Interpolation, Template
else:
from typing import Generic, Literal
from dataclasses import dataclass
T = TypeVar("T")
class Template:
strings: tuple[str]
interpolations: tuple[Interpolation[Any]]
def __new__(cls, *args: str | Interpolation[Any]) -> Self:
return cls()
def __iter__(self) -> Iterator[str | Interpolation[Any]]:
return
yield
@dataclass
class Interpolation(Generic[T]):
value: T
expression: str
conversion: Literal["a", "r", "s"] | None
format_spec: str
__all__ = [
"Interpolation",
"LiteralString",
"Self",
"Template",
"TypeVar",
]