Change reject_invalid_constraint_types to be reusable

This commit is contained in:
Pradyun Gedam 2020-07-04 17:48:05 +05:30
parent 0acdbf8943
commit ace5485836
No known key found for this signature in database
GPG Key ID: DA17C4B29CB32E4B
1 changed files with 7 additions and 4 deletions

View File

@ -32,8 +32,8 @@ if MYPY_CHECK_RUNNING:
logger = logging.getLogger(__name__)
def reject_invalid_constraint_types(req):
# type: (InstallRequirement) -> None
def check_invalid_constraint_type(req):
# type: (InstallRequirement) -> str
# Check for unsupported forms
problem = ""
@ -60,7 +60,8 @@ def reject_invalid_constraint_types(req):
gone_in=None,
issue=8210
)
raise InstallationError(problem)
return problem
class Resolver(BaseResolver):
@ -108,7 +109,9 @@ class Resolver(BaseResolver):
for req in root_reqs:
if req.constraint:
# Ensure we only accept valid constraints
reject_invalid_constraint_types(req)
problem = check_invalid_constraint_type(req)
if problem:
raise InstallationError(problem)
name = canonicalize_name(req.name)
if name in constraints: