-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
test_bot: Bump some files to Sorbet typed: strict
#21010
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 migrates the test-bot codebase from typed: true to typed: strict mode in Sorbet, adding comprehensive type annotations throughout the codebase to enable stricter type checking.
Key changes:
- Upgraded Sorbet typing level from
truetostrictacross all test-bot files - Added explicit type signatures (
sig) to all methods, attributes, and instance variables - Used
T.letto explicitly type all instance variable initializations - Added
T.must()calls where needed to satisfy Sorbet's strict null checking
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| Library/Homebrew/test_bot/test_runner.rb | Added strict typing with method signatures and instance variable types; includes an initialize method for module (potential issue) |
| Library/Homebrew/test_bot/test_formulae.rb | Added comprehensive type annotations for attributes, methods, and complex instance variables including hashes and arrays |
| Library/Homebrew/test_bot/test_cleanup.rb | Added type signatures and converted repository parameters to use .to_s for git commands |
| Library/Homebrew/test_bot/test.rb | Added passed? helper method and upgraded to strict typing |
| Library/Homebrew/test_bot/tap_syntax.rb | Added method signature and upgraded to strict typing |
| Library/Homebrew/test_bot/step.rb | Added extensive type annotations for all attributes and methods; includes type assertions with T.must() |
| Library/Homebrew/test_bot/setup.rb | Added method signature with T.self_type return type |
| Library/Homebrew/test_bot/junit.rb | Added type signatures and moved require statement to top of file |
| Library/Homebrew/test_bot/formulae_detect.rb | Added comprehensive type signatures including complex parameter lists |
| Library/Homebrew/test_bot/formulae_dependents.rb | Added type signatures and extensive use of T.must() for nullable variables |
| Library/Homebrew/test_bot/formulae.rb | Added type annotations and fixed array wrapping pattern from Array.new to literal syntax |
| Library/Homebrew/test_bot/cleanup_before.rb | Added signature and simplified conditional logic |
| Library/Homebrew/test_bot/cleanup_after.rb | Added method signature and upgraded to strict typing |
| Library/Homebrew/test_bot/bottles_fetch.rb | Added type signatures for accessor and methods |
| Library/Homebrew/test_bot.rb | Added type annotations for constants and module methods |
Comments suppressed due to low confidence (1)
Library/Homebrew/test_bot/setup.rb:21
- The
run!method signature declares a return type ofT.self_type, but the method doesn't have an explicit return statement. In Ruby, methods return the value of the last expression, which in this case would be the result of the lasttestcall (either"brew", "doctor", "--debug", verbose: trueor"brew", "doctor").
The method should either explicitly return self to match the signature, or the return type should be changed to match what test returns (which appears to be a Step object based on the Test class implementation).
sig { params(args: Homebrew::CLI::Args).returns(T.self_type) }
def run!(args:)
test_header(:Setup)
test "brew", "install-bundler-gems", "--add-groups=ast,audit,bottle,formula_test,livecheck,style"
# Always output `brew config` output even when it doesn't fail.
test "brew", "config", verbose: true
if ENV["HOMEBREW_TEST_BOT_VERBOSE_DOCTOR"]
test "brew", "doctor", "--debug", verbose: true
else
test "brew", "doctor"
end
end
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
- There's one left (as of 2025-11-09), `test_bot/test.rb` which shows >70 errors when making `strict`, so I'm leaving that one for future us!
brew stylewith your changes locally?brew typecheckwith your changes locally?brew testswith your changes locally?typed: strictin all (non-package) files in Homebrew organisation #17297.test_bot/test.rbwhich shows >70 errors when moved tostrict(as there's a lot ofT.nilable(String)orPathnamefor things like args), so I'm leaving that one for future us who are maybe less tired.