Skip to content

Commit 4bc1bed

Browse files
committed
pylock: packages list is requried
1 parent 0f0c91c commit 4bc1bed

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/pip/_internal/models/pylock.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ def from_install_requirement(cls, ireq: InstallRequirement, base_dir: Path) -> S
412412
package_archive = PackageArchive(
413413
url=download_info.url,
414414
path=None,
415-
size=None,
415+
size=None, # not supported
416416
hashes=download_info.info.hashes,
417417
subdirectory=download_info.subdirectory,
418418
)
@@ -431,7 +431,7 @@ def from_install_requirement(cls, ireq: InstallRequirement, base_dir: Path) -> S
431431
name=link.filename,
432432
url=download_info.url,
433433
path=None,
434-
size=None,
434+
size=None, # not supported
435435
hashes=download_info.info.hashes,
436436
)
437437
]
@@ -440,7 +440,7 @@ def from_install_requirement(cls, ireq: InstallRequirement, base_dir: Path) -> S
440440
name=link.filename,
441441
url=download_info.url,
442442
path=None,
443-
size=None,
443+
size=None, # not supported
444444
hashes=download_info.info.hashes,
445445
)
446446
else:
@@ -449,8 +449,8 @@ def from_install_requirement(cls, ireq: InstallRequirement, base_dir: Path) -> S
449449
return cls(
450450
name=dist.canonical_name,
451451
version=package_version,
452-
marker=None,
453-
requires_python=None,
452+
marker=None, # not supported
453+
requires_python=None, # not supported
454454
vcs=package_vcs,
455455
directory=package_directory,
456456
archive=package_archive,
@@ -461,13 +461,13 @@ def from_install_requirement(cls, ireq: InstallRequirement, base_dir: Path) -> S
461461

462462
@dataclass
463463
class Pylock:
464-
lock_version: Version = Version("1.0")
465-
environments: Optional[List[Marker]] = None
466-
requires_python: Optional[SpecifierSet] = None
464+
lock_version: Version
465+
environments: Optional[List[Marker]]
466+
requires_python: Optional[SpecifierSet]
467467
# (not supported) extras: List[str] = []
468468
# (not supported) dependency_groups: List[str] = []
469-
created_by: str = "pip"
470-
packages: List[Package] = dataclasses.field(default_factory=list)
469+
created_by: str
470+
packages: List[Package]
471471
# (not supported) tool: Optional[Dict[str, Any]]
472472

473473
def _validate_version(self) -> None:
@@ -504,11 +504,15 @@ def from_install_requirements(
504504
cls, install_requirements: Iterable[InstallRequirement], base_dir: Path
505505
) -> Self:
506506
return cls(
507+
lock_version=Version("1.0"),
508+
environments=None, # not supported
509+
requires_python=None, # not supported
510+
created_by="pip",
507511
packages=sorted(
508512
(
509513
Package.from_install_requirement(ireq, base_dir)
510514
for ireq in install_requirements
511515
),
512516
key=lambda p: p.name,
513-
)
517+
),
514518
)

0 commit comments

Comments
 (0)