@@ -45,7 +45,7 @@ def _dfs_values(self):
4545 if isinstance (v , ExprNode ):
4646 yield from v ._dfs_values ()
4747
48- def cast_to (self , to ):
48+ def cast_to (self , to ) -> "Cast" :
4949 return Cast (self , to )
5050
5151
@@ -110,7 +110,7 @@ def select(self, *exprs, distinct=SKIP, optimizer_hints=SKIP, **named_exprs) ->
110110 resolve_names (self .source_table , exprs )
111111 return Select .make (self , columns = exprs , distinct = distinct , optimizer_hints = optimizer_hints )
112112
113- def where (self , * exprs ):
113+ def where (self , * exprs ) -> "Select" :
114114 """Filter the rows, based on the given predicates. (aka Selection)"""
115115 exprs = args_as_tuple (exprs )
116116 exprs = _drop_skips (exprs )
@@ -120,7 +120,7 @@ def where(self, *exprs):
120120 resolve_names (self .source_table , exprs )
121121 return Select .make (self , where_exprs = exprs )
122122
123- def order_by (self , * exprs ):
123+ def order_by (self , * exprs ) -> "Select" :
124124 """Order the rows lexicographically, according to the given expressions."""
125125 exprs = _drop_skips (exprs )
126126 if not exprs :
@@ -129,14 +129,14 @@ def order_by(self, *exprs):
129129 resolve_names (self .source_table , exprs )
130130 return Select .make (self , order_by_exprs = exprs )
131131
132- def limit (self , limit : int ):
132+ def limit (self , limit : int ) -> "Select" :
133133 """Stop yielding rows after the given limit. i.e. take the first 'n=limit' rows"""
134134 if limit is SKIP :
135135 return self
136136
137137 return Select .make (self , limit_expr = limit )
138138
139- def join (self , target : "ITable" ):
139+ def join (self , target : "ITable" ) -> "Join" :
140140 """Join the current table with the target table, returning a new table containing both side-by-side.
141141
142142 When joining, it's recommended to use explicit tables names, instead of `this`, in order to avoid potential name collisions.
@@ -180,37 +180,37 @@ def group_by(self, *keys) -> "GroupBy":
180180
181181 return GroupBy (self , keys )
182182
183- def _get_column (self , name : str ):
183+ def _get_column (self , name : str ) -> "Column" :
184184 if self .schema :
185185 name = self .schema .get_key (name ) # Get the actual name. Might be case-insensitive.
186186 return Column (self , name )
187187
188188 # def __getattr__(self, column):
189189 # return self._get_column(column)
190190
191- def __getitem__ (self , column ):
191+ def __getitem__ (self , column ) -> "Column" :
192192 if not isinstance (column , str ):
193193 raise TypeError ()
194194 return self ._get_column (column )
195195
196- def count (self ):
196+ def count (self ) -> "Select" :
197197 """SELECT count() FROM self"""
198198 return Select (self , [Count ()])
199199
200- def union (self , other : "ITable" ):
200+ def union (self , other : "ITable" ) -> "TableOp" :
201201 """SELECT * FROM self UNION other"""
202202 return TableOp ("UNION" , self , other )
203203
204- def union_all (self , other : "ITable" ):
204+ def union_all (self , other : "ITable" ) -> "TableOp" :
205205 """SELECT * FROM self UNION ALL other"""
206206 return TableOp ("UNION ALL" , self , other )
207207
208- def minus (self , other : "ITable" ):
208+ def minus (self , other : "ITable" ) -> "TableOp" :
209209 """SELECT * FROM self EXCEPT other"""
210210 # aka
211211 return TableOp ("EXCEPT" , self , other )
212212
213- def intersect (self , other : "ITable" ):
213+ def intersect (self , other : "ITable" ) -> "TableOp" :
214214 """SELECT * FROM self INTERSECT other"""
215215 return TableOp ("INTERSECT" , self , other )
216216
@@ -233,51 +233,51 @@ def type(self) -> Optional[type]:
233233
234234@attrs .define (frozen = False , eq = False )
235235class LazyOps :
236- def __add__ (self , other ):
236+ def __add__ (self , other ) -> "BinOp" :
237237 return BinOp ("+" , [self , other ])
238238
239- def __sub__ (self , other ):
239+ def __sub__ (self , other ) -> "BinOp" :
240240 return BinOp ("-" , [self , other ])
241241
242- def __neg__ (self ):
242+ def __neg__ (self ) -> "UnaryOp" :
243243 return UnaryOp ("-" , self )
244244
245- def __gt__ (self , other ):
245+ def __gt__ (self , other ) -> "BinBoolOp" :
246246 return BinBoolOp (">" , [self , other ])
247247
248- def __ge__ (self , other ):
248+ def __ge__ (self , other ) -> "BinBoolOp" :
249249 return BinBoolOp (">=" , [self , other ])
250250
251- def __eq__ (self , other ):
251+ def __eq__ (self , other ) -> "BinBoolOp" :
252252 if other is None :
253253 return BinBoolOp ("IS" , [self , None ])
254254 return BinBoolOp ("=" , [self , other ])
255255
256- def __lt__ (self , other ):
256+ def __lt__ (self , other ) -> "BinBoolOp" :
257257 return BinBoolOp ("<" , [self , other ])
258258
259- def __le__ (self , other ):
259+ def __le__ (self , other ) -> "BinBoolOp" :
260260 return BinBoolOp ("<=" , [self , other ])
261261
262- def __or__ (self , other ):
262+ def __or__ (self , other ) -> "BinBoolOp" :
263263 return BinBoolOp ("OR" , [self , other ])
264264
265- def __and__ (self , other ):
265+ def __and__ (self , other ) -> "BinBoolOp" :
266266 return BinBoolOp ("AND" , [self , other ])
267267
268- def is_distinct_from (self , other ):
268+ def is_distinct_from (self , other ) -> "IsDistinctFrom" :
269269 return IsDistinctFrom (self , other )
270270
271- def like (self , other ):
271+ def like (self , other ) -> "BinBoolOp" :
272272 return BinBoolOp ("LIKE" , [self , other ])
273273
274- def sum (self ):
274+ def sum (self ) -> "Func" :
275275 return Func ("SUM" , [self ])
276276
277- def max (self ):
277+ def max (self ) -> "Func" :
278278 return Func ("MAX" , [self ])
279279
280- def min (self ):
280+ def min (self ) -> "Func" :
281281 return Func ("MIN" , [self ])
282282
283283
0 commit comments