From 8e0209c5b89af57b62ab60127837b7f68399e3f9 Mon Sep 17 00:00:00 2001 From: Duncan Dewhurst Date: Mon, 13 Nov 2023 14:16:05 +1300 Subject: [PATCH] manage.py (pre-commit): Improve clarity of paths_to_skip logic --- manage.py | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/manage.py b/manage.py index 10bd0cf6..bfc7990c 100755 --- a/manage.py +++ b/manage.py @@ -343,23 +343,16 @@ def update_sub_schema_reference(schema): # Add examples definition["references"] = get_definition_references(schema, defn) for ref in definition["references"]: - if ref[0] not in schema['definitions']: - skip = False - - for path_to_skip in paths_to_skip: - if path_to_skip == '/'.join(ref)[:len(path_to_skip)]: - skip = True - - if not skip: - if ref[-1] == '0': - ref.pop(-1) - - definition["content"].extend([ - "```{jsoninclude} ../../docs/examples/example.json\n", - f":jsonpointer: /projects/0/{'/'.join(ref)}\n", - f":title: {'/'.join(ref)}\n", - "```\n\n" - ]) + if ref[0] not in schema['definitions'] and not any(p == '/'.join(ref)[:len(p)] for p in paths_to_skip): + if ref[-1] == '0': + ref.pop(-1) + + definition["content"].extend([ + "```{jsoninclude} ../../docs/examples/example.json\n", + f":jsonpointer: /projects/0/{'/'.join(ref)}\n", + f":title: {'/'.join(ref)}\n", + "```\n\n" + ]) definition["content"].extend([ "````\n\n",