diff --git a/haystack/core/component/component.py b/haystack/core/component/component.py index b20fb6095..d50bb6afd 100644 --- a/haystack/core/component/component.py +++ b/haystack/core/component/component.py @@ -70,7 +70,6 @@ method decorated with `@component.input`. This dataclass contains: """ import inspect -import sys from collections.abc import Callable from contextlib import contextmanager from contextvars import ContextVar @@ -157,11 +156,7 @@ class Component(Protocol): # arguments. Even defining here a method with `**kwargs` doesn't work as the # expected signature must be identical. # This makes most Language Servers and type checkers happy and shows less errors. - # NOTE: This check can be removed when we drop Python 3.8 support. - if sys.version_info >= (3, 9): - run: Callable[..., Dict[str, Any]] - else: - run: Callable + run: Callable[..., Dict[str, Any]] class ComponentMeta(type): diff --git a/haystack/core/component/types.py b/haystack/core/component/types.py index b08681a75..f3da97849 100644 --- a/haystack/core/component/types.py +++ b/haystack/core/component/types.py @@ -3,9 +3,9 @@ # SPDX-License-Identifier: Apache-2.0 from dataclasses import dataclass, field -from typing import Any, Iterable, List, Type, TypeVar, get_args +from typing import Annotated, Any, Iterable, List, Type, TypeVar, get_args -from typing_extensions import Annotated, TypeAlias # Python 3.8 compatibility +from typing_extensions import TypeAlias # Python 3.9 compatibility HAYSTACK_VARIADIC_ANNOTATION = "__haystack__variadic_t" HAYSTACK_GREEDY_VARIADIC_ANNOTATION = "__haystack__greedy_variadic_t" diff --git a/pyproject.toml b/pyproject.toml index aaf9c961f..d1e49d5c8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ dynamic = ["version"] description = "LLM framework to build customizable, production-ready LLM applications. Connect components (models, vector DBs, file converters) to pipelines or agents that can interact with your data." readme = "README.md" license = "Apache-2.0" -requires-python = ">=3.8" +requires-python = ">=3.9" authors = [{ name = "deepset.ai", email = "malte.pietsch@deepset.ai" }] keywords = [ "BERT", @@ -34,7 +34,6 @@ classifiers = [ "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -53,7 +52,7 @@ dependencies = [ "pyyaml", "more-itertools", # TextDocumentSplitter "networkx", # Pipeline graphs - "typing_extensions>=4.7", # typing support for Python 3.8 + "typing_extensions>=4.7", # typing support for Python 3.9 "requests", "numpy", "python-dateutil", @@ -289,7 +288,6 @@ ignore_missing_imports = true [tool.ruff] line-length = 120 -target-version = "py38" exclude = [".github", "proposals"] [tool.ruff.format] diff --git a/releasenotes/notes/drop-python-3.8-868710963e794c83.yaml b/releasenotes/notes/drop-python-3.8-868710963e794c83.yaml new file mode 100644 index 000000000..d220520e0 --- /dev/null +++ b/releasenotes/notes/drop-python-3.8-868710963e794c83.yaml @@ -0,0 +1,5 @@ +--- +upgrade: + - | + Starting from Haystack 2.11.0 Python 3.8 is no longer supported. + Python 3.8 reached its end of life on October 2024. diff --git a/test/components/converters/test_markdown_to_document.py b/test/components/converters/test_markdown_to_document.py index 19b82d78e..6aa7cadd0 100644 --- a/test/components/converters/test_markdown_to_document.py +++ b/test/components/converters/test_markdown_to_document.py @@ -54,8 +54,9 @@ class TestMarkdownToDocument: converter = MarkdownToDocument() - with patch("haystack.components.converters.markdown.normalize_metadata") as normalize_metadata, patch( - "haystack.components.converters.markdown.MarkdownIt" + with ( + patch("haystack.components.converters.markdown.normalize_metadata") as normalize_metadata, + patch("haystack.components.converters.markdown.MarkdownIt"), ): converter.run(sources=[bytestream, test_files_path / "markdown" / "sample.md"], meta={"language": "it"}) diff --git a/test/core/component/test_component.py b/test/core/component/test_component.py index 49d3a8bd5..784c3f172 100644 --- a/test/core/component/test_component.py +++ b/test/core/component/test_component.py @@ -496,8 +496,9 @@ def test_pre_init_hooking_variadic_positional_args(): assert c.kwarg1 is None assert c.kwarg2 == "string" - with pytest.raises(ComponentError), _hook_component_init( - partial(pre_init_hook, expected_params={"args": (1, 2), "kwarg1": None}) + with ( + pytest.raises(ComponentError), + _hook_component_init(partial(pre_init_hook, expected_params={"args": (1, 2), "kwarg1": None})), ): _ = MockComponent(1, 2, kwarg1=None) diff --git a/test/tools/test_from_function.py b/test/tools/test_from_function.py index 4516a78a6..5834b737d 100644 --- a/test/tools/test_from_function.py +++ b/test/tools/test_from_function.py @@ -2,12 +2,7 @@ import pytest from haystack.tools.from_function import create_tool_from_function, _remove_title_from_schema, tool from haystack.tools.errors import SchemaGenerationError -from typing import Literal, Optional - -try: - from typing import Annotated -except ImportError: - from typing_extensions import Annotated +from typing import Annotated, Literal, Optional def function_with_docstring(city: str) -> str: