dahlia / wikidata

Wikidata client library for Python
https://pypi.org/project/Wikidata/
GNU General Public License v3.0
337 stars 31 forks source link

Entity.lists() is not robust to unknown locales #27

Closed nelson-liu closed 4 years ago

nelson-liu commented 4 years ago

See, for instance:

client = Client()
client.get("Q5", load=True).lists()
*** babel.core.UnknownLocaleError: unknown locale 'io'

I know that I can manually access all the data, but it'd be nice if .lists() was a bit more robust...

dahlia commented 4 years ago

Babel is a library for software internationalization (like translating UI messages), so its Locale deals with only languages listed in Unicode CLDR. Babel seems to have no plan to provide a way to instantiate Locale object with an “unknown locale.”

One possible solution would be to remove Babel from this project's dependencies. We could declare an our own distinct type instead, in the same way we declared EntityId:

Locale = NewType('Locale', str)