Truncate content and append a notice if content exceeds the specified length.
(content: str, truncate_after: Optional[int] = MAX_RESPONSE_LEN)
| 85 | |
| 86 | |
| 87 | def maybe_truncate(content: str, truncate_after: Optional[int] = MAX_RESPONSE_LEN): |
| 88 | """Truncate content and append a notice if content exceeds the specified length.""" |
| 89 | return ( |
| 90 | content |
| 91 | if not truncate_after or len(content) <= truncate_after |
| 92 | else content[:truncate_after] + TRUNCATED_MESSAGE |
| 93 | ) |
| 94 | |
| 95 | |
| 96 | class Flake8Error: |
no outgoing calls
no test coverage detected