bazel-contrib / bazel-contrib/buildtools

buildifier feature request: sort attribute dicts by mandatory=True, then by name

Open
#1,390 1 comment 0 reactions 0 assignees View on GitHub
P3
Dominant language
Go
Stars
1.2k
Forks
471
Avg merge
2d 22h
Merged PRs (30d)
13

Description

To improve usability for people reading the source code, we usually organize attrs such that all mandatory attributes are first, then the optional ones, e.g.
```
attrs = {
"required1": attr.whatever(mandatory=True),
"required2": attr.whatever(mandatory=True),

"optional1": ...
"optional2": ...
},
```

Is there a way to configure buildifier to honor that, short of just having it ignore the block? If I did the work, would a change like that be accepted?

Contributor guide

Open the contributing guide

Research direction

Start by reading buildifier’s existing attribute-dictionary sorting behavior and its configuration options; the issue names no files or tests. Confirm the intended ordering of mandatory=True attributes before optional ones, with names sorted within each group, and verify the formatter’s output on representative attrs dictionaries.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
build-system, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.