Skip to content

feat: Add alias_kind directive support to Gazelle plugin.#3713

Merged
dougthor42 merged 10 commits intobazel-contrib:mainfrom
canislupaster:main
Apr 30, 2026
Merged

feat: Add alias_kind directive support to Gazelle plugin.#3713
dougthor42 merged 10 commits intobazel-contrib:mainfrom
canislupaster:main

Conversation

@canislupaster
Copy link
Copy Markdown
Contributor

Currently the collision detection prevents Gazelle from respecting alias_kind. This PR cleans up the behavior by referencing the configured alias and map kind instead of storing a bunch of mapped actualPy*Kind vars.

I've added two tests heavily based on respect_map_kind: one with just alias_kind, and one using both map_kind and alias_kind.

Fixes #3183 .

@canislupaster canislupaster changed the title feat: Add alias_kind support to Gazelle. feat: Add alias_kind directive support to Gazelle plugin. Apr 17, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for the alias_kind directive in the Gazelle Python extension, allowing users to map canonical Python rule kinds to custom wrapper macros. The implementation centralizes rule matching logic through a new kindMatches helper and updates collision detection to respect both map_kind and alias_kind configurations. A potential breaking change was noted regarding the removal of the exported GetActualKindName function, which might affect external tools or other Gazelle extensions relying on the public API.

Comment thread gazelle/python/generate.go
Copy link
Copy Markdown
Collaborator

@dougthor42 dougthor42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, TIL about alias_kind! I've been using map_kind this whole time...

Ah, no wonder: alias_kind was added in bazel-gazelle 0.41.0, and we only bumped to Gazelle >= 0.41 in #3404 / v1.8.0.

The WORKSPACE builds are failing because that still uses gazelle 0.36

@aignas I don't remember - are we blocked from upgrading WORKSPACE to gazelle >= 0.41?

Comment thread gazelle/python/testdata/naming_convention_mapped_fail/__init__.py Outdated
Comment thread gazelle/python/testdata/respect_alias_kind/README.md Outdated
@aignas
Copy link
Copy Markdown
Collaborator

aignas commented Apr 18, 2026

I think we just forgot to bump gazelle in the Workspace. Can't remember about any blocking issues.

@dougthor42
Copy link
Copy Markdown
Collaborator

👍 I opened #3717 for the WORKSPACE change. @canislupaster please rebase once that's merged.

Copy link
Copy Markdown
Collaborator

@dougthor42 dougthor42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... CI is still getting

python/generate.go:63:49: c.AliasMap undefined (type *config.Config has no field or method AliasMap)

for WORKSPACE. I thought #3717 would resolve that.

...

...

/facepalm: I didn't complete the upgrade:

"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.36.0/bazel-gazelle-v0.36.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.36.0/bazel-gazelle-v0.36.0.tar.gz",

Opened #3724.

Comment thread gazelle/python/testdata/naming_convention_mapped_fail/test.yaml Outdated
@dougthor42 dougthor42 added this pull request to the merge queue Apr 30, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 30, 2026
@dougthor42 dougthor42 added this pull request to the merge queue Apr 30, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 30, 2026
@dougthor42 dougthor42 added this pull request to the merge queue Apr 30, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 30, 2026
@dougthor42
Copy link
Copy Markdown
Collaborator

These GET returned 502 Bad Gateway or Proxy Error GitHub issues are becoming more and more common. It's a PITA. https://www.githubstatus.com/incidents/x69zbgdyfzg0

https://mrshu.github.io/github-statuses/ shows 85% total uptime over the past 90d. That's absurd!

I'll keep trying the merge.

@dougthor42 dougthor42 added this pull request to the merge queue Apr 30, 2026
Merged via the queue into bazel-contrib:main with commit b87cf67 Apr 30, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

alias_kind doesn't work with Gazelle

3 participants