@@ -256,7 +256,7 @@ class PylockUnsupportedVersionError(PylockValidationError):
256
256
pass
257
257
258
258
259
- @dataclass
259
+ @dataclass ( frozen = True )
260
260
class PackageVcs :
261
261
type : str
262
262
url : Optional [str ] # = None
@@ -276,12 +276,12 @@ def __init__(
276
276
subdirectory : Optional [str ] = None ,
277
277
) -> None :
278
278
# In Python 3.10+ make dataclass kw_only=True and remove __init__
279
- self . type = type
280
- self . url = url
281
- self . path = path
282
- self . requested_revision = requested_revision
283
- self . commit_id = commit_id
284
- self . subdirectory = subdirectory
279
+ object . __setattr__ ( self , " type" , type )
280
+ object . __setattr__ ( self , " url" , url )
281
+ object . __setattr__ ( self , " path" , path )
282
+ object . __setattr__ ( self , " requested_revision" , requested_revision )
283
+ object . __setattr__ ( self , " commit_id" , commit_id )
284
+ object . __setattr__ ( self , " subdirectory" , subdirectory )
285
285
# __post_init__ in Python 3.10+
286
286
_validate_path_url (self .path , self .url )
287
287
@@ -297,7 +297,7 @@ def from_dict(cls, d: Dict[str, Any]) -> "Self":
297
297
)
298
298
299
299
300
- @dataclass
300
+ @dataclass ( frozen = True )
301
301
class PackageDirectory :
302
302
path : str
303
303
editable : Optional [bool ] = None
@@ -311,9 +311,9 @@ def __init__(
311
311
subdirectory : Optional [str ] = None ,
312
312
) -> None :
313
313
# In Python 3.10+ make dataclass kw_only=True and remove __init__
314
- self . path = path
315
- self . editable = editable
316
- self . subdirectory = subdirectory
314
+ object . __setattr__ ( self , " path" , path )
315
+ object . __setattr__ ( self , " editable" , editable )
316
+ object . __setattr__ ( self , " subdirectory" , subdirectory )
317
317
318
318
@classmethod
319
319
def from_dict (cls , d : Dict [str , Any ]) -> "Self" :
@@ -324,7 +324,7 @@ def from_dict(cls, d: Dict[str, Any]) -> "Self":
324
324
)
325
325
326
326
327
- @dataclass
327
+ @dataclass ( frozen = True )
328
328
class PackageArchive :
329
329
url : Optional [str ] # = None
330
330
path : Optional [str ] # = None
@@ -344,12 +344,12 @@ def __init__(
344
344
subdirectory : Optional [str ] = None ,
345
345
) -> None :
346
346
# In Python 3.10+ make dataclass kw_only=True and remove __init__
347
- self . url = url
348
- self . path = path
349
- self . size = size
350
- self . upload_time = upload_time
351
- self . hashes = hashes
352
- self . subdirectory = subdirectory
347
+ object . __setattr__ ( self , " url" , url )
348
+ object . __setattr__ ( self , " path" , path )
349
+ object . __setattr__ ( self , " size" , size )
350
+ object . __setattr__ ( self , " upload_time" , upload_time )
351
+ object . __setattr__ ( self , " hashes" , hashes )
352
+ object . __setattr__ ( self , " subdirectory" , subdirectory )
353
353
# __post_init__ in Python 3.10+
354
354
_validate_path_url (self .path , self .url )
355
355
_validate_hashes (self .hashes )
@@ -366,7 +366,7 @@ def from_dict(cls, d: Dict[str, Any]) -> "Self":
366
366
)
367
367
368
368
369
- @dataclass
369
+ @dataclass ( frozen = True )
370
370
class PackageSdist :
371
371
name : str
372
372
upload_time : Optional [datetime ] # = None
@@ -386,12 +386,12 @@ def __init__(
386
386
size : Optional [int ] = None ,
387
387
) -> None :
388
388
# In Python 3.10+ make dataclass kw_only=True and remove __init__
389
- self . name = name
390
- self . upload_time = upload_time
391
- self . url = url
392
- self . path = path
393
- self . size = size
394
- self . hashes = hashes
389
+ object . __setattr__ ( self , " name" , name )
390
+ object . __setattr__ ( self , " upload_time" , upload_time )
391
+ object . __setattr__ ( self , " url" , url )
392
+ object . __setattr__ ( self , " path" , path )
393
+ object . __setattr__ ( self , " size" , size )
394
+ object . __setattr__ ( self , " hashes" , hashes )
395
395
# __post_init__ in Python 3.10+
396
396
_validate_path_url (self .path , self .url )
397
397
_validate_hashes (self .hashes )
@@ -408,7 +408,7 @@ def from_dict(cls, d: Dict[str, Any]) -> "Self":
408
408
)
409
409
410
410
411
- @dataclass
411
+ @dataclass ( frozen = True )
412
412
class PackageWheel :
413
413
name : str
414
414
upload_time : Optional [datetime ] # = None
@@ -428,12 +428,12 @@ def __init__(
428
428
size : Optional [int ] = None ,
429
429
) -> None :
430
430
# In Python 3.10+ make dataclass kw_only=True and remove __init__
431
- self . name = name
432
- self . upload_time = upload_time
433
- self . url = url
434
- self . path = path
435
- self . size = size
436
- self . hashes = hashes
431
+ object . __setattr__ ( self , " name" , name )
432
+ object . __setattr__ ( self , " upload_time" , upload_time )
433
+ object . __setattr__ ( self , " url" , url )
434
+ object . __setattr__ ( self , " path" , path )
435
+ object . __setattr__ ( self , " size" , size )
436
+ object . __setattr__ ( self , " hashes" , hashes )
437
437
# __post_init__ in Python 3.10+
438
438
_validate_path_url (self .path , self .url )
439
439
_validate_hashes (self .hashes )
@@ -451,7 +451,7 @@ def from_dict(cls, d: Dict[str, Any]) -> "Self":
451
451
return wheel
452
452
453
453
454
- @dataclass
454
+ @dataclass ( frozen = True )
455
455
class Package :
456
456
name : str
457
457
version : Optional [Version ] = None
@@ -485,19 +485,19 @@ def __init__(
485
485
tool : Optional [Dict [str , Any ]] = None ,
486
486
) -> None :
487
487
# In Python 3.10+ make dataclass kw_only=True and remove __init__
488
- self . name = name
489
- self . version = version
490
- self . marker = marker
491
- self . requires_python = requires_python
492
- self . dependencies = dependencies
493
- self . vcs = vcs
494
- self . directory = directory
495
- self . archive = archive
496
- self . index = index
497
- self . sdist = sdist
498
- self . wheels = wheels
499
- self . attestation_identities = attestation_identities
500
- self . tool = tool
488
+ object . __setattr__ ( self , " name" , name )
489
+ object . __setattr__ ( self , " version" , version )
490
+ object . __setattr__ ( self , " marker" , marker )
491
+ object . __setattr__ ( self , " requires_python" , requires_python )
492
+ object . __setattr__ ( self , " dependencies" , dependencies )
493
+ object . __setattr__ ( self , " vcs" , vcs )
494
+ object . __setattr__ ( self , " directory" , directory )
495
+ object . __setattr__ ( self , " archive" , archive )
496
+ object . __setattr__ ( self , " index" , index )
497
+ object . __setattr__ ( self , " sdist" , sdist )
498
+ object . __setattr__ ( self , " wheels" , wheels )
499
+ object . __setattr__ ( self , " attestation_identities" , attestation_identities )
500
+ object . __setattr__ ( self , " tool" , tool )
501
501
# __post_init__ in Python 3.10+
502
502
if self .sdist or self .wheels :
503
503
if any ([self .vcs , self .directory , self .archive ]):
@@ -533,7 +533,7 @@ def from_dict(cls, d: Dict[str, Any]) -> "Self":
533
533
return package
534
534
535
535
536
- @dataclass
536
+ @dataclass ( frozen = True )
537
537
class Pylock :
538
538
lock_version : Version
539
539
environments : Optional [List [Marker ]] # = None
@@ -559,15 +559,15 @@ def __init__(
559
559
tool : Optional [Dict [str , Any ]] = None ,
560
560
) -> None :
561
561
# In Python 3.10+ make dataclass kw_only=True and remove __init__
562
- self . lock_version = lock_version
563
- self . environments = environments
564
- self . requires_python = requires_python
565
- self . extras = extras or []
566
- self . dependency_groups = dependency_groups or []
567
- self . default_groups = default_groups or []
568
- self . created_by = created_by
569
- self . packages = packages
570
- self . tool = tool
562
+ object . __setattr__ ( self , " lock_version" , lock_version )
563
+ object . __setattr__ ( self , " environments" , environments )
564
+ object . __setattr__ ( self , " requires_python" , requires_python )
565
+ object . __setattr__ ( self , " extras" , extras or [])
566
+ object . __setattr__ ( self , " dependency_groups" , dependency_groups or [])
567
+ object . __setattr__ ( self , " default_groups" , default_groups or [])
568
+ object . __setattr__ ( self , " created_by" , created_by )
569
+ object . __setattr__ ( self , " packages" , packages )
570
+ object . __setattr__ ( self , " tool" , tool )
571
571
# __post_init__ in Python 3.10+
572
572
if self .lock_version < Version ("1" ) or self .lock_version >= Version ("2" ):
573
573
raise PylockUnsupportedVersionError (
0 commit comments