Skip to content

Commit 5972713

Browse files
committed
format
1 parent b826d89 commit 5972713

File tree

7 files changed

+32
-22
lines changed

7 files changed

+32
-22
lines changed

infrahub_sdk/ctl/example_repo/tasks.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
from invoke import Context, task
1+
import os
22
from pathlib import Path
3+
34
import httpx
4-
import os
5+
from invoke import Context, task
56

67
# If no version is indicated, we will take the latest
78
VERSION = os.getenv("INFRAHUB_IMAGE_VER", None)
@@ -12,7 +13,7 @@ def start(context: Context) -> None:
1213
"""
1314
Start the services using docker-compose in detached mode.
1415
"""
15-
compose_file = download_compose_file(context, override=False)
16+
download_compose_file(context, override=False)
1617
context.run("docker compose up -d")
1718

1819

@@ -21,7 +22,7 @@ def destroy(context: Context) -> None:
2122
"""
2223
Stop and remove containers, networks, and volumes.
2324
"""
24-
compose_file = download_compose_file(context, override=False)
25+
download_compose_file(context, override=False)
2526
context.run("docker compose down -v")
2627

2728

@@ -30,7 +31,7 @@ def stop(context: Context) -> None:
3031
"""
3132
Stop containers and remove networks.
3233
"""
33-
compose_file = download_compose_file(context, override=False)
34+
download_compose_file(context, override=False)
3435
context.run("docker compose down")
3536

3637

@@ -64,7 +65,7 @@ def test(ctx: Context):
6465

6566

6667
@task(help={"override": "Redownload the compose file even if it already exists."})
67-
def download_compose_file(context: Context, override: bool = False) -> Path:
68+
def download_compose_file(context: Context, override: bool = False) -> Path: # noqa ARG001
6869
"""
6970
Download docker-compose.yml from InfraHub if missing or override is True.
7071
"""
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
from infrahub_sdk import InfrahubClient
2-
from infrahub_sdk.node import InfrahubNode
3-
from typing import List
41
import logging
52

3+
from infrahub_sdk.node import InfrahubNode
4+
65

7-
def print_nodes(client: InfrahubClient, log: logging.Logger, nodes: List[InfrahubNode]):
6+
def print_nodes(log: logging.Logger, nodes: list[InfrahubNode]):
87
for node in nodes.keys():
98
log.info(f"{node} present.")
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import logging
22

3-
from infrahub_sdk import InfrahubClient
43
from lib.example import print_nodes
54

5+
from infrahub_sdk import InfrahubClient
6+
67

78
async def run(
89
client: InfrahubClient,
910
log: logging.Logger,
1011
branch: str,
1112
):
12-
log.info("Running example script...")
13+
log.info(f"Running example script on {branch}...")
1314
nodes = await client.schema.all()
14-
print_nodes(client, log, nodes)
15+
print_nodes(log, nodes)

infrahub_sdk/ctl/example_repo/{% if tests %}tests{% endif %}/integration/conftest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import pytest
21
from pathlib import Path
3-
42
from typing import Any
3+
4+
import pytest
5+
56
from infrahub_sdk.yaml import SchemaFile
67

78
CURRENT_DIRECTORY = Path(__file__).parent.resolve()

infrahub_sdk/ctl/example_repo/{% if tests %}tests{% endif %}/integration/test_infrahub.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
import pytest
21
from pathlib import Path
2+
3+
import pytest
4+
35
from infrahub_sdk import InfrahubClient
4-
from infrahub_sdk.testing.docker import TestInfrahubDockerClient
56
from infrahub_sdk.protocols import CoreGenericRepository
7+
from infrahub_sdk.testing.docker import TestInfrahubDockerClient
68
from infrahub_sdk.testing.repository import GitRepo
79

810

911
class TestInfrahub(TestInfrahubDockerClient):
1012
@pytest.mark.asyncio
11-
async def test_load_schema(self, default_branch: str, client: InfrahubClient, schemas):
13+
async def test_load_schema(self, default_branch: str, client: InfrahubClient, schemas: list[dict]):
1214
await client.schema.wait_until_converged(branch=default_branch)
1315

1416
resp = await client.schema.load(schemas=schemas, branch=default_branch, wait_until_converged=True)
@@ -34,7 +36,7 @@ async def test_load_repository(
3436

3537
repos = await client.all(kind=CoreGenericRepository)
3638

37-
### A breakpoint can be added to pause the tests from running and keep the test containers active
39+
# A breakpoint can be added to pause the tests from running and keep the test containers active
3840
# breakpoint()
3941

4042
assert repos

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,11 @@ max-complexity = 17
283283
"ANN204", # Missing return type annotation for special method
284284
]
285285

286+
"infrahub_sdk/ctl/example_repo/**/*.py" = [
287+
"S101", # Use of assert detected
288+
"N999", # Invalid module name
289+
]
290+
286291
"tests/unit/sdk/test_client.py" = [
287292
"W293", # Blank line contains whitespace (used within output check)
288293
]

tests/unit/ctl/test_repository_app.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,10 @@ def test_repo_list(self, mock_repositories_list) -> None:
293293
assert strip_color(result.stdout) == read_fixture("output.txt", "integration/test_infrahubctl/repository_list")
294294

295295
def test_repo_init(self) -> None:
296-
with tempfile.TemporaryDirectory() as temp_dst, tempfile.NamedTemporaryFile(
297-
mode="w", suffix=".yml", delete=False, encoding="utf-8"
298-
) as temp_yaml:
296+
with (
297+
tempfile.TemporaryDirectory() as temp_dst,
298+
tempfile.NamedTemporaryFile(mode="w", suffix=".yml", delete=False, encoding="utf-8") as temp_yaml,
299+
):
299300
dst = Path(temp_dst)
300301
yaml_path = Path(temp_yaml.name)
301302

0 commit comments

Comments
 (0)