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

Fix for sync error when the ireqs being merged have no names #1802

Merged
merged 2 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix for sync error when the ireqs being merged have no names
When no name was provided, the ireqs would have no underlying req
attribute. Calling ireq.specifier would raise an AttributeError.
  • Loading branch information
richafrank committed Feb 2, 2023
commit 3ad248cd3d04db897ee7c8674f34dbf0c1ae720d
6 changes: 5 additions & 1 deletion piptools/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ def merge(
if existing_ireq:
# NOTE: We check equality here since we can assume that the
# requirements are all pinned
if ireq.specifier != existing_ireq.specifier:
if (
ireq.req
and existing_ireq.req
and ireq.specifier != existing_ireq.specifier
):
raise IncompatibleRequirements(ireq, existing_ireq)

# TODO: Always pick the largest specifier in case of a conflict
Expand Down
20 changes: 20 additions & 0 deletions tests/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,26 @@ def test_merge_urls(from_line):
)


@pytest.mark.parametrize(
"install_req",
(
"from_line",
"from_editable",
),
)
def test_merge_no_name_urls(install_req, request):
install_req = request.getfixturevalue(install_req)
url = "file:///example.zip"
requirements = [
install_req(url),
install_req(url),
]

assert Counter(requirements[1:]) == Counter(
merge(requirements, ignore_conflicts=False)
)


def test_diff_should_do_nothing():
installed = [] # empty env
reqs = [] # no requirements
Expand Down