New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MutableMapping code smell (see OrderedDict) #49652
Comments
Copy of bpo-5397 In python 3, UserDict (and DictMixin) are gone; presumably they should Unfortunately, there doesn't seem to be a clean way to inherit from In python 2.x, you could write class MyDict(DictMixin, dict): ... but with class MyDict(MutableMapping, dict): ... MutableMapping explicitly overrides __getitem__, __setitem__, and The OrderedDict implementation in bpo-5397 puts the concrete class Both solutions seem fragile. Unfortunately, the closest I come to a solution is to split the ABC # The concrete methods of the current ABC
class MapMixin:
# The abstract methods that get checked
class MutableMapping(MapMixin):
# Trust that dict will always implement
# all required concrete methods for us
class MyDict(MapMixin, dict): |
FWIW, I'm happy with Guido's design of MutableMapping. It parallels all The case with OrderedDict is not a typical use of mixins because the With OrderedDict, the only reason we subclassed from dict was to provide The proposed splitting of MutableMapping looks unhealthy and overly If this *really* bugs you, OrderedDict doesn't have to inherit from FWIW, the UserDict class in Py3.x was relocated to the collections |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: