mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
bpo-32467: Let collections.abc.ValuesView inherit from Collection (#5152)
This commit is contained in:
parent
782d6fe443
commit
02556fbade
4 changed files with 6 additions and 4 deletions
|
|
@ -87,7 +87,8 @@ ABC Inherits from Abstract Methods Mixin
|
|||
:class:`Set` ``__iter__``
|
||||
:class:`KeysView` :class:`MappingView`, ``__contains__``,
|
||||
:class:`Set` ``__iter__``
|
||||
:class:`ValuesView` :class:`MappingView` ``__contains__``, ``__iter__``
|
||||
:class:`ValuesView` :class:`MappingView`, ``__contains__``, ``__iter__``
|
||||
:class:`Collection`
|
||||
:class:`Awaitable` ``__await__``
|
||||
:class:`Coroutine` :class:`Awaitable` ``send``, ``throw`` ``close``
|
||||
:class:`AsyncIterable` ``__aiter__``
|
||||
|
|
|
|||
|
|
@ -746,7 +746,7 @@ def __iter__(self):
|
|||
ItemsView.register(dict_items)
|
||||
|
||||
|
||||
class ValuesView(MappingView):
|
||||
class ValuesView(MappingView, Collection):
|
||||
|
||||
__slots__ = ()
|
||||
|
||||
|
|
|
|||
|
|
@ -843,13 +843,13 @@ def test_Collection(self):
|
|||
self.assertFalse(issubclass(type(x), Collection), repr(type(x)))
|
||||
# Check some non-collection iterables
|
||||
non_col_iterables = [_test_gen(), iter(b''), iter(bytearray()),
|
||||
(x for x in []), dict().values()]
|
||||
(x for x in [])]
|
||||
for x in non_col_iterables:
|
||||
self.assertNotIsInstance(x, Collection)
|
||||
self.assertFalse(issubclass(type(x), Collection), repr(type(x)))
|
||||
# Check some collections
|
||||
samples = [set(), frozenset(), dict(), bytes(), str(), tuple(),
|
||||
list(), dict().keys(), dict().items()]
|
||||
list(), dict().keys(), dict().items(), dict().values()]
|
||||
for x in samples:
|
||||
self.assertIsInstance(x, Collection)
|
||||
self.assertTrue(issubclass(type(x), Collection), repr(type(x)))
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
collections.abc.ValuesView now inherits from collections.abc.Collection.
|
||||
Loading…
Add table
Add a link
Reference in a new issue