Skip to content

Commit 2402cdf

Browse files
committed
clean up operations
1 parent 523875b commit 2402cdf

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

pymongo/operations.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ def __init__(
376376
else:
377377
self._hint = hint
378378

379+
self._sort = sort
379380
self._filter = filter
380381
self._doc = replacement
381382
self._upsert = upsert
@@ -390,6 +391,7 @@ def _add_to_bulk(self, bulkobj: _AgnosticBulk) -> None:
390391
self._upsert,
391392
collation=validate_collation_or_none(self._collation),
392393
hint=self._hint,
394+
sort=self._sort,
393395
)
394396

395397
def _add_to_client_bulk(self, bulkobj: _AgnosticClientBulk) -> None:
@@ -405,6 +407,7 @@ def _add_to_client_bulk(self, bulkobj: _AgnosticClientBulk) -> None:
405407
self._upsert,
406408
collation=validate_collation_or_none(self._collation),
407409
hint=self._hint,
410+
sort=self._sort,
408411
)
409412

410413
def __eq__(self, other: Any) -> bool:
@@ -416,13 +419,15 @@ def __eq__(self, other: Any) -> bool:
416419
other._collation,
417420
other._hint,
418421
other._namespace,
422+
other._sort,
419423
) == (
420424
self._filter,
421425
self._doc,
422426
self._upsert,
423427
self._collation,
424-
other._hint,
428+
self._hint,
425429
self._namespace,
430+
self._sort,
426431
)
427432
return NotImplemented
428433

@@ -431,22 +436,24 @@ def __ne__(self, other: Any) -> bool:
431436

432437
def __repr__(self) -> str:
433438
if self._namespace:
434-
return "{}({!r}, {!r}, {!r}, {!r}, {!r}, {!r})".format(
439+
return "{}({!r}, {!r}, {!r}, {!r}, {!r}, {!r}, {!r})".format(
435440
self.__class__.__name__,
436441
self._filter,
437442
self._doc,
438443
self._upsert,
439444
self._collation,
440445
self._hint,
441446
self._namespace,
447+
self._sort,
442448
)
443-
return "{}({!r}, {!r}, {!r}, {!r}, {!r})".format(
449+
return "{}({!r}, {!r}, {!r}, {!r}, {!r}, {!r})".format(
444450
self.__class__.__name__,
445451
self._filter,
446452
self._doc,
447453
self._upsert,
448454
self._collation,
449455
self._hint,
456+
self._sort,
450457
)
451458

452459

@@ -485,15 +492,13 @@ def __init__(
485492
self._hint: Union[str, dict[str, Any], None] = helpers_shared._index_document(hint)
486493
else:
487494
self._hint = hint
488-
if sort is not None:
489-
self._sort = sort
490-
491495
self._filter = filter
492496
self._doc = doc
493497
self._upsert = upsert
494498
self._collation = collation
495499
self._array_filters = array_filters
496500
self._namespace = namespace
501+
self._sort = sort
497502

498503
def __eq__(self, other: object) -> bool:
499504
if isinstance(other, type(self)):
@@ -505,6 +510,7 @@ def __eq__(self, other: object) -> bool:
505510
other._array_filters,
506511
other._hint,
507512
other._namespace,
513+
other._sort,
508514
) == (
509515
self._filter,
510516
self._doc,
@@ -513,6 +519,7 @@ def __eq__(self, other: object) -> bool:
513519
self._array_filters,
514520
self._hint,
515521
self._namespace,
522+
self._sort,
516523
)
517524
return NotImplemented
518525

@@ -529,8 +536,8 @@ def __repr__(self) -> str:
529536
self._collation,
530537
self._array_filters,
531538
self._hint,
532-
self._sort,
533539
self._namespace,
540+
self._sort,
534541
)
535542
return "{}({!r}, {!r}, {!r}, {!r}, {!r}, {!r}, {!r})".format(
536543
self.__class__.__name__,
@@ -608,6 +615,7 @@ def _add_to_bulk(self, bulkobj: _AgnosticBulk) -> None:
608615
collation=validate_collation_or_none(self._collation),
609616
array_filters=self._array_filters,
610617
hint=self._hint,
618+
sort=self._sort,
611619
)
612620

613621
def _add_to_client_bulk(self, bulkobj: _AgnosticClientBulk) -> None:
@@ -625,6 +633,7 @@ def _add_to_client_bulk(self, bulkobj: _AgnosticClientBulk) -> None:
625633
collation=validate_collation_or_none(self._collation),
626634
array_filters=self._array_filters,
627635
hint=self._hint,
636+
sort=self._sort,
628637
)
629638

630639

0 commit comments

Comments
 (0)