Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

locker: less verbose output for package.files in lock file 2.0 #6734

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 3 additions & 10 deletions src/poetry/packages/locker.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@
from tomlkit import comment
from tomlkit import document
from tomlkit import inline_table
from tomlkit import item
from tomlkit import table
from tomlkit.exceptions import TOMLKitError
from tomlkit.items import Array


if TYPE_CHECKING:
Expand Down Expand Up @@ -228,24 +226,19 @@ def locked_repository(self) -> LockfileRepository:
return repository

def set_lock_data(self, root: Package, packages: list[Package]) -> bool:
files: dict[str, Any] = table()
package_specs = self._lock_packages(packages)
# Retrieving hashes
for package in package_specs:
if package["name"] not in files:
files[package["name"]] = []
files = array()

for f in package["files"]:
file_metadata = inline_table()
for k, v in sorted(f.items()):
file_metadata[k] = v

files[package["name"]].append(file_metadata)
files.append(file_metadata)

if files[package["name"]]:
package_files = item(files[package["name"]])
assert isinstance(package_files, Array)
files[package["name"]] = package_files.multiline(True)
package["files"] = files.multiline(True)

lock = document()
lock.add(comment(GENERATED_COMMENT))
Expand Down
19 changes: 7 additions & 12 deletions tests/packages/test_locker.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,10 @@ def test_lock_file_data_is_ordered(locker: Locker, root: ProjectPackage):
category = "main"
optional = false
python-versions = "*"

[[package.files]]
file = "bar"
hash = "123"

[[package.files]]
file = "foo"
hash = "456"
files = [
{{file = "bar", hash = "123"}},
{{file = "foo", hash = "456"}},
]

[package.dependencies]
B = "^1.0"
Expand All @@ -123,10 +119,9 @@ def test_lock_file_data_is_ordered(locker: Locker, root: ProjectPackage):
category = "main"
optional = false
python-versions = "*"

[[package.files]]
file = "baz"
hash = "345"
files = [
{{file = "baz", hash = "345"}},
]

[[package]]
name = "B"
Expand Down