Skip to content

Commit

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

sig { returns(T.untyped) }
sig { returns(T.nilable(String)) }
def homepage_url
pypi_listing.dig("info", "home_page") ||
pypi_listing.dig("info", "project_urls", "Homepage") ||
Expand Down Expand Up @@ -47,7 +47,7 @@ def look_up_source
end

# rubocop:disable Metrics/PerceivedComplexity
sig { returns(T.nilable(Dependabot::Source)) }
sig { returns(T.nilable(String)) }
def source_from_description
potential_source_urls = []
desc = pypi_listing.dig("info", "description")
Expand Down Expand Up @@ -83,7 +83,7 @@ def source_from_description
# rubocop:enable Metrics/PerceivedComplexity

# rubocop:disable Metrics/PerceivedComplexity
sig { returns(T.nilable(Dependabot::Source)) }
sig { returns(T.nilable(String)) }
def source_from_homepage
return unless homepage_body

Expand Down Expand Up @@ -113,7 +113,7 @@ def source_from_homepage
end
# rubocop:enable Metrics/PerceivedComplexity

sig { returns(T.untyped) }
sig { returns(T.nilable(String)) }
def homepage_body
homepage_url = pypi_listing.dig("info", "home_page")

Expand All @@ -123,14 +123,14 @@ def homepage_body
"pypi.python.org"
].include?(URI(homepage_url).host)

@homepage_response = T.let(nil, T.nilable(Excon::Response))
@homepage_response =
@homepage_response = T.let(
begin
Dependabot::RegistryClient.get(url: homepage_url)
rescue Excon::Error::Timeout, Excon::Error::Socket,
Excon::Error::TooManyRedirects, ArgumentError
nil
end
end, T.nilable(Excon::Response)
)

return unless @homepage_response&.status == 200

Expand All @@ -139,7 +139,7 @@ def homepage_body

sig { returns(T::Hash[String, T.untyped]) }
def pypi_listing
@pypi_listing = T.let(nil, T.nilable(T::Hash[String, T.untyped]))
@pypi_listing = T.let(nil, T.untyped)
return @pypi_listing unless @pypi_listing.nil?
return @pypi_listing = {} if dependency.version&.include?("+")

Expand Down Expand Up @@ -176,7 +176,7 @@ def fetch_authed_url(url)
end
end

sig { returns(T.untyped) }
sig { returns(T::Array[T.untyped]) }
def possible_listing_urls
credential_urls =
credentials
Expand Down

0 comments on commit 2666b0b

Please sign in to comment.