From 694c4d84a526c72034c04b97f99bab82f8858b80 Mon Sep 17 00:00:00 2001 From: Jan Tilly Date: Mon, 19 Dec 2022 14:41:49 +0000 Subject: [PATCH] Use extend instead of append. This makes the function (more) thread safe. --- jsonschema/validators.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jsonschema/validators.py b/jsonschema/validators.py index 66e803ea2..bd267b3fe 100644 --- a/jsonschema/validators.py +++ b/jsonschema/validators.py @@ -102,12 +102,16 @@ def _id_of(schema): def _store_schema_list(): + _vocabularies: list[tuple[str, typing.Any]] = [] if not _VOCABULARIES: package = _utils.resources.files(__package__) for version in package.joinpath("schemas", "vocabularies").iterdir(): for path in version.iterdir(): vocabulary = json.loads(path.read_text()) - _VOCABULARIES.append((vocabulary["$id"], vocabulary)) + _vocabularies.append((vocabulary["$id"], vocabulary)) + + _VOCABULARIES.extend(_vocabularies) + return [ (id, validator.META_SCHEMA) for id, validator in _META_SCHEMAS.items() ] + _VOCABULARIES