From 24ac6967ba6fd9bc1ea65627c5098ba57d4e953f Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Sat, 31 Aug 2024 16:42:43 -0400 Subject: [PATCH] Adjust typing around #check_pull_requests `brew bump-formula-pr` is encountering a type error, as the inferred return type of `GitHub#check_for_duplicate_pull_requests` doesn't align with the explicit return type of `#check_pull_requests`: ``` Error: Return value: Expected type T.nilable(T::Array[String]), got type Module with value T::Private::Types::Void::VOID Caller: /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/dev-cmd/ bump-formula-pr.rb:137 Definition: /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/ dev-cmd/bump-formula-pr.rb:472 (Homebrew::DevCmd::BumpFormulaPr #check_pull_requests) ``` This addresses the issue by adding a type signature with a `void` return type to `#check_for_duplicate_pull_requests` and setting the return type of `#check_pull_requests` to `void` as well. The return type from `#check_pull_requests` isn't used, so a `void` return type is arguably a better reflection of the method's behavior. The `#check_pull_requests` method in `BumpCaskPr` has a `void` return type, so this change brings the `BumpFormulaPr` method in line. --- Library/Homebrew/dev-cmd/bump-formula-pr.rb | 2 +- Library/Homebrew/utils/github.rb | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index a1a51c738e..12a4a636ad 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -467,7 +467,7 @@ module Homebrew sig { params(formula: Formula, tap_remote_repo: String, state: T.nilable(String), - version: T.nilable(String)).returns(T.nilable(T::Array[String])) + version: T.nilable(String)).void } def check_pull_requests(formula, tap_remote_repo, state: nil, version: nil) tap = formula.tap diff --git a/Library/Homebrew/utils/github.rb b/Library/Homebrew/utils/github.rb index 74fbe2afea..c934012d28 100644 --- a/Library/Homebrew/utils/github.rb +++ b/Library/Homebrew/utils/github.rb @@ -629,7 +629,17 @@ module GitHub pull_requests || [] end - def self.check_for_duplicate_pull_requests(name, tap_remote_repo, file:, quiet:, state: nil, version: nil) + sig { + params( + name: String, + tap_remote_repo: String, + file: String, + quiet: T::Boolean, + state: T.nilable(String), + version: T.nilable(String), + ).void + } + def self.check_for_duplicate_pull_requests(name, tap_remote_repo, file:, quiet: false, state: nil, version: nil) pull_requests = fetch_pull_requests(name, tap_remote_repo, state:, version:) pull_requests.select! do |pr|