Skip to content

Commit

Permalink
fix typings
Browse files Browse the repository at this point in the history
  • Loading branch information
kbukum1 committed Feb 28, 2025
1 parent a956eca commit 01dc304
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions python/lib/dependabot/python/metadata_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ class MetadataFinder < Dependabot::MetadataFinders::Base
extend T::Sig
MAIN_PYPI_URL = "https://pypi.org/pypi"

sig do
params(
dependency: Dependabot::Dependency,
credentials: T::Array[Dependabot::Credential]
)
.void
end
def initialize(dependency:, credentials:)
super
@pypi_listing = T.let(nil, T.nilable(T::Hash[String, T.untyped]))
end

sig { returns(T.nilable(String)) }
def homepage_url
pypi_listing.dig("info", "home_page") ||
Expand Down Expand Up @@ -85,10 +97,11 @@ def source_from_description
# rubocop:disable Metrics/PerceivedComplexity
sig { returns(T.nilable(String)) }
def source_from_homepage
return unless homepage_body
homepage_body_local = homepage_body
return unless homepage_body_local

potential_source_urls = []
T.must(homepage_body).scan(Source::SOURCE_REGEX) do
homepage_body_local.scan(Source::SOURCE_REGEX) do
potential_source_urls << Regexp.last_match.to_s
end

Expand Down Expand Up @@ -146,8 +159,8 @@ def pypi_listing
response = fetch_authed_url(url)
next unless response.status == 200

@pypi_listing = T.let(JSON.parse(response.body), T.nilable(T::Hash[String, T.untyped]))
return T.must(@pypi_listing)
@pypi_listing = JSON.parse(response.body)
return @pypi_listing
rescue JSON::ParserError
next
rescue Excon::Error::Timeout
Expand Down

0 comments on commit 01dc304

Please sign in to comment.