Navigation | Overlay |
---|---|
t Navigate files | h Toggle hits |
y Change url to tip of branch | m Toggle misses |
b / v Jump to prev/next hit line | p Toggle partial |
z / x Jump to prev/next missed or partial line | 1..9 Toggle flags |
shift + o Open current page in GitHub | a Toggle all on |
/ or ? Show keyboard shortcuts dialog | c Toggle context lines or commits |
1 | 34 |
import abc |
2 | 34 |
from collections.abc import Mapping, MutableMapping |
3 |
|
|
4 |
|
|
5 | 34 |
class _TypingMeta(abc.ABCMeta): |
6 |
# A fake metaclass to satisfy typing deps in runtime
|
|
7 |
# basically MultiMapping[str] and other generic-like type instantiations
|
|
8 |
# are emulated.
|
|
9 |
# Note: real type hints are provided by __init__.pyi stub file
|
|
10 | 34 |
def __getitem__(self, key): |
11 | 34 |
return self |
12 |
|
|
13 |
|
|
14 | 34 |
class MultiMapping(Mapping, metaclass=_TypingMeta): |
15 | 34 |
@abc.abstractmethod
|
16 | 34 |
def getall(self, key, default=None): |
17 | 34 |
raise KeyError |
18 |
|
|
19 | 34 |
@abc.abstractmethod
|
20 | 34 |
def getone(self, key, default=None): |
21 | 34 |
raise KeyError |
22 |
|
|
23 |
|
|
24 | 34 |
class MutableMultiMapping(MultiMapping, MutableMapping): |
25 | 34 |
@abc.abstractmethod
|
26 | 16 |
def add(self, key, value): |
27 | 34 |
raise NotImplementedError |
28 |
|
|
29 | 34 |
@abc.abstractmethod
|
30 | 16 |
def extend(self, *args, **kwargs): |
31 | 34 |
raise NotImplementedError |
32 |
|
|
33 | 34 |
@abc.abstractmethod
|
34 | 34 |
def popone(self, key, default=None): |
35 | 34 |
raise KeyError |
36 |
|
|
37 | 34 |
@abc.abstractmethod
|
38 | 34 |
def popall(self, key, default=None): |
39 | 34 |
raise KeyError |
Read our documentation on viewing source code .