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
2 changes: 1 addition & 1 deletion infrahub_sdk/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class GraphQLOperation(BaseModel):


class GraphQLQueryAnalyzer:
def __init__(self, query: str, schema: GraphQLSchema | None = None):
def __init__(self, query: str, schema: GraphQLSchema | None = None) -> None:
self.query: str = query
self.schema: GraphQLSchema | None = schema
self.document: DocumentNode = parse(self.query)
Expand Down
4 changes: 2 additions & 2 deletions infrahub_sdk/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __init__(
semaphore: asyncio.Semaphore | None = None,
max_concurrent_execution: int = 5,
return_exceptions: bool = False,
):
) -> None:
self._tasks: list[BatchTask] = []
self.semaphore = semaphore or asyncio.Semaphore(value=max_concurrent_execution)
self.return_exceptions = return_exceptions
Expand Down Expand Up @@ -90,7 +90,7 @@ async def execute(self) -> AsyncGenerator:


class InfrahubBatchSync:
def __init__(self, max_concurrent_execution: int = 5, return_exceptions: bool = False):
def __init__(self, max_concurrent_execution: int = 5, return_exceptions: bool = False) -> None:
self._tasks: list[BatchTaskSync] = []
self.max_concurrent_execution = max_concurrent_execution
self.return_exceptions = return_exceptions
Expand Down
4 changes: 2 additions & 2 deletions infrahub_sdk/branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def generate_diff_data_url(


class InfrahubBranchManager(InfraHubBranchManagerBase):
def __init__(self, client: InfrahubClient):
def __init__(self, client: InfrahubClient) -> None:
self.client = client

@overload
Expand Down Expand Up @@ -233,7 +233,7 @@ async def diff_data(


class InfrahubBranchManagerSync(InfraHubBranchManagerBase):
def __init__(self, client: InfrahubClientSync):
def __init__(self, client: InfrahubClientSync) -> None:
self.client = client

def all(self) -> dict[str, BranchData]:
Expand Down
2 changes: 1 addition & 1 deletion infrahub_sdk/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(
initializer: InfrahubCheckInitializer | None = None,
params: dict | None = None,
client: InfrahubClient | None = None,
):
) -> None:
self.git: GitRepoManager | None = None
self.initializer = initializer or InfrahubCheckInitializer()

Expand Down
2 changes: 1 addition & 1 deletion infrahub_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def __init__(
self,
address: str = "",
config: Config | dict[str, Any] | None = None,
):
) -> None:
self.client = None
self.headers = {"content-type": "application/json"}
self.access_token: str = ""
Expand Down
2 changes: 1 addition & 1 deletion infrahub_sdk/ctl/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ class Error(Exception):


class QueryNotFoundError(Error):
def __init__(self, name: str, message: str = ""):
def __init__(self, name: str, message: str = "") -> None:
self.message = message or f"The requested query '{name}' was not found."
super().__init__(self.message)
36 changes: 18 additions & 18 deletions infrahub_sdk/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@


class Error(Exception):
def __init__(self, message: str | None = None):
def __init__(self, message: str | None = None) -> None:
self.message = message
super().__init__(self.message)


