Descriptor used by target classes to deliver the _Dispatch class at the class level and produce new _Dispatch instances for target instances.
| 426 | |
| 427 | |
| 428 | class dispatcher(Generic[_ET]): |
| 429 | """Descriptor used by target classes to |
| 430 | deliver the _Dispatch class at the class level |
| 431 | and produce new _Dispatch instances for target |
| 432 | instances. |
| 433 | |
| 434 | """ |
| 435 | |
| 436 | def __init__(self, events: Type[_HasEventsDispatch[_ET]]): |
| 437 | self.dispatch = events.dispatch |
| 438 | self.events = events |
| 439 | |
| 440 | @overload |
| 441 | def __get__( |
| 442 | self, obj: Literal[None], cls: Type[Any] |
| 443 | ) -> Type[_Dispatch[_ET]]: ... |
| 444 | |
| 445 | @overload |
| 446 | def __get__(self, obj: Any, cls: Type[Any]) -> _DispatchCommon[_ET]: ... |
| 447 | |
| 448 | def __get__(self, obj: Any, cls: Type[Any]) -> Any: |
| 449 | if obj is None: |
| 450 | return self.dispatch |
| 451 | |
| 452 | disp = self.dispatch._for_instance(obj) |
| 453 | try: |
| 454 | obj.__dict__["dispatch"] = disp |
| 455 | except AttributeError as ae: |
| 456 | raise TypeError( |
| 457 | "target %r doesn't have __dict__, should it be " |
| 458 | "defining _slots_dispatch?" % (obj,) |
| 459 | ) from ae |
| 460 | return disp |
| 461 | |
| 462 | |
| 463 | class slots_dispatcher(dispatcher[_ET]): |
no outgoing calls
no test coverage detected