* fix mutable default argument in graph_analyzer.py
* fix mutable default argument in kg_chunkers.py
* fix mutable default argument in methods.py
* Address review: move default-init code out of docstrings, default levels in split_hierarchical
Three findings from the Qodo review:
- analyze_temporal_evolution: the 'if metrics is None' block had landed
inside the docstring, so it never executed and metrics_tracked came back
None. Moved below the docstring where it runs.
- HierarchicalChunker.__init__: the same misplacement turned the docstring
into a dead string constant and broke help()/introspection. Moved the
default-init below it.
- split_hierarchical: the signature now defaults levels to None, but the
body still ran 'in levels' membership tests — calling it without levels
raised TypeError. Defaults to the documented hierarchy, matching the
class-level default.
* test: add mutable-default regression tests for the three fixed sites
- tests/split/test_chunkers.py: TestMutableDefaultRegression (6 tests)
- split_hierarchical() default levels and chunk_sizes stay independent across calls
- HierarchicalChunker() default levels stay independent across instances
- tests/kg/test_kg.py: TestAnalyzeTemporalEvolutionMutableDefault (5 tests)
- analyze_temporal_evolution() default metrics value is canonical
- mutations to a returned metrics_tracked list do not affect the next call
- explicit metrics override is forwarded and reflected in the return value
- mutating an explicitly passed list does not corrupt a subsequent default call
All 96 tests in the two affected test files pass.
---------
Co-authored-by: Zohaib Hassnain <109234410+ZohaibHassan16@users.noreply.github.com>
Co-authored-by: Sameer Kadam <sskadam6305@gmail.com>
- Reject non-positive stride values before chunking and validate temporary overlap overrides before mutating chunker state.
- Restore the original overlap and custom stride with `try/finally` so state remains unchanged after both successful and failed `chunk_with_overlap()` calls.
- Add regression coverage for invalid stride and overlap values, valid boundary cases, and state restoration.