Return True if this Python file is auto-generated and its module docstring is noise. Covers: Alembic/Flask-Migrate revisions, Django migrations, protobuf/gRPC/OpenAPI stubs. Module docstrings in these files are change annotations or boilerplate, not rationale.
(source: bytes)
| 5724 | |
| 5725 | |
| 5726 | def _is_autogenerated_python(source: bytes) -> bool: |
| 5727 | """Return True if this Python file is auto-generated and its module docstring is noise. |
| 5728 | |
| 5729 | Covers: Alembic/Flask-Migrate revisions, Django migrations, protobuf/gRPC/OpenAPI stubs. |
| 5730 | Module docstrings in these files are change annotations or boilerplate, not rationale. |
| 5731 | """ |
| 5732 | head = source[:2048].decode("utf-8", errors="replace") |
| 5733 | # Generic generated-file markers (protobuf, gRPC, OpenAPI codegen, etc.) |
| 5734 | if any(m in head for m in ("DO NOT EDIT", "@generated", "Generated by the protocol buffer")): |
| 5735 | return True |
| 5736 | # Alembic / Flask-Migrate revision files |
| 5737 | if (re.search(r"^revision\s*[:=]", head, re.MULTILINE) |
| 5738 | and "def upgrade(" in head |
| 5739 | and "down_revision" in head): |
| 5740 | return True |
| 5741 | # Django migrations |
| 5742 | if "class Migration(migrations.Migration)" in head and "operations" in head: |
| 5743 | return True |
| 5744 | return False |
| 5745 | |
| 5746 | |
| 5747 | def _extract_python_rationale(path: Path, result: dict) -> None: |
no outgoing calls
no test coverage detected