Skip to content

Commit d0dd721

Browse files
committed
Fixes for test annotations and split up rules
1 parent bdc4ca9 commit d0dd721

File tree

6 files changed

+62
-17
lines changed

6 files changed

+62
-17
lines changed

pyproject.toml

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -330,13 +330,53 @@ max-complexity = 17
330330
"S106", # Possible hardcoded password assigned to argument
331331
"ARG001", # Unused function argument
332332
"ARG002", # Unused method argument
333-
334-
##################################################################################################
335-
# Review and change the below later #
336-
##################################################################################################
337-
"ANN001", # Missing type annotation for function argument
338333
]
339334

335+
##################################################################################################
336+
# ANN001 ignores - broken down for incremental cleanup #
337+
# Remove each section as type annotations are added to that directory #
338+
##################################################################################################
339+
340+
# tests/unit/sdk/ - 478 errors total
341+
"tests/unit/sdk/test_node.py" = ["ANN001"] # 206 errors
342+
"tests/unit/sdk/test_client.py" = ["ANN001"] # 85 errors
343+
"tests/unit/sdk/test_schema.py" = ["ANN001"] # 36 errors
344+
"tests/unit/sdk/test_artifact.py" = ["ANN001"] # 27 errors
345+
"tests/unit/sdk/test_hierarchical_nodes.py" = ["ANN001"] # 26 errors
346+
"tests/unit/sdk/test_task.py" = ["ANN001"] # 21 errors
347+
"tests/unit/sdk/test_store.py" = ["ANN001"] # 12 errors
348+
"tests/unit/sdk/spec/test_object.py" = ["ANN001"] # 11 errors
349+
"tests/unit/sdk/conftest.py" = ["ANN001"] # 11 errors
350+
"tests/unit/sdk/test_diff_summary.py" = ["ANN001"] # 9 errors
351+
"tests/unit/sdk/test_object_store.py" = ["ANN001"] # 7 errors
352+
"tests/unit/sdk/graphql/test_query.py" = ["ANN001"] # 7 errors
353+
"tests/unit/sdk/test_timestamp.py" = ["ANN001"] # 6 errors
354+
"tests/unit/sdk/test_repository.py" = ["ANN001"] # 6 errors
355+
"tests/unit/sdk/test_utils.py" = ["ANN001"] # 4 errors
356+
"tests/unit/sdk/test_store_branch.py" = ["ANN001"] # 4 errors
357+
"tests/unit/sdk/test_query_analyzer.py" = ["ANN001"] # 4 errors
358+
"tests/unit/sdk/test_group_context.py" = ["ANN001"] # 4 errors
359+
"tests/unit/sdk/test_branch.py" = ["ANN001"] # 4 errors
360+
"tests/unit/sdk/test_batch.py" = ["ANN001"] # 4 errors
361+
"tests/unit/sdk/graphql/test_renderer.py" = ["ANN001"] # 4 errors
362+
"tests/unit/sdk/checks/test_checks.py" = ["ANN001"] # 2 errors
363+
"tests/unit/sdk/test_schema_sorter.py" = ["ANN001"] # 1 error
364+
"tests/unit/sdk/test_protocols_generator.py" = ["ANN001"] # 1 error
365+
366+
# tests/integration/ - 60 errors total
367+
"tests/integration/test_infrahub_client.py" = ["ANN001"] # 32 errors
368+
"tests/integration/test_node.py" = ["ANN001"] # 15 errors
369+
"tests/integration/test_infrahubctl.py" = ["ANN001"] # 9 errors
370+
"tests/integration/test_convert_object_type.py" = ["ANN001"] # 3 errors
371+
"tests/integration/test_repository.py" = ["ANN001"] # 1 error
372+
373+
# tests/unit/ctl/ - 25 errors total
374+
"tests/unit/ctl/test_repository_app.py" = ["ANN001"] # 11 errors
375+
"tests/unit/ctl/test_render_app.py" = ["ANN001"] # 5 errors
376+
"tests/unit/ctl/test_cli.py" = ["ANN001"] # 5 errors
377+
"tests/unit/ctl/test_branch_app.py" = ["ANN001"] # 3 errors
378+
"tests/unit/ctl/test_branch_report.py" = ["ANN001"] # 1 error
379+
340380
"tasks.py" = [
341381
"PLC0415", # `import` should be at the top-level of a file
342382
]

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
ENV_VARS_TO_CLEAN = ["INFRAHUB_ADDRESS", "INFRAHUB_TOKEN", "INFRAHUB_BRANCH", "INFRAHUB_USERNAME", "INFRAHUB_PASSWORD"]
1212

1313

