From e83bb1f69a4612941c0aec519452f3e6cf7c5cd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?El=C5=91d=20Ill=C3=A9s?= Date: Mon, 25 Jul 2022 15:38:25 +0200 Subject: [PATCH] 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] https://github.com/python-jsonschema/jsonschema/commit/d9f63840609176f0b7328f2088c3b2a4016526cd Closes-Bug: #1982757 Change-Id: Ida6310dd822e587ce9c424a228fdff5192ba0476 --- .zuul.yaml | 20 +++++++++++++++----- openstack_releases/cmds/check_schema.py | 20 ++++++++++---------- requirements.txt | 2 +- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/.zuul.yaml b/.zuul.yaml index 0a48041fa7..032a0da29d 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -10,7 +10,7 @@ - project: templates: - - openstack-python3-victoria-jobs + - openstack-python3-zed-jobs - build-openstack-docs-pti check: jobs: @@ -19,12 +19,17 @@ irrelevant-files: - ^doc/.*$ - releases-tox-list-changes - - openstack-tox-py36: + - openstack-tox-py38: irrelevant-files: - ^data/.*$ - ^deliverables/.*$ - ^doc/.*$ - - openstack-tox-py37: + - openstack-tox-py39: + irrelevant-files: + - ^data/.*$ + - ^deliverables/.*$ + - ^doc/.*$ + - openstack-tox-py310: irrelevant-files: - ^data/.*$ - ^deliverables/.*$ @@ -46,12 +51,17 @@ timeout: 10800 irrelevant-files: - ^doc/.*$ - - openstack-tox-py36: + - openstack-tox-py38: irrelevant-files: - ^data/.*$ - ^deliverables/.*$ - ^doc/.*$ - - openstack-tox-py37: + - openstack-tox-py39: + irrelevant-files: + - ^data/.*$ + - ^deliverables/.*$ + - ^doc/.*$ + - openstack-tox-py310: irrelevant-files: - ^data/.*$ - ^deliverables/.*$ diff --git a/openstack_releases/cmds/check_schema.py b/openstack_releases/cmds/check_schema.py index 3a2fdb8297..8060b4e365 100644 --- a/openstack_releases/cmds/check_schema.py +++ b/openstack_releases/cmds/check_schema.py @@ -45,20 +45,20 @@ _LIAISONS_SCHEMA = yamlutils.loads( ) -def is_date(validator, value, instance, schema): - if not isinstance(instance, str): - return - try: - return datetime.datetime.strptime(instance, "%Y-%m-%d") - except Exception: - yield jsonschema.ValidationError('Invalid date {!r}'.format(instance)) +def is_date(validator, instance): + return ( + isinstance(instance, datetime.date) and + not isinstance(instance, datetime.datetime) + ) 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( - validator=jsonschema.Draft4Validator(schema_data), - validators={'date': is_date}, - )(schema_data, types={'date': datetime.date}) + validator=draft4_validator, + type_checker=date_type_checker + )(schema=schema_data) def validate_one_file(filename, schema_data, debug): diff --git a/requirements.txt b/requirements.txt index a567f662cd..c44b27603e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,7 +17,7 @@ yamlordereddictloader prompt_toolkit>=2.0.7 tqdm mwclient==0.8.1 -jsonschema<4.0.0,>=3.2.0 +jsonschema>=3.2.0 twine>=1.13.0 wheel>=0.34.2 ruamel.yaml>=0.15