dependabot-julia 0.394.0 → 0.395.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0219cc4b94273c02bf11ff9ca22e92ec689176e726642e5ef6c997c37fdbf135'
4
- data.tar.gz: 5f9bfa61d84f6e038708ada16bf668bddca75cd16d21c16391398384193c2a81
3
+ metadata.gz: 54579433c6beab3470827fa806a2e620123a56fd2d4b52e1b20573558630cb4c
4
+ data.tar.gz: 9d9d3d58871d1cfbc2ef1dd47f51628d6b9af1473f0559ebc58783433f5f53d1
5
5
  SHA512:
6
- metadata.gz: 3e5b6dc2946c09316008c22a48760367eb4fc194713bae8cf3502480ed1c4309c062b022026648551b0f012e4f5ea81d43648c673b50b87483a8e18b799f6489
7
- data.tar.gz: 02ad07a0267576e4adcf8f428f485c45536a4e78e6b638b61e6313b3d4721ee3f48f40adb6de4d9bf98e112a0907326e4e4421c2e571ff81d5098d3e30aea837
6
+ metadata.gz: 84c9be79e65dd54336e7d4edf6547099dcc9454f9199774f1b7781f322eafd869622740d7197183dcf35211495cd1d712fdc7aac0e27d322064119d0902117d4
7
+ data.tar.gz: c94d643415848f2ff46c5c69303321a535404f64eb53a39ca1ba39035a528711a9ecf2ecde5c1b8835e851bf390469a7ed58d0c0363f8e87798166f0d696e4ca
@@ -33,10 +33,12 @@ module Dependabot
33
33
  sig { params(temp_dir: T.any(Pathname, String)).returns(T::Array[Dependabot::DependencyFile]) }
34
34
  def fetch_files_using_julia_helper(temp_dir)
35
35
  workspace_info = registry_client.find_workspace_project_files(temp_dir.to_s)
36
- validate_workspace_info!(workspace_info)
36
+ if workspace_info.is_a?(Dependabot::Julia::RegistryClient::Result::Failure)
37
+ raise Dependabot::DependencyFileNotFound, "No Project.toml or JuliaProject.toml found."
38
+ end
37
39
 
38
- project_files = T.cast(workspace_info["project_files"], T::Array[String])
39
- manifest_path = T.cast(workspace_info["manifest_file"], String)
40
+ project_files = workspace_info.project_files
41
+ manifest_path = workspace_info.manifest_file
40
42
 
41
43
  fetched_files = fetch_all_project_files(project_files, temp_dir.to_s)
42
44
  raise Dependabot::DependencyFileNotFound, "No Project.toml or JuliaProject.toml found." if fetched_files.empty?
@@ -45,20 +47,6 @@ module Dependabot
45
47
  fetched_files
46
48
  end
47
49
 
48
- sig { params(workspace_info: T::Hash[String, Object]).void }
49
- def validate_workspace_info!(workspace_info)
50
- # Only domain errors ("no project file found") reach here; helper
51
- # crashes raise from RegistryClient rather than being misreported as
52
- # a missing Project.toml.
53
- error_value = T.cast(workspace_info["error"], T.nilable(String))
54
- has_error = !error_value.nil?
55
- project_files = T.cast(workspace_info["project_files"], T.nilable(T::Array[String]))
56
- no_projects = project_files.nil? || project_files.empty?
57
- return unless has_error || no_projects
58
-
59
- raise Dependabot::DependencyFileNotFound, "No Project.toml or JuliaProject.toml found."
60
- end
61
-
62
50
  sig { params(project_files: T::Array[String], base_dir: String).returns(T::Array[Dependabot::DependencyFile]) }
63
51
  def fetch_all_project_files(project_files, base_dir)
64
52
  project_files.filter_map do |project_path|
@@ -1,4 +1,4 @@
1
- # typed: strict
1
+ # typed: strong
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "tempfile"
@@ -114,22 +114,20 @@ module Dependabot
114
114
  # a sibling member) resolve by path within the workspace, never from a
115
115
  # registry, so they must not be treated as updatable dependencies.
116
116
  workspace_package_uuids = parsed_projects.filter_map do |_, result|
