Skip to content
Draft
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
6 changes: 4 additions & 2 deletions infrahub_sdk/async_typer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

import asyncio
import inspect
from collections.abc import Callable
from functools import partial, wraps
from typing import Any
from typing import TYPE_CHECKING, Any

from typer import Typer

if TYPE_CHECKING:
from collections.abc import Callable


class AsyncTyper(Typer):
@staticmethod
Expand Down
3 changes: 2 additions & 1 deletion infrahub_sdk/batch.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from __future__ import annotations

import asyncio
from collections.abc import AsyncGenerator, Awaitable, Callable, Generator
from concurrent.futures import ThreadPoolExecutor
from dataclasses import dataclass
from typing import TYPE_CHECKING, Any

if TYPE_CHECKING:
from collections.abc import AsyncGenerator, Awaitable, Callable, Generator

from .node import InfrahubNode, InfrahubNodeSync


Expand Down
4 changes: 2 additions & 2 deletions infrahub_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import logging
import time
import warnings
from collections.abc import Callable, Coroutine, Mapping, MutableMapping
from datetime import datetime
from functools import wraps
from time import sleep
from typing import (
Expand Down Expand Up @@ -61,6 +59,8 @@
from .utils import decode_json, get_user_permissions, is_valid_uuid

if TYPE_CHECKING:
from collections.abc import Callable, Coroutine, Mapping, MutableMapping
from datetime import datetime
from types import TracebackType

from httpx._transports.base import AsyncBaseTransport, BaseTransport
Expand Down
3 changes: 2 additions & 1 deletion infrahub_sdk/ctl/cli_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import logging
import platform
import sys
from collections.abc import Callable
from pathlib import Path
from typing import TYPE_CHECKING, Any

Expand Down Expand Up @@ -56,6 +55,8 @@
from .parameters import CONFIG_PARAM

if TYPE_CHECKING:
from collections.abc import Callable

from ..schema.repository import InfrahubRepositoryConfig

app = AsyncTyper(pretty_exceptions_show_locals=False)
Expand Down
5 changes: 4 additions & 1 deletion infrahub_sdk/ctl/graphql.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from __future__ import annotations

import ast
from collections import defaultdict
from pathlib import Path
from typing import TYPE_CHECKING

import typer
from ariadne_codegen.client_generators.package import PackageGenerator, get_package_generator
Expand Down Expand Up @@ -30,6 +30,9 @@
)
from .parameters import CONFIG_PARAM

if TYPE_CHECKING:
import ast

app = AsyncTyper()
console = Console()

Expand Down
2 changes: 1 addition & 1 deletion infrahub_sdk/ctl/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import asyncio
import time
from pathlib import Path
from pathlib import Path # noqa: TC003
from typing import TYPE_CHECKING, Any

import typer
Expand Down
3 changes: 2 additions & 1 deletion infrahub_sdk/ctl/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import inspect
import logging
import traceback
from collections.abc import Callable, Coroutine
from functools import wraps
from pathlib import Path
from typing import TYPE_CHECKING, Any, NoReturn, TypeVar
Expand Down Expand Up @@ -32,6 +31,8 @@
from .exceptions import QueryNotFoundError

if TYPE_CHECKING:
from collections.abc import Callable, Coroutine

from ..schema.repository import InfrahubRepositoryConfig
from ..spec.object import ObjectFile

Expand Down
6 changes: 4 additions & 2 deletions infrahub_sdk/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from __future__ import annotations

from collections.abc import Mapping
from typing import Any
from typing import TYPE_CHECKING, Any

if TYPE_CHECKING:
from collections.abc import Mapping


class Error(Exception):
Expand Down
3 changes: 2 additions & 1 deletion infrahub_sdk/node/attribute.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import ipaddress
from collections.abc import Callable
from typing import TYPE_CHECKING, Any, get_args

from ..protocols_base import CoreNodeBase
Expand All @@ -10,6 +9,8 @@
from .property import NodeProperty

if TYPE_CHECKING:
from collections.abc import Callable

