Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
WISEPLAT
GitHub Repository: WISEPLAT/python-code
Path: blob/master/ invest-robot-contest_TinkoffBotTwitch-main/venv/lib/python3.8/site-packages/multidict/_abc.py
12295 views
1
import abc
2
import sys
3
import types
4
from collections.abc import Mapping, MutableMapping
5
6
7
class _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):
13
14
def __getitem__(self, key):
15
return types.GenericAlias(self, key)
16
17
else:
18
19
def __getitem__(self, key):
20
return self
21
22
23
class MultiMapping(Mapping, metaclass=_TypingMeta):
24
@abc.abstractmethod
25
def getall(self, key, default=None):
26
raise KeyError
27
28
@abc.abstractmethod
29
def getone(self, key, default=None):
30
raise KeyError
31
32
33
class MutableMultiMapping(MultiMapping, MutableMapping):
34
@abc.abstractmethod
35
def add(self, key, value):
36
raise NotImplementedError
37
38
@abc.abstractmethod
39
def extend(self, *args, **kwargs):
40
raise NotImplementedError
41
42
@abc.abstractmethod
43
def popone(self, key, default=None):
44
raise KeyError
45
46
@abc.abstractmethod
47
def popall(self, key, default=None):
48
raise KeyError
49
50