Skip to content

Commit 04ad4fa

Browse files
asaphkoclaude
andcommitted
fix(gitlab): resolve mypy strict errors in client tests
Add type annotations and type: ignore comments for PaginatedResponse union type access in test assertions, IssueQueryParams dynamic kwargs, and responses.calls union attribute access. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e1716f2 commit 04ad4fa

1 file changed

Lines changed: 20 additions & 15 deletions

File tree

api/tests/unit/integrations/gitlab/test_unit_gitlab_client.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from requests.exceptions import HTTPError
55
from responses.matchers import header_matcher, query_param_matcher
66

7+
from integrations.gitlab.types import GitLabProject
78
from integrations.gitlab.client import (
89
_build_paginated_response,
910
create_flagsmith_flag_label,
@@ -90,10 +91,12 @@ def test_fetch_search_gitlab_resource__issues__returns_results() -> None:
9091
)
9192

9293
# Then
93-
assert len(result["results"]) == 1
94-
assert result["results"][0]["title"] == "Bug fix"
95-
assert result["results"][0]["merged"] is False
96-
assert result["results"][0]["draft"] is False
94+
results = result["results"]
95+
assert len(results) == 1
96+
resource = results[0]
97+
assert resource["title"] == "Bug fix" # type: ignore[typeddict-item]
98+
assert resource["merged"] is False # type: ignore[typeddict-item]
99+
assert resource["draft"] is False # type: ignore[typeddict-item]
97100

98101

99102
@responses.activate
@@ -128,9 +131,11 @@ def test_fetch_search_gitlab_resource__merge_requests__returns_mr_fields() -> No
128131
)
129132

130133
# Then
131-
assert len(result["results"]) == 1
132-
assert result["results"][0]["merged"] is True
133-
assert result["results"][0]["draft"] is False
134+
results = result["results"]
135+
assert len(results) == 1
136+
resource = results[0]
137+
assert resource["merged"] is True # type: ignore[typeddict-item]
138+
assert resource["draft"] is False # type: ignore[typeddict-item]
134139

135140

136141
@pytest.mark.parametrize(
@@ -155,12 +160,11 @@ def test_fetch_search_gitlab_resource__with_filter__appends_query_param(
155160
status=200,
156161
headers={"x-total": "0"},
157162
)
158-
kwargs = {
159-
"gitlab_project_id": 1,
160-
"project_name": "group/project",
161-
filter_field: filter_value,
162-
}
163-
params = IssueQueryParams(**kwargs)
163+
params = IssueQueryParams(
164+
gitlab_project_id=1,
165+
project_name="group/project",
166+
**{filter_field: filter_value}, # type: ignore[arg-type]
167+
)
164168

165169
# When
166170
fetch_search_gitlab_resource(
@@ -172,7 +176,7 @@ def test_fetch_search_gitlab_resource__with_filter__appends_query_param(
172176

173177
# Then
174178
assert len(responses.calls) == 1
175-
request_url: str = responses.calls[0].request.url or ""
179+
request_url = responses.calls[0].request.url or "" # type: ignore[union-attr]
176180
assert f"{expected_param}=" in request_url
177181

178182

@@ -401,8 +405,9 @@ def test_build_paginated_response__pagination_headers__returns_correct_links(
401405
resp.headers["x-total-pages"] = x_total_pages
402406

403407
# When
408+
results: list[GitLabProject] = [{"id": 1, "name": "p", "path_with_namespace": "g/p"}]
404409
result = _build_paginated_response(
405-
results=[{"id": 1, "name": "p", "path_with_namespace": "g/p"}],
410+
results=results,
406411
response=resp,
407412
total_count=10,
408413
)

0 commit comments

Comments
 (0)