Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generated loads are out of order for buildifier #116

Open
chulkilee opened this issue Sep 6, 2024 · 2 comments
Open

generated loads are out of order for buildifier #116

chulkilee opened this issue Sep 6, 2024 · 2 comments

Comments

@chulkilee
Copy link

The generated load is out of order for buildifier

Generated:

load("@@rules_pycross~//pycross:defs.bzl", "pycross_wheel_library", "pypi_file")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")

Formatted:

load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("@@rules_pycross~//pycross:defs.bzl", "pycross_wheel_library", "pypi_file")

One option is to add # buildifier: disable=out-of-order-load. However it seems like it tries to put that in order on purpose ("# External repo loads come before local loads." - but I'm wondering if it's even necessary to keep the order, as buildifier suggested to reorder it.

https://github.com/bazelbuild/buildtools/blob/main/WARNINGS.md#load-statements-should-be-ordered-by-their-labels

@jvolkman
Copy link
Owner

jvolkman commented Sep 6, 2024

It was definitely correct at one point, but it looks like the addition of @@ with bzlmod support broke it.

If you're able, can you figure out if @@ always comes after @ according to buildifier, or if all of the lines are ordered by their repo names?

I.e., should it be

load("@@bar//:bar.bzl", "bar")
load("@foo//:foo.bzl", "foo")
load("@@qux//:qux.bzl", "qux")

or

load("@foo//:foo.bzl", "foo")
load("@@bar//:bar.bzl", "bar")
load("@@qux//:qux.bzl", "qux")

@jvolkman
Copy link
Owner

jvolkman commented Sep 6, 2024

I just tested, and it's the first way. buildifier seems to order them by repo name, not by the label string.

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

No branches or pull requests

2 participants