diff --git a/infrahub_sdk/analyzer.py b/infrahub_sdk/analyzer.py index 5bca02e1..09a5ce80 100644 --- a/infrahub_sdk/analyzer.py +++ b/infrahub_sdk/analyzer.py @@ -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) diff --git a/infrahub_sdk/batch.py b/infrahub_sdk/batch.py index 2f1db7f4..49e974ca 100644 --- a/infrahub_sdk/batch.py +++ b/infrahub_sdk/batch.py @@ -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 @@ -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 diff --git a/infrahub_sdk/branch.py b/infrahub_sdk/branch.py index 4f5e050f..53623eae 100644 --- a/infrahub_sdk/branch.py +++ b/infrahub_sdk/branch.py @@ -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 @@ -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]: diff --git a/infrahub_sdk/checks.py b/infrahub_sdk/checks.py index 5fdac509..e0880da9 100644 --- a/infrahub_sdk/checks.py +++ b/infrahub_sdk/checks.py @@ -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() diff --git a/infrahub_sdk/client.py b/infrahub_sdk/client.py index b837e3a8..d7b79047 100644 --- a/infrahub_sdk/client.py +++ b/infrahub_sdk/client.py @@ -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 = "" diff --git a/infrahub_sdk/ctl/exceptions.py b/infrahub_sdk/ctl/exceptions.py index fc764f3b..78e07ce8 100644 --- a/infrahub_sdk/ctl/exceptions.py +++ b/infrahub_sdk/ctl/exceptions.py @@ -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) diff --git a/infrahub_sdk/exceptions.py b/infrahub_sdk/exceptions.py index d8982d8e..e1dba1d5 100644 --- a/infrahub_sdk/exceptions.py +++ b/infrahub_sdk/exceptions.py @@ -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 @@ -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}'." @@ -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 @@ -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) @@ -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 @@ -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 @@ -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) @@ -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) @@ -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) diff --git a/infrahub_sdk/graphql/query.py b/infrahub_sdk/graphql/query.py index 7e7cc660..54078b76 100644 --- a/infrahub_sdk/graphql/query.py +++ b/infrahub_sdk/graphql/query.py @@ -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 "" @@ -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) diff --git a/infrahub_sdk/node/attribute.py b/infrahub_sdk/node/attribute.py index 9c752521..1d97e0b0 100644 --- a/infrahub_sdk/node/attribute.py +++ b/infrahub_sdk/node/attribute.py @@ -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. diff --git a/infrahub_sdk/node/property.py b/infrahub_sdk/node/property.py index 8de0ab43..7a8fcd6d 100644 --- a/infrahub_sdk/node/property.py +++ b/infrahub_sdk/node/property.py @@ -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. diff --git a/infrahub_sdk/node/related_node.py b/infrahub_sdk/node/related_node.py index bf6cb532..ab6cf17f 100644 --- a/infrahub_sdk/node/related_node.py +++ b/infrahub_sdk/node/related_node.py @@ -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. @@ -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. @@ -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. diff --git a/infrahub_sdk/node/relationship.py b/infrahub_sdk/node/relationship.py index 4867efdd..55aad544 100644 --- a/infrahub_sdk/node/relationship.py +++ b/infrahub_sdk/node/relationship.py @@ -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. @@ -107,7 +107,7 @@ def __init__( branch: str, schema: RelationshipSchemaAPI, data: Any | dict, - ): + ) -> None: """ Args: name (str): The name of the relationship. @@ -230,7 +230,7 @@ def __init__( branch: str, schema: RelationshipSchemaAPI, data: Any | dict, - ): + ) -> None: """ Args: name (str): The name of the relationship. diff --git a/infrahub_sdk/object_store.py b/infrahub_sdk/object_store.py index b62d0d9e..a6cd4bdb 100644 --- a/infrahub_sdk/object_store.py +++ b/infrahub_sdk/object_store.py @@ -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: @@ -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: diff --git a/infrahub_sdk/operation.py b/infrahub_sdk/operation.py index f52db43d..4f431a5e 100644 --- a/infrahub_sdk/operation.py +++ b/infrahub_sdk/operation.py @@ -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() diff --git a/infrahub_sdk/protocols_generator/generator.py b/infrahub_sdk/protocols_generator/generator.py index e6fe0ce3..82771fa6 100644 --- a/infrahub_sdk/protocols_generator/generator.py +++ b/infrahub_sdk/protocols_generator/generator.py @@ -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] = {} diff --git a/infrahub_sdk/pytest_plugin/exceptions.py b/infrahub_sdk/pytest_plugin/exceptions.py index b46dfac5..1bc89129 100644 --- a/infrahub_sdk/pytest_plugin/exceptions.py +++ b/infrahub_sdk/pytest_plugin/exceptions.py @@ -7,37 +7,37 @@ class Error(Exception): class InvalidResourceConfigError(Error): - def __init__(self, resource_name: str): + def __init__(self, resource_name: str) -> None: super().__init__(f"Improperly configured resource with name '{resource_name}'.") class DirectoryNotFoundError(Error): - def __init__(self, name: str, message: str = ""): + def __init__(self, name: str, message: str = "") -> None: self.message = message or f"Unable to find directory {name!r}." super().__init__(self.message) class FileNotValidError(Error): - def __init__(self, name: str, message: str = ""): + def __init__(self, name: str, message: str = "") -> None: self.message = message or f"Unable to access file {name!r}." super().__init__(self.message) class OutputMatchError(Error): - def __init__(self, name: str, message: str = "", differences: str = ""): + def __init__(self, name: str, message: str = "", differences: str = "") -> None: self.message = message or f"Rendered output does not match expected output for {name!r}." self.differences = differences super().__init__(self.message) class Jinja2TransformError(Error): - def __init__(self, name: str, message: str = ""): + def __init__(self, name: str, message: str = "") -> None: self.message = message or f"Unexpected error happened while processing {name!r}." super().__init__(self.message) class Jinja2TransformUndefinedError(Error): - def __init__(self, name: str, rtb: Traceback, errors: list[tuple[Frame, Syntax]], message: str = ""): + def __init__(self, name: str, rtb: Traceback, errors: list[tuple[Frame, Syntax]], message: str = "") -> None: self.rtb = rtb self.errors = errors self.message = message or f"Unable to render Jinja2 transform {name!r}." @@ -45,18 +45,18 @@ def __init__(self, name: str, rtb: Traceback, errors: list[tuple[Frame, Syntax]] class CheckDefinitionError(Error): - def __init__(self, name: str, message: str = ""): + def __init__(self, name: str, message: str = "") -> None: self.message = message or f"Check {name!r} is not properly defined." super().__init__(self.message) class CheckResultError(Error): - def __init__(self, name: str, message: str = ""): + def __init__(self, name: str, message: str = "") -> None: self.message = message or f"Unexpected result for check {name!r}." super().__init__(self.message) class PythonTransformDefinitionError(Error): - def __init__(self, name: str, message: str = ""): + def __init__(self, name: str, message: str = "") -> None: self.message = message or f"Python transform {name!r} is not properly defined." super().__init__(self.message) diff --git a/infrahub_sdk/pytest_plugin/items/base.py b/infrahub_sdk/pytest_plugin/items/base.py index e00db68a..a1b35a00 100644 --- a/infrahub_sdk/pytest_plugin/items/base.py +++ b/infrahub_sdk/pytest_plugin/items/base.py @@ -25,7 +25,7 @@ def __init__( resource_config: InfrahubRepositoryConfigElement, test: InfrahubTest, **kwargs: dict[str, Any], - ): + ) -> None: super().__init__(*args, **kwargs) # type: ignore[arg-type] self.resource_name: str = resource_name self.resource_config: InfrahubRepositoryConfigElement = resource_config diff --git a/infrahub_sdk/pytest_plugin/items/check.py b/infrahub_sdk/pytest_plugin/items/check.py index c0e56eb0..f42f4808 100644 --- a/infrahub_sdk/pytest_plugin/items/check.py +++ b/infrahub_sdk/pytest_plugin/items/check.py @@ -27,7 +27,7 @@ def __init__( resource_config: InfrahubRepositoryConfigElement, test: InfrahubTest, **kwargs: dict[str, Any], - ): + ) -> None: super().__init__(*args, resource_name=resource_name, resource_config=resource_config, test=test, **kwargs) self.check_instance: InfrahubCheck diff --git a/infrahub_sdk/pytest_plugin/items/python_transform.py b/infrahub_sdk/pytest_plugin/items/python_transform.py index 02977f48..f77b1aa1 100644 --- a/infrahub_sdk/pytest_plugin/items/python_transform.py +++ b/infrahub_sdk/pytest_plugin/items/python_transform.py @@ -28,7 +28,7 @@ def __init__( resource_config: InfrahubRepositoryConfigElement, test: InfrahubTest, **kwargs: dict[str, Any], - ): + ) -> None: super().__init__(*args, resource_name=resource_name, resource_config=resource_config, test=test, **kwargs) self.transform_instance: InfrahubTransform diff --git a/infrahub_sdk/repository.py b/infrahub_sdk/repository.py index 331d15f1..2ad2080a 100644 --- a/infrahub_sdk/repository.py +++ b/infrahub_sdk/repository.py @@ -7,7 +7,7 @@ class GitRepoManager: - def __init__(self, root_directory: str, branch: str = "main"): + def __init__(self, root_directory: str, branch: str = "main") -> None: self.root_directory = root_directory self.branch = branch self.git: Repo = self.initialize_repo() diff --git a/infrahub_sdk/schema/__init__.py b/infrahub_sdk/schema/__init__.py index 320c43a9..1ca3a7a0 100644 --- a/infrahub_sdk/schema/__init__.py +++ b/infrahub_sdk/schema/__init__.py @@ -115,7 +115,7 @@ class InfrahubSchemaBase: client: InfrahubClient | InfrahubClientSync cache: dict[str, BranchSchema] - def __init__(self, client: InfrahubClient | InfrahubClientSync): + def __init__(self, client: InfrahubClient | InfrahubClientSync) -> None: self.client = client self.cache = {} diff --git a/infrahub_sdk/task/exceptions.py b/infrahub_sdk/task/exceptions.py index add4e72e..fc8de8e9 100644 --- a/infrahub_sdk/task/exceptions.py +++ b/infrahub_sdk/task/exceptions.py @@ -2,24 +2,24 @@ class TaskError(Exception): - def __init__(self, message: str | None = None): + def __init__(self, message: str | None = None) -> None: self.message = message super().__init__(self.message) class TaskNotFoundError(TaskError): - def __init__(self, id: str): + def __init__(self, id: str) -> None: self.message = f"Task with id {id} not found" super().__init__(self.message) class TooManyTasksError(TaskError): - def __init__(self, expected_id: str, received_ids: list[str]): + def __init__(self, expected_id: str, received_ids: list[str]) -> None: self.message = f"Expected 1 task with id {expected_id}, but got {len(received_ids)}" super().__init__(self.message) class TaskNotCompletedError(TaskError): - def __init__(self, id: str, message: str | None = None): + def __init__(self, id: str, message: str | None = None) -> None: self.message = message or f"Task with id {id} is not completed" super().__init__(self.message) diff --git a/infrahub_sdk/task/manager.py b/infrahub_sdk/task/manager.py index 910030dd..d50ff05d 100644 --- a/infrahub_sdk/task/manager.py +++ b/infrahub_sdk/task/manager.py @@ -86,7 +86,7 @@ def _generate_count_query(cls, filters: TaskFilter | None = None) -> Query: class InfrahubTaskManager(InfraHubTaskManagerBase): client: InfrahubClient - def __init__(self, client: InfrahubClient): + def __init__(self, client: InfrahubClient) -> None: self.client = client async def count(self, filters: TaskFilter | None = None) -> int: @@ -321,7 +321,7 @@ async def process_non_batch( class InfrahubTaskManagerSync(InfraHubTaskManagerBase): client: InfrahubClientSync - def __init__(self, client: InfrahubClientSync): + def __init__(self, client: InfrahubClientSync) -> None: self.client = client def count(self, filters: TaskFilter | None = None) -> int: diff --git a/infrahub_sdk/timestamp.py b/infrahub_sdk/timestamp.py index a3da1005..46a728c8 100644 --- a/infrahub_sdk/timestamp.py +++ b/infrahub_sdk/timestamp.py @@ -29,7 +29,7 @@ class SubstractParams(TypedDict): class Timestamp: _obj: ZonedDateTime - def __init__(self, value: str | ZonedDateTime | Timestamp | None = None): + def __init__(self, value: str | ZonedDateTime | Timestamp | None = None) -> None: if value and isinstance(value, ZonedDateTime): self._obj = value elif value and isinstance(value, self.__class__): diff --git a/infrahub_sdk/transfer/exporter/json.py b/infrahub_sdk/transfer/exporter/json.py index 79a813d8..077ee8fa 100644 --- a/infrahub_sdk/transfer/exporter/json.py +++ b/infrahub_sdk/transfer/exporter/json.py @@ -22,7 +22,7 @@ class LineDelimitedJSONExporter(ExporterInterface): - def __init__(self, client: InfrahubClient, console: Console | None = None): + def __init__(self, client: InfrahubClient, console: Console | None = None) -> None: self.client = client self.console = console diff --git a/infrahub_sdk/transfer/importer/json.py b/infrahub_sdk/transfer/importer/json.py index 9803d338..cd3e4508 100644 --- a/infrahub_sdk/transfer/importer/json.py +++ b/infrahub_sdk/transfer/importer/json.py @@ -31,7 +31,7 @@ def __init__( topological_sorter: InfrahubSchemaTopologicalSorter, continue_on_error: bool = False, console: Console | None = None, - ): + ) -> None: self.client = client self.topological_sorter = topological_sorter self.continue_on_error = continue_on_error diff --git a/infrahub_sdk/transforms.py b/infrahub_sdk/transforms.py index f6b31bae..0c07e296 100644 --- a/infrahub_sdk/transforms.py +++ b/infrahub_sdk/transforms.py @@ -27,7 +27,7 @@ def __init__( branch: str = "", root_directory: str = "", server_url: str = "", - ): + ) -> None: super().__init__( client=client, infrahub_node=infrahub_node, diff --git a/pyproject.toml b/pyproject.toml index 37e1a418..e21cb915 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -237,9 +237,7 @@ max-complexity = 17 ################################################################################################## # Review and change the below later # ################################################################################################## - "ANN201", # ANN201 Missing return type annotation for public function "ANN202", # Missing return type annotation for private function - "ANN204", # Missing return type annotation for special method "ANN401", # Dynamically typed expressions (typing.Any) are disallowed ] diff --git a/tests/integration/test_infrahub_client.py b/tests/integration/test_infrahub_client.py index 7b95773b..8c972d0a 100644 --- a/tests/integration/test_infrahub_client.py +++ b/tests/integration/test_infrahub_client.py @@ -187,7 +187,13 @@ async def test_task_query(self, client: InfrahubClient, base_dataset, set_pagina # Query Tasks using Parallel mode tasks_parallel = await client.task.filter(filter=TaskFilter(state=[TaskState.COMPLETED]), parallel=True) assert tasks_parallel - assert len(tasks_parallel) == len(tasks) + task_parallel_ids = [task.id for task in tasks_parallel] + + # Additional tasks might have been completed between the two queries + # validate that we get at least as many tasks as in the first query + # and that all task IDs from the first query are present in the second one + assert len(tasks_parallel) >= len(tasks) + assert set(task_ids).issubset(set(task_parallel_ids)) # Query Tasks by ID tasks_parallel_filtered = await client.task.filter(filter=TaskFilter(ids=task_ids[:2]), parallel=True)