Skip to content

Conversation

@cho-m
Copy link
Member

@cho-m cho-m commented Dec 15, 2025

  • 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 lgtm (style, typechecking and tests) with your changes locally?

Part of

Copilot AI review requested due to automatic review settings December 15, 2025 22:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enables Sorbet's typed: strict mode for the commands-related modules by adding comprehensive type signatures and annotations throughout the codebase. This is part of a larger effort (#17297) to improve type safety across the Homebrew codebase.

Key Changes:

  • Upgraded Library/Homebrew/commands.rb from typed: true to typed: strict with complete type signatures for all methods
  • Added type annotations to constants using T.let() for proper type inference
  • Added necessary type casts and safe navigation operators to satisfy strict type checking

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
Library/Homebrew/commands.rb Main changes: upgraded to typed: strict, added method signatures, annotated constants with T.let(), converted .presence to .blank?, added explicit return nil, and converted .basename() to return String
Library/Homebrew/completions.rb Added type casts for partitioned arrays to T::Array[Symbol], replaced .presence with .blank?, added .to_s for nilable command descriptions
Library/Homebrew/cli/parser.rb Added .to_s conversion for HOMEBREW_DEV_CMD_PATH in string comparison, added nil check for arg before calling Commands.path()
Library/Homebrew/dev-cmd/prof.rb Added T.must() assertion for args.named.first (safe due to min: 1 validation)
Library/Homebrew/dev-cmd/debugger.rb Added T.must() assertion for args.named.first (safe due to min: 1 validation)
Library/Homebrew/brew.rb Moved T.must(cmd) before conditional check (safe since help handling exits when cmd is nil)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

Looks good, thanks! One question.

@cho-m cho-m force-pushed the commands-strict-type branch from fc8507e to d2b6953 Compare December 16, 2025 15:48
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