Xqt has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1341935?usp=email )
Change subject: Use plain dictionaries for Wikibase claim mappings
......................................................................
Use plain dictionaries for Wikibase claim mappings
Preserve qualifier and reference property insertion order with dict,
which is guaranteed on all supported Python versions. Remove the
unused OrderedDict import.
Document that direct mapping equality is now insensitive to key order.
Claim.same_as() and serialized order remain unchanged.
Change-Id: Ie9b55fc67b5484e2eadd2deb98b44331c51b9202
---
M pywikibot/page/_wikibase.py
1 file changed, 8 insertions(+), 3 deletions(-)
Approvals:
Xqt: Verified; Looks good to me, approved
diff --git a/pywikibot/page/_wikibase.py b/pywikibot/page/_wikibase.py
index 2e1a3a4..ec64857 100644
--- a/pywikibot/page/_wikibase.py
+++ b/pywikibot/page/_wikibase.py
@@ -16,7 +16,7 @@
import json as jsonlib
import re
-from collections import OrderedDict, defaultdict
+from collections import defaultdict
from contextlib import suppress
from itertools import chain
from typing import TYPE_CHECKING, Any, Literal, NoReturn
@@ -1639,6 +1639,11 @@
"""A Claim on a Wikibase entity.
Claims are standard claims as well as references and qualifiers.
+
+ .. version-changed:: 11.8
+ Qualifiers and reference groups loaded from JSON use :class:`dict`
+ instead of :class:`collections.OrderedDict`. Insertion order is
+ preserved; mapping equality no longer depends on key order.
"""
TARGET_CONVERTER = {
@@ -1702,7 +1707,7 @@
if self.isQualifier and self.isReference:
raise ValueError('Claim cannot be both a qualifier and reference.')
self.sources = []
- self.qualifiers = OrderedDict()
+ self.qualifiers = {}
self.target = None
self.snaktype = 'value'
self._on_item = None # The item it's on
@@ -1873,7 +1878,7 @@
Reference objects are represented a bit differently, and require
some more handling.
"""
- source = OrderedDict()
+ source = {}
# Before #84516 Wikibase did not implement snaks-order.
# https://gerrit.wikimedia.org/r/c/84516/
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1341935?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: Ie9b55fc67b5484e2eadd2deb98b44331c51b9202
Gerrit-Change-Number: 1341935
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]