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)
| 2008 | |
| 2009 | |
| 2010 | def _is_autogenerated_python(source: bytes) -> bool: |
| 2011 | """Return True if this Python file is auto-generated and its module docstring is noise. |
| 2012 | |
| 2013 | Covers: Alembic/Flask-Migrate revisions, Django migrations, protobuf/gRPC/OpenAPI stubs. |
| 2014 | Module docstrings in these files are change annotations or boilerplate, not rationale. |
| 2015 | """ |
| 2016 | head = source[:2048].decode("utf-8", errors="replace") |
| 2017 | # Generic generated-file markers (protobuf, gRPC, OpenAPI codegen, etc.) |
| 2018 | if any(m in head for m in ("DO NOT EDIT", "@generated", "Generated by the protocol buffer")): |
| 2019 | return True |
| 2020 | # Alembic / Flask-Migrate revision files |
| 2021 | if (re.search(r"^revision\s*[:=]", head, re.MULTILINE) |
| 2022 | and "def upgrade(" in head |
| 2023 | and "down_revision" in head): |
| 2024 | return True |
| 2025 | # Django migrations |
| 2026 | if "class Migration(migrations.Migration)" in head and "operations" in head: |
| 2027 | return True |
| 2028 | return False |
| 2029 | |
| 2030 | |
| 2031 | def _extract_python_rationale(path: Path, result: dict, parsed=None) -> None: |
no outgoing calls
no test coverage detected