Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/multidict/__init__.py: 71%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2Multidict implementation.
4HTTP Headers and URL query string require specific data structure:
5multidict. It behaves mostly like a dict but it can have
6several values for the same key.
7"""
9import warnings
10from pathlib import Path
11from typing import TYPE_CHECKING, Any
13from ._abc import MultiMapping, MutableMultiMapping
14from ._compat import USE_EXTENSIONS
16__all__ = (
17 "CIMultiDict",
18 "CIMultiDictProxy",
19 "MultiDict",
20 "MultiDictProxy",
21 "MultiMapping",
22 "MutableMultiMapping",
23 "get_include",
24 "getversion",
25 "istr",
26)
28__version__ = "7.2.0"
31if TYPE_CHECKING or not USE_EXTENSIONS:
32 from ._multidict_py import (
33 CIMultiDict,
34 CIMultiDictProxy,
35 MultiDict,
36 MultiDictProxy,
37 getversion,
38 istr,
39 )
40else:
41 from collections.abc import ItemsView, KeysView, ValuesView
43 from ._multidict import (
44 CIMultiDict,
45 CIMultiDictProxy,
46 MultiDict,
47 MultiDictProxy,
48 _ItemsView,
49 _KeysView,
50 _ValuesView,
51 getversion,
52 istr,
53 )
55 MultiMapping.register(MultiDictProxy)
56 MutableMultiMapping.register(MultiDict)
57 KeysView.register(_KeysView)
58 ItemsView.register(_ItemsView)
59 ValuesView.register(_ValuesView)
62if TYPE_CHECKING:
63 upstr = istr
64else:
66 def __getattr__(name: str) -> Any:
67 if name == "upstr":
68 warnings.warn(
69 "upstr is deprecated, use istr instead",
70 DeprecationWarning,
71 stacklevel=2,
72 )
73 return istr
74 raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
77def __dir__() -> list[str]:
78 return [*globals(), "upstr"]
81def get_include() -> str:
82 """Return the directory containing multidict's C API headers.
84 Pass it as an ``-I`` include path when building a C extension
85 against ``multidict_capi.h``.
86 """
87 return str(Path(__file__).absolute().parent)