Skip to content

Commit a0e1ae4

Browse files
authored
Merge pull request #12 from bryanforbes/improve-util
Improve typings for util
2 parents 14ecd6d + dda56a8 commit a0e1ae4

File tree

12 files changed

+794
-472
lines changed

12 files changed

+794
-472
lines changed

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ install_requires =
3434
[options.data_files]
3535

3636
[mypy]
37+
incremental = True
3738

3839

3940

sqlalchemy-stubs/sql/type_api.pyi

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import sys
21
from typing import Any
3-
from typing import Callable
42
from typing import Generic
53
from typing import Mapping
64
from typing import Optional
@@ -17,6 +15,7 @@ from .visitors import Traversible as Traversible
1715
from .visitors import TraversibleType as TraversibleType
1816
from .. import exc as exc
1917
from .. import util as util
18+
from ..util import compat
2019

2120
BOOLEANTYPE: Any
2221
INTEGERTYPE: Any
@@ -36,13 +35,6 @@ _NFE = TypeVar("_NFE", bound=NativeForEmulated)
3635
_TD = TypeVar("_TD", bound=TypeDecorator[Any])
3736
_VT = TypeVar("_VT", bound=Variant[Any])
3837

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-
4638
class _LiteralProcessor(Protocol[_T_contra]):
4739
def __call__(self, __value: Optional[_T_contra]) -> str: ...
4840

@@ -64,7 +56,7 @@ class TypeEngine(Traversible, Generic[_T]):
6456
def __reduce__(self): ...
6557
hashable: bool = ...
6658
comparator_factory: Type[Any] = ...
67-
sort_key_function: Optional[_SortKeyFunction] = ...
59+
sort_key_function: Optional[compat._SortKeyFunction] = ...
6860
should_evaluate_none: bool = ...
6961
def evaluates_none(self: _TE) -> _TE: ...
7062
def copy(self: _TE, **kw: Any) -> _TE: ...
@@ -145,7 +137,7 @@ class TypeDecorator(SchemaEventTarget, TypeEngine[_T]):
145137
def get_dbapi_type(self, dbapi: Any) -> Any: ...
146138
def compare_values(self, x: Any, y: Any) -> bool: ...
147139
@property
148-
def sort_key_function(self) -> Optional[_SortKeyFunction]: ... # type: ignore[override]
140+
def sort_key_function(self) -> Optional[compat._SortKeyFunction]: ... # type: ignore[override]
149141

150142
class Variant(TypeDecorator[_T]):
151143
impl: TypeEngine[Any] = ...

sqlalchemy-stubs/util/__init__.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ from ._collections import WeakPopulateDict as WeakPopulateDict
4040
from ._collections import WeakSequence as WeakSequence
4141
from ._preloaded import preload_module as preload_module
4242
from ._preloaded import preloaded as preloaded
43+
from .compat import _SortKeyFunction as _SortKeyFunction
4344
from .compat import ABC as ABC
4445
from .compat import arm as arm
4546
from .compat import b as b

0 commit comments

Comments
 (0)