>>> a = FormatReplace('something') >>> f"{a:5d}" 'something'
| 100 | |
| 101 | |
| 102 | class FormatReplace: |
| 103 | """ |
| 104 | >>> a = FormatReplace('something') |
| 105 | >>> f"{a:5d}" |
| 106 | 'something' |
| 107 | """ # NOQA: P102 |
| 108 | def __init__(self, replace=''): |
| 109 | self.replace = replace |
| 110 | self.format_called = 0 |
| 111 | |
| 112 | def __format__(self, _): |
| 113 | self.format_called += 1 |
| 114 | return self.replace |
| 115 | |
| 116 | |
| 117 | class Comparable: |