Skip to content

Commit ae99c6f

Browse files
committed
A few more updates
1 parent 53e7a90 commit ae99c6f

File tree

2 files changed

+31
-15
lines changed

2 files changed

+31
-15
lines changed

sqlalchemy-stubs/sql/sqltypes.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ from ..util import compat as compat
3838
from ..util import langhelpers as langhelpers
3939
from ..util import pickle as pickle
4040

41-
_U = TypeVar("_U")
41+
_T = TypeVar("_T")
4242

4343
class _LookupExpressionAdapter:
4444
class Comparator(TypeEngine.Comparator): ...
@@ -187,7 +187,7 @@ class SchemaType(SchemaEventTarget):
187187
_create_events: bool = ...,
188188
) -> None: ...
189189
def copy(self, **kw: Any): ...
190-
def adapt(self, __impltype: Type[_U], **kw: Any) -> _U: ...
190+
def adapt(self, __impltype: Type[_T], **kw: Any) -> _T: ...
191191
@property
192192
def bind(self): ...
193193
def create(
@@ -208,7 +208,7 @@ class Enum(Emulated, String, SchemaType):
208208
comparator_factory: Any = ...
209209
def as_generic(self, allow_nulltype: bool = ...): ...
210210
def adapt_to_emulated(self, impltype: Any, **kw: Any): ...
211-
def adapt(self, __impltype: Type[_U], **kw: Any) -> _U: ...
211+
def adapt(self, __impltype: Type[_T], **kw: Any) -> _T: ...
212212
def literal_processor(self, dialect: Any): ...
213213
def bind_processor(self, dialect: Any): ...
214214
def result_processor(self, dialect: Any, coltype: Any): ...

sqlalchemy-stubs/sql/type_api.pyi

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from _typeshed import SupportsLessThan
1+
import sys
22
from typing import Any
33
from typing import Callable
44
from typing import Generic
@@ -27,14 +27,30 @@ INDEXABLE: Any
2727
TABLEVALUE: Any
2828

2929
_T = TypeVar("_T")
30+
_T_co = TypeVar("_T_co", covariant=True)
31+
_T_contra = TypeVar("_T_contra", contravariant=True)
3032
_U = TypeVar("_U")
3133

32-
_TE = TypeVar('_TE', bound=TypeEngine[Any])
33-
_NFE = TypeVar('_NFE', bound=NativeForEmulated)
34-
_TD = TypeVar('_TD', bound=TypeDecorator[Any])
35-
_VT = TypeVar('_VT', bound=Variant[Any])
34+
_TE = TypeVar("_TE", bound=TypeEngine[Any])
35+
_NFE = TypeVar("_NFE", bound=NativeForEmulated)
36+
_TD = TypeVar("_TD", bound=TypeDecorator[Any])
37+
_VT = TypeVar("_VT", bound=Variant[Any])
3638

37-
_SortKeyFunction = Callable[[Any], SupportsLessThan]
39+
if sys.version_info[0] < 3:
40+
from _typeshed import SupportsLessThan
41+
42+
_SortKeyFunction = Callable[[Any], SupportsLessThan]
43+
else:
44+
_SortKeyFunction = Callable[[Any], Any]
45+
46+
class _LiteralProcessor(Protocol[_T_contra]):
47+
def __call__(self, __value: Optional[_T_contra]) -> str: ...
48+
49+
class _BindProcessor(Protocol[_T_contra]):
50+
def __call__(self, __value: Optional[_T_contra]) -> Optional[Any]: ...
51+
52+
class _ResultProcessor(Protocol[_T_co]):
53+
def __call__(self, __value: Optional[Any]) -> Optional[_T_co]: ...
3854

3955
class TypeEngine(Traversible, Generic[_T]):
4056
class Comparator(operators.ColumnOperators):
@@ -56,9 +72,9 @@ class TypeEngine(Traversible, Generic[_T]):
5672
self, dialect: Any, conn_type: Any
5773
) -> Any: ...
5874
def copy_value(self, value: _T) -> _T: ...
59-
def literal_processor(self, dialect: Any) -> Optional[Callable[[Optional[_T]], str]]: ...
60-
def bind_processor(self, dialect: Any) -> Optional[Callable[[Optional[_T]], Optional[Any]]]: ...
61-
def result_processor(self, dialect: Any, coltype: Any) -> Optional[Callable[[Optional[Any]], Optional[_T]]]: ...
75+
def literal_processor(self, dialect: Any) -> Optional[_LiteralProcessor[_T]]: ...
76+
def bind_processor(self, dialect: Any) -> Optional[_BindProcessor[_T]]: ...
77+
def result_processor(self, dialect: Any, coltype: Any) -> Optional[_ResultProcessor[_T]]: ...
6278
def column_expression(self, colexpr: Any) -> Any: ...
6379
def bind_expression(self, bindvalue: Any) -> Any: ...
6480
def compare_values(self, x: Any, y: Any) -> bool: ...
@@ -105,9 +121,9 @@ class TypeDecorator(SchemaEventTarget, TypeEngine[_T]):
105121
def process_literal_param(self, value: Optional[_T], dialect: Any) -> str: ...
106122
def process_bind_param(self, value: Optional[_T], dialect: Any) -> Any: ...
107123
def process_result_value(self, value: Any, dialect: Any) -> Optional[_T]: ...
108-
def literal_processor(self, dialect: Any) -> Callable[[Optional[_T]], str]: ...
109-
def bind_processor(self, dialect: Any) -> Callable[[Optional[_T]], Optional[Any]]: ...
110-
def result_processor(self, dialect: Any, coltype: Any) -> Callable[[Optional[Any]], Optional[_T]]: ...
124+
def literal_processor(self, dialect: Any) -> _LiteralProcessor[_T]: ...
125+
def bind_processor(self, dialect: Any) -> _BindProcessor[_T]: ...
126+
def result_processor(self, dialect: Any, coltype: Any) -> _ResultProcessor[_T]: ...
111127
def bind_expression(self, bindparam: Any) -> Any: ...
112128
def column_expression(self, column: Any) -> Any: ...
113129
def coerce_compared_value(self, op: Any, value: Any) -> Any: ...

0 commit comments

Comments
 (0)