Wikibase (the software behind Wikidata) has been updated to support federation. In the old system a wiki was a database (wikidata.org) and another wiki was a client (commons.wikimedia.org). In the new system with federation a client wiki (commons) can be a database wiki too.
We should support this in Pywikibot too. Somewhere hiding on labs is already a test setup. Can someone please add a link to it?
Not sure what we have to do exactly for it,. Feel free to make this task more specific or add subtasks.