Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more selectable typings #33

Merged
merged 4 commits into from
Dec 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
)
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