Import MutableMapping and MutableSet from collections.abc.

Aliases in collections itself are removed in 3.8.
This commit is contained in:
Valentin Lorentz 2020-01-09 01:11:02 +01:00
parent 94ca4cc810
commit 0fccea30ce
3 changed files with 7 additions and 7 deletions

View File

@ -36,7 +36,7 @@ import codecs
import fnmatch import fnmatch
import os.path import os.path
import threading import threading
import collections import collections.abc
from .. import callbacks, conf, dbi, ircdb, ircutils, log, utils, world from .. import callbacks, conf, dbi, ircdb, ircutils, log, utils, world
from ..commands import * from ..commands import *
@ -174,7 +174,7 @@ class DbiChannelDB(object):
return _getDbAndDispatcher return _getDbAndDispatcher
class ChannelUserDictionary(collections.MutableMapping): class ChannelUserDictionary(collections.abc.MutableMapping):
IdDict = dict IdDict = dict
def __init__(self): def __init__(self):
self.channels = ircutils.IrcDict() self.channels = ircutils.IrcDict()

View File

@ -37,7 +37,7 @@ import textwrap
import warnings import warnings
import functools import functools
import traceback import traceback
import collections import collections.abc
from . import crypt from . import crypt
@ -254,7 +254,7 @@ class IterableMap(object):
__nonzero__ = __bool__ __nonzero__ = __bool__
class InsensitivePreservingDict(collections.MutableMapping): class InsensitivePreservingDict(collections.abc.MutableMapping):
def key(self, s): def key(self, s):
"""Override this if you wish.""" """Override this if you wish."""
if s is not None: if s is not None:

View File

@ -32,7 +32,7 @@ Data structures for Python.
""" """
import time import time
import collections import collections.abc
class RingBuffer(object): class RingBuffer(object):
@ -427,7 +427,7 @@ class MultiSet(object):
return elt in self.d return elt in self.d
class CacheDict(collections.MutableMapping): class CacheDict(collections.abc.MutableMapping):
__slots__ = ('d', 'max') __slots__ = ('d', 'max')
def __init__(self, max, **kwargs): def __init__(self, max, **kwargs):
self.d = dict(**kwargs) self.d = dict(**kwargs)
@ -456,7 +456,7 @@ class CacheDict(collections.MutableMapping):
def __len__(self): def __len__(self):
return len(self.d) return len(self.d)
class TruncatableSet(collections.MutableSet): class TruncatableSet(collections.abc.MutableSet):
"""A set that keeps track of the order of inserted elements so """A set that keeps track of the order of inserted elements so
the oldest can be removed.""" the oldest can be removed."""
__slots__ = ('_ordered_items', '_items') __slots__ = ('_ordered_items', '_items')