Skip to content

Commit

Permalink
Fix #102: Introduce abstract base classes
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Oct 4, 2017
1 parent 498c718 commit bdb4816
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
3.3.0 (2017-10-xx)
------------------

* Introduce abstract base classes (#102)


3.2.0 (2017-09-17)
------------------

Expand Down
5 changes: 4 additions & 1 deletion multidict/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
from ._compat import USE_CYTHON_EXTENSIONS


__all__ = ('MultiDictProxy', 'CIMultiDictProxy',
__all__ = ('MultiMapping', 'MutableMultiMapping',
'MultiDictProxy', 'CIMultiDictProxy',
'MultiDict', 'CIMultiDict', 'upstr', 'istr')

__version__ = '3.2.0'


from ._abc import MultiMapping, MutableMultiMapping

try:
if not USE_CYTHON_EXTENSIONS:
raise ImportError
Expand Down
9 changes: 5 additions & 4 deletions multidict/_multidict.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ from collections.abc import Iterable, Set

from cpython.object cimport PyObject_Str

from ._abc import MultiMapping, MutableMultiMapping
from ._istr import istr

cdef object _marker = object()
Expand Down Expand Up @@ -238,7 +239,7 @@ cdef class MultiDictProxy(_Base):
"""Return a copy of itself."""
return self._base_class(self)

abc.Mapping.register(MultiDictProxy)
MultiMapping.register(MultiDictProxy)


cdef class CIMultiDictProxy(MultiDictProxy):
Expand All @@ -254,7 +255,7 @@ cdef class CIMultiDictProxy(MultiDictProxy):
return s.title()


abc.Mapping.register(CIMultiDictProxy)
MultiMapping.register(CIMultiDictProxy)


cdef str _str(key):
Expand Down Expand Up @@ -519,7 +520,7 @@ cdef class MultiDict(_Base):
self._extend(args, kwargs, "update", False)


abc.MutableMapping.register(MultiDict)
MutableMultiMapping.register(MultiDict)


cdef class CIMultiDict(MultiDict):
Expand Down Expand Up @@ -551,7 +552,7 @@ cdef class CIMultiDict(MultiDict):



abc.MutableMapping.register(CIMultiDict)
MutableMultiMapping.register(CIMultiDict)


cdef class _ViewBase:
Expand Down
7 changes: 5 additions & 2 deletions multidict/_multidict_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
from collections import abc
import sys

from ._abc import MultiMapping, MutableMultiMapping


_marker = object()


Expand Down Expand Up @@ -140,7 +143,7 @@ def __repr__(self):
return '<{}({})>'.format(self.__class__.__name__, body)


class MultiDictProxy(_Base, abc.Mapping):
class MultiDictProxy(_Base, MultiMapping):

def __init__(self, arg):
if not isinstance(arg, (MultiDict, MultiDictProxy)):
Expand Down Expand Up @@ -179,7 +182,7 @@ def copy(self):
return CIMultiDict(self.items())


class MultiDict(_Base, abc.MutableMapping):
class MultiDict(_Base, MutableMultiMapping):

def __init__(self, *args, **kwargs):
self._impl = _Impl()
Expand Down

0 comments on commit bdb4816

Please sign in to comment.