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

Function _is_autogenerated_python

graphify/extract.py:2010–2028  ·  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

2008
2009
2010def _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
2031def _extract_python_rationale(path: Path, result: dict, parsed=None) -> None:

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected