MCPcopy Create free account
hub / github.com/cdgriffith/Box / __new__

Method __new__

box/box.py:360–372  ·  view source on GitHub ↗

Due to the way pickling works in python 3, we need to make sure the box config is created as early as possible.

(cls, *args: Any, **kwargs: Any)

Source from the content-addressed store, hash-verified

358 cls._box_resolved_defaults = {**getattr(cls, "_box_resolved_defaults", {}), **own}
359
360 def __new__(cls, *args: Any, **kwargs: Any):
361 """
362 Due to the way pickling works in python 3, we need to make sure
363 the box config is created as early as possible.
364 """
365 config = _build_box_config(cls, kwargs)
366 obj = super().__new__(cls, *args, **kwargs)
367 obj._box_config = config
368 # Pickle reconstructs via __new__ + item assignment + __setstate__.
369 # Item assignment happens first, while this Box still has default options,
370 # so nested Box/BoxList values must be stored as-is (see __convert_and_store).
371 obj._box_config["__unpickling"] = True
372 return obj
373
374 def __init__(self, *args: Any, **kwargs: Any):
375 super().__init__()

Callers

nothing calls this directly

Calls 1

_build_box_configFunction · 0.85

Tested by

no test coverage detected