unset _instance for this class and singleton parents.
(cls)
| 541 | |
| 542 | @classmethod |
| 543 | def clear_instance(cls) -> None: |
| 544 | """unset _instance for this class and singleton parents.""" |
| 545 | if not cls.initialized(): |
| 546 | return |
| 547 | for subclass in cls._walk_mro(): |
| 548 | if isinstance(subclass._instance, cls): |
| 549 | # only clear instances that are instances |
| 550 | # of the calling class |
| 551 | subclass._instance = None # type:ignore[unreachable] |
| 552 | |
| 553 | @classmethod |
| 554 | def instance(cls: type[CT], *args: t.Any, **kwargs: t.Any) -> CT: |