bazel-contrib / bazel-contrib/buildtools
Buildifier does not support f-strings
- Dominant language
- Go
- Stars
- 1.2k
- Forks
- 471
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 13
Description
Buck2 supports f-string (although [Bazel does not](https://github.com/bazelbuild/starlark/issues/91), at least yet), so it would be nice if `buildifier` did not consider them invalid syntax.
Currently, running it over:
```starlark
name = "Cédric"
print(f"Hello, {name}!")
```
gives
```
> buildifier asdf.bzl
asdf.bzl:2:24: syntax error near "Hello, {name}!"
asdf.bzl # reformat
```
It seems like this could be implemented quite easily similarly to [raw strings](https://github.com/bazelbuild/buildtools/blob/main/build/lex.go#L547), is this correct?
Contributor guide
Research direction
Start in build/lex.go near the raw-string handling linked in the issue, then reproduce the buildifier asdf.bzl example with the provided f-string. Trace how the lexer handles the string and interpolation syntax; done means buildifier accepts the example without a syntax error and formats it successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- build-system, tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100