Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@ max-complexity = 17
# Review and change the below later #
##################################################################################################
"ANN001", # Missing type annotation for function argument
"ANN201", # ANN201 Missing return type annotation for public function
"RET504", # Unnecessary assignment to `data` before `return` statement
]

Expand Down
5 changes: 3 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import os
from collections.abc import Generator

import pytest

Expand All @@ -11,7 +12,7 @@


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


@pytest.fixture(scope="session", autouse=True)
def clean_env_vars():
def clean_env_vars() -> Generator:
"""Cleans the environment variables before any test is run."""
original_values = {}
for name in ENV_VARS_TO_CLEAN:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class TagsTransform(InfrahubTransform):
query = "tags_query"
url = "my-tags"

async def transform(self, data):
async def transform(self, data) -> dict[str, str]:
tag = data["BuiltinTag"]["edges"][0]["node"]
tag_name = tag["name"]["value"]
tag_description = tag["description"]["value"]
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/test_infrahub_client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

from collections.abc import AsyncGenerator
from typing import TYPE_CHECKING

import pytest
Expand Down Expand Up @@ -33,7 +34,7 @@ async def base_dataset(
await client.branch.create(branch_name="branch01")

@pytest.fixture
async def set_pagination_size3(self, client: InfrahubClient):
async def set_pagination_size3(self, client: InfrahubClient) -> AsyncGenerator:
original_pagination_size = client.pagination_size
client.pagination_size = 3
yield
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/ctl/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Any

import pytest
import ujson
from pytest_httpx import HTTPXMock
Expand Down Expand Up @@ -63,8 +65,8 @@ async def mock_branches_list_query(httpx_mock: HTTPXMock) -> HTTPXMock:


@pytest.fixture
async def authentication_error_payload():
response = {
async def authentication_error_payload() -> dict[str, Any]:
return {
"data": None,
"errors": [
{
Expand All @@ -74,8 +76,6 @@ async def authentication_error_payload():
],
}

return response


@pytest.fixture
async def mock_branch_create_error(httpx_mock: HTTPXMock) -> HTTPXMock:
Expand Down
4 changes: 3 additions & 1 deletion tests/unit/ctl/test_render_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ def test_validate_template_not_found(test_case: RenderAppFailure, httpx_mock: HT
(None, None, True, "git-branch"),
],
)
def test_render_branch_selection(monkeypatch, httpx_mock: HTTPXMock, cli_branch, env_branch, from_git, expected_branch):
def test_render_branch_selection(
monkeypatch, httpx_mock: HTTPXMock, cli_branch, env_branch, from_git, expected_branch
) -> None:
"""Test that the render command uses the correct branch source."""

if from_git:
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/ctl/test_transform_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import shutil
import tempfile
from collections.abc import Generator
from pathlib import Path

import pytest
Expand All @@ -24,7 +25,7 @@


@pytest.fixture
def tags_transform_dir():
def tags_transform_dir() -> Generator[str]:
temp_dir = tempfile.mkdtemp()

try:
Expand Down
Loading