Skip to content

Commit 40605b1

Browse files
authored
fix: fix openrouter types + add py.typed (#2029)
1 parent 78a0dd0 commit 40605b1

4 files changed

Lines changed: 9 additions & 28 deletions

File tree

.github/workflows/openrouter.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/openrouter/pyproject.toml

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,14 @@ unit = 'pytest -m "not integration" {args:tests}'
6565
integration = 'pytest -m "integration" {args:tests}'
6666
all = 'pytest {args:tests}'
6767
cov-retry = 'all --cov=haystack_integrations --reruns 3 --reruns-delay 30 -x'
68-
types = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}"
6968

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

8077

8178
[tool.ruff]
@@ -152,22 +149,9 @@ omit = ["*/tests/*", "*/__init__.py"]
152149
show_missing = true
153150
exclude_lines = ["no cov", "if __name__ == .__main__.:", "if TYPE_CHECKING:"]
154151

155-
156-
[[tool.mypy.overrides]]
157-
module = [
158-
"haystack.*",
159-
"haystack_integrations.*",
160-
"openai.*",
161-
"pytest.*",
162-
"numpy.*",
163-
]
164-
ignore_missing_imports = true
165-
166152
[tool.pytest.ini_options]
167153
addopts = "--strict-markers"
168154
markers = [
169155
"integration: integration tests",
170-
"unit: unit tests",
171-
"chat_generators: chat_generators tests",
172156
]
173157
log_cli = true

integrations/openrouter/src/haystack_integrations/components/generators/openrouter/chat/chat_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def _prepare_api_call(
173173

174174
tools = tools or self.tools
175175
tools_strict = tools_strict if tools_strict is not None else self.tools_strict
176-
_check_duplicate_tool_names(tools)
176+
_check_duplicate_tool_names(list(tools or []))
177177

178178
openai_tools = {}
179179
if tools:

integrations/openrouter/src/haystack_integrations/components/generators/py.typed

Whitespace-only changes.

0 commit comments

Comments
 (0)