MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / immutabledict

Class immutabledict

lib/sqlalchemy/util/_immutabledict_cy.py:110–240  ·  view source on GitHub ↗

An immutable version of a dict.

Source from the content-addressed store, hash-verified

108# a type checking section and other workaround for the crash
109@cython.cclass
110class immutabledict(Dict[_KT, _VT]):
111 """An immutable version of a dict."""
112
113 # ImmutableDictBase start
114 @classmethod
115 def __class_getitem__( # type: ignore[override]
116 cls, key: Any
117 ) -> type[Self]:
118 return cls
119
120 def __delitem__(self, key: Any) -> NoReturn:
121 _immutable_fn(self)
122
123 def __setitem__(self, key: Any, value: Any) -> NoReturn:
124 _immutable_fn(self)
125
126 def __setattr__(self, key: Any, value: Any) -> NoReturn:
127 _immutable_fn(self)
128
129 def clear(self) -> NoReturn:
130 _immutable_fn(self)
131
132 def pop(self, key: Any, default: Optional[Any] = None) -> NoReturn:
133 _immutable_fn(self)
134
135 def popitem(self) -> NoReturn:
136 _immutable_fn(self)
137
138 def setdefault(self, key: Any, default: Optional[Any] = None) -> NoReturn:
139 _immutable_fn(self)
140
141 def update(self, *arg: Any, **kw: Any) -> NoReturn:
142 _immutable_fn(self)
143
144 # ImmutableDictBase end
145
146 def __repr__(self) -> str:
147 return f"immutabledict({dict.__repr__(self)})"
148
149 @cython.annotation_typing(False) # avoid cython crash from generic return
150 def union(
151 self, *dicts: Optional[Mapping[_KT, _VT]]
152 ) -> immutabledict[_KT, _VT]:
153 return self._union_other(dicts) # type: ignore[no-any-return]
154
155 @cython.annotation_typing(False) # avoid cython crash from generic return
156 def merge_with(
157 self, *dicts: Optional[Mapping[_KT, _VT]]
158 ) -> immutabledict[_KT, _VT]:
159 # this is an alias of union
160 return self._union_other(dicts) # type: ignore[no-any-return]
161
162 @cython.cfunc
163 @cython.inline
164 def _union_other(self, others: tuple) -> immutabledict:
165 size = len(others)
166 if size == 0:
167 return self

Callers 9

create.pyFile · 0.90
engine.pyFile · 0.90
coerce_to_immutabledictFunction · 0.90
_collections.pyFile · 0.90
test_distill_20_dictMethod · 0.90
test_distill_raw_dictMethod · 0.90
_union_otherMethod · 0.70
__or__Method · 0.70
__ror__Method · 0.70

Calls

no outgoing calls

Tested by 2

test_distill_20_dictMethod · 0.72
test_distill_raw_dictMethod · 0.72