Skip to content

Commit c04c900

Browse files
build: drop Python 3.8 support (#8978)
* draft * readd typing_extensions * small fix + release note * remove ruff target-version * Update releasenotes/notes/drop-python-3.8-868710963e794c83.yaml Co-authored-by: David S. Batista <[email protected]> --------- Co-authored-by: David S. Batista <[email protected]>
1 parent 4a87ceb commit c04c900

File tree

7 files changed

+17
-22
lines changed

7 files changed

+17
-22
lines changed

haystack/core/component/component.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
"""
7171

7272
import inspect
73-
import sys
7473
from collections.abc import Callable
7574
from contextlib import contextmanager
7675
from contextvars import ContextVar
@@ -157,11 +156,7 @@ def run(self, **kwargs):
157156
# arguments. Even defining here a method with `**kwargs` doesn't work as the
158157
# expected signature must be identical.
159158
# This makes most Language Servers and type checkers happy and shows less errors.
160-
# NOTE: This check can be removed when we drop Python 3.8 support.
161-
if sys.version_info >= (3, 9):
162-
run: Callable[..., Dict[str, Any]]
163-
else:
164-
run: Callable
159+
run: Callable[..., Dict[str, Any]]
165160

166161

167162
class ComponentMeta(type):

haystack/core/component/types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
# SPDX-License-Identifier: Apache-2.0
44

55
from dataclasses import dataclass, field
6-
from typing import Any, Iterable, List, Type, TypeVar, get_args
6+
from typing import Annotated, Any, Iterable, List, Type, TypeVar, get_args
77

8-
from typing_extensions import Annotated, TypeAlias # Python 3.8 compatibility
8+
from typing_extensions import TypeAlias # Python 3.9 compatibility
99

1010
HAYSTACK_VARIADIC_ANNOTATION = "__haystack__variadic_t"
1111
HAYSTACK_GREEDY_VARIADIC_ANNOTATION = "__haystack__greedy_variadic_t"

pyproject.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dynamic = ["version"]
88
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."
99
readme = "README.md"
1010
license = "Apache-2.0"
11-
requires-python = ">=3.8"
11+
requires-python = ">=3.9"
1212
authors = [{ name = "deepset.ai", email = "[email protected]" }]
1313
keywords = [
1414
"BERT",
@@ -34,7 +34,6 @@ classifiers = [
3434
"Operating System :: OS Independent",
3535
"Programming Language :: Python",
3636
"Programming Language :: Python :: 3",
37-
"Programming Language :: Python :: 3.8",
3837
"Programming Language :: Python :: 3.9",
3938
"Programming Language :: Python :: 3.10",
4039
"Programming Language :: Python :: 3.11",
@@ -53,7 +52,7 @@ dependencies = [
5352
"pyyaml",
5453
"more-itertools", # TextDocumentSplitter
5554
"networkx", # Pipeline graphs
56-
"typing_extensions>=4.7", # typing support for Python 3.8
55+
"typing_extensions>=4.7", # typing support for Python 3.9
5756
"requests",
5857
"numpy",
5958
"python-dateutil",
@@ -289,7 +288,6 @@ ignore_missing_imports = true
289288

290289
[tool.ruff]
291290
line-length = 120
292-
target-version = "py38"
293291
exclude = [".github", "proposals"]
294292

295293
[tool.ruff.format]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
upgrade:
3+
- |
4+
Starting from Haystack 2.11.0 Python 3.8 is no longer supported.
5+
Python 3.8 reached its end of life on October 2024.

test/components/converters/test_markdown_to_document.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ def test_run_calls_normalize_metadata(self, test_files_path):
5454

5555
converter = MarkdownToDocument()
5656

57-
with patch("haystack.components.converters.markdown.normalize_metadata") as normalize_metadata, patch(
58-
"haystack.components.converters.markdown.MarkdownIt"
57+
with (
58+
patch("haystack.components.converters.markdown.normalize_metadata") as normalize_metadata,
59+
patch("haystack.components.converters.markdown.MarkdownIt"),
5960
):
6061
converter.run(sources=[bytestream, test_files_path / "markdown" / "sample.md"], meta={"language": "it"})
6162

test/core/component/test_component.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,9 @@ def pre_init_hook(component_class, init_params, expected_params):
496496
assert c.kwarg1 is None
497497
assert c.kwarg2 == "string"
498498

499-
with pytest.raises(ComponentError), _hook_component_init(
500-
partial(pre_init_hook, expected_params={"args": (1, 2), "kwarg1": None})
499+
with (
500+
pytest.raises(ComponentError),
501+
_hook_component_init(partial(pre_init_hook, expected_params={"args": (1, 2), "kwarg1": None})),
501502
):
502503
_ = MockComponent(1, 2, kwarg1=None)
503504

test/tools/test_from_function.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22

33
from haystack.tools.from_function import create_tool_from_function, _remove_title_from_schema, tool
44
from haystack.tools.errors import SchemaGenerationError
5-
from typing import Literal, Optional
6-
7-
try:
8-
from typing import Annotated
9-
except ImportError:
10-
from typing_extensions import Annotated
5+
from typing import Annotated, Literal, Optional
116

127

138
def function_with_docstring(city: str) -> str:

0 commit comments

Comments
 (0)