Skip to content

Commit dfcbc82

Browse files
committed
Move standard library imports into a type-checking block
1 parent f1d6479 commit dfcbc82

File tree

28 files changed

+74
-39
lines changed

28 files changed

+74
-39
lines changed

infrahub_sdk/async_typer.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
import asyncio
44
import inspect
5-
from collections.abc import Callable
65
from functools import partial, wraps
7-
from typing import Any
6+
from typing import TYPE_CHECKING, Any
87

98
from typer import Typer
109

10+
if TYPE_CHECKING:
11+
from collections.abc import Callable
12+
1113

1214
class AsyncTyper(Typer):
1315
@staticmethod

infrahub_sdk/batch.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
from __future__ import annotations
22

33
import asyncio
4-
from collections.abc import AsyncGenerator, Awaitable, Callable, Generator
54
from concurrent.futures import ThreadPoolExecutor
65
from dataclasses import dataclass
76
from typing import TYPE_CHECKING, Any
87

98
if TYPE_CHECKING:
9+
from collections.abc import AsyncGenerator, Awaitable, Callable, Generator
10+
1011
from .node import InfrahubNode, InfrahubNodeSync
1112

1213

infrahub_sdk/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import logging
66
import time
77
import warnings
8-
from collections.abc import Callable, Coroutine, Mapping, MutableMapping
9-
from datetime import datetime
108
from functools import wraps
119
from time import sleep
1210
from typing import (
@@ -61,6 +59,8 @@
6159
from .utils import decode_json, get_user_permissions, is_valid_uuid
6260

6361
if TYPE_CHECKING:
62+
from collections.abc import Callable, Coroutine, Mapping, MutableMapping
63+
from datetime import datetime
6464
from types import TracebackType
6565

6666
from httpx._transports.base import AsyncBaseTransport, BaseTransport

infrahub_sdk/ctl/cli_commands.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import logging
88
import platform
99
import sys
10-
from collections.abc import Callable
1110
from pathlib import Path
1211
from typing import TYPE_CHECKING, Any
1312

@@ -56,6 +55,8 @@
5655
from .parameters import CONFIG_PARAM
5756

5857
if TYPE_CHECKING:
58+
from collections.abc import Callable
59+
5960
from ..schema.repository import InfrahubRepositoryConfig
6061

6162
app = AsyncTyper(pretty_exceptions_show_locals=False)

infrahub_sdk/ctl/graphql.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from __future__ import annotations
22

3-
import ast
43
from collections import defaultdict
54
from pathlib import Path
5+
from typing import TYPE_CHECKING
66

77
import typer
88
from ariadne_codegen.client_generators.package import PackageGenerator, get_package_generator
@@ -30,6 +30,9 @@
3030
)
3131
from .parameters import CONFIG_PARAM
3232

33+
if TYPE_CHECKING:
34+
import ast
35+
3336
app = AsyncTyper()
3437
console = Console()
3538

infrahub_sdk/ctl/schema.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import asyncio
44
import time
5-
from pathlib import Path
65
from typing import TYPE_CHECKING, Any
76

87
import typer
@@ -20,6 +19,8 @@
2019
from .utils import load_yamlfile_from_disk_and_exit
2120

2221
if TYPE_CHECKING:
22+
from pathlib import Path
23+
2324
from .. import InfrahubClient
2425

2526
app = AsyncTyper()

infrahub_sdk/ctl/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import inspect
44
import logging
55
import traceback
6-
from collections.abc import Callable, Coroutine
76
from functools import wraps
87
from pathlib import Path
98
from typing import TYPE_CHECKING, Any, NoReturn, TypeVar
@@ -32,6 +31,8 @@
3231
from .exceptions import QueryNotFoundError
3332

3433
if TYPE_CHECKING:
34+
from collections.abc import Callable, Coroutine
35+
3536
from ..schema.repository import InfrahubRepositoryConfig
3637
from ..spec.object import ObjectFile
3738

infrahub_sdk/exceptions.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
from __future__ import annotations
22

3-
from collections.abc import Mapping
4-
from typing import Any
3+
from typing import TYPE_CHECKING, Any
4+
5+
if TYPE_CHECKING:
6+
from collections.abc import Mapping
57

68

79
class Error(Exception):

infrahub_sdk/node/attribute.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import annotations
22

33
import ipaddress
4-
from collections.abc import Callable
54
from typing import TYPE_CHECKING, Any, get_args
65

76
from ..protocols_base import CoreNodeBase
@@ -10,6 +9,8 @@
109
from .property import NodeProperty
1110

1211
if TYPE_CHECKING:
12+
from collections.abc import Callable
13+
1314
from ..schema import AttributeSchemaAPI
1415

1516

infrahub_sdk/node/node.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from __future__ import annotations
22

3-
from collections.abc import Iterable
43
from copy import copy, deepcopy
54
from typing import TYPE_CHECKING, Any
65

@@ -28,6 +27,8 @@
2827
from .relationship import RelationshipManager, RelationshipManagerBase, RelationshipManagerSync
2928

3029
if TYPE_CHECKING:
30+
from collections.abc import Iterable
31+
3132
from typing_extensions import Self
3233

3334
from ..client import InfrahubClient, InfrahubClientSync

0 commit comments

Comments
 (0)