main commit
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-10-16 16:30:25 +09:00
parent 91c7e04474
commit 537e7b363f
1146 changed files with 45926 additions and 77196 deletions

View File

@@ -1,5 +1,5 @@
# util/_collections.py
# Copyright (C) 2005-2025 the SQLAlchemy authors and contributors
# Copyright (C) 2005-2023 the SQLAlchemy authors and contributors
# <see AUTHORS file>
#
# This module is part of SQLAlchemy and is released under
@@ -9,6 +9,7 @@
"""Collection classes and helpers."""
from __future__ import annotations
import collections.abc as collections_abc
import operator
import threading
import types
@@ -16,7 +17,6 @@ import typing
from typing import Any
from typing import Callable
from typing import cast
from typing import Container
from typing import Dict
from typing import FrozenSet
from typing import Generic
@@ -36,7 +36,6 @@ from typing import ValuesView
import weakref
from ._has_cy import HAS_CYEXTENSION
from .typing import is_non_string_iterable
from .typing import Literal
from .typing import Protocol
@@ -80,8 +79,8 @@ def merge_lists_w_ordering(a: List[Any], b: List[Any]) -> List[Any]:
Example::
>>> a = ["__tablename__", "id", "x", "created_at"]
>>> b = ["id", "name", "data", "y", "created_at"]
>>> a = ['__tablename__', 'id', 'x', 'created_at']
>>> b = ['id', 'name', 'data', 'y', 'created_at']
>>> merge_lists_w_ordering(a, b)
['__tablename__', 'id', 'name', 'data', 'y', 'x', 'created_at']
@@ -228,10 +227,12 @@ class Properties(Generic[_T]):
self._data.update(value)
@overload
def get(self, key: str) -> Optional[_T]: ...
def get(self, key: str) -> Optional[_T]:
...
@overload
def get(self, key: str, default: Union[_DT, _T]) -> Union[_DT, _T]: ...
def get(self, key: str, default: Union[_DT, _T]) -> Union[_DT, _T]:
...
def get(
self, key: str, default: Optional[Union[_DT, _T]] = None
@@ -418,7 +419,9 @@ def coerce_generator_arg(arg: Any) -> List[Any]:
def to_list(x: Any, default: Optional[List[Any]] = None) -> List[Any]:
if x is None:
return default # type: ignore
if not is_non_string_iterable(x):
if not isinstance(x, collections_abc.Iterable) or isinstance(
x, (str, bytes)
):
return [x]
elif isinstance(x, list):
return x
@@ -426,14 +429,15 @@ def to_list(x: Any, default: Optional[List[Any]] = None) -> List[Any]:
return list(x)
def has_intersection(set_: Container[Any], iterable: Iterable[Any]) -> bool:
def has_intersection(set_, iterable):
r"""return True if any items of set\_ are present in iterable.
Goes through special effort to ensure __hash__ is not called
on items in iterable that don't support it.
"""
return any(i in set_ for i in iterable if i.__hash__)
# TODO: optimize, write in C, etc.
return bool(set_.intersection([i for i in iterable if i.__hash__]))
def to_set(x):
@@ -454,9 +458,7 @@ def to_column_set(x: Any) -> Set[Any]:
return x
def update_copy(
d: Dict[Any, Any], _new: Optional[Dict[Any, Any]] = None, **kw: Any
) -> Dict[Any, Any]:
def update_copy(d, _new=None, **kw):
"""Copy the given dict and update with the given values."""
d = d.copy()
@@ -520,10 +522,12 @@ class LRUCache(typing.MutableMapping[_KT, _VT]):
return self._counter
@overload
def get(self, key: _KT) -> Optional[_VT]: ...
def get(self, key: _KT) -> Optional[_VT]:
...
@overload
def get(self, key: _KT, default: Union[_VT, _T]) -> Union[_VT, _T]: ...
def get(self, key: _KT, default: Union[_VT, _T]) -> Union[_VT, _T]:
...
def get(
self, key: _KT, default: Optional[Union[_VT, _T]] = None
@@ -585,11 +589,13 @@ class LRUCache(typing.MutableMapping[_KT, _VT]):
class _CreateFuncType(Protocol[_T_co]):
def __call__(self) -> _T_co: ...
def __call__(self) -> _T_co:
...
class _ScopeFuncType(Protocol):
def __call__(self) -> Any: ...
def __call__(self) -> Any:
...
class ScopedRegistry(Generic[_T]):