117
- T.cast(result["uuid"], T.nilable(String))
117
+ result.uuid
118
118
  end
119
119
 
120
120
  parsed_projects.each do |proj_file, result|
121
- parsed_deps = T.cast(result["dependencies"] || [], T::Array[T.untyped])
122
121
  merge_dependencies_from_list(
123
- parsed_deps,
122
+ result.dependencies,
124
123
  ["deps"],
125
124
  proj_file.name,
126
125
  dependencies_map,
127
126
  workspace_package_uuids
128
127
  )
129
128
 
130
- parsed_weak_deps = T.cast(result["weak_dependencies"] || [], T::Array[T.untyped])
131
129
  merge_dependencies_from_list(
132
- parsed_weak_deps,
130
+ result.weak_dependencies,
133
131
  ["weakdeps"],
134
132
  proj_file.name,
135
133
  dependencies_map,
@@ -171,34 +169,34 @@ module Dependabot
171
169
 
172
170
  result = parse_manifest_content(T.must(manifest.content))
173
171
 
174
- if result["error"]
175
- Dependabot.logger.warn("Failed to parse Julia manifest: #{result['error']}")
172
+ if result.is_a?(Dependabot::Julia::RegistryClient::Result::Failure)
173
+ Dependabot.logger.warn("Failed to parse Julia manifest: #{result.message}")
176
174
  return {}
177
175
  end
178
176
 
179
- deps = T.cast(result["dependencies"] || [], T::Array[T.untyped])
180
- deps.each_with_object({}) do |dep_info, map|
181
- dep_hash = T.cast(dep_info, T::Hash[String, T.untyped])
182
- uuid = T.cast(dep_hash["uuid"], T.nilable(String))
183
- version = T.cast(dep_hash["version"], T.nilable(String)).to_s
184
- next if uuid.nil? || version.empty?
177
+ result.dependencies.each_with_object({}) do |dependency, map|
178
+ next if dependency.version.empty?
185
179
 
186
- map[uuid] = version
180
+ map[dependency.uuid] = dependency.version
187
181
  end
188
182
  end
189
183
 
190
- sig { params(content: String).returns(T::Hash[String, T.untyped]) }
184
+ sig do
185
+ params(content: String)
186
+ .returns(T.any(
187
+ Dependabot::Julia::RegistryClient::Result::Manifest,
188
+ Dependabot::Julia::RegistryClient::Result::Failure
189
+ ))
190
+ end
191
191
  def parse_manifest_content(content)
192
- result = T.let(nil, T.nilable(T::Hash[String, T.untyped]))
193
192
  Dir.mktmpdir("julia_manifest") do |temp_dir|
194
193
  # Written under a fixed name: version-suffixed manifests
195
194
  # (Manifest-v1.11.toml) would otherwise be skipped by Pkg when the
196
195
  # helper's Julia version doesn't match.
197
196
  manifest_path = File.join(temp_dir, "Manifest.toml")
198
197
  File.write(manifest_path, content)
199
- result = registry_client.parse_manifest(manifest_path)
198
+ registry_client.parse_manifest(manifest_path)
200
199
  end
201
- T.must(result)
202
200
  end
203
201
 
204
202
  sig { returns(T.nilable(Dependabot::DependencyFile)) }
@@ -208,7 +206,10 @@ module Dependabot
208
206
  end
209
207
  end
210
208
 
211
- sig { params(proj_file: Dependabot::DependencyFile).returns(T.nilable(T::Hash[String, T.untyped])) }
209
+ sig do
210
+ params(proj_file: Dependabot::DependencyFile)
211
+ .returns(T.nilable(Dependabot::Julia::RegistryClient::Result::Project))
212
+ end
212
213
  def parse_project_file(proj_file)
213
214
  temp_dir = Dir.mktmpdir("julia_project")
214
215
  # File names like "../Project.toml" (a workspace root fetched from a
@@ -224,7 +225,7 @@ module Dependabot
224
225
  begin
225
226
  result = registry_client.parse_project(project_path: project_path)
226
227
 
227
- return nil if result["error"]
228
+ return nil if result.is_a?(Dependabot::Julia::RegistryClient::Result::Failure)
228
229
 
229
230
  result
230
231
  ensure
@@ -234,7 +235,7 @@ module Dependabot
234
235
 
235
236
  sig do
236
237
  params(
237
- dep_list: T::Array[T.untyped],
238
+ dep_list: T::Array[Dependabot::Julia::RegistryClient::Result::ProjectDependency],
238
239
  groups: T::Array[String],
239
240
  file_name: String,
240
241
  dependencies_map: T::Hash[String, Dependabot::Dependency],
@@ -242,13 +243,12 @@ module Dependabot
242
243
  ).void
243
244
  end
244
245
  def merge_dependencies_from_list(dep_list, groups, file_name, dependencies_map, workspace_package_uuids)
245
- dep_list.each do |dep_info|
246
- dep_hash = T.cast(dep_info, T::Hash[String, T.untyped])
247
- name = T.cast(dep_hash["name"], String)
246
+ dep_list.each do |dependency|
247
+ name = dependency.name
248
248
  next if name == "julia" # Skip Julia version requirement
249
249
 
250
- uuid = T.cast(dep_hash["uuid"], T.nilable(String))
251
- requirement_string = T.cast(dep_hash["requirement"], T.nilable(String))
250
+ uuid = dependency.uuid
251
+ requirement_string = dependency.requirement
252
252
 
253
253
  next if skip_dependency?(uuid, requirement_string, file_name, workspace_package_uuids)
254
254
 
@@ -279,7 +279,7 @@ module Dependabot
279
279
  version: nil,
280
280
  requirements: [new_requirement],
281
281
  package_manager: "julia",
282
- metadata: uuid ? { julia_uuid: uuid } : {}
282
+ metadata: { julia_uuid: uuid }
283
283
  )
