Skip to content

config: inheritance semantics — explicit empty lists can't clear inherited lists, cycle error messages report a wrong chain, template doc mismatches scan/match #145

Open

Description

@falbany

Problem

Three related inheritance defects (all verified):

  1. Empty lists can't clear. A child config with extensions: [] under extends: base resolves to the base's list — _merge_str (inheritance.py:20-28) appends base items to the empty local list, and line 107 additionally merges defaults.extensions unconditionally, so a config can never have fewer extensions than defaults. Either honor an explicitly-set empty list as "clear" (distinguish model_fields_set from is None — the machinery is already there) or document the merge-only semantics per field.

  2. Wrong cycle chains in error messages. For A→B→A, validator.collect_issues reports inheritance cycle: A -> A -> B -> A and resolve_configs reports configs.B.extends: inheritance cycle: A -> A -> A; for A→B→C→A the validator says A -> A -> B -> C -> A while inheritance says A -> A -> B -> A (the config where the cycle closed is missing). Root cause in both files: the stack is seeded (name,) and the recursion appends name again — validator.py:61-85 and inheritance.py:55. Fix: seed the initial call with an empty tuple; add a regression test asserting the message for a 3-node cycle.

  3. Template doc overstates merging. template.py:323-324 claims "lists are merged: local items first, then inherited items not already present" — but scan and match are replaced, not merged (inheritance.py:75-85, pick_scan/pick_match). Fix the doc to state per-field: "extensions/filters/row_colors/excludes merge; scan/match replace".

Activity

  1. added
    code-quality
    on Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    code-quality

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions