utils/github/api: fix Sorbet types.

Let's not use `T.unsafe(nil)` but instead an empty hash.
This commit is contained in:
Mike McQuaid 2025-06-17 14:59:46 +01:00
parent 09eaf1495a
commit f2103c7138
No known key found for this signature in database

View File

@ -378,7 +378,7 @@ module GitHub
raise_errors: T::Boolean, raise_errors: T::Boolean,
).returns(T.untyped) ).returns(T.untyped)
} }
def self.open_graphql(query, variables: T.unsafe(nil), scopes: [].freeze, raise_errors: true) def self.open_graphql(query, variables: {}, scopes: [].freeze, raise_errors: true)
data = { query:, variables: } data = { query:, variables: }
result = open_rest("#{API_URL}/graphql", scopes:, data:, request_method: :POST) result = open_rest("#{API_URL}/graphql", scopes:, data:, request_method: :POST)
@ -400,11 +400,10 @@ module GitHub
_block: T.proc.params(data: T::Hash[String, T.untyped]).returns(T.untyped), _block: T.proc.params(data: T::Hash[String, T.untyped]).returns(T.untyped),
).void ).void
} }
def self.paginate_graphql(query, variables: T.unsafe(nil), scopes: [].freeze, raise_errors: true, &_block) def self.paginate_graphql(query, variables: {}, scopes: [].freeze, raise_errors: true, &_block)
result = API.open_graphql(query, variables:, scopes:, raise_errors:) result = API.open_graphql(query, variables:, scopes:, raise_errors:)
has_next_page = T.let(true, T::Boolean) has_next_page = T.let(true, T::Boolean)
variables ||= {}
while has_next_page while has_next_page
page_info = yield result page_info = yield result
has_next_page = page_info["hasNextPage"] has_next_page = page_info["hasNextPage"]