Format a GraphQL field or argument name into Python.
(s: str)
| 470 | |
| 471 | |
| 472 | def format_name(s: str) -> str: |
| 473 | """Format a GraphQL field or argument name into Python.""" |
| 474 | # rewrite acronyms, initialisms and abbreviations |
| 475 | s = ACRONYM_RE.sub(lambda m: m.group(0).title(), s) |
| 476 | s = camel_to_snake(s) |
| 477 | if iskeyword(s) or s in _reserved_builtins: |
| 478 | s += "_" |
| 479 | return s |
| 480 | |
| 481 | |
| 482 | def format_input_type( |