* chore: enable ANN ruff ruleset, exclude components and testing dirs
- Add ANN (flake8-annotations) to ruff select in pyproject.toml
- Globally ignore ANN401 (Any) for legitimate dynamic types
- Exclude haystack/components/** and haystack/testing/** from ANN checks
(mirrors existing mypy disallow_incomplete_defs=false overrides)
- Fix all 43 ANN violations in the remaining modules:
- Add -> None to __post_init__ in breakpoints, file_content,
image_content, sparse_embedding, streaming_chunk, tool, toolset, auth
- Add -> str to __str__ in filter_policy, auth, hf (2x)
- Add *args: Any, **kwargs: Any + return types to metaclass __call__
in component.py and document.py, and __new__ in chat_message.py
- Add -> None to async _runner() in async_pipeline.py
- Type _check_callable_compatibility args and return bool
- Add Callable return type to _dispatch_bm25
- Type send_telemetry decorator params and return
- Type __init_track__ and __setattr_warn__ wrapper functions
- Type _parse_date, _parse_generic_args, async run()
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore: fix ANN violations in .github/utils and docs-website scripts
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore: fix mypy errors introduced by ANN annotations
- async_pipeline.py: _runner() returns Mapping[str, Any], not None
- dataclasses.py: extend type: ignore to cover arg-type in addition to call-arg
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* alphabetical order of ruff rules
* fix: add ANN type annotations to haystack/components and remove per-file-ignore
Fix all ANN (flake8-annotations) violations in haystack/components/ so
the per-file-ignore for that directory can be removed entirely.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore: remove haystack.components.* from mypy disallow_incomplete_defs override
All ANN type annotations have been added to haystack/components/, so the
mypy override is no longer needed for that module.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
* add type annotations to run,warm_up, __str__
* none and any type annotations
* type annotations
* __init__ return type annotation
* list[Document] instead of Any return type annotations
* fmt
* typing
* add run_async return type annotation for LinkContentFetcher
* run_async return type annotations
* fixing docstrings
---------
Co-authored-by: David S. Batista <dsbatista@gmail.com>
* 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
* fix: wrap long line in chat_prompt_builder and add release notes
- Break line 272 in chat_prompt_builder.py to satisfy E501 (max 120 chars)
- Add reno release note for the dataclass mutation fix
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix: replace all remaining in-place dataclass mutations with dataclasses.replace()
Address reviewer feedback:
- Remove unnecessary deepcopy in chat_prompt_builder (dataclasses.replace
creates a new instance, so deepcopy is redundant)
- Fix in-place mutation of Document.score in HuggingFaceTEIRanker,
MetaFieldRanker, SentenceTransformersSimilarityRanker, and
TransformersSimilarityRanker
- Fix in-place mutation of ExtractedAnswer.query in ExtractiveReader
- Fix in-place mutation of Document.embedding in InMemoryDocumentStore
- Fix in-place mutation in test helpers (file router, document splitter
mocks, pipeline tests, tracing tests, document equality test)
- Update release notes to list all affected components and dataclasses
* Keep in-place modification of dataclasses for tests that require it
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: bogdankostic <bogdankostic@web.de>
* Add notes for places that would need to be updated
* First draft for supporting auto layz variadic
* Fix and add some dev comments
* Add pipeline_run test using the automatic joining behavior
* Finish todo
* Fix mypy error
* Add new test
* Add reno
* update reno
* Update releasenotes/notes/add-auto-joiners-for-lists-types-b07771e6d8add3da.yaml
Co-authored-by: Stefano Fiorucci <stefanofiorucci@gmail.com>
* Apply suggestion from @sjrl
* Apply suggestion from @sjrl
* Expand dev comment
* Add more unit tests and a bit of refactoring
---------
Co-authored-by: Stefano Fiorucci <stefanofiorucci@gmail.com>
* Update default OpenAI model to gpt-5-mini
* Update tests
* Fix tool invoker tests
* Update integration tests
* Update fragile test
* More robust tests
* Harden test
* More test improvements
* Better prompting, to trigger tools
* Simplify
* Simplify more
* Simplify even more, less maintenance in the future
* Mark two integration tests flaky
* Fixing fine details
* Add release note for OpenAI default model update to gpt-5-mini
* Add upgrade section to OpenAI default model release note
* chore(lint): enforce and apply PEP 585 type hinting
* Run fmt fixes
* Fix all typing imports using some regex
* Fix all typing written in string in tests
* undo changes in the e2e tests
* make e2e test use list instead of List
* type fixes
* remove type:ignore
* pylint
* Remove typing from Usage example comments
* Remove typing from most of comments
* try to fix e2e tests on comm PRs
* fix
* Add tests typing.List in to adjust test compatiplity
- test/components/agents/test_state_class.py
- test/components/converters/test_output_adapter.py
- test/components/joiners/test_list_joiner.py
* simplify pyproject
* improve relnote
---------
Co-authored-by: anakin87 <stefanofiorucci@gmail.com>
* initial experiments
* progress
* draft
* fix header
* fix linting
* lot more lazy inits
* fixes to main init
* linting
* small refinements
* header fix
* release note
* improve consistency
* test: make sure no extra modules are being imported due to `__init__` definitions
* extend release note with an example
* refactoring import test
* updating release notes
* casting .keys() to list
* reverting to list
* Update haystack/__init__.py
Co-authored-by: Julian Risch <julian.risch@deepset.ai>
* fixing ident problem
* better comments
---------
Co-authored-by: David S. Batista <dsbatista@gmail.com>
Co-authored-by: Julian Risch <julian.risch@deepset.ai>
* Parametrize document joiner tests with empty lists
* Skip loop in _distribution_based_rank_fusion if document list is empty
* Parametrize test_empty_list with join_mode
* Prevent division by zero in _merge and _reciprocal_rank_fusion
* Add release notes
---------
Co-authored-by: Silvano Cerza <silvanocerza@gmail.com>
* chaning default model to gpt-4o-mini
* adding release notes
* fixing some missed tests
* fixing some more missed tests
* fixing one last missed test
* fixing linting issues
* making pylint happy about an end2end test
* chaning if test to walruss operator
* fixing azure embedder from ada to text-embedding-ada-002
* ruff settings
enable ruff format and re-format outdated files
feat: `EvaluationRunResult` add parameter to specify columns to keep in the comparative `Dataframe` (#7879)
* adding param to explictily state which cols to keep
* adding param to explictily state which cols to keep
* adding param to explictily state which cols to keep
* updating tests
* adding release notes
* Update haystack/evaluation/eval_run_result.py
Co-authored-by: Madeesh Kannan <shadeMe@users.noreply.github.com>
* Update releasenotes/notes/add-keep-columns-to-EvalRunResult-comparative-be3e15ce45de3e0b.yaml
Co-authored-by: Madeesh Kannan <shadeMe@users.noreply.github.com>
* updating docstring
---------
Co-authored-by: Madeesh Kannan <shadeMe@users.noreply.github.com>
add format-check
fail on format and linting failures
fix string formatting
reformat long lines
fix tests
fix typing
linter
pull from main
* reformat
* lint -> check
* lint -> check