(self, args: Sequence[Any], kwargs: Mapping[str, Any])
| 86 | return self._format([], mapping) |
| 87 | |
| 88 | def _format(self, args: Sequence[Any], kwargs: Mapping[str, Any]) -> TF: |
| 89 | full_message = self.factory() |
| 90 | used_args, arg_index = set(), 0 |
| 91 | |
| 92 | if isinstance(self.template, str): |
| 93 | msg, arg_index = self._vformat( |
| 94 | self.template, args, kwargs, used_args, arg_index |
| 95 | ) |
| 96 | full_message += msg |
| 97 | elif isinstance(self.template, self.factory): |
| 98 | template = cast("Message[MessageSegment]", self.template) |
| 99 | for seg in template: |
| 100 | if not seg.is_text(): |
| 101 | full_message += seg |
| 102 | else: |
| 103 | msg, arg_index = self._vformat( |
| 104 | str(seg), args, kwargs, used_args, arg_index |
| 105 | ) |
| 106 | full_message += msg |
| 107 | else: |
| 108 | raise TypeError("template must be a string or instance of Message!") |
| 109 | |
| 110 | self.check_unused_args(used_args, args, kwargs) |
| 111 | return cast(TF, full_message) |
| 112 | |
| 113 | def vformat( # pyright: ignore[reportIncompatibleMethodOverride] |
| 114 | self, |
no test coverage detected