Page MenuHomePhabricator

Pywikibot fails with test.wikidata in PAWS
Closed, ResolvedPublic


While trying to use to play with pywikibot-Wikidata in PAWS we get an error EntityTypeUnknownException: DataSite("test", "wikidata") does not support entity type "item"

import pywikibot
    site = pywikibot.Site("test", "wikidata")

def create_item(site, label_dict):
    new_item = pywikibot.ItemPage(site)
    new_item.editLabels(labels=label_dict, summary="Setting labels")
    # Add description here or in another function
    return new_item.getID()

some_labels = {"en": "Hamburg Main Station", "de": "Hamburg Hauptbahnhof"}
new_item_id = create_item(site, some_labels)

EntityTypeUnknownException                Traceback (most recent call last)
<ipython-input-10-07e996cb8911> in <module>
     10 some_labels = {"en": "Hamburg Main Station", "de": "Hamburg Hauptbahnhof"}
---> 11 new_item_id = create_item(site, some_labels)

<ipython-input-10-07e996cb8911> in create_item(site, label_dict)
      4 def create_item(site, label_dict):
----> 5     new_item = pywikibot.ItemPage(site)
      6     new_item.editLabels(labels=label_dict, summary="Setting labels")
      7     # Add description here or in another function

/srv/paws/pwb/pywikibot/ in __init__(self, site, title, ns)
   4347         """
   4348         if ns is None:
-> 4349             ns = site.item_namespace
   4350         # Special case for empty item.
   4351         if title is None or title == '-1':

/srv/paws/pwb/pywikibot/ in item_namespace(self)
   7524             raise EntityTypeUnknownException(
   7525                 '%r does not support entity type "item"'
-> 7526                 % self)
   7528     @property

EntityTypeUnknownException: DataSite("test", "wikidata") does not support entity type "item"

Event Timeline

Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald Transcript

There is no similar issue on Travis (py3.4). I can not reproduce it either (py3.7).

Niether can I:

>>> import pywikibot
>>> site = pywikibot.Site('test', 'wikidata')
>>> site.item_namespace
Namespace(id=0, custom_name='', canonical_name='', aliases=['Item'], case='first-letter', content=True, defaultcontentmodel='wikibase-item', nonincludable=False, subpages=False)
>>> isinstance(site._item_namespace,

Sorry, this was in PAWS, so maybe something we're doing with Auth there is messing this up.

Chicocvenancio renamed this task from Pywikibot fails with test.wikidata to Pywikibot fails with test.wikidata in PAWS.May 19 2019, 1:58 PM
Chicocvenancio claimed this task.
Chicocvenancio updated the task description. (Show Details)

Not quite sure what happened, while it still shows up on @Jampo001's notebook. Trying again from PAWS just now got me no errors.

@Jampo001 could you rerun that notebook to see if the error persists?

There is no error so it seems to be fixed it also created an item on test wikidata instance :)
Thank you @Chicocvenancio