Uncap jsonschema

With the latest upper constraints updating generated patch [1] the
openstack-tox-docs job started to fail, due to conflict:

ERROR: Cannot install jsonschema<4.0.0 and >=3.2.0 because these
package versions have conflicting dependencies.

The conflict is caused by:
    The user requested jsonschema<4.0.0 and >=3.2.0
    The user requested (constraint) jsonschema===4.7.2

This is because we have jsonschema<4.0.0 in our requirements.txt.
By uncapping the constraint the docs job is passing.

Date validation needed to be updated as well, because a deprecated
usage of validator extending method was used in the code, which was
removed [2] from jsonschema with the 4.0.0 release. This patch replaces
that with adding a TYPE_CHECKER instead.

With the new jsonschema constraint openstack-tox-py36 job does not pass
anymore, but py36 is dropped from zed anyway. That job is pulled in by
an old job template, which needs to be replaced to the new zed job
templates, too.

[1] I89576353371aa87d181610eb6242cbe961487af6
[2] d9f6384060

Closes-Bug: #1982757
Change-Id: Ida6310dd822e587ce9c424a228fdff5192ba0476
This commit is contained in:
Előd Illés 2022-07-25 15:38:25 +02:00
parent 5d54e97383
commit e83bb1f69a
3 changed files with 26 additions and 16 deletions

View File

@ -10,7 +10,7 @@
- project: - project:
templates: templates:
- openstack-python3-victoria-jobs - openstack-python3-zed-jobs
- build-openstack-docs-pti - build-openstack-docs-pti
check: check:
jobs: jobs:
@ -19,12 +19,17 @@
irrelevant-files: irrelevant-files:
- ^doc/.*$ - ^doc/.*$
- releases-tox-list-changes - releases-tox-list-changes
- openstack-tox-py36: - openstack-tox-py38:
irrelevant-files: irrelevant-files:
- ^data/.*$ - ^data/.*$
- ^deliverables/.*$ - ^deliverables/.*$
- ^doc/.*$ - ^doc/.*$
- openstack-tox-py37: - openstack-tox-py39:
irrelevant-files:
- ^data/.*$
- ^deliverables/.*$
- ^doc/.*$
- openstack-tox-py310:
irrelevant-files: irrelevant-files:
- ^data/.*$ - ^data/.*$
- ^deliverables/.*$ - ^deliverables/.*$
@ -46,12 +51,17 @@
timeout: 10800 timeout: 10800
irrelevant-files: irrelevant-files:
- ^doc/.*$ - ^doc/.*$
- openstack-tox-py36: - openstack-tox-py38:
irrelevant-files: irrelevant-files:
- ^data/.*$ - ^data/.*$
- ^deliverables/.*$ - ^deliverables/.*$
- ^doc/.*$ - ^doc/.*$
- openstack-tox-py37: - openstack-tox-py39:
irrelevant-files:
- ^data/.*$
- ^deliverables/.*$
- ^doc/.*$
- openstack-tox-py310:
irrelevant-files: irrelevant-files:
- ^data/.*$ - ^data/.*$
- ^deliverables/.*$ - ^deliverables/.*$

View File

@ -45,20 +45,20 @@ _LIAISONS_SCHEMA = yamlutils.loads(
) )
def is_date(validator, value, instance, schema): def is_date(validator, instance):
if not isinstance(instance, str): return (
return isinstance(instance, datetime.date) and
try: not isinstance(instance, datetime.datetime)
return datetime.datetime.strptime(instance, "%Y-%m-%d") )
except Exception:
yield jsonschema.ValidationError('Invalid date {!r}'.format(instance))
def make_validator_with_date(schema_data): def make_validator_with_date(schema_data):
draft4_validator = jsonschema.Draft4Validator
date_type_checker = draft4_validator.TYPE_CHECKER.redefine("date", is_date)
return jsonschema.validators.extend( return jsonschema.validators.extend(
validator=jsonschema.Draft4Validator(schema_data), validator=draft4_validator,
validators={'date': is_date}, type_checker=date_type_checker
)(schema_data, types={'date': datetime.date}) )(schema=schema_data)
def validate_one_file(filename, schema_data, debug): def validate_one_file(filename, schema_data, debug):

View File

@ -17,7 +17,7 @@ yamlordereddictloader
prompt_toolkit>=2.0.7 prompt_toolkit>=2.0.7
tqdm tqdm
mwclient==0.8.1 mwclient==0.8.1
jsonschema<4.0.0,>=3.2.0 jsonschema>=3.2.0
twine>=1.13.0 twine>=1.13.0
wheel>=0.34.2 wheel>=0.34.2
ruamel.yaml>=0.15 ruamel.yaml>=0.15