)]}'
{
  "commit": "0fcd86fa38764afebf1fa480e77599b27b3d00d2",
  "tree": "6d6b700d97fa89f1e1f0a112ed3ba2a818c3b605",
  "parents": [
    "6836552e2573b833f3375b1a781625897688d1c2"
  ],
  "author": {
    "name": "Protobuf Team Bot",
    "email": "protobuf-github-bot@google.com",
    "time": "Tue Aug 25 10:55:27 2026 -0700"
  },
  "committer": {
    "name": "Copybara-Service",
    "email": "copybara-worker@google.com",
    "time": "Tue Aug 25 10:59:09 2026 -0700"
  },
  "message": "Fix name shadowing in python pyi generator for enum and message types\n\nWhen a protobuf message contains fields or nested classes whose names\nshadow an enum or message type used in field annotations (e.g. an\n`int32 kind` field shadowing enum `kind`, or an enclosing class/nested\ntype shadowing an outer type), Python class attributes shadow the type\nnames in class and method scope. Consequently, `__init__` parameter\nannotations and class attributes emitted by `pyi_generator.cc` fail\ntype checking (e.g. Mypy `Variable \"...\" is not valid as a type\n[valid-type]`).\n\nNote that this shadowing can only happen when schemas do not follow\nthe Protobuf naming guidelines\n(https://protobuf.dev/programming-guides/style/), which recommend\nTitleCase for messages/enums and snake_case for field names.\n\nThis change:\n1. Introduces `IsTypeShadowed` to detect whether a type name\u0027s root\n   token collides with any field, nested enum, nested message, or\n   enclosing class in the Python scope hierarchy.\n2. Emits private module-level type aliases (`_Type_\u003cname\u003e \u003d \u003cname\u003e`)\n   on-demand when top-level types are shadowed.\n3. Updates `GetFieldType` and `PrintInit` to use the alias when\n   shadowed, ensuring robust resolution across all class and method\n   scopes.\n4. Adds tests covering top-level, nested, and map field shadowing\n   scenarios.\n\nPiperOrigin-RevId: 970661048\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "e792566b55145f8e59ade51a2a68729cf57c5ceb",
      "old_mode": 33188,
      "old_path": "src/google/protobuf/compiler/python/plugin_unittest.cc",
      "new_id": "e51925c83e6f9b06d8177085da3432f0ec0063e4",
      "new_mode": 33188,
      "new_path": "src/google/protobuf/compiler/python/plugin_unittest.cc"
    },
    {
      "type": "modify",
      "old_id": "541bec0aa91b48098b9ef086e2370d20c83159f5",
      "old_mode": 33188,
      "old_path": "src/google/protobuf/compiler/python/pyi_generator.cc",
      "new_id": "5272132adf82d69b7f87f01418df8f36851cf649",
      "new_mode": 33188,
      "new_path": "src/google/protobuf/compiler/python/pyi_generator.cc"
    },
    {
      "type": "modify",
      "old_id": "1beb4d11af39b640f5ff9458b9089f691e54b8e3",
      "old_mode": 33188,
      "old_path": "src/google/protobuf/compiler/python/pyi_generator.h",
      "new_id": "377f2456b4dc70c2a9c4c84e2785c15d5417b3f0",
      "new_mode": 33188,
      "new_path": "src/google/protobuf/compiler/python/pyi_generator.h"
    }
  ]
}