from ..schema import AttributeSchemaAPI


Expand Down
3 changes: 2 additions & 1 deletion infrahub_sdk/node/node.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

from collections.abc import Iterable
from copy import copy, deepcopy
from typing import TYPE_CHECKING, Any

Expand Down Expand Up @@ -28,6 +27,8 @@
from .relationship import RelationshipManager, RelationshipManagerBase, RelationshipManagerSync

if TYPE_CHECKING:
from collections.abc import Iterable

from typing_extensions import Self

from ..client import InfrahubClient, InfrahubClientSync
Expand Down
3 changes: 2 additions & 1 deletion infrahub_sdk/node/relationship.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

from collections import defaultdict
from collections.abc import Iterable
from typing import TYPE_CHECKING, Any

from ..exceptions import (
Expand All @@ -14,6 +13,8 @@
from .related_node import RelatedNode, RelatedNodeSync

if TYPE_CHECKING:
from collections.abc import Iterable

from ..client import InfrahubClient, InfrahubClientSync
from ..schema import RelationshipSchemaAPI
from .node import InfrahubNode, InfrahubNodeSync
Expand Down
5 changes: 4 additions & 1 deletion infrahub_sdk/protocols_generator/generator.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from collections.abc import Mapping
from pathlib import Path
from typing import TYPE_CHECKING

import jinja2

Expand All @@ -19,6 +19,9 @@
)
from .constants import ATTRIBUTE_KIND_MAP, CORE_BASE_CLASS_TO_SYNCIFY, TEMPLATE_FILE_NAME

if TYPE_CHECKING:
from collections.abc import Mapping


def load_template() -> str:
path = Path(__file__).parent / TEMPLATE_FILE_NAME
Expand Down
6 changes: 4 additions & 2 deletions infrahub_sdk/pytest_plugin/loader.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from __future__ import annotations

import contextlib
from collections.abc import Iterable
from typing import Any
from typing import TYPE_CHECKING, Any

import pytest
import yaml
Expand All @@ -25,6 +24,9 @@
)
from .models import InfrahubTestFileV1, InfrahubTestGroup

if TYPE_CHECKING:
from collections.abc import Iterable

MARKER_MAPPING = {
"Check": pytest.mark.infrahub_check,
"GraphQLQuery": pytest.mark.infrahub_graphql_query,
Expand Down
3 changes: 2 additions & 1 deletion infrahub_sdk/query_groups.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from __future__ import annotations

from collections.abc import Sequence
from typing import TYPE_CHECKING, Any

from .constants import InfrahubClientMode
from .exceptions import NodeNotFoundError
from .utils import dict_hash

if TYPE_CHECKING:
from collections.abc import Sequence

from .client import InfrahubClient, InfrahubClientSync
from .node import InfrahubNode, InfrahubNodeSync, RelatedNodeBase
from .schema import MainSchemaTypesAPI
Expand Down
3 changes: 2 additions & 1 deletion infrahub_sdk/schema/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import inspect
import json
import warnings
from collections.abc import MutableMapping
from enum import Enum
from time import sleep
from typing import TYPE_CHECKING, Any, TypeAlias, TypedDict
Expand Down Expand Up @@ -42,6 +41,8 @@
)

if TYPE_CHECKING:
from collections.abc import MutableMapping

from ..client import InfrahubClient, InfrahubClientSync, SchemaType, SchemaTypeSync
from ..node import InfrahubNode, InfrahubNodeSync

Expand Down
2 changes: 1 addition & 1 deletion infrahub_sdk/schema/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import warnings
from collections.abc import MutableMapping
from collections.abc import MutableMapping # noqa: TC003 - Required at runtime for Pydantic field validation
from enum import Enum
from typing import TYPE_CHECKING, Any

Expand Down
2 changes: 1 addition & 1 deletion infrahub_sdk/task/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from datetime import datetime
from datetime import datetime # noqa: TC003 - Required at runtime for Pydantic field validation
from enum import Enum

