Skip to content

Commit 3ffb8a3

Browse files
committed
build: bump python to 3.14 and update Docker image
1 parent a56b332 commit 3ffb8a3

File tree

24 files changed

+367
-359
lines changed

24 files changed

+367
-359
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG PYTHON_IMAGE=3.13-slim@sha256:1020ca463dc51c26bbad49de85dbb2986d93b71050102f3fa2a7f0fc4c2ea81e
1+
ARG PYTHON_IMAGE=3.14-slim@sha256:4ed33101ee7ec299041cc41dd268dae17031184be94384b1ce7936dc4e5dead3
22

33
# --------------- `base` stage ---------------
44
FROM python:${PYTHON_IMAGE} AS base

eval/classifier.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import logging
22
import time
33
from concurrent.futures import ThreadPoolExecutor
4+
from typing import TYPE_CHECKING
45

5-
from lightman_ai.ai.base.agent import BaseAgent
66
from lightman_ai.ai.gemini.agent import GeminiAgent
77
from lightman_ai.ai.openai.agent import OpenAIAgent
88
from lightman_ai.article.models import Article, ArticlesList, SelectedArticle, SelectedArticlesList
@@ -11,6 +11,9 @@
1111
from eval.constants import MAX_WORKERS, MISSED_ARTICLE_REASON, MISSED_ARTICLE_RELEVANCE_SCORE
1212
from eval.utils import ClassifiedArticleResults
1313

14+
if TYPE_CHECKING:
15+
from lightman_ai.ai.base.agent import BaseAgent
16+
1417
logger = logging.getLogger("eval")
1518

1619

eval/evaluator.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import logging
2+
from typing import TYPE_CHECKING
23

34
from lightman_ai.ai.utils import get_agent_class_from_agent_name
4-
from lightman_ai.article.models import Article
55

66
from eval.classifier import Classifier
77
from eval.templates import ResultsFileBuilder
88
from eval.utils import ResultsMetrics
99

10+
if TYPE_CHECKING:
11+
from lightman_ai.article.models import Article
12+
1013
logger = logging.getLogger("eval")
1114

1215

eval/templates.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import logging
22
from datetime import date
3-
from decimal import Decimal
43
from pathlib import Path
4+
from typing import TYPE_CHECKING
55

6-
from eval.utils import ClassifiedArticleResults, ResultsMetrics
6+
if TYPE_CHECKING:
7+
from decimal import Decimal
8+
9+
from eval.utils import ClassifiedArticleResults, ResultsMetrics
710

811
RESULTS_DIR = "eval/results/"
912

eval/utils.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import inspect
2-
from collections.abc import Iterable
32
from dataclasses import dataclass
43
from decimal import Decimal
5-
from typing import Any
4+
from typing import TYPE_CHECKING, Any
65

7-
from lightman_ai.article.models import SelectedArticle
86
from lightman_ai.core.config import FileConfig, FinalConfig
97
from lightman_ai.core.settings import Settings
10-
from pydantic import PositiveInt
8+
from pydantic import PositiveInt # noqa: TC002
9+
10+
if TYPE_CHECKING:
11+
from collections.abc import Iterable
12+
13+
from lightman_ai.article.models import SelectedArticle
1114

1215

1316
class EvalSettings(Settings):

justfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# VARIABLE DEFINITIONS
22
venv := ".venv"
3-
python_version :="3.13"
3+
python_version :="3.14"
44
run := "uv run"
55
eval_path := "eval/cli.py"
66

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ authors = [
44
{name = "sdn4z", email = "[email protected]"},
55
{name = "scastlara", email = "[email protected]"}
66
]
7-
requires-python = "<4,>=3.13"
7+
requires-python = "==3.14.*"
88
dependencies = [
99
"httpx<1.0.0,>=0.28.0",
1010
"python-dotenv<2.0.0,>=1.1.1",
@@ -60,7 +60,7 @@ asyncio_default_fixture_loop_scope = "session"
6060

6161

6262
[tool.ruff]
63-
target-version = "py312"
63+
target-version = "py314"
6464
line-length = 120
6565
src = ["src", "tests"]
6666

src/lightman_ai/ai/base/agent.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import logging
22
from abc import ABC, abstractmethod
3-
from typing import Never
3+
from typing import TYPE_CHECKING
44

55
from lightman_ai.article.models import SelectedArticlesList
66
from pydantic_ai import Agent
7-
from pydantic_ai.models.google import GoogleModel
8-
from pydantic_ai.models.openai import OpenAIModel
7+
8+
if TYPE_CHECKING:
9+
from pydantic_ai.models.google import GoogleModel
10+
from pydantic_ai.models.openai import OpenAIChatModel
911

1012

1113
class BaseAgent(ABC):
12-
_class: type[OpenAIModel] | type[GoogleModel]
14+
_class: type[OpenAIChatModel] | type[GoogleModel]
1315
_default_model_name: str
1416

1517
def __init__(self, system_prompt: str, model: str | None = None, logger: logging.Logger | None = None) -> None:
1618
agent_model = self._class(model or self._default_model_name)
17-
self.agent: Agent[Never, SelectedArticlesList] = Agent(
18-
model=agent_model, output_type=SelectedArticlesList, system_prompt=system_prompt
19-
)
19+
self.agent = Agent(model=agent_model, output_type=SelectedArticlesList, system_prompt=system_prompt)
2020
self.logger = logger or logging.getLogger("lightman")
2121

2222
def get_prompt_result(self, prompt: str) -> SelectedArticlesList:

src/lightman_ai/ai/gemini/agent.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
from typing import override
1+
from typing import TYPE_CHECKING, override
22

33
from lightman_ai.ai.base.agent import BaseAgent
44
from lightman_ai.ai.gemini.exceptions import map_gemini_exceptions
5-
from lightman_ai.article.models import SelectedArticlesList
65
from pydantic_ai.models.google import GoogleModel
76

7+
if TYPE_CHECKING:
8+
from lightman_ai.article.models import SelectedArticlesList
9+
810

911
class GeminiAgent(BaseAgent):
1012
"""Class that provides an interface to operate with the Gemini model."""

src/lightman_ai/ai/gemini/exceptions.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
from collections.abc import Generator
21
from contextlib import contextmanager
3-
from typing import Any
2+
from typing import TYPE_CHECKING, Any
43

54
from lightman_ai.core.exceptions import BaseLightmanError
65

6+
if TYPE_CHECKING:
7+
from collections.abc import Generator
8+
79

810
class BaseGeminiError(BaseLightmanError): ...
911

0 commit comments

Comments
 (0)