class JsonDecodeError(Error):
def __init__(self, message: str | None = None, content: str | None = None, url: str | None = None):
def __init__(self, message: str | None = None, content: str | None = None, url: str | None = None) -> None:
self.message = message
self.content = content
self.url = url
Expand All @@ -23,14 +23,14 @@ def __init__(self, message: str | None = None, content: str | None = None, url:


class ServerNotReachableError(Error):
def __init__(self, address: str, message: str | None = None):
def __init__(self, address: str, message: str | None = None) -> None:
self.address = address
self.message = message or f"Unable to connect to '{address}'."
super().__init__(self.message)


class ServerNotResponsiveError(Error):
def __init__(self, url: str, timeout: int | None = None, message: str | None = None):
def __init__(self, url: str, timeout: int | None = None, message: str | None = None) -> None:
self.url = url
self.timeout = timeout
self.message = message or f"Unable to read from '{url}'."
Expand All @@ -40,7 +40,7 @@ def __init__(self, url: str, timeout: int | None = None, message: str | None = N


class GraphQLError(Error):
def __init__(self, errors: list[dict[str, Any]], query: str | None = None, variables: dict | None = None):
def __init__(self, errors: list[dict[str, Any]], query: str | None = None, variables: dict | None = None) -> None:
self.query = query
self.variables = variables
self.errors = errors
Expand All @@ -49,21 +49,21 @@ def __init__(self, errors: list[dict[str, Any]], query: str | None = None, varia


class BranchNotFoundError(Error):
def __init__(self, identifier: str, message: str | None = None):
def __init__(self, identifier: str, message: str | None = None) -> None:
self.identifier = identifier
self.message = message or f"Unable to find the branch '{identifier}' in the Database."
super().__init__(self.message)


class SchemaNotFoundError(Error):
def __init__(self, identifier: str, message: str | None = None):
def __init__(self, identifier: str, message: str | None = None) -> None:
self.identifier = identifier
self.message = message or f"Unable to find the schema '{identifier}'."
super().__init__(self.message)


class ModuleImportError(Error):
def __init__(self, message: str | None = None):
def __init__(self, message: str | None = None) -> None:
self.message = message or "Unable to import the module"
super().__init__(self.message)

Expand All @@ -75,7 +75,7 @@ def __init__(
message: str = "Unable to find the node in the database.",
branch_name: str | None = None,
node_type: str | None = None,
):
) -> None:
self.node_type = node_type or "unknown"
self.identifier = identifier
self.branch_name = branch_name
Expand All @@ -97,25 +97,25 @@ class NodeInvalidError(NodeNotFoundError):
class ResourceNotDefinedError(Error):
"""Raised when trying to access a resource that hasn't been defined."""

def __init__(self, message: str | None = None):
def __init__(self, message: str | None = None) -> None:
self.message = message or "The requested resource was not found"
super().__init__(self.message)


class InfrahubCheckNotFoundError(Error):
def __init__(self, name: str, message: str | None = None):
def __init__(self, name: str, message: str | None = None) -> None:
self.message = message or f"The requested InfrahubCheck '{name}' was not found."
super().__init__(self.message)


class InfrahubTransformNotFoundError(Error):
def __init__(self, name: str, message: str | None = None):
def __init__(self, name: str, message: str | None = None) -> None:
self.message = message or f"The requested InfrahubTransform '{name}' was not found."
super().__init__(self.message)


class ValidationError(Error):
def __init__(self, identifier: str, message: str | None = None, messages: list[str] | None = None):
def __init__(self, identifier: str, message: str | None = None, messages: list[str] | None = None) -> None:
self.identifier = identifier
self.message = message
self.messages = messages
Expand All @@ -130,7 +130,7 @@ def __str__(self) -> str:


class ObjectValidationError(Error):
def __init__(self, position: list[int | str], message: str):
def __init__(self, position: list[int | str], message: str) -> None:
self.position = position
self.message = message
super().__init__(self.message)
Expand All @@ -140,13 +140,13 @@ def __str__(self) -> str:


class AuthenticationError(Error):
def __init__(self, message: str | None = None):
def __init__(self, message: str | None = None) -> None:
self.message = message or "Authentication Error, unable to execute the query."
super().__init__(self.message)


class URLNotFoundError(Error):
def __init__(self, url: str):
def __init__(self, url: str) -> None:
self.message = f"`{url}` not found."
super().__init__(self.message)

Expand All @@ -164,12 +164,12 @@ class InvalidResponseError(Error):


class FileNotValidError(Error):
def __init__(self, name: str, message: str = ""):
def __init__(self, name: str, message: str = "") -> None:
self.message = message or f"Cannot parse '{name}' content."
super().__init__(self.message)


class TimestampFormatError(Error):
def __init__(self, message: str | None = None):
def __init__(self, message: str | None = None) -> None:
self.message = message or "Invalid timestamp format"
super().__init__(self.message)
4 changes: 2 additions & 2 deletions infrahub_sdk/graphql/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class BaseGraphQLQuery:
query_type: str = "not-defined"
indentation: int = 4

def __init__(self, query: dict, variables: dict | None = None, name: str | None = None):
def __init__(self, query: dict, variables: dict | None = None, name: str | None = None) -> None:
self.query = query
self.variables = variables
self.name = name or ""
Expand Down Expand Up @@ -46,7 +46,7 @@ def render(self, convert_enum: bool = False) -> str:
class Mutation(BaseGraphQLQuery):
query_type = "mutation"

def __init__(self, *args: Any, mutation: str, input_data: dict, **kwargs: Any):
def __init__(self, *args: Any, mutation: str, input_data: dict, **kwargs: Any) -> None:
self.input_data = input_data
self.mutation = mutation
super().__init__(*args, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion infrahub_sdk/node/attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class Attribute:
"""Represents an attribute of a Node, including its schema, value, and properties."""

def __init__(self, name: str, schema: AttributeSchemaAPI, data: Any | dict):
def __init__(self, name: str, schema: AttributeSchemaAPI, data: Any | dict) -> None:
"""
Args:
name (str): The name of the attribute.
Expand Down
2 changes: 1 addition & 1 deletion infrahub_sdk/node/property.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class NodeProperty:
"""Represents a property of a node, typically used for metadata like display labels."""

def __init__(self, data: dict | str):
def __init__(self, data: dict | str) -> None:
"""
Args:
data (Union[dict, str]): Data representing the node property.
Expand Down
6 changes: 3 additions & 3 deletions infrahub_sdk/node/related_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class RelatedNodeBase:
"""Base class for representing a related node in a relationship."""

def __init__(self, branch: str, schema: RelationshipSchemaAPI, data: Any | dict, name: str | None = None):
def __init__(self, branch: str, schema: RelationshipSchemaAPI, data: Any | dict, name: str | None = None) -> None:
"""
Args:
branch (str): The branch where the related node resides.
Expand Down Expand Up @@ -189,7 +189,7 @@ def __init__(
schema: RelationshipSchemaAPI,
data: Any | dict,
name: str | None = None,
):
) -> None:
"""
Args:
client (InfrahubClient): The client used to interact with the backend asynchronously.
Expand Down Expand Up @@ -236,7 +236,7 @@ def __init__(
schema: RelationshipSchemaAPI,
data: Any | dict,
name: str | None = None,
):
) -> None:
"""
Args:
client (InfrahubClientSync): The client used to interact with the backend synchronously.
Expand Down
6 changes: 3 additions & 3 deletions infrahub_sdk/node/relationship.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
class RelationshipManagerBase:
"""Base class for RelationshipManager and RelationshipManagerSync"""

def __init__(self, name: str, branch: str, schema: RelationshipSchemaAPI):
def __init__(self, name: str, branch: str, schema: RelationshipSchemaAPI) -> None:
"""
Args:
name (str): The name of the relationship.
Expand Down Expand Up @@ -107,7 +107,7 @@ def __init__(
branch: str,
schema: RelationshipSchemaAPI,
data: Any | dict,
):
) -> None:
"""
Args:
name (str): The name of the relationship.
Expand Down Expand Up @@ -230,7 +230,7 @@ def __init__(
branch: str,
schema: RelationshipSchemaAPI,
data: Any | dict,
):
) -> None:
"""
Args:
name (str): The name of the relationship.
Expand Down
4 changes: 2 additions & 2 deletions infrahub_sdk/object_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ObjectStoreBase:


class ObjectStore(ObjectStoreBase):
def __init__(self, client: InfrahubClient):
def __init__(self, client: InfrahubClient) -> None:
self.client = client

async def get(self, identifier: str, tracker: str | None = None) -> str:
Expand Down Expand Up @@ -64,7 +64,7 @@ async def upload(self, content: str, tracker: str | None = None) -> dict[str, st


class ObjectStoreSync(ObjectStoreBase):
def __init__(self, client: InfrahubClientSync):
def __init__(self, client: InfrahubClientSync) -> None:
self.client = client

def get(self, identifier: str, tracker: str | None = None) -> str:
Expand Down
2 changes: 1 addition & 1 deletion infrahub_sdk/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(
convert_query_response: bool,
branch: str,
root_directory: str,
):
) -> None:
self.branch = branch
self.convert_query_response = convert_query_response
self.root_directory = root_directory or os.getcwd()
Expand Down
2 changes: 1 addition & 1 deletion infrahub_sdk/protocols_generator/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def move_to_end_of_list(lst: list, item: str) -> list:


class CodeGenerator:
def __init__(self, schema: dict[str, MainSchemaTypesAll]):
def __init__(self, schema: dict[str, MainSchemaTypesAll]) -> None:
self.generics: dict[str, GenericSchemaAPI | GenericSchema] = {}
self.nodes: dict[str, NodeSchemaAPI | NodeSchema] = {}
self.profiles: dict[str, ProfileSchemaAPI] = {}
Expand Down
Loading