from pydantic import BaseModel, Field
Expand Down
6 changes: 4 additions & 2 deletions infrahub_sdk/template/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from __future__ import annotations

import linecache
from collections.abc import Callable
from pathlib import Path
from typing import Any, NoReturn
from typing import TYPE_CHECKING, Any, NoReturn

import jinja2
from jinja2 import meta, nodes
Expand All @@ -22,6 +21,9 @@
from .filters import AVAILABLE_FILTERS
from .models import UndefinedJinja2Error

if TYPE_CHECKING:
from collections.abc import Callable

netutils_filters = jinja2_convenience_function()


Expand Down
6 changes: 4 additions & 2 deletions infrahub_sdk/topological_sort.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from __future__ import annotations

from collections.abc import Iterable, Mapping, Sequence
from itertools import chain
from typing import Any
from typing import TYPE_CHECKING, Any

if TYPE_CHECKING:
from collections.abc import Iterable, Mapping, Sequence


class DependencyCycleExistsError(Exception):
Expand Down
5 changes: 4 additions & 1 deletion infrahub_sdk/transfer/exporter/interface.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from __future__ import annotations

from abc import ABC, abstractmethod
from pathlib import Path
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from pathlib import Path


class ExporterInterface(ABC):
Expand Down
5 changes: 3 additions & 2 deletions infrahub_sdk/transfer/exporter/json.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from __future__ import annotations

from collections.abc import Generator
from contextlib import contextmanager
from pathlib import Path
from typing import TYPE_CHECKING, Any

import ujson
Expand All @@ -15,6 +13,9 @@
from .interface import ExporterInterface

if TYPE_CHECKING:
from collections.abc import Generator
from pathlib import Path

from rich.console import Console

from ...client import InfrahubClient
Expand Down
5 changes: 3 additions & 2 deletions infrahub_sdk/transfer/importer/json.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from __future__ import annotations

from collections import defaultdict
from collections.abc import Generator, Mapping, Sequence
from contextlib import contextmanager
from pathlib import Path
from typing import TYPE_CHECKING, Any

import pyarrow.json as pa_json
Expand All @@ -16,6 +14,9 @@
from .interface import ImporterInterface

if TYPE_CHECKING:
from collections.abc import Generator, Mapping, Sequence
from pathlib import Path

from rich.console import Console

from ...batch import InfrahubBatch
Expand Down
3 changes: 2 additions & 1 deletion infrahub_sdk/transfer/schema_sorter.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from __future__ import annotations

from collections.abc import Sequence
from typing import TYPE_CHECKING

from ..topological_sort import DependencyCycleExistsError, topological_sort
from .exceptions import SchemaImportError

if TYPE_CHECKING:
from collections.abc import Sequence

from ..schema import NodeSchema


Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ ignore = [
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes
"S701", # By default, jinja2 sets `autoescape` to `False`. Consider using `autoescape=True`
"SIM108", # Use ternary operator `key_str = f"{value[ALIAS_KEY]}: {key}" if ALIAS_KEY in value and value[ALIAS_KEY] else key` instead of `if`-`else`-block
"TC003", # Move standard library import `collections.abc.Iterable` into a type-checking block
"UP031", # Use format specifiers instead of percent format
]

Expand Down
8 changes: 5 additions & 3 deletions tests/integration/test_infrahub_client.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from __future__ import annotations

from collections.abc import AsyncGenerator
from pathlib import Path
from typing import Any
from typing import TYPE_CHECKING, Any

import pytest

Expand All @@ -19,6 +17,10 @@
from infrahub_sdk.testing.schemas.animal import TESTING_ANIMAL, TESTING_CAT, TESTING_DOG, TESTING_PERSON, SchemaAnimal
from infrahub_sdk.types import Order

if TYPE_CHECKING:
from collections.abc import AsyncGenerator
from pathlib import Path


class TestInfrahubNode(TestInfrahubDockerClient, SchemaAnimal):
@pytest.fixture(scope="class")
Expand Down
Loading
Loading