summaryrefslogtreecommitdiff
path: root/src/pip/_internal/req/constructors.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/pip/_internal/req/constructors.py')
-rw-r--r--src/pip/_internal/req/constructors.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/pip/_internal/req/constructors.py b/src/pip/_internal/req/constructors.py
index b279bccbc..a659b4d6e 100644
--- a/src/pip/_internal/req/constructors.py
+++ b/src/pip/_internal/req/constructors.py
@@ -182,7 +182,7 @@ def parse_req_from_editable(editable_req):
if name is not None:
try:
- req = Requirement(name)
+ req = Requirement(name) # type: Optional[Requirement]
except InvalidRequirement:
raise InstallationError(f"Invalid requirement: '{name}'")
else:
@@ -335,7 +335,7 @@ def parse_req_from_line(name, line_source):
return text
return f'{text} (from {line_source})'
- if req_as_string is not None:
+ def _parse_req_string(req_as_string: str) -> Requirement:
try:
req = Requirement(req_as_string)
except InvalidRequirement:
@@ -363,6 +363,10 @@ def parse_req_from_line(name, line_source):
if spec_str.endswith(']'):
msg = f"Extras after version '{spec_str}'."
raise InstallationError(msg)
+ return req
+
+ if req_as_string is not None:
+ req = _parse_req_string(req_as_string) # type: Optional[Requirement]
else:
req = None