MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / _is_autogenerated_python

Function _is_autogenerated_python

graphify/extract.py:5726–5744  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

5724
5725
5726def _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
5747def _extract_python_rationale(path: Path, result: dict) -> None:

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected