Try to emit long strings as multiline. The normal class only tries to emit docstrings as multiline, but the resulting source doesn't pass flake8.
| 575 | |
| 576 | |
| 577 | class Unparser(ast._Unparser): # type: ignore |
| 578 | """ |
| 579 | Try to emit long strings as multiline. |
| 580 | |
| 581 | The normal class only tries to emit docstrings as multiline, |
| 582 | but the resulting source doesn't pass flake8. |
| 583 | """ |
| 584 | |
| 585 | # Beware: private method. Tested with in Python 3.10, 3.11. |
| 586 | def _write_constant(self, value: Any) -> None: |
| 587 | if isinstance(value, str) and len(value) > 50: |
| 588 | self._write_str_avoiding_backslashes(value) |
| 589 | else: |
| 590 | super()._write_constant(value) |
| 591 | |
| 592 | |
| 593 | def parse_cmdline() -> Namespace: |