Skip to content

Commit f2d7269

Browse files
authored
fix: fix deepeval types + add py.typed (#2028)
1 parent 6af577b commit f2d7269

File tree

5 files changed

+14
-29
lines changed

5 files changed

+14
-29
lines changed

.github/workflows/deepeval.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,9 @@ jobs:
4949

5050
- name: Install Hatch
5151
run: pip install --upgrade hatch
52-
53-
# TODO: Once this integration is properly typed, use hatch run test:types
54-
# https://github.com/deepset-ai/haystack-core-integrations/issues/1771
5552
- name: Lint
5653
if: matrix.python-version == '3.9' && runner.os == 'Linux'
57-
run: hatch run fmt-check && hatch run lint:typing
54+
run: hatch run fmt-check && hatch run test:types
5855

5956
- name: Generate docs
6057
if: matrix.python-version == '3.9' && runner.os == 'Linux'

integrations/deepeval/pyproject.toml

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,17 @@ unit = 'pytest -m "not integration" {args:tests}'
6464
integration = 'pytest -m "integration" {args:tests}'
6565
all = 'pytest {args:tests}'
6666
cov-retry = 'all --cov=haystack_integrations --reruns 3 --reruns-delay 30 -x'
67-
types = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}"
67+
types = "mypy -p haystack_integrations.components.evaluators.deepeval {args}"
6868

69-
# TODO: remove lint environment once this integration is properly typed
70-
# test environment should be used instead
71-
# https://github.com/deepset-ai/haystack-core-integrations/issues/1771
72-
[tool.hatch.envs.lint]
73-
installer = "uv"
74-
detached = true
75-
dependencies = ["pip", "mypy>=1.0.0", "ruff>=0.0.243"]
76-
[tool.hatch.envs.lint.scripts]
77-
typing = "mypy --install-types --non-interactive {args:src/}"
69+
[tool.mypy]
70+
install_types = true
71+
non_interactive = true
72+
check_untyped_defs = true
73+
disallow_incomplete_defs = true
74+
75+
[[tool.mypy.overrides]]
76+
module = ["deepeval.*"]
77+
ignore_missing_imports = true
7878

7979
[tool.ruff]
8080
target-version = "py38"
@@ -153,15 +153,3 @@ parallel = false
153153
omit = ["*/tests/*", "*/__init__.py"]
154154
show_missing = true
155155
exclude_lines = ["no cov", "if __name__ == .__main__.:", "if TYPE_CHECKING:"]
156-
157-
158-
[[tool.mypy.overrides]]
159-
module = [
160-
"haystack.*",
161-
"pytest.*",
162-
"deepeval.*",
163-
"numpy",
164-
"grpc",
165-
"haystack_integrations.*",
166-
]
167-
ignore_missing_imports = true

integrations/deepeval/src/haystack_integrations/components/evaluators/deepeval/evaluator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def __init__(
7272
component.set_input_types(self, **expected_inputs)
7373

7474
@component.output_types(results=List[List[Dict[str, Any]]])
75-
def run(self, **inputs) -> Dict[str, Any]:
75+
def run(self, **inputs: Any) -> Dict[str, Any]:
7676
"""
7777
Run the DeepEval evaluator on the provided inputs.
7878
@@ -107,7 +107,7 @@ def to_dict(self) -> Dict[str, Any]:
107107
If the component cannot be serialized.
108108
"""
109109

110-
def check_serializable(obj: Any):
110+
def check_serializable(obj: Any) -> bool:
111111
try:
112112
json.dumps(obj)
113113
return True

integrations/deepeval/src/haystack_integrations/components/evaluators/deepeval/metrics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def _validate_input_elements(**kwargs):
175175
raise ValueError(msg)
176176

177177
@staticmethod
178-
def validate_input_parameters(metric: DeepEvalMetric, expected: Dict[str, Any], received: Dict[str, Any]):
178+
def validate_input_parameters(metric: DeepEvalMetric, expected: Dict[str, Any], received: Dict[str, Any]) -> None:
179179
for param, _ in expected.items():
180180
if param not in received:
181181
msg = f"DeepEval evaluator expected input parameter '{param}' for metric '{metric}'"

integrations/deepeval/src/haystack_integrations/components/evaluators/py.typed

Whitespace-only changes.

0 commit comments

Comments
 (0)