@@ -13,6 +13,7 @@ from .type_api import TypeEngine
1313from .sqltypes import NullType , Boolean , Integer
1414from .selectable import TextAsFrom , TableClause
1515from .functions import FunctionElement
16+ from .schema import ForeignKey
1617
1718_T = TypeVar ('_T' )
1819_T_contra = TypeVar ('_T_contra' , contravariant = True )
@@ -44,27 +45,32 @@ class ClauseElement(Visitable):
4445 def __bool__ (self ): ...
4546 __nonzero__ : Any = ...
4647
48+ _CE = TypeVar ('_CE' , bound = ColumnElement )
49+
4750class ColumnElement (operators .ColumnOperators , ClauseElement , Generic [_T ]):
4851 __visit_name__ : str = ...
49- primary_key : Any = ...
50- foreign_keys : List [Any ] = ...
51- key : Any = ...
52- def self_group (self , against : Optional [Any ] = ...): ...
52+ primary_key : bool = ...
53+ foreign_keys : List [ForeignKey ] = ...
54+ key : Optional [ str ] = ...
55+ def self_group (self : _CE , against : Optional [Any ] = ...) -> Union [ AsBoolean , Grouping [ _T ], _CE ] : ...
5356 @property
5457 def type (self ) -> TypeEngine [_T ]: ...
5558 def comparator (self ): ...
56- def __getattr__ (self , key ) : ...
59+ def __getattr__ (self , key : str ) -> Any : ...
5760 def operate (self , op , * other , ** kwargs ): ...
5861 def reverse_operate (self , op , other , ** kwargs ): ...
5962 @property
60- def expression (self ): ...
61- def base_columns (self ): ...
62- def proxy_set (self ): ...
63- def shares_lineage (self , othercolumn ): ...
64- def compare (self , other : Any , ** kw : Any ) -> bool : ...
65- def cast (self , type_ ): ...
66- def label (self , name ): ...
67- def anon_label (self ): ...
63+ def expression (self : _CE ) -> _CE : ...
64+ def base_columns (self ) -> Set [ColumnElement [Any ]]: ...
65+ def proxy_set (self ) -> Set [ColumnElement [Any ]]: ...
66+ def shares_lineage (self , othercolumn : ColumnElement [Any ]) -> bool : ...
67+ def compare (self , other : ColumnElement [Any ], use_proxies : bool = ..., equivalents : bool = ..., ** kw : Any ) -> bool : ...
68+ @overload
69+ def cast (self , type_ : Type [TypeEngine [_U ]]) -> Cast [_U ]: ...
70+ @overload
71+ def cast (self , type_ : TypeEngine [_U ]) -> Cast [_U ]: ...
72+ def label (self , name : str ) -> Label [_T ]: ...
73+ def anon_label (self ) -> _anonymous_label : ...
6874
6975class BindParameter (ColumnElement [_T ]):
7076 __visit_name__ : str = ...
@@ -87,7 +93,8 @@ class BindParameter(ColumnElement[_T]):
8793 _compared_to_type : Optional [Any ] = ...) -> None : ...
8894 @property
8995 def effective_value (self ) -> _T : ...
90- def compare (self , other : Any , ** kw : Any ) -> bool : ...
96+ # Signature of "compare" incompatible with supertype "ColumnElement"
97+ def compare (self , other : ColumnElement [Any ], ** kw : Any ) -> bool : ... # type: ignore
9198
9299class TypeClause (ClauseElement , Generic [_T ]):
93100 __visit_name__ : str = ...
@@ -168,19 +175,21 @@ class ClauseList(ClauseElement):
168175
169176_BCL = TypeVar ('_BCL' , bound = BooleanClauseList )
170177
171- class BooleanClauseList (ClauseList , ColumnElement [bool ]):
178+ # Definitions of "compare" and "self_group" in ClauseList are incompatible with ColumnElement
179+ class BooleanClauseList (ClauseList , ColumnElement [bool ]): # type: ignore
172180 __visit_name__ : str = ...
173181 # Note: passing strings to below generates a warning, but still works.
174182 @classmethod
175183 def and_ (cls , * clauses : Union [ClauseElement , str , bool ]) -> BooleanClauseList : ...
176184 @classmethod
177185 def or_ (cls , * clauses : Union [ClauseElement , str , bool ]) -> BooleanClauseList : ...
178- def self_group (self : _BCL , against : Optional [Any ] = ...) -> Union [_BCL , Grouping [Any ]]: ...
186+ def self_group (self : _BCL , against : Optional [Any ] = ...) -> Union [_BCL , Grouping [bool ]]: ...
179187
180188and_ = BooleanClauseList .and_
181189or_ = BooleanClauseList .or_
182190
183- class Tuple (ClauseList , ColumnElement [_T ]):
191+ # Definitions of "compare" and "self_group" in ClauseList are incompatible with ColumnElement
192+ class Tuple (ClauseList , ColumnElement [_T ]): # type: ignore
184193 type : TypeEngine [_T ] = ...
185194 @overload
186195 def __init__ (self , * clauses : ColumnElement [Any ], type_ : Type [TypeEngine [_T ]], ** kw : Any ) -> None : ...
@@ -261,7 +270,8 @@ class UnaryExpression(ColumnElement[_T]):
261270 type_ : Optional [TypeEngine [_T ]] = ..., negate : Optional [Any ] = ...,
262271 wraps_column_expression : bool = ...) -> None : ...
263272 def get_children (self , ** kwargs ) -> _TupleType [Any ]: ...
264- def compare (self , other : Any , ** kw : Any ) -> bool : ...
273+ # Signature of "compare" incompatible with supertype "ColumnElement"
274+ def compare (self , other : ColumnElement [Any ], ** kw : Any ) -> bool : ... # type: ignore
265275 def self_group (self : _UE , against : Optional [Any ] = ...) -> Union [_UE , Grouping [_T ]]: ...
266276 @classmethod
267277 def _create_nullsfirst (cls , column : ColumnElement [Any ]) -> UnaryExpression [NullType ]: ...
@@ -292,14 +302,14 @@ class CollectionAggregate(UnaryExpression[_T]):
292302
293303_AB = TypeVar ('_AB' , bound = AsBoolean )
294304
295- class AsBoolean (UnaryExpression ):
296- element : Any = ...
305+ class AsBoolean (UnaryExpression [ bool ] ):
306+ element : ColumnElement [ Any ] = ...
297307 type : Boolean = ...
298308 operator : Callable [..., Any ] = ...
299- negate : Any = ...
309+ negate : Callable [..., Any ] = ...
300310 modifier : Any = ...
301311 wraps_column_expression : bool = ...
302- def __init__ (self , element : Any , operator : Callable [..., Any ], negate : Any ) -> None : ...
312+ def __init__ (self , element : ColumnElement [ Any ] , operator : Callable [..., Any ], negate : Callable [..., Any ] ) -> None : ...
303313 def self_group (self : _AB , against : Optional [Any ] = ...) -> _AB : ...
304314
305315_BE = TypeVar ('_BE' , bound = BinaryExpression )
@@ -324,7 +334,8 @@ class BinaryExpression(ColumnElement[_T], Generic[_T, _U, _V]):
324334 @property
325335 def is_comparison (self ): ...
326336 def get_children (self , ** kwargs ): ...
327- def compare (self , other : Any , ** kw : Any ) -> bool : ...
337+ # Signature of "compare" incompatible with supertype "ColumnElement"
338+ def compare (self , other : ColumnElement [Any ], ** kw : Any ) -> bool : ... # type: ignore
328339 def self_group (self : _BE , against : Optional [Any ] = ...) -> Union [_BE , Grouping [_T ]]: ...
329340
330341_SL = TypeVar ('_SL' , bound = Slice )
@@ -336,7 +347,7 @@ class Slice(ColumnElement[None]):
336347 step : Any = ...
337348 type : NullType = ...
338349 def __init__ (self , start , stop , step ) -> None : ...
339- def self_group (self : _SL , against : Optional [Any ] = ...) -> Union [ _SL , Grouping [ NullType ]] : ...
350+ def self_group (self : _SL , against : Optional [Any ] = ...) -> _SL : ...
340351
341352class IndexExpression (BinaryExpression ): ...
342353
@@ -354,7 +365,8 @@ class Grouping(ColumnElement[_T]):
354365 def self_group (self : _G , against : Optional [Any ] = ...) -> _G : ...
355366 def get_children (self , ** kwargs ) -> _TupleType [ClauseElement ]: ...
356367 def __getattr__ (self , attr ): ...
357- def compare (self , other : Any , ** kw : Any ) -> bool : ...
368+ # Signature of "compare" incompatible with supertype "ColumnElement"
369+ def compare (self , other : ColumnElement [Any ], ** kw : Any ) -> bool : ... # type: ignore
358370
359371RANGE_UNBOUNDED : util .symbol = ...
360372RANGE_CURRENT : util .symbol = ...
@@ -432,11 +444,13 @@ class Label(ColumnElement[_T]):
432444 def type (self ) -> TypeEngine [_T ]: ...
433445 @property
434446 def element (self ) -> ColumnElement [_T ]: ...
435- def self_group (self , against : Optional [Any ] = ...) -> Union [ColumnElement [_T ], Grouping [_T ]]: ...
447+ def self_group (self : _L , against : Optional [Any ] = ...) -> Union [_L , Label [_T ]]: ...
448+ # Signature of "primary_key" incompatible with supertype "ColumnElement"
436449 @property
437- def primary_key (self ) -> Any : ...
450+ def primary_key (self ) -> bool : ... # type: ignore
451+ # Signature of "foreign_keys" incompatible with supertype "ColumnElement"
438452 @property
439- def foreign_keys (self ) -> List [Any ]: ... # type: ignore
453+ def foreign_keys (self ) -> List [ForeignKey ]: ... # type: ignore
440454 def get_children (self , ** kwargs : Any ) -> Any : ...
441455
442456class ColumnClause (Immutable , ColumnElement [_T ]):
@@ -485,6 +499,8 @@ class _truncated_label(quoted_name):
485499
486500class conv (_truncated_label ): ...
487501
502+ class _anonymous_label (_truncated_label ): ...
503+
488504class AnnotatedColumnElement (Annotated , Generic [_T ]):
489505 def __init__ (self , element : ColumnElement [_T ], values : Any ) -> None : ...
490506 @property
0 commit comments