284
284
  end
285
285
  end
@@ -1,4 +1,4 @@
1
- # typed: strict
1
+ # typed: strong
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "toml-rb"
@@ -70,7 +70,9 @@ module Dependabot
70
70
  write_all_temporary_files(updated_project_files, actual_manifest)
71
71
  result = call_julia_helper
72
72
 
73
- return handle_julia_helper_error_multi(result, actual_manifest, updated_project_files) if result["error"]
73
+ if result.is_a?(Dependabot::Julia::RegistryClient::Result::Failure)
74
+ return handle_julia_helper_error_multi(result, actual_manifest, updated_project_files)
75
+ end
74
76
 
75
77
  build_updated_files_multi(updated_files, updated_project_files, actual_manifest, result)
76
78
  end
@@ -147,7 +149,14 @@ module Dependabot
147
149
  File.write(manifest_path, actual_manifest.content)
148
150
  end
149
151
 
150
- sig { returns(T::Hash[String, T.untyped]) }
152
+ sig do
153
+ returns(
154
+ T.any(
155
+ Dependabot::Julia::RegistryClient::Result::ManifestUpdate,
156
+ Dependabot::Julia::RegistryClient::Result::Failure
157
+ )
158
+ )
159
+ end
151
160
  def call_julia_helper
152
161
  registry_client.update_manifest(
153
162
  project_path: Dir.pwd,
@@ -157,13 +166,13 @@ module Dependabot
157
166
 
158
167
  sig do
159
168
  params(
160
- result: T::Hash[String, T.untyped],
169
+ result: Dependabot::Julia::RegistryClient::Result::Failure,
161
170
  actual_manifest: Dependabot::DependencyFile,
162
171
  updated_project_files: T::Array[T::Hash[Symbol, T.untyped]]
163
172
  ).returns(T::Array[Dependabot::DependencyFile])
164
173
  end
165
174
  def handle_julia_helper_error_multi(result, actual_manifest, updated_project_files)
166
- error_message = result["error"]
175
+ error_message = result.message
167
176
  manifest_path = actual_manifest.name
168
177
 
169
178
  is_resolver_error = resolver_error?(error_message)
@@ -212,7 +221,7 @@ module Dependabot
212
221
  updated_files: T::Array[Dependabot::DependencyFile],
213
222
  updated_project_files: T::Array[T::Hash[Symbol, T.untyped]],
214
223
  actual_manifest: Dependabot::DependencyFile,
215
- result: T::Hash[String, T.untyped]
224
+ result: Dependabot::Julia::RegistryClient::Result::ManifestUpdate
216
225
  ).void
