import pywikibot

site = pywikibot.Site("wikidata", "wikidata")
repo = site.data_repository()
item = pywikibot.ItemPage(repo, "L42")

print(item)
---------------------------------------------------------------------------
InvalidTitle                              Traceback (most recent call last)
<ipython-input-1-d182b6cdd526> in <module>
      3 site = pywikibot.Site("wikidata", "wikidata")
      4 repo = site.data_repository()
----> 5 item = pywikibot.ItemPage(repo, "L42")
      6 
      7 print(item)

/srv/paws/pwb/pywikibot/page.py in __init__(self, site, title, ns)
   4358             raise pywikibot.InvalidTitle("Item's title cannot be empty")
   4359 
-> 4360         super(ItemPage, self).__init__(site, title, ns=ns)
   4361 
   4362         assert self.id == self._link.title

/srv/paws/pwb/pywikibot/page.py in __init__(self, site, title, **kwargs)
   3788             raise pywikibot.InvalidTitle(
   3789                 "'%s' is not a valid %s page title"
-> 3790                 % (self.id, self.entity_type))
   3791 
   3792     def _defined_by(self, singular=False):

InvalidTitle: 'L42' is not a valid item page title