Skip to content

Commit f5ed365

Browse files
authored
Merge pull request #644 from opsmill/pog-return-annotations-to-infrahub-develop-20251118
Fix return annotations and changes for early returns
2 parents 1dcbcec + 0aa08c2 commit f5ed365

File tree

12 files changed

+83
-107
lines changed

12 files changed

+83
-107
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ max-complexity = 17
282282
# Review and change the below later #
283283
##################################################################################################
284284
"ANN001", # Missing type annotation for function argument
285-
"ANN201", # ANN201 Missing return type annotation for public function
286285
"RET504", # Unnecessary assignment to `data` before `return` statement
287286
]
288287

tests/conftest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import asyncio
22
import os
3+
from collections.abc import Generator
34

45
import pytest
56

@@ -11,7 +12,7 @@
1112

1213

1314
@pytest.fixture(scope="session")
14-
def event_loop():
15+
def event_loop() -> Generator[asyncio.AbstractEventLoop]:
1516
"""Overrides pytest default function scoped event loop"""
1617
policy = asyncio.get_event_loop_policy()
1718
loop = policy.new_event_loop()
@@ -26,7 +27,7 @@ def execute_before_any_test() -> None:
2627

2728

2829
@pytest.fixture(scope="session", autouse=True)
29-
def clean_env_vars():
30+
def clean_env_vars() -> Generator:
3031
"""Cleans the environment variables before any test is run."""
3132
original_values = {}
3233
for name in ENV_VARS_TO_CLEAN:

tests/fixtures/integration/test_infrahubctl/tags_transform/tags_transform.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class TagsTransform(InfrahubTransform):
55
query = "tags_query"
66
url = "my-tags"
77

8-
async def transform(self, data):
8+
async def transform(self, data) -> dict[str, str]:
99
tag = data["BuiltinTag"]["edges"][0]["node"]
1010
tag_name = tag["name"]["value"]
1111
tag_description = tag["description"]["value"]

tests/integration/test_infrahub_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
from collections.abc import AsyncGenerator
34
from typing import TYPE_CHECKING
45

56
import pytest
@@ -33,7 +34,7 @@ async def base_dataset(
3334
await client.branch.create(branch_name="branch01")
3435

3536
@pytest.fixture
36-
async def set_pagination_size3(self, client: InfrahubClient):
37+
async def set_pagination_size3(self, client: InfrahubClient) -> AsyncGenerator:
3738
original_pagination_size = client.pagination_size
3839
client.pagination_size = 3
3940
yield

tests/unit/ctl/conftest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import Any
2+
13
import pytest
24
import ujson
35
from pytest_httpx import HTTPXMock
@@ -63,8 +65,8 @@ async def mock_branches_list_query(httpx_mock: HTTPXMock) -> HTTPXMock:
6365

6466

6567
@pytest.fixture
66-
async def authentication_error_payload():
67-
response = {
68+
async def authentication_error_payload() -> dict[str, Any]:
69+
return {
6870
"data": None,
6971
"errors": [
7072
{
@@ -74,8 +76,6 @@ async def authentication_error_payload():
7476
],
7577
}
7678

77-
return response
78-
7979

8080
@pytest.fixture
8181
async def mock_branch_create_error(httpx_mock: HTTPXMock) -> HTTPXMock:

tests/unit/ctl/test_render_app.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ def test_validate_template_not_found(test_case: RenderAppFailure, httpx_mock: HT
7979
(None, None, True, "git-branch"),
8080
],
8181
)
82-
def test_render_branch_selection(monkeypatch, httpx_mock: HTTPXMock, cli_branch, env_branch, from_git, expected_branch):
82+
def test_render_branch_selection(
83+
monkeypatch, httpx_mock: HTTPXMock, cli_branch, env_branch, from_git, expected_branch
84+
) -> None:
8385
"""Test that the render command uses the correct branch source."""
8486

8587
if from_git:

tests/unit/ctl/test_transform_app.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import os
55
import shutil
66
import tempfile
7+
from collections.abc import Generator
78
from pathlib import Path
89

910
import pytest
@@ -24,7 +25,7 @@
2425

2526

2627
@pytest.fixture
27-
def tags_transform_dir():
28+
def tags_transform_dir() -> Generator[str]:
2829
temp_dir = tempfile.mkdtemp()
2930

3031
try:

0 commit comments

Comments
 (0)