Skip to content

Can we add a python directive to tell gazelle to avoid adding visibility annotations? #2953

Description

@antspy

Hi,

I have a library which I want to make public since it's a base library for many other parts of the codebase. Therefore I set the visibility to public for the whole file:

load("@aspect_rules_py//py:defs.bzl", "py_library")

package(default_visibility = ["//visibility:public"])

py_library(
    name = "test",
    srcs = ["test.py"],
)

Running gazelle however incorrectly adds a more restrictive visibility annotation, transforming the BUILD file to:

load("@aspect_rules_py//py:defs.bzl", "py_library")

package(default_visibility = ["//visibility:public"])

py_library(
    name = "cli",
    srcs = ["cli.py"],
    visibility = ["//:__subpackages__"], # <---- This should not be added, right?
)

The added visibility is incorrect, as it overwrite the default visibility set at the package level.

Is there a way to fix this behavior, or at least provide a gazelle directive (at the root level) to tell gazelle to not add a visibility field to python targets?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions