Return a `TOMLDecodeError` where error message is suffixed with coordinates in source.
(src: str, pos: Pos, msg: str)
| 630 | |
| 631 | |
| 632 | def suffixed_err(src: str, pos: Pos, msg: str) -> TOMLDecodeError: |
| 633 | """Return a `TOMLDecodeError` where error message is suffixed with |
| 634 | coordinates in source.""" |
| 635 | |
| 636 | def coord_repr(src: str, pos: Pos) -> str: |
| 637 | if pos >= len(src): |
| 638 | return "end of document" |
| 639 | line = src.count("\n", 0, pos) + 1 |
| 640 | if line == 1: |
| 641 | column = pos + 1 |
| 642 | else: |
| 643 | column = pos - src.rindex("\n", 0, pos) |
| 644 | return f"line {line}, column {column}" |
| 645 | |
| 646 | return TOMLDecodeError(f"{msg} (at {coord_repr(src, pos)})") |
| 647 | |
| 648 | |
| 649 | def is_unicode_scalar_value(codepoint: int) -> bool: |
no test coverage detected
searching dependent graphs…