You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: replace in-place dataclass mutations with dataclasses.replace()
Resolves the in-place mutation warnings introduced by the
_warn_on_inplace_mutation guard in PR #10650.
Running `hatch run test:unit | grep "Mutating attribute"` surfaced
mutations across five components. Each is replaced with
`dataclasses.replace(instance, field=new_value)` so that dataclass
instances are never mutated after creation.
Changed files:
- components/builders/chat_prompt_builder.py: replace _content mutation
on rendered ChatMessage copy with dataclasses.replace()
- core/pipeline/pipeline.py: replace two-field mutation on PipelineSnapshot
(agent_snapshot + break_point) with a single dataclasses.replace() call
- components/converters/image/file_to_image.py: replace ByteStream.mime_type
mutation with dataclasses.replace()
- components/extractors/llm_metadata_extractor.py: replace Document.content
mutation with dataclasses.replace() (already imported `replace`)
- components/fetchers/link_content.py: replace ByteStream.mime_type
mutations in both sync and async run() methods
- components/joiners/document_joiner.py: replace Document.score mutations in
_score_norm, _reciprocal_rank_fusion, and _distribution_based_rank_fusion
with non-mutating list comprehensions using dataclasses.replace()
Also updates test_document_joiner.py::test_list_with_one_empty_list to
compare by document ID rather than object identity, since the test
previously relied on the mutation side-effect to make the assertion pass.
Fixes#10659
0 commit comments