Skip to content

Commit 8176019

Browse files
committed
A constraint is not a top level requirement
1 parent b114a52 commit 8176019

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/pip/_internal/cli/req_command.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ def get_requirements(
314314
parsed_req,
315315
isolated=options.isolated_mode,
316316
)
317-
req_to_add.is_direct = True
317+
req_to_add.is_direct = False
318318
requirement_set.add_requirement(req_to_add)
319319

320320
for req in args:

src/pip/_internal/req/req_set.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,8 @@ def add_requirement(
110110
)
111111

112112
# This next bit is really a sanity check.
113-
assert install_req.is_direct == (parent_req_name is None), (
114-
"a direct req shouldn't have a parent and also, "
115-
"a non direct req should have a parent"
113+
assert not install_req.is_direct or parent_req_name is None, (
114+
"a direct req shouldn't have a parent"
116115
)
117116

118117
# Unnamed requirements are scanned again and the requirement won't be
@@ -167,6 +166,10 @@ def add_requirement(
167166
# If we're now installing a constraint, mark the existing
168167
# object for real installation.
169168
existing_req.constraint = False
169+
# If we're now installing a top level requirement, mark the existing
170+
# object as top level.
171+
if install_req.is_direct:
172+
existing_req.is_direct = True
170173
existing_req.extras = tuple(sorted(
171174
set(existing_req.extras) | set(install_req.extras)
172175
))

0 commit comments

Comments
 (0)