(self, item, attr=False)
| 501 | return False |
| 502 | |
| 503 | def __get_default(self, item, attr=False): |
| 504 | if item in ("getdoc", "shape") and _is_ipython(): |
| 505 | return None |
| 506 | default_value = self._box_config["default_box_attr"] |
| 507 | if default_value in (self._box_config["box_class"], dict): |
| 508 | value = self._box_config["box_class"](**self.__box_config(extra_namespace=item)) |
| 509 | elif isinstance(default_value, dict): |
| 510 | value = self._box_config["box_class"](**self.__box_config(extra_namespace=item), **default_value) |
| 511 | elif isinstance(default_value, list): |
| 512 | value = box.BoxList(**self.__box_config(extra_namespace=item)) |
| 513 | elif isinstance(default_value, Callable): |
| 514 | args = [] |
| 515 | kwargs = {} |
| 516 | p_sigs = [ |
| 517 | p.name |
| 518 | for p in signature(default_value).parameters.values() |
| 519 | if p.kind in (p.POSITIONAL_ONLY, p.POSITIONAL_OR_KEYWORD) |
| 520 | ] |
| 521 | k_sigs = [p.name for p in signature(default_value).parameters.values() if p.kind is p.KEYWORD_ONLY] |
| 522 | for name in p_sigs: |
| 523 | if name not in ("key", "box_instance"): |
| 524 | raise BoxError("default_box_attr can only have the arguments 'key' and 'box_instance'") |
| 525 | if "key" in p_sigs: |
| 526 | args.append(item) |
| 527 | if "box_instance" in p_sigs: |
| 528 | args.insert(p_sigs.index("box_instance"), self) |
| 529 | if "key" in k_sigs: |
| 530 | kwargs["key"] = item |
| 531 | if "box_instance" in k_sigs: |
| 532 | kwargs["box_instance"] = self |
| 533 | value = default_value(*args, **kwargs) |
| 534 | elif hasattr(default_value, "copy"): |
| 535 | value = default_value.copy() |
| 536 | else: |
| 537 | value = default_value |
| 538 | if self._box_config["default_box_create_on_get"]: |
| 539 | if not attr or not (item.startswith("_") and item.endswith("_")): |
| 540 | if self.__process_dotted_key(item): |
| 541 | first_item, children = _parse_box_dots(self, item, setting=True) |
| 542 | if first_item in self.keys(): |
| 543 | if hasattr(self[first_item], "__setitem__"): |
| 544 | self[first_item].__setitem__(children, value) |
| 545 | else: |
| 546 | super().__setitem__( |
| 547 | first_item, self._box_config["box_class"](**self.__box_config(extra_namespace=first_item)) |
| 548 | ) |
| 549 | self[first_item].__setitem__(children, value) |
| 550 | else: |
| 551 | super().__setitem__(item, value) |
| 552 | return value |
| 553 | |
| 554 | def __box_config(self, extra_namespace: Any = NO_NAMESPACE) -> dict: |
| 555 | out = {} |
no test coverage detected