@@ -193,15 +193,15 @@ def restrict_in_place(self, restriction):
193
193
194
194
def __and__ (self , restriction ):
195
195
"""
196
- Restriction operator e.g. q1 & q2.
196
+ Restriction operator e.g. `` q1 & q2`` .
197
197
:return: a restricted copy of the input argument
198
198
See QueryExpression.restrict for more detail.
199
199
"""
200
200
return self .restrict (restriction )
201
201
202
202
def __xor__ (self , restriction ):
203
203
"""
204
- Permissive restriction operator ignoring compatibility check e.g. q1 ^ q2.
204
+ Permissive restriction operator ignoring compatibility check e.g. `` q1 ^ q2`` .
205
205
"""
206
206
if inspect .isclass (restriction ) and issubclass (restriction , QueryExpression ):
207
207
restriction = restriction ()
@@ -211,15 +211,15 @@ def __xor__(self, restriction):
211
211
212
212
def __sub__ (self , restriction ):
213
213
"""
214
- Inverted restriction e.g. q1 - q2.
214
+ Inverted restriction e.g. `` q1 - q2`` .
215
215
:return: a restricted copy of the input argument
216
216
See QueryExpression.restrict for more detail.
217
217
"""
218
218
return self .restrict (Not (restriction ))
219
219
220
220
def __neg__ (self ):
221
221
"""
222
- Convert between restriction and inverted restriction e.g. -q1.
222
+ Convert between restriction and inverted restriction e.g. `` -q1`` .
223
223
:return: target restriction
224
224
See QueryExpression.restrict for more detail.
225
225
"""
@@ -229,14 +229,14 @@ def __neg__(self):
229
229
230
230
def __mul__ (self , other ):
231
231
"""
232
- join of query expressions `self` and `other` e.g. q1 * q2.
232
+ join of query expressions `self` and `other` e.g. `` q1 * q2`` .
233
233
"""
234
234
return self .join (other )
235
235
236
236
def __matmul__ (self , other ):
237
237
"""
238
238
Permissive join of query expressions `self` and `other` ignoring compatibility check
239
- e.g. q1 @ q2.
239
+ e.g. `` q1 @ q2`` .
240
240
"""
241
241
if inspect .isclass (other ) and issubclass (other , QueryExpression ):
242
242
other = other () # instantiate
@@ -282,7 +282,7 @@ def join(self, other, semantic_check=True, left=False):
282
282
return result
283
283
284
284
def __add__ (self , other ):
285
- """union e.g. q1 + q2."""
285
+ """union e.g. `` q1 + q2`` ."""
286
286
return Union .create (self , other )
287
287
288
288
def proj (self , * attributes , ** named_attributes ):
@@ -435,7 +435,7 @@ def tail(self, limit=25, **fetch_kwargs):
435
435
return self .fetch (order_by = "KEY DESC" , limit = limit , ** fetch_kwargs )[::- 1 ]
436
436
437
437
def __len__ (self ):
438
- """:return: number of elements in the result set e.g. len(q1)."""
438
+ """:return: number of elements in the result set e.g. `` len(q1)`` ."""
439
439
return self .connection .query (
440
440
'SELECT count(DISTINCT {fields}) FROM {from_}{where}' .format (
441
441
fields = self .heading .as_sql (self .primary_key , include_aliases = False ),
@@ -445,7 +445,7 @@ def __len__(self):
445
445
def __bool__ (self ):
446
446
"""
447
447
:return: True if the result is not empty. Equivalent to len(self) > 0 but often
448
- faster e.g. bool(q1).
448
+ faster e.g. `` bool(q1)`` .
449
449
"""
450
450
return bool (self .connection .query (
451
451
'SELECT EXISTS(SELECT 1 FROM {from_}{where})' .format (
@@ -454,7 +454,8 @@ def __bool__(self):
454
454
455
455
def __contains__ (self , item ):
456
456
"""
457
- returns True if a restriction results with any records e.g. restriction in q1.
457
+ returns True if the restriction in item matches any entries in self
458
+ e.g. ``restriction in q1``.
458
459
:param item: any restriction
459
460
(item in query_expression) is equivalent to bool(query_expression & item) but may be
460
461
executed more efficiently.
@@ -463,7 +464,7 @@ def __contains__(self, item):
463
464
464
465
def __iter__ (self ):
465
466
"""
466
- returns an iterator-compatible QueryExpression object e.g. iter(q1).
467
+ returns an iterator-compatible QueryExpression object e.g. `` iter(q1)`` .
467
468
468
469
:param self: iterator-compatible QueryExpression object
469
470
"""
@@ -474,9 +475,11 @@ def __iter__(self):
474
475
def __next__ (self ):
475
476
"""
476
477
returns the next record on an iterator-compatible QueryExpression object
477
- e.g. next(q1).
478
+ e.g. `` next(q1)`` .
478
479
479
- :param self: fetch1 record
480
+ :param self: A query expression
481
+ :type self: :class:`QueryExpression`
482
+ :rtype: dict
480
483
"""
481
484
try :
482
485
key = self ._iter_keys .pop (0 )
@@ -514,9 +517,11 @@ def cursor(self, offset=0, limit=None, order_by=None, as_dict=False):
514
517
515
518
def __repr__ (self ):
516
519
"""
517
- returns the string representation of a QueryExpression object e.g. str(q1).
520
+ returns the string representation of a QueryExpression object e.g. `` str(q1)`` .
518
521
519
- :param self: String version of query result
522
+ :param self: A query expression
523
+ :type self: :class:`QueryExpression`
524
+ :rtype: str
520
525
"""
521
526
return super ().__repr__ () if config ['loglevel' ].lower () == 'debug' else self .preview ()
522
527
0 commit comments