(
self,
*args: Any,
default_box: bool = False,
default_box_attr: Any = NO_DEFAULT,
default_box_none_transform: bool = True,
default_box_create_on_get: bool = True,
frozen_box: bool = False,
camel_killer_box: bool = False,
conversion_box: bool = True,
modify_tuples_box: bool = False,
box_safe_prefix: str = "x",
box_duplicates: str = "ignore",
box_intact_types: tuple | list = (),
box_recast: dict | None = None,
box_dots: bool = False,
box_dots_exclude: str | None = None,
box_class: dict | type[Box] | None = None,
box_namespace: tuple[str, ...] | Literal[False] = (),
**kwargs: Any,
)
| 240 | return obj |
| 241 | |
| 242 | def __init__( |
| 243 | self, |
| 244 | *args: Any, |
| 245 | default_box: bool = False, |
| 246 | default_box_attr: Any = NO_DEFAULT, |
| 247 | default_box_none_transform: bool = True, |
| 248 | default_box_create_on_get: bool = True, |
| 249 | frozen_box: bool = False, |
| 250 | camel_killer_box: bool = False, |
| 251 | conversion_box: bool = True, |
| 252 | modify_tuples_box: bool = False, |
| 253 | box_safe_prefix: str = "x", |
| 254 | box_duplicates: str = "ignore", |
| 255 | box_intact_types: tuple | list = (), |
| 256 | box_recast: dict | None = None, |
| 257 | box_dots: bool = False, |
| 258 | box_dots_exclude: str | None = None, |
| 259 | box_class: dict | type[Box] | None = None, |
| 260 | box_namespace: tuple[str, ...] | Literal[False] = (), |
| 261 | **kwargs: Any, |
| 262 | ): |
| 263 | super().__init__() |
| 264 | self._box_config = _get_box_config() |
| 265 | self._box_config.update( |
| 266 | { |
| 267 | "default_box": default_box, |
| 268 | "default_box_attr": self.__class__ if default_box_attr is NO_DEFAULT else default_box_attr, |
| 269 | "default_box_none_transform": default_box_none_transform, |
| 270 | "default_box_create_on_get": default_box_create_on_get, |
| 271 | "conversion_box": conversion_box, |
| 272 | "box_safe_prefix": box_safe_prefix, |
| 273 | "frozen_box": frozen_box, |
| 274 | "camel_killer_box": camel_killer_box, |
| 275 | "modify_tuples_box": modify_tuples_box, |
| 276 | "box_duplicates": box_duplicates, |
| 277 | "box_intact_types": tuple(box_intact_types), |
| 278 | "box_recast": box_recast, |
| 279 | "box_dots": box_dots, |
| 280 | "box_dots_exclude": re.compile(box_dots_exclude) if box_dots_exclude else None, |
| 281 | "box_class": box_class if box_class is not None else self.__class__, |
| 282 | "box_namespace": box_namespace, |
| 283 | } |
| 284 | ) |
| 285 | if not self._box_config["conversion_box"] and self._box_config["box_duplicates"] != "ignore": |
| 286 | raise BoxError("box_duplicates are only for conversion_boxes") |
| 287 | if len(args) == 1: |
| 288 | if isinstance(args[0], str): |
| 289 | raise BoxValueError("Cannot extrapolate Box from string") |
| 290 | if isinstance(args[0], Mapping): |
| 291 | for k, v in args[0].items(): |
| 292 | if v is args[0]: |
| 293 | v = self |
| 294 | if v is None and self._box_config["default_box"] and self._box_config["default_box_none_transform"]: |
| 295 | continue |
| 296 | self.__setitem__(k, v) |
| 297 | elif isinstance(args[0], Iterable): |
| 298 | for k, v in args[0]: |
| 299 | self.__setitem__(k, v) |
nothing calls this directly
no test coverage detected