@@ -202,9 +202,8 @@ def from_url(cls, url):
202202@functools .total_ordering
203203class PackageCommitPatchData :
204204 vcs_url : str
205- commit_hash : str
205+ commit_hash : Optional [ str ]
206206 patch_text : Optional [str ] = None
207- patch_url : Optional [str ] = None
208207
209208 def __post_init__ (self ):
210209 if not self .commit_hash :
@@ -227,7 +226,6 @@ def _cmp_key(self):
227226 self .vcs_url ,
228227 self .commit_hash ,
229228 self .patch_text ,
230- self .patch_url ,
231229 )
232230
233231 def to_dict (self ) -> dict :
@@ -236,7 +234,6 @@ def to_dict(self) -> dict:
236234 "vcs_url" : self .vcs_url ,
237235 "commit_hash" : self .commit_hash ,
238236 "patch_text" : self .patch_text ,
239- "patch_url" : self .patch_url ,
240237 }
241238
242239 @classmethod
@@ -246,7 +243,6 @@ def from_dict(cls, data: dict):
246243 vcs_url = data .get ("vcs_url" ),
247244 commit_hash = data .get ("commit_hash" ),
248245 patch_text = data .get ("patch_text" ),
249- patch_url = data .get ("patch_url" ),
250246 )
251247
252248
@@ -256,19 +252,11 @@ class PatchData:
256252 patch_url : Optional [str ] = None
257253 patch_text : Optional [str ] = None
258254 patch_checksum : Optional [str ] = dataclasses .field (init = False , default = None )
259- vcs_url : Optional [str ] = None
260- commit_hash : Optional [str ] = None
261255
262256 def __post_init__ (self ):
263- if not (self .patch_url or self .patch_text or self . vcs_url ):
257+ if not (self .patch_url or self .patch_text ):
264258 raise ValueError ("A patch must include either patch_url or patch_text or vcs_url" )
265259
266- if self .vcs_url and not self .commit_hash :
267- raise ValueError ("If vcs_url is provided, commit_hash is required" )
268-
269- if self .commit_hash and not self .vcs_url :
270- raise ValueError ("commit_hash requires vcs_url" )
271-
272260 if self .patch_text :
273261 self .patch_checksum = hashlib .sha512 (self .patch_text .encode ()).hexdigest ()
274262
@@ -281,8 +269,6 @@ def _cmp_key(self):
281269 return (
282270 self .patch_url ,
283271 self .patch_text ,
284- self .commit_hash ,
285- self .vcs_url ,
286272 self .patch_checksum ,
287273 )
288274
@@ -292,17 +278,13 @@ def to_dict(self) -> dict:
292278 "patch_url" : self .patch_url ,
293279 "patch_text" : self .patch_text ,
294280 "patch_checksum" : self .patch_checksum ,
295- "vcs_url" : self .vcs_url ,
296- "commit_hash" : self .commit_hash ,
297281 }
298282
299283 @classmethod
300284 def from_dict (cls , data : dict ):
301285 """Create a PatchData instance from a dictionary."""
302286 return cls (
303287 patch_url = data .get ("patch_url" ),
304- vcs_url = data .get ("vcs_url" ),
305- commit_hash = data .get ("commit_hash" ),
306288 patch_text = data .get ("patch_text" ),
307289 )
308290
0 commit comments