braintrustdata / braintrust-ruby

Apache License 2.0
0 stars 0 forks source link

Sorbet Typing #1

Open matv-stripe opened 1 week ago

matv-stripe commented 1 week ago

It is neat to see that this is being built with Stainless! I know Ruby support in Stainless is somewhat in beta - is it on the roadmap to generate Sorbet annotations / RBI files?

ankrgyl commented 1 week ago

Asking and will follow up!

mmcgrana commented 1 week ago

Hi @matv-stripe! I'm Mark and I work on the Ruby SDK generator at Stainless (and am a former Stripe). I was chatting a bit with @ankrgyl and wanted to share the context directly here.

Sorbet is something that we’re definetly interested in. We don’t have it concretely on the roadmap yet though (before 1.0), primarily due to not having a clear design / approach for incorporating it.

In particular we haven’t yet found a good solution for incorporating Sorbet into a gem in a way that works great for Sorbet users and where the API design, gem-developer & end-developer DX, and runtime footprint is also excellent for non-Sorbet users. We’re still eager to learn more about this could work and would be happy to hear from Sorbet experts about their thoughts on Sorbet in gems.

We’ve also thought about more of a forked approach, where you generate e.g. braintrust and/or braintrust-sorbet, and the design and runtime of each is specialized.

Curious to hear your reactions!

matv-stripe commented 6 days ago

Hi @mmcgrana ! That makes sense and I appreciate the thought here. (We have ran into similar concerns generating our own stripe ruby SDK). I think the forked approach could make sense

I am curious if @jez-stripe has opinions here. I would love to see a world where we have a good story for library authors and consumers when using Sorbet in Ruby libraries

matv-stripe commented 5 days ago

In the meantime, I asked Claude Sonnet to write a script to parse the open api spec and generate starter Sorbet types that we can use in our application automatically. With small tweaks it looks like it works well as a start for us:

https://gist.github.com/matv-stripe/024852b3293e239add2e8f8da7ded412 https://gist.github.com/matv-stripe/cd1df667ada5dbed4a97198b6d074263

(As I did this it felt like someone must have solved this already and I found https://gitlab.com/tanna.dev/schema-sorbet which looked intriguing)

ankrgyl commented 5 days ago

That is super cool!