Skip to content
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: Migrate dev-cmd files from typed: true to typed: strict #17606

Merged
merged 24 commits into from
Jul 4, 2024

Conversation

issyl0
Copy link
Member

@issyl0 issyl0 commented Jul 1, 2024

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?


Draft because I'm not quite done yet (dev-cmd/bottle is being annoyingly fiddly) and I need to do a self-review of this PR to catch any little things I missed.

  • There's lots of T.must here. I could probably do better with returning early or otherwise handling nils.
  • There's quite a lot of T.untyped that I could think more about? Some of them are auto-fixed signatures that I need to go and tighten up.

@MikeMcQuaid
Copy link
Member

  • There's lots of T.must here. I could probably do better with returning early or otherwise handling nils.

Yes. T.must is kind of a smell to be avoided. Best bet is typically:

  • assign to a variable (as Sorbet never assumes that calling the same function twice will get the same result)
  • check the variable is nil and return/raise/etc. if so
  • Use the variable after this time without needing T.must
  • There's quite a lot of T.untyped that I could think more about?

I think T.untyped is OK as a Hash value if it cannot be otherwise represented with a single type (e.g. String, Symbol, etc.) because it stores multiple different types. All other cases: it should be avoided.

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work so far @issyl0! May be worth splitting this up even smaller to make review easier but don't feel strongly either way.

Library/Homebrew/dev-cmd/bottle.rb Outdated Show resolved Hide resolved
@issyl0
Copy link
Member Author

issyl0 commented Jul 2, 2024

Yes. T.must is kind of a smell to be avoided.

Yeah, coming back to this is why it's still draft!

@issyl0 issyl0 force-pushed the sorbet-strict-devcmd branch 2 times, most recently from 84e4ece to 8865cd6 Compare July 3, 2024 13:56
Co-authored-by: Mike McQuaid <[email protected]>
@issyl0
Copy link
Member Author

issyl0 commented Jul 3, 2024

Alright, there's many fewer T.musts here now, in fact, zero! And I removed some pre-existing ones! ❤️

- Otherwise we get: `uninitialized constant String::Formula (NameError)```
@issyl0 issyl0 marked this pull request as ready for review July 3, 2024 20:39
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @issyl0, great work!

Think it'd be good to get rid of some of the T.nilable and T.untyped when possible later but: this is better than the status quo for sure. There's also some returns(NilClass) that should probably be void. All this can be done in follow-ups. Thanks again!

@MikeMcQuaid MikeMcQuaid merged commit 3773940 into master Jul 4, 2024
25 checks passed
@MikeMcQuaid MikeMcQuaid deleted the sorbet-strict-devcmd branch July 4, 2024 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants