Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/multidict/_abc.py: 73%
30 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-08 06:40 +0000
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-08 06:40 +0000
1import abc
2import sys
3import types
4from collections.abc import Mapping, MutableMapping
7class _TypingMeta(abc.ABCMeta):
8 # A fake metaclass to satisfy typing deps in runtime
9 # basically MultiMapping[str] and other generic-like type instantiations
10 # are emulated.
11 # Note: real type hints are provided by __init__.pyi stub file
12 if sys.version_info >= (3, 9):
14 def __getitem__(self, key):
15 return types.GenericAlias(self, key)
17 else:
19 def __getitem__(self, key):
20 return self
23class MultiMapping(Mapping, metaclass=_TypingMeta):
24 @abc.abstractmethod
25 def getall(self, key, default=None):
26 raise KeyError
28 @abc.abstractmethod
29 def getone(self, key, default=None):
30 raise KeyError
33class MutableMultiMapping(MultiMapping, MutableMapping):
34 @abc.abstractmethod
35 def add(self, key, value):
36 raise NotImplementedError
38 @abc.abstractmethod
39 def extend(self, *args, **kwargs):
40 raise NotImplementedError
42 @abc.abstractmethod
43 def popone(self, key, default=None):
44 raise KeyError
46 @abc.abstractmethod
47 def popall(self, key, default=None):
48 raise KeyError