Skip to content

Commit

Permalink
locker: less verbose output for package.files in lockfile 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
radoering authored and neersighted committed Oct 7, 2022
1 parent 4578c6f commit 0418424
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 22 deletions.
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

0 comments on commit 0418424

Please sign in to comment.