| 452 | |
| 453 | def _make_unbound_method(self): |
| 454 | def _method(cls_or_self, /, *args, **keywords): |
| 455 | phcount = self._phcount |
| 456 | if phcount: |
| 457 | try: |
| 458 | pto_args = self._merger(self.args + args) |
| 459 | args = args[phcount:] |
| 460 | except IndexError: |
| 461 | raise TypeError("missing positional arguments " |
| 462 | "in 'partialmethod' call; expected " |
| 463 | f"at least {phcount}, got {len(args)}") |
| 464 | else: |
| 465 | pto_args = self.args |
| 466 | keywords = {**self.keywords, **keywords} |
| 467 | return self.func(cls_or_self, *pto_args, *args, **keywords) |
| 468 | _method.__isabstractmethod__ = self.__isabstractmethod__ |
| 469 | _method.__partialmethod__ = self |
| 470 | return _method |