PEP 633: Reference implementation fixes (#1608)

This commit is contained in:
Laurie O 2020-09-21 16:51:49 +00:00 committed by GitHub
parent e8d68f32b4
commit 8bd1c6510d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 39 additions and 23 deletions

View File

@ -183,9 +183,9 @@ performed):
pep508 += " @ " + requirement["url"] pep508 += " @ " + requirement["url"]
for vcs in ("git", "hg", "bzr", "svn"): for vcs in ("git", "hg", "bzr", "svn"):
if vcs in requirement: if vcs in requirement:
pep508 += " @ " + vcs + "+" requirement[vcs] pep508 += " @ " + vcs + "+" + requirement[vcs]
if "revision" in requirement: if "revision" in requirement:
pep508 += "@" + revision pep508 += "@" + requirement["revision"]
extra = None extra = None
if "for-extra" in requirement: if "for-extra" in requirement:
extra = requirement["for-extra"] extra = requirement["for-extra"]
@ -199,19 +199,19 @@ performed):
def convert_requirements_to_pep508(dependencies): def convert_requirements_to_pep508(dependencies):
pep508s = [] pep508s = []
extras = [] extras = set()
for name, req in dependencies.items(): for name, req in dependencies.items():
if isinstance(req, list): if isinstance(req, list):
for sub_req in req: for sub_req in req:
pep508, extra = convert_requirement_to_pep508(name, sub_req) pep508, extra = convert_requirement_to_pep508(name, sub_req)
pep508s.append(pep508) pep508s.append(pep508)
if extra: if extra:
extras.append(extra) extras.add(extra)
else: else:
pep508, extra = convert_requirement_to_pep508(name, sub_req) pep508, extra = convert_requirement_to_pep508(name, req)
pep508s.append(pep508) pep508s.append(pep508)
if extra: if extra:
extras.append(extra) extras.add(extra)
return pep508s, extras return pep508s, extras
@ -233,7 +233,7 @@ validation errors as users are building the dependencies list.
.. code-block:: .. code-block::
{ {
"$id": "http://sitesee.com.au/schemas/equipment/v3.json", "$id": "spam",
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"title": "Project metadata", "title": "Project metadata",
"type": "object", "type": "object",
@ -255,6 +255,19 @@ validation errors as users are building the dependencies list.
"type": "string" "type": "string"
} }
}, },
"propertyNames": {
"enum": [
"extras",
"markers",
"version",
"url",
"git",
"hg",
"bzr",
"svn",
"for-extra"
]
},
"oneOf": [ "oneOf": [
{ {
"title": "Version requirement", "title": "Version requirement",
@ -366,24 +379,11 @@ validation errors as users are building the dependencies list.
} }
] ]
}, },
"optionalRequirement": { "optionalRequirementTable": {
"title": "Project optional dependency specification", "title": "Project optional dependency specification table",
"allOf": [ "allOf": [
{ {
"title": "Base requirement", "$ref": "#/definitions/requirementTable"
"oneOf": [
{
"$ref": "#/definitions/requirementTable"
},
{
"title": "Multiple specifications",
"type": "array",
"items": {
"$ref": "#/definitions/requirementTable"
},
"minLength": 1
}
]
}, },
{ {
"properties": { "properties": {
@ -397,6 +397,22 @@ validation errors as users are building the dependencies list.
] ]
} }
] ]
},
"optionalRequirement": {
"title": "Project optional dependency specification",
"oneOf": [
{
"$ref": "#/definitions/optionalRequirementTable"
},
{
"title": "Multiple specifications",
"type": "array",
"items": {
"$ref": "#/definitions/optionalRequirementTable"
},
"minLength": 1
}
]
} }
}, },
"properties": { "properties": {