14-
def pytest_collection_modifyitems(items) -> None:
14+
def pytest_collection_modifyitems(items: list[pytest.Item]) -> None:
1515
pytest_asyncio_tests = (item for item in items if pytest_asyncio.is_async_test(item))
1616
session_scope_marker = pytest.mark.asyncio(loop_scope="session")
1717
for async_test in pytest_asyncio_tests:

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
from typing import Any
2+
13
from infrahub_sdk.transforms import InfrahubTransform
24

35

46
class TagsTransform(InfrahubTransform):
57
query = "tags_query"
68
url = "my-tags"
79

8-
async def transform(self, data) -> dict[str, str]:
10+
async def transform(self, data: dict[str, Any]) -> dict[str, str]:
911
tag = data["BuiltinTag"]["edges"][0]["node"]
1012
tag_name = tag["name"]["value"]
1113
tag_description = tag["description"]["value"]

tests/fixtures/repos/ctl_integration/transforms/animal_person.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class AnimalPerson(InfrahubTransform):
77
query = "animal_person"
88

9-
async def transform(self, data) -> dict[str, Any]:
9+
async def transform(self, data: dict[str, Any]) -> dict[str, Any]:
1010
response_person = data["TestingPerson"]["edges"][0]["node"]
1111
name: str = response_person["name"]["value"]
1212
animal_names = sorted(

tests/fixtures/repos/ctl_integration/transforms/converted.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class ConvertedAnimalPerson(InfrahubTransform):
88
query = "animal_person"
99

10-
async def transform(self, data) -> dict[str, Any]:
10+
async def transform(self, data: dict[str, Any]) -> dict[str, Any]:
1111
response_person = data["TestingPerson"]["edges"][0]["node"]
1212
name: str = response_person["name"]["value"]
1313
person = self.store.get(key=name, kind="TestingPerson")

tests/unit/pytest_plugin/test_plugin.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
def test_help_message(pytester) -> None:
1+
import pytest
2+
3+
4+
def test_help_message(pytester: pytest.Pytester) -> None:
25
"""Make sure that the plugin is loaded by capturing an option it adds in the help message."""
36
result = pytester.runpytest("--help")
47
result.stdout.fnmatch_lines(["*Infrahub configuration file for the repository*"])
58

69

7-
def test_without_config(pytester) -> None:
10+
def test_without_config(pytester: pytest.Pytester) -> None:
811
"""Make sure 0 tests run when test file is not found."""
912
result = pytester.runpytest()
1013
result.assert_outcomes()
1114

1215

13-
def test_emptyconfig(pytester) -> None:
16+
def test_emptyconfig(pytester: pytest.Pytester) -> None:
1417
"""Make sure that the plugin load the test file properly."""
1518
pytester.makefile(
1619
".yml",
@@ -25,7 +28,7 @@ def test_emptyconfig(pytester) -> None:
2528
result.assert_outcomes()
2629

2730

28-
def test_jinja2_transform_config_missing_directory(pytester) -> None:
31+
def test_jinja2_transform_config_missing_directory(pytester: pytest.Pytester) -> None:
2932
"""Make sure tests raise errors if directories are not found."""
3033
pytester.makefile(
3134
".yml",
@@ -63,7 +66,7 @@ def test_jinja2_transform_config_missing_directory(pytester) -> None:
6366
result.assert_outcomes(errors=1)
6467

6568

66-
def test_jinja2_transform_config_missing_input(pytester) -> None:
69+
def test_jinja2_transform_config_missing_input(pytester: pytest.Pytester) -> None:
6770
"""Make sure tests raise errors if no inputs are provided."""
6871
pytester.makefile(
6972
".yml",
@@ -104,7 +107,7 @@ def test_jinja2_transform_config_missing_input(pytester) -> None:
104107
result.assert_outcomes(errors=1)
105108

106109

107-
def test_jinja2_transform_no_expected_output(pytester) -> None:
110+
def test_jinja2_transform_no_expected_output(pytester: pytest.Pytester) -> None:
108111
"""Make sure tests succeed if no expect outputs are provided."""
109112
pytester.makefile(
110113
".yml",
@@ -161,7 +164,7 @@ def test_jinja2_transform_no_expected_output(pytester) -> None:
161164
result.assert_outcomes(passed=1)
162165

163166

164-
def test_jinja2_transform_unexpected_output(pytester) -> None:
167+
def test_jinja2_transform_unexpected_output(pytester: pytest.Pytester) -> None:
165168
"""Make sure tests fail if the expected and computed outputs don't match."""
166169
pytester.makefile(
167170
".yml",
@@ -233,7 +236,7 @@ def test_jinja2_transform_unexpected_output(pytester) -> None:
233236
result.assert_outcomes(failed=1)
234237

235238

236-
def test_python_transform(pytester) -> None:
239+
def test_python_transform(pytester: pytest.Pytester) -> None:
237240
pytester.makefile(
238241
".yml",
239242
test_python_transform="""

0 commit comments

Comments
 (0)