(s: Optional[str], position: str)
| 408 | """ |
| 409 | |
| 410 | def esc(s: Optional[str], position: str) -> str: |
| 411 | if position == "value" and s is None: |
| 412 | return "NULL" |
| 413 | elif isinstance(s, str): |
| 414 | return '"%s"' % s.replace("\\", "\\\\").replace('"', r"\"") |
| 415 | else: |
| 416 | raise ValueError( |
| 417 | "%r in %s position is not a string." % (s, position) |
| 418 | ) |
| 419 | |
| 420 | return ", ".join( |
| 421 | "%s=>%s" % (esc(k, "key"), esc(v, "value")) for k, v in val.items() |
no test coverage detected