Skip to content

Commit

Permalink
Add more selectable typings (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanforbes authored and ilevkivskyi committed Dec 17, 2018
1 parent 8cc001c commit b6647c0
Show file tree
Hide file tree
Showing 5 changed files with 281 additions and 172 deletions.
11 changes: 10 additions & 1 deletion sqlalchemy-stubs/sql/elements.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ from typing import (
Any, Optional, Union, Type, TypeVar, Generic, Callable, List, Dict, Set, Iterator, Iterable, Tuple as _TupleType,
Mapping, overload, Text
)
from typing_extensions import Protocol
from . import operators
from .. import util
from .visitors import Visitable as Visitable
Expand All @@ -14,6 +15,7 @@ from .selectable import TextAsFrom, TableClause
from .functions import FunctionElement

_T = TypeVar('_T')
_T_contra = TypeVar('_T_contra', contravariant=True)
_V = TypeVar('_V')
_U = TypeVar('_U')

Expand Down Expand Up @@ -142,13 +144,20 @@ class True_(ColumnElement[bool]):

_CL = TypeVar('_CL', bound=ClauseList)

class _LiteralAsTextCallback(Protocol[_T_contra]):
def __call__(self, clause: _T_contra) -> List[ClauseElement]: ...

class ClauseList(ClauseElement):
__visit_name__: str = ...
operator: Any = ...
group: bool = ...
group_contents: bool = ...
clauses: List[ClauseElement] = ...
def __init__(self, *clauses: ClauseElement, operator: Callable[..., Any] = ..., group: bool = ...,
@overload
def __init__(self, *clauses: _T, operator: Callable[..., Any] = ..., group: bool = ..., group_contents: bool = ...,
_literal_as_text: _LiteralAsTextCallback[_T] = ..., **kwargs: Any) -> None: ...
@overload
def __init__(self, *clauses: Optional[Union[str, bool, Visitable]], operator: Callable[..., Any] = ..., group: bool = ...,
group_contents: bool = ..., **kwargs: Any) -> None: ...
def __iter__(self) -> Iterator[ClauseElement]: ...
def __len__(self) -> int: ...
Expand Down
9 changes: 5 additions & 4 deletions sqlalchemy-stubs/sql/schema.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Optional, Set, Generic, TypeVar, overload, Type
from typing import Any, Optional, Set, Generic, TypeVar, Type, Iterable, overload
from . import visitors
from .base import SchemaEventTarget as SchemaEventTarget, DialectKWArgs as DialectKWArgs, ColumnCollection
from .elements import ColumnClause as ColumnClause
Expand All @@ -12,13 +12,14 @@ BLANK_SCHEMA: Any = ...

class SchemaItem(SchemaEventTarget, visitors.Visitable):
__visit_name__: str = ...
def get_children(self, **kwargs): ...
def get_children(self, **kwargs: Any) -> Iterable[Any]: ...
@property
def quote(self): ...
@property
def info(self): ...

class Table(DialectKWArgs, SchemaItem, TableClause):
# Definition of "get_children" in base class "SchemaItem" is incompatible with definition in base class "TableClause"
class Table(DialectKWArgs, SchemaItem, TableClause): # type: ignore
__visit_name__: str
metadata: Any
schema: Any
Expand All @@ -43,7 +44,7 @@ class Table(DialectKWArgs, SchemaItem, TableClause):
def append_column(self, column): ...
def append_constraint(self, constraint): ...
def append_ddl_listener(self, event_name, listener): ...
def get_children(self, column_collections: bool = ..., schema_visitor: bool = ..., **kw): ...
def get_children(self, column_collections: bool = ..., schema_visitor: bool = ..., **kwargs): ...
def exists(self, bind: Optional[Any] = ...): ...
def create(self, bind: Optional[Any] = ..., checkfirst: bool = ...): ...
def drop(self, bind: Optional[Any] = ..., checkfirst: bool = ...): ...
Expand Down
Loading

0 comments on commit b6647c0

Please sign in to comment.