Skip to content

MAINT: use collections.abc for 3.7 #11733

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

Merged
merged 3 commits into from
Jul 24, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions lib/matplotlib/cbook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"""

import collections
import collections.abc
import contextlib
import datetime
import errno
Expand Down Expand Up @@ -1638,7 +1639,8 @@ def pts_to_midstep(x, *args):
The x location of the steps. May be empty.

y1, ..., yp : array
y arrays to be turned into steps; all must be the same length as ``x``.
y arrays to be turned into steps; all must be the same length as
``x``.

Returns
-------
Expand Down Expand Up @@ -1697,7 +1699,7 @@ def index_of(y):


def safe_first_element(obj):
if isinstance(obj, collections.Iterator):
if isinstance(obj, collections.abc.Iterator):
# needed to accept `array.flat` as input.
# np.flatiter reports as an instance of collections.Iterator
# but can still be indexed via [].
Expand All @@ -1714,7 +1716,8 @@ def safe_first_element(obj):

def sanitize_sequence(data):
"""Converts dictview object to list"""
return list(data) if isinstance(data, collections.MappingView) else data
return (list(data) if isinstance(data, collections.abc.MappingView)
else data)


def normalize_kwargs(kw, alias_mapping=None, required=(), forbidden=(),
Expand Down Expand Up @@ -2088,7 +2091,7 @@ def _warn_external(message, category=None):
warnings.warn(message, category, stacklevel)


class _OrderedSet(collections.MutableSet):
class _OrderedSet(collections.abc.MutableSet):
def __init__(self):
self._od = collections.OrderedDict()

Expand Down