)]}'
{
  "commit": "d12fe38eb8b1680838af70fe9a797feb9c3f71ba",
  "tree": "f8ebb25a966754956ca33e3e8c1d0aa79889f5a9",
  "parents": [
    "933e9bbe17f7619afaca1dd58ce22810042f1c13"
  ],
  "author": {
    "name": "Fabian Meumertzheim",
    "email": "fabian@meumertzhe.im",
    "time": "Tue Sep 22 23:41:31 2026 +0200"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Tue Sep 22 23:41:31 2026 +0200"
  },
  "message": "Preserve comments on the final function parameter (#1519)\n\nBuildifier currently moves a trailing comment on the final function\nparameter past the closing `)` and any return annotation. For example:\n\n```python\ndef f(\n    x,  # @unused\n) -\u003e int:\n    return 1\n```\n\nbecomes:\n\n```python\ndef f(\n        x) -\u003e int:  # @unused\n    return 1\n```\n\nSince #1488, these two spellings have different AST attachments: the\nfirst comment belongs to `x`, while the second belongs to the function\nheader\u0027s colon. #1518 intentionally interprets an `@unused` comment on\nthe header as applying to the final parameter, preserving the\nlongstanding behavior of existing files. However, buildifier should not\nconvert the preferred parameter-attached form into that legacy\nheader-attached form. Keeping the forms distinguishable lets users write\nthe clearer form today and leaves room to change or deprecate the legacy\ninterpretation in the future.\n\nThis PR keeps signatures with parameter suffix comments multiline and\nemits a pending final parameter comment before the closing parenthesis:\n\n```python\ndef f(\n        x  # @unused\n) -\u003e int:\n    return 1\n```\n\nBoth forms remain supported, with `@unused` applying only to the final\nparameter:\n\n```python\n# Preferred: the comment is attached to y.\ndef f(\n        x,\n        y  # @unused\n):\n    pass\n\n# Legacy compatibility: a header comment applies to y, not x.\ndef g(x, y):  # @unused\n    pass\n```\n\nThe lexer previously treated a comment following a line containing only\n`):` as a body comment. That exception was added in #276 before\nblock-header comments had their own AST node. Remove it so comments\nvisibly written after the colon remain attached to the header, including\nmultiline `def`, `if`, and `for` headers.\n\nFinally, flush queued end-of-line comments before reducing the\nindentation margin. This keeps continuation comments on a final\nparameter aligned with that parameter and makes formatting idempotent.\n\nThe `unused-variable` documentation now recommends the\nparameter-attached form and documents the header-attached form as\nbackward compatibility behavior.",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "0dfb4da2b6b9b1130197baef145699e02a4ca114",
      "old_mode": 33188,
      "old_path": "WARNINGS.md",
      "new_id": "331cc95dbfe5fc0dedb512f3928e612049deab47",
      "new_mode": 33188,
      "new_path": "WARNINGS.md"
    },
    {
      "type": "modify",
      "old_id": "12b1afdd3066ae6e4adc65965dbb5c21a58a0b37",
      "old_mode": 33188,
      "old_path": "build/lex.go",
      "new_id": "6fb76f468a461abba6bc9212b4a11f54d7bb7bc4",
      "new_mode": 33188,
      "new_path": "build/lex.go"
    },
    {
      "type": "modify",
      "old_id": "374487557218c6f9f80af0910128f4f570bc1763",
      "old_mode": 33188,
      "old_path": "build/print.go",
      "new_id": "875bff1bed56646d814801dd6dd17f3525e6fc7f",
      "new_mode": 33188,
      "new_path": "build/print.go"
    },
    {
      "type": "modify",
      "old_id": "d86f6d3e31b7570ca635acbc833333669b50bd23",
      "old_mode": 33188,
      "old_path": "build/print_test.go",
      "new_id": "b0b4a597e5f93d8a5737019479cd4c101910ffb3",
      "new_mode": 33188,
      "new_path": "build/print_test.go"
    },
    {
      "type": "modify",
      "old_id": "7d9f186b026e7c4a3219a8fad8c006e3592ce562",
      "old_mode": 33188,
      "old_path": "build/testdata/051.build.golden",
      "new_id": "089763168074d82b82b06a44aaf42373272161ee",
      "new_mode": 33188,
      "new_path": "build/testdata/051.build.golden"
    },
    {
      "type": "modify",
      "old_id": "ff4be4b65923630984835e998af6a89572c8eb4a",
      "old_mode": 33188,
      "old_path": "build/testdata/051.bzl.golden",
      "new_id": "51b22a76e6f4034f217ae09799bd56ec1cfc0e2f",
      "new_mode": 33188,
      "new_path": "build/testdata/051.bzl.golden"
    },
    {
      "type": "modify",
      "old_id": "81b814fd453a8aa99946ab2ea43e81badd858987",
      "old_mode": 33188,
      "old_path": "build/testdata/056.golden",
      "new_id": "f8588aa502224b6cba6bf2dc14e587565f76cec8",
      "new_mode": 33188,
      "new_path": "build/testdata/056.golden"
    },
    {
      "type": "modify",
      "old_id": "e24c95f4f22d1a8d8852e5d17ba6a540231d08d1",
      "old_mode": 33188,
      "old_path": "warn/docs/warnings.textproto",
      "new_id": "d983a52765d22de7a188e1ffb7da2cba00793c4f",
      "new_mode": 33188,
      "new_path": "warn/docs/warnings.textproto"
    },
    {
      "type": "modify",
      "old_id": "a721ced91c3789a873c2bfed57d4ed0ececb721e",
      "old_mode": 33188,
      "old_path": "warn/warn_control_flow_test.go",
      "new_id": "6b8ebcb572a1909ce82908330fc5655c9bafcaa2",
      "new_mode": 33188,
      "new_path": "warn/warn_control_flow_test.go"
    }
  ]
}
