Skip to content

Commit 3a4f8dd

Browse files
committed
Change ctl check to not use InfrahubCheck.init()
1 parent 758f6ac commit 3a4f8dd

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

infrahub_sdk/checks.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import asyncio
44
import importlib
55
import os
6+
import warnings
67
from abc import abstractmethod
78
from typing import TYPE_CHECKING, Any, Optional
89

@@ -81,6 +82,11 @@ def client(self, value: InfrahubClient) -> None:
8182
@classmethod
8283
async def init(cls, client: Optional[InfrahubClient] = None, *args: Any, **kwargs: Any) -> InfrahubCheck:
8384
"""Async init method, If an existing InfrahubClient client hasn't been provided, one will be created automatically."""
85+
warnings.warn(
86+
"InfrahubCheck.init has been deprecated and will be removed in the version in Infrahub SDK 1.1.0",
87+
DeprecationWarning,
88+
stacklevel=1,
89+
)
8490

8591
instance = cls(*args, **kwargs)
8692
instance.client = client or InfrahubClient()

infrahub_sdk/ctl/check.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from dataclasses import dataclass
66
from pathlib import Path
77
from types import ModuleType
8-
from typing import Optional
8+
from typing import Optional, Type
99

1010
import typer
1111
from rich.console import Console
@@ -30,7 +30,7 @@ class CheckModule:
3030
module: ModuleType
3131
definition: InfrahubCheckDefinitionConfig
3232

33-
def get_check(self) -> InfrahubCheck:
33+
def get_check(self) -> Type[InfrahubCheck]:
3434
return getattr(self.module, self.definition.class_name)
3535

3636

@@ -100,7 +100,7 @@ async def run_check(
100100
log = logging.getLogger("infrahub")
101101
passed = True
102102
check_class = check_module.get_check()
103-
check = await check_class.init(client=client, params=params, output=output, root_directory=path, branch=branch)
103+
check = check_class(client=client, params=params, output=output, root_directory=path, branch=branch)
104104
param_log = f" - {params}" if params else ""
105105
try:
106106
data = execute_graphql_query(

0 commit comments

Comments
 (0)