Closed dimbleby closed 1 year ago
Just spotted previous discussion in #384. Conversation there doesn't sound too opposed to this.
IMO it's a very natural thing to have on the API, perhaps the new annoyance with the hard-to-avoid warning, alongside an actual merge request, is enough to settle the matter...
__getitem__
warns that it will raiseKeyError
rather than returningNone
(I see #371 etc)that's all very well but there's currently no comfortable way for users who anticipate missing values to write their code in a way that doesn't trigger that warning. We seem to be steered towards
which sure seems like a lot of ceremony.
The natural way to do it would be just
value = metadata.get(key)
. That method exists, but is not exposed by the protocol so if we try to use it then mypy shouts at usTherefore add
get()
to that protocol (and testcases showing that it works).