217
226
  end
218
227
  def build_updated_files_multi(updated_files, updated_project_files, actual_manifest, result)
@@ -225,16 +234,10 @@ module Dependabot
225
234
  updated_files << updated_file(file: file, content: content)
226
235
  end
227
236
 
228
- return unless result["manifest_content"]
229
-
230
- updated_manifest_content = result["manifest_content"]
237
+ updated_manifest_content = result.manifest_content
231
238
  return unless updated_manifest_content != actual_manifest.content
232
239
 
233
- manifest_for_update = if result["manifest_path"]
234
- manifest_file_for_path(result["manifest_path"])
235
- else
236
- actual_manifest
237
- end
240
+ manifest_for_update = manifest_file_for_path(result.manifest_path)
238
241
  updated_files << updated_file(file: manifest_for_update, content: updated_manifest_content)
239
242
  end
240
243
 
@@ -30,10 +30,9 @@ module Dependabot
30
30
  def source_url_from_julia_helper
31
31
  uuid = T.cast(dependency.metadata[:julia_uuid], T.nilable(String))
32
32
  result = registry_client.find_package_source_url(dependency.name, uuid)
33
- error = T.cast(result["error"], T.nilable(T.any(String, T::Boolean)))
34
- return nil if error
33
+ return nil if result.is_a?(Dependabot::Julia::RegistryClient::Result::Failure)
35
34
 
36
- T.cast(result["source_url"], T.nilable(String))
35
+ result.source_url
37
36
  rescue StandardError => e
38
37
  Dependabot.logger.warn("Failed to get source URL from Julia helper: #{e.message}")
39
38
  nil
@@ -1,4 +1,4 @@
1
- # typed: strict
1
+ # typed: strong
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "time"
@@ -89,35 +89,41 @@ module Dependabot
89
89
  def fetch_release_dates_batch(registry_client, available_versions, uuid)
90
90
  return {} if available_versions.empty?
91
91
 
92
- packages_versions = [{
93
- name: dependency.name,
94
- uuid: uuid || "",
95
- versions: available_versions
96
- }]
92
+ packages_versions = [
93
+ RegistryClient::Result::PackageVersionsRequest.new(
94
+ name: dependency.name,
95
+ uuid: uuid || "",
96
+ versions: available_versions
97
+ )
98
+ ]
97
99
 
98
100
  result = registry_client.batch_fetch_version_release_dates(packages_versions)
99
- dates_for_package = result[dependency.name] || {}
101
+ return {} if result.is_a?(RegistryClient::Result::Failure)
102
+
103
+ dates_for_package = result.packages[dependency.name]
104
+ return {} unless dates_for_package.is_a?(RegistryClient::Result::ReleaseDates)
100
105
 
101
106
  convert_dates_to_time_objects(dates_for_package)
102
107
  end
103
108
 
104
109
  sig do
105
110
  params(
106
- dates_hash: T::Hash[String, T.untyped]
111
+ release_dates: RegistryClient::Result::ReleaseDates
107
112
  ).returns(T::Hash[String, T.nilable(Time)])
108
113
  end
109
- def convert_dates_to_time_objects(dates_hash)
110
- dates_hash.transform_values do |date_value|
111
- convert_single_date(date_value)
114
+ def convert_dates_to_time_objects(release_dates)
115
+ release_dates.dates.transform_values do |result|
116
+ next if result.is_a?(RegistryClient::Result::Failure)
117
+
118
+ convert_single_date(result.release_date)
112
119
  end
113
120
  end
114
121
 
115
- sig { params(date_value: T.untyped).returns(T.nilable(Time)) }
122
+ sig { params(date_value: T.nilable(String)).returns(T.nilable(Time)) }
116
123
  def convert_single_date(date_value)
117
124
  return nil if date_value.nil?
118
- return nil if date_value.is_a?(Hash) && date_value["error"]
119
125
 
120
- Time.parse(date_value.to_s)
126
+ Time.parse(date_value)
121
127
  rescue ArgumentError, TypeError
122
128
  nil
123
129
  end