Return a short human label for a non-ASCII character. Falls back to the codepoint when the character isn't in the curated table — that way the report names every offender without needing an exhaustive map.
(ch: str)
| 1296 | |
| 1297 | |
| 1298 | def _describe_non_ascii(ch: str) -> str: |
| 1299 | """Return a short human label for a non-ASCII character. Falls back to |
| 1300 | the codepoint when the character isn't in the curated table — that way |
| 1301 | the report names every offender without needing an exhaustive map.""" |
| 1302 | if ch in _NON_ASCII_NAMES: |
| 1303 | return _NON_ASCII_NAMES[ch] |
| 1304 | cp = ord(ch) |
| 1305 | return f"U+{cp:04X} ({ch!r})" |
| 1306 | |
| 1307 | |
| 1308 | # Translation calls — non-ASCII inside their string args is allowed because |
no outgoing calls
no test coverage detected