Skip to content

Refactor: unify duplicate deep_merge implementations #485

Description

@shenxianpeng

There are two deep_merge functions — one in config.py (private, returns a new dict) and one in config_merger.py (public, mutates in place). The merge logic is identical.

File Signature Behavior
commit_check/config.py:26 (base, override) -> dict Returns a new dict
commit_check/config_merger.py:97 (base, override) -> None Modifies in-place

We only need one implementation. The fix:

  1. Make config.py:_deep_merge a thin wrapper that copies base, then delegates to config_merger.deep_merge.
  2. Delete the original function body (~7 lines).

config.py needs the copy because _deep_merge(parent, config) (line 128) is used for the inherit_from feature — you don't want to mutate the parent config. config_merger.py builds a single accumulator dict layer by layer (defaults → toml → env → cli), so in-place is fine. The wrapper preserves both, drops the duplicate.

Required change:

  • commit_check/config.py — replace _deep_merge body with a delegation wrapper

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions