MCPcopy Create free account
hub / github.com/rthalley/dnspython / __init__

Method __init__

dns/immutable.py:11–28  ·  view source on GitHub ↗

Make an immutable dictionary from the specified dictionary. If *no_copy* is `True`, then *dictionary* will be wrapped instead of copied. Only set this if you are sure there will be no external references to the dictionary.

(
        self,
        dictionary: Any,
        no_copy: bool = False,
        map_factory: Callable[[], collections.abc.MutableMapping] = dict,
    )

Source from the content-addressed store, hash-verified

9@immutable
10class Dict(collections.abc.Mapping): # lgtm[py/missing-equals]
11 def __init__(
12 self,
13 dictionary: Any,
14 no_copy: bool = False,
15 map_factory: Callable[[], collections.abc.MutableMapping] = dict,
16 ):
17 """Make an immutable dictionary from the specified dictionary.
18
19 If *no_copy* is `True`, then *dictionary* will be wrapped instead
20 of copied. Only set this if you are sure there will be no external
21 references to the dictionary.
22 """
23 if no_copy and isinstance(dictionary, collections.abc.MutableMapping):
24 self._odict = dictionary
25 else:
26 self._odict = map_factory()
27 self._odict.update(dictionary)
28 self._hash = None
29
30 def __getitem__(self, key):
31 return self._odict.__getitem__(key)

Callers

nothing calls this directly

Calls 1

updateMethod · 0.45

Tested by

no test coverage detected