Format this fraction according to the given format specification.
(self, format_spec, /)
| 597 | return sign + padding + body |
| 598 | |
| 599 | def __format__(self, format_spec, /): |
| 600 | """Format this fraction according to the given format specification.""" |
| 601 | |
| 602 | if match := _GENERAL_FORMAT_SPECIFICATION_MATCHER(format_spec): |
| 603 | return self._format_general(match) |
| 604 | |
| 605 | if match := _FLOAT_FORMAT_SPECIFICATION_MATCHER(format_spec): |
| 606 | # Refuse the temptation to guess if both alignment _and_ |
| 607 | # zero padding are specified. |
| 608 | if match["align"] is None or match["zeropad"] is None: |
| 609 | return self._format_float_style(match) |
| 610 | |
| 611 | raise ValueError( |
| 612 | f"Invalid format specifier {format_spec!r} " |
| 613 | f"for object of type {type(self).__name__!r}" |
| 614 | ) |
| 615 | |
| 616 | def _operator_fallbacks(monomorphic_operator, fallback_operator, |
| 617 | handle_complex=True): |
nothing calls this directly
no test coverage detected