jsonschema_diff.core.tools.context

Attributes

Classes

RenderContextHandler

Expand context comparators based on pair- and directed-dependency rules.

Module Contents

type RULE_KEY = str | Type['Compare'][source]
type CONTEXT_RULES_TYPE = Mapping[RULE_KEY, Sequence[RULE_KEY]][source]
type PAIR_CONTEXT_RULES_TYPE = Sequence[Sequence[RULE_KEY]][source]
class RenderContextHandler[source]

Expand context comparators based on pair- and directed-dependency rules.

static resolve(
*,
pair_context_rules: PAIR_CONTEXT_RULES_TYPE,
context_rules: CONTEXT_RULES_TYPE,
for_render: Mapping[str, jsonschema_diff.core.parameter_base.Compare],
not_for_render: Mapping[str, jsonschema_diff.core.parameter_base.Compare],
) Dict[str, jsonschema_diff.core.parameter_base.Compare][source]

Build the final ordered context for rendering.

Parameters:
  • pair_context_rules (Sequence[Sequence[RULE_KEY]]) – Undirected groups: if one member is rendered, pull the rest (order preserved).

  • context_rules (Mapping[RULE_KEY, Sequence[RULE_KEY]]) – Directed dependencies: source [targets...].

  • for_render (Mapping[str, Compare]) – Initial items, order defines primary screen order.

  • not_for_render (Mapping[str, Compare]) – Optional items that may be added by the rules.

Returns:

  • dict – Ordered {name -> Compare} ready for UI.

  • Algorithm (high-level)

  • ———————-

  • * Walk through *for_render keys.*

  • * While iterating, append new candidates to the tail of the scan list.

  • * A candidate is added once when first matched by any rule.