Page MenuHomePhabricator

__contains__ method of SiteInfo does not work as expected
Closed, ResolvedPublicBUG REPORT

Description

List of steps to reproduce:

SiteInfo is a container but the in operator does not work as expected with the key is not already preloaded:

import pywikibot
s = pywikibot.Site()
'dbrepllag' in s.siteinfo
False
s.siteinfo['dbrepllag']
[{'host': 'db1144:3315', 'lag': 0.493909}]
'dbrepllag' in s.siteinfo
True

What should have happened instead?:

'dbrepllag' in s.siteinfo should return True even it is not preloaded:

import pywikibot
s = pywikibot.Site()
'dbrepllag' in s.siteinfo
True
s.siteinfo['dbrepllag']
[{'host': 'db1144:3315', 'lag': 0.493909}]
'dbrepllag' in s.siteinfo
True

Software version:
Pywikibot 3.0.20190430+

Event Timeline

Xqt triaged this task as High priority.Mar 2 2022, 9:20 AM

Change 767481 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] [IMPR] Always check for real Siteinfo contents with __contains__

https://gerrit.wikimedia.org/r/767481

Change 767481 merged by jenkins-bot:

[pywikibot/core@master] [IMPR] Always check for real Siteinfo contents with __contains__

https://gerrit.wikimedia.org/r/767481

Xqt claimed this task.