jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1336199?usp=email )
Change subject: itertools: Deduplicate intersections with a single input
......................................................................
itertools: Deduplicate intersections with a single input
The single-input shortcut yielded every value even when allow_duplicates
was false, unlike intersections with multiple inputs.
Use filter_unique for a single input when duplicates are disabled,
preserving encounter order and lazy iteration. Retain the direct pass
through when duplicates are explicitly allowed.
Change-Id: Ia8fec7805d78f2682be88ba58306428ac08932ca
---
M pywikibot/tools/itertools.py
1 file changed, 4 insertions(+), 1 deletion(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pywikibot/tools/itertools.py b/pywikibot/tools/itertools.py
index c32ac4a..b7d4949 100644
--- a/pywikibot/tools/itertools.py
+++ b/pywikibot/tools/itertools.py
@@ -140,7 +140,10 @@
return
if len(iterables) == 1:
- yield from iterables[0]
+ if allow_duplicates:
+ yield from iterables[0]
+ else:
+ yield from filter_unique(iterables[0])
return
# If any iterable is empty, no pages are going to be returned
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1336199?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ia8fec7805d78f2682be88ba58306428ac08932ca
Gerrit-Change-Number: 1336199
Gerrit-PatchSet: 2
Gerrit-Owner: Mahveotm <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]