An exciting new feature just merged for Pants 2.11...
# general
h
An exciting new feature just merged for Pants 2.11 thanks to @narrow-vegetable-37489: Protobuf linting with Buf. Thank you ๐Ÿ™Œ https://github.com/pantsbuild/pants/pull/14540
๐ŸŽ‰ 4
๐Ÿ”ฅ 5
๐Ÿฅ 1
๐Ÿ™Œ 4
w
Sweet, I've been using Buf for a while now. I like lots of it. Would be nice to not have to keep updating it in Brew though ๐Ÿ™‚
โค๏ธ 1
h
And make sure CI is aligned with what you use on your desktop. That's what motivated our Shell support, that Shellcheck in CI had lint failures people didn't get via brew install
๐Ÿ™Œ 1
h
Nice! We just started using this internally separate from Pants.
๐Ÿ’ฏ 1
h
Neat! Btw if there are ever (open source) linters like that that you're using but Pants doesn't yet support, please do open up a GitHub ticket. Even if you don't have time to implement it. That's how Buf support started https://github.com/pantsbuild/pants/issues/13189
โž• 1
n
๐Ÿ––
f
this is awesome. I was looking briefly into linting of protobufs a couple of years ago. One thing that I donโ€™t think any of the linters supported then (and I didnโ€™t bother writing own plugins/rules) was checking for using Python reserved keywords as fields, see https://developers.google.com/protocol-buffers/docs/reference/python-generated#keyword-conflicts:
Copy code
message Baz {
  optional int32 from = 1
  repeated int32 in = 2;
}
Copy code
baz = Baz()
setattr(baz, "from", 99)
assert getattr(baz, "from") == 99
getattr(baz, "in").append(42)
assert getattr(baz, "in") == [42]
Copy code
# WRONG!
<http://baz.in|baz.in>  # SyntaxError: invalid syntax
baz.from  # SyntaxError: invalid syntax
does any of the linters support this?
h
Buf does not analyze generated code. It's about detecting styling and wire format breaking changes with just .proto definitions as far as I understand it.
Oh I see what you mean. I was confused by the wording with the example usage.
b
Really cool! Thank you @narrow-vegetable-37489!
๐Ÿ™Œ 1
h
Buf integration gets even better in 2.11! @narrow-vegetable-37489 strikes again by adding
buf format
support to
fmt
goal to autoformat Proto files! (edit: buf only released this feature yesterday ๐Ÿ˜ฎ)
๐Ÿ™Œ 5
๐Ÿ‘ 1
๐Ÿ™ 3
h
Love to see it!
b
Wow, cool...
buf
released that feature yesterday
โ— 3
๐Ÿ˜… 1
b
We're so fortunate to have you, @narrow-vegetable-37489. Thanks for all the cool work you've been doing.
๐Ÿ™ 1
๐ŸŽ‰ 2