(match: Match)
| 125 | keys.setdefault('%', '%') |
| 126 | |
| 127 | def resolve(match: Match) -> str | Any: |
| 128 | key = match.expand(expand) |
| 129 | try: |
| 130 | resolver = keys[key] |
| 131 | except KeyError: |
| 132 | raise ValueError(UNKNOWN_SIMPLE_FORMAT_KEY.format(key, s)) |
| 133 | if callable(resolver): |
| 134 | return resolver() |
| 135 | return resolver |
| 136 | |
| 137 | return pattern.sub(resolve, s) |
| 138 | return s |