Skip to content

Commit

Permalink
code review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalkuo committed Jun 13, 2022
1 parent f1453ed commit ab6a3f5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
5 changes: 3 additions & 2 deletions src/poetry/packages/locker.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
from poetry.repositories import Repository

logger = logging.getLogger(__name__)

_GENERATED_IDENTIFIER = "@" + "generated"
GENERATED_COMMENT = f"This file is automatically {_GENERATED_IDENTIFIER} by Poetry and should not be changed by hand."

class Locker:

Expand Down Expand Up @@ -398,7 +399,7 @@ def set_lock_data(self, root: Package, packages: list[Package]) -> bool:
del package["files"]

lock = document()
lock.add(comment("@" + "generated"))
lock.add(comment(GENERATED_COMMENT))
lock["package"] = package_specs

if root.extras:
Expand Down
24 changes: 12 additions & 12 deletions tests/packages/test_locker.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_lock_file_data_is_ordered(locker: Locker, root: ProjectPackage):
content = f.read()

expected = """\
# @generated
# This file is automatically @generated by Poetry and should not be changed by hand.
[[package]]
name = "A"
Expand Down Expand Up @@ -127,7 +127,7 @@ def test_lock_file_data_is_ordered(locker: Locker, root: ProjectPackage):

def test_locker_properly_loads_extras(locker: Locker):
content = """\
# @generated
# This file is automatically @generated by Poetry and should not be changed by hand.
[[package]]
name = "cachecontrol"
Expand Down Expand Up @@ -174,7 +174,7 @@ def test_locker_properly_loads_extras(locker: Locker):

def test_locker_properly_loads_nested_extras(locker: Locker):
content = """\
# @generated
# This file is automatically @generated by Poetry and should not be changed by hand.
[[package]]
name = "a"
Expand Down Expand Up @@ -256,7 +256,7 @@ def test_locker_properly_loads_nested_extras(locker: Locker):

def test_locker_properly_loads_extras_legacy(locker: Locker):
content = """\
# @generated
# This file is automatically @generated by Poetry and should not be changed by hand.
[[package]]
name = "a"
Expand Down Expand Up @@ -316,7 +316,7 @@ def test_lock_packages_with_null_description(locker: Locker, root: ProjectPackag
content = f.read()

expected = """\
# @generated
# # This file is automatically @generated by Poetry and should not be changed by hand.
[[package]]
name = "A"
Expand Down Expand Up @@ -350,7 +350,7 @@ def test_lock_file_should_not_have_mixed_types(locker: Locker, root: ProjectPack
locker.set_lock_data(root, [package_a])

expected = """\
# @generated
# This file is automatically @generated by Poetry and should not be changed by hand.
[[package]]
name = "A"
Expand Down Expand Up @@ -386,7 +386,7 @@ def test_lock_file_should_not_have_mixed_types(locker: Locker, root: ProjectPack

def test_reading_lock_file_should_raise_an_error_on_invalid_data(locker: Locker):
content = """\
# @generated
# This file is automatically @generated by Poetry and should not be changed by hand.
[[package]]
name = "A"
Expand Down Expand Up @@ -437,7 +437,7 @@ def test_locking_legacy_repository_package_should_include_source_section(
content = f.read()

expected = """\
# @generated
# This file is automatically @generated by Poetry and should not be changed by hand.
[[package]]
name = "A"
Expand Down Expand Up @@ -499,7 +499,7 @@ def test_locker_should_raise_an_error_if_lock_version_is_newer_and_not_allowed(
locker: Locker, caplog: LogCaptureFixture
):
content = """\
# @generated
# This file is automatically @generated by Poetry and should not be changed by hand.
[metadata]
lock-version = "2.0"
Expand Down Expand Up @@ -528,7 +528,7 @@ def test_extras_dependencies_are_ordered(locker: Locker, root: ProjectPackage):
locker.set_lock_data(root, [package_a])

expected = """\
# @generated
# This file is automatically @generated by Poetry and should not be changed by hand.
[[package]]
name = "A"
Expand Down Expand Up @@ -620,7 +620,7 @@ def test_locker_dumps_dependency_information_correctly(
with locker.lock.open(encoding="utf-8") as f:
content = f.read()

expected = """# @generated
expected = """# This file is automatically @generated by Poetry and should not be changed by hand.
[[package]]
name = "A"
Expand Down Expand Up @@ -653,7 +653,7 @@ def test_locked_repository_uses_root_dir_of_package(
locker: Locker, mocker: MockerFixture
):
content = """\
# @generated
# This file is automatically @generated by Poetry and should not be changed by hand.
[[package]]
name = "lib-a"
Expand Down

0 comments on commit ab6a3f5

Please sign in to comment.