multidict 6.7.0__cp314-cp314-macosx_10_13_universal2.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of multidict might be problematic. Click here for more details.

multidict/__init__.py ADDED
@@ -0,0 +1,60 @@
1
+ """
2
+ Multidict implementation.
3
+
4
+ HTTP Headers and URL query string require specific data structure:
5
+ multidict. It behaves mostly like a dict but it can have
6
+ several values for the same key.
7
+ """
8
+
9
+ from typing import TYPE_CHECKING
10
+
11
+ from ._abc import MultiMapping, MutableMultiMapping
12
+ from ._compat import USE_EXTENSIONS
13
+
14
+ __all__ = (
15
+ "CIMultiDict",
16
+ "CIMultiDictProxy",
17
+ "MultiDict",
18
+ "MultiDictProxy",
19
+ "MultiMapping",
20
+ "MutableMultiMapping",
21
+ "getversion",
22
+ "istr",
23
+ "upstr",
24
+ )
25
+
26
+ __version__ = "6.7.0"
27
+
28
+
29
+ if TYPE_CHECKING or not USE_EXTENSIONS:
30
+ from ._multidict_py import (
31
+ CIMultiDict,
32
+ CIMultiDictProxy,
33
+ MultiDict,
34
+ MultiDictProxy,
35
+ getversion,
36
+ istr,
37
+ )
38
+ else:
39
+ from collections.abc import ItemsView, KeysView, ValuesView
40
+
41
+ from ._multidict import (
42
+ CIMultiDict,
43
+ CIMultiDictProxy,
44
+ MultiDict,
45
+ MultiDictProxy,
46
+ _ItemsView,
47
+ _KeysView,
48
+ _ValuesView,
49
+ getversion,
50
+ istr,
51
+ )
52
+
53
+ MultiMapping.register(MultiDictProxy)
54
+ MutableMultiMapping.register(MultiDict)
55
+ KeysView.register(_KeysView)
56
+ ItemsView.register(_ItemsView)
57
+ ValuesView.register(_ValuesView)
58
+
59
+
60
+ upstr = istr
multidict/_abc.py ADDED
@@ -0,0 +1,73 @@
1
+ import abc
2
+ from collections.abc import Iterable, Mapping, MutableMapping
3
+ from typing import TYPE_CHECKING, Protocol, TypeVar, Union, overload
4
+
5
+ if TYPE_CHECKING:
6
+ from ._multidict_py import istr
7
+ else:
8
+ istr = str
9
+
10
+ _V = TypeVar("_V")
11
+ _V_co = TypeVar("_V_co", covariant=True)
12
+ _T = TypeVar("_T")
13
+
14
+
15
+ class SupportsKeys(Protocol[_V_co]):
16
+ def keys(self) -> Iterable[str]: ...
17
+ def __getitem__(self, key: str, /) -> _V_co: ...
18
+
19
+
20
+ class SupportsIKeys(Protocol[_V_co]):
21
+ def keys(self) -> Iterable[istr]: ...
22
+ def __getitem__(self, key: istr, /) -> _V_co: ...
23
+
24
+
25
+ MDArg = Union[SupportsKeys[_V], SupportsIKeys[_V], Iterable[tuple[str, _V]], None]
26
+
27
+
28
+ class MultiMapping(Mapping[str, _V_co]):
29
+ @overload
30
+ def getall(self, key: str) -> list[_V_co]: ...
31
+ @overload
32
+ def getall(self, key: str, default: _T) -> Union[list[_V_co], _T]: ...
33
+ @abc.abstractmethod
34
+ def getall(self, key: str, default: _T = ...) -> Union[list[_V_co], _T]:
35
+ """Return all values for key."""
36
+
37
+ @overload
38
+ def getone(self, key: str) -> _V_co: ...
39
+ @overload
40
+ def getone(self, key: str, default: _T) -> Union[_V_co, _T]: ...
41
+ @abc.abstractmethod
42
+ def getone(self, key: str, default: _T = ...) -> Union[_V_co, _T]:
43
+ """Return first value for key."""
44
+
45
+
46
+ class MutableMultiMapping(MultiMapping[_V], MutableMapping[str, _V]):
47
+ @abc.abstractmethod
48
+ def add(self, key: str, value: _V) -> None:
49
+ """Add value to list."""
50
+
51
+ @abc.abstractmethod
52
+ def extend(self, arg: MDArg[_V] = None, /, **kwargs: _V) -> None:
53
+ """Add everything from arg and kwargs to the mapping."""
54
+
55
+ @abc.abstractmethod
56
+ def merge(self, arg: MDArg[_V] = None, /, **kwargs: _V) -> None:
57
+ """Merge into the mapping, adding non-existing keys."""
58
+
59
+ @overload
60
+ def popone(self, key: str) -> _V: ...
61
+ @overload
62
+ def popone(self, key: str, default: _T) -> Union[_V, _T]: ...
63
+ @abc.abstractmethod
64
+ def popone(self, key: str, default: _T = ...) -> Union[_V, _T]:
65
+ """Remove specified key and return the corresponding value."""
66
+
67
+ @overload
68
+ def popall(self, key: str) -> list[_V]: ...
69
+ @overload
70
+ def popall(self, key: str, default: _T) -> Union[list[_V], _T]: ...
71
+ @abc.abstractmethod
72
+ def popall(self, key: str, default: _T = ...) -> Union[list[_V], _T]:
73
+ """Remove all occurrences of key and return the list of corresponding values."""
multidict/_compat.py ADDED
@@ -0,0 +1,15 @@
1
+ import os
2
+ import platform
3
+
4
+ NO_EXTENSIONS = bool(os.environ.get("MULTIDICT_NO_EXTENSIONS"))
5
+
6
+ PYPY = platform.python_implementation() == "PyPy"
7
+
8
+ USE_EXTENSIONS = not NO_EXTENSIONS and not PYPY
9
+
10
+ if USE_EXTENSIONS:
11
+ try:
12
+ from . import _multidict # type: ignore[attr-defined] # noqa: F401
13
+ except ImportError: # pragma: no cover
14
+ # FIXME: Refactor for coverage. See #837.
15
+ USE_EXTENSIONS = False