-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
sorbet: Autogenerate the RBI file for utils/tty.rb
#14896
sorbet: Autogenerate the RBI file for utils/tty.rb
#14896
Conversation
Review period will end on 2023-03-07 at 00:08:08 UTC. |
Yes I agree. The Parlour way makes sense on a technical sense as it's the way Sorbet does it - i.e. parsing an AST. However parsing AST is always not the easiest to understand. With Rubocop there's some AST stuff but we've built a few helper functions on top still. An alternative way (i.e. like how Tapioca does it) would be runtime generation. It's sometimes a bit more "hacky" (i.e. for attr you would inject something that listens into The way you're doing here is not far off that so it makes sense to me, even as is. |
Agreed!
Good to know, happy to merge given that! |
- Sort of. It's not via Parlour, because I read the docs and all it says about dynamically generating things is "of course it's better to do that", no examples. I tried my best, but Bo's work on `attr.rb` was mind-boggling. - Instead, let's add a simple but functional generator script that I actually understand, as an alternative to maintaining these RBI files for dynamic methods manually, so that we can get rid of some use of `srb rbi hidden-definitions` since that's deprecated. - TODO: Run this script as part of `brew typecheck --update` so it gets updated with all the other RBI files periodically. - Follow up to PR 14651.
- I needed to add some more `require`s to the `tty.rb` generator script since it failed to recognise `env_config` and Sorbet's `T` setup if I ran it not via `brew ruby`, and I couldn't get `brew ruby` to work within `safe_system` in the `typecheck` dev-cmd.
0522498
to
48802da
Compare
Review period ended. |
Thanks again @issyl0! |
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?attr.rb
was mind-boggling.srb rbi hidden-definitions
since that's deprecated.hidden-definitions
into RBI files #14651.TODO (if this is the direction we want to go): Run this script as part of
brew typecheck --update
so it gets updated with all the other RBI files periodically.Feel free to throw this away if this isn't the direction we want to go or if it's rubbish and/or not the Proper Way - no hard feelings! ❤️