This all likes fine to me, but it made me realize we never fixed the implementation of __getitem__(). If an object is missing a key, then it should raise a KeyError when __getitem__ is called. In contrast, we just have it returning None if the key is missing. The code will definitely function, but this is slightly non-standard behavior.
Realistically, how we want to implement it is have __getitem__ raise a KeyError, and then instead of a series of if statements, it should be a series of try..except blocks. Other than that implementation detail that's not directly related to this PR, the logic of this seems fine to me.
This all likes fine to me, but it made me realize we never fixed the implementation of
__getitem__()
. If an object is missing a key, then it should raise aKeyError
when__getitem__
is called. In contrast, we just have it returningNone
if the key is missing. The code will definitely function, but this is slightly non-standard behavior.Realistically, how we want to implement it is have
__getitem__
raise aKeyError
, and then instead of a series ofif
statements, it should be a series oftry..except
blocks. Other than that implementation detail that's not directly related to this PR, the logic of this seems fine to me.