This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients r.david.murray, rhettinger, yahya-abou-imran
Date 2017-12-31.09:39:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1514713178.32.0.467229070634.issue32449@psf.upfronthosting.co.za>
In-reply-to
Content
> After I generate an UML diagram from collections.abc, I found 
> very strange that MappingView inherit from Sized instead
> of Collection (new in python 3.6).

That isn't strange at all.  MappingView predates Collection, so of course it didn't inherit from collection.

> Yes, MappingView only define __len__ and not __iter__ 
> and __contains__, but all of its subclasses define them 
> (KeysView, ValuesView and ItemViews).

It is irrelevant what extra behaviors subclasses may or may not add.  The MappingView ABC is a public API and users are free to use it in other ways (as long as they stick with the publicly document API).  For example, the following is allowed (even it seems odd to you):

    >>> from collections.abc import MappingView
    >>> mv = MappingView(['a', 'b'])
    >>> len(mv)                        # guaranteed
    2
    >>> repr(mv)                       # guaranteed
    "MappingView(['a', 'b'])"
    >>> 'a' in mv                      # not guaranteed 
    Traceback (most recent call last):
      File "<pyshell#9>", line 1, in <module>
        'a' in mv
    TypeError: argument of type 'MappingView' is not iterable
    >>> list(mv)                       # not guaranteed
    Traceback (most recent call last):
      File "<pyshell#10>", line 1, in <module>
        list(mv)
    TypeError: 'MappingView' object is not iterable
History
Date User Action Args
2017-12-31 09:39:38rhettingersetrecipients: + rhettinger, r.david.murray, yahya-abou-imran
2017-12-31 09:39:38rhettingersetmessageid: <1514713178.32.0.467229070634.issue32449@psf.upfronthosting.co.za>
2017-12-31 09:39:38rhettingerlinkissue32449 messages
2017-12-31 09:39:36rhettingercreate