Find the first line where we can add a comment.
(lines)
| 47 | |
| 48 | |
| 49 | def first_commentable_line(lines): |
| 50 | """Find the first line where we can add a comment.""" |
| 51 | max_len = 100 |
| 52 | if lines[0].startswith(('"""', 'r"""')): |
| 53 | if lines[0].count('"""') == 2: |
| 54 | return 1 |
| 55 | for insert in range(1, min(max_len, len(lines))): |
| 56 | if '"""' in lines[insert]: |
| 57 | return insert + 1 |
| 58 | else: |
| 59 | raise RuntimeError( |
| 60 | f"Failed to find end of file docstring within {max_len} lines" |
| 61 | ) |
| 62 | if lines[0].startswith("#!"): |
| 63 | return 1 |
| 64 | else: |
| 65 | return 0 |
| 66 | |
| 67 | |
| 68 | def path_multi_author(path): |