Skip to content

Commit d2599ec

Browse files
committed
Fix typehints and remove type ignores for ctl.importer & exporter
This change also highlighted an issue as we were still running aiorun to get the client.
1 parent 43879f6 commit d2599ec

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

infrahub_sdk/ctl/exporter.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from .parameters import CONFIG_PARAM
1414

1515

16-
def directory_name_with_timestamp():
16+
def directory_name_with_timestamp() -> str:
1717
right_now = datetime.now(timezone.utc).astimezone()
1818
timestamp = right_now.strftime("%Y%m%d-%H%M%S")
1919
return f"infrahubexport-{timestamp}"
@@ -39,9 +39,10 @@ def dump(
3939
"""Export nodes and their relationships out of the database."""
4040
console = Console()
4141

42-
client = aiorun(
43-
initialize_client(branch=branch, timeout=timeout, max_concurrent_execution=concurrent, retry_on_failure=True)
42+
client = initialize_client(
43+
branch=branch, timeout=timeout, max_concurrent_execution=concurrent, retry_on_failure=True
4444
)
45+
4546
exporter = LineDelimitedJSONExporter(client, console=Console() if not quiet else None)
4647
try:
4748
aiorun(exporter.export(export_directory=directory, namespaces=namespace, branch=branch, exclude=exclude))

infrahub_sdk/ctl/importer.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from .parameters import CONFIG_PARAM
1313

1414

15-
def local_directory():
15+
def local_directory() -> Path:
1616
# We use a function here to avoid failure when generating the documentation due to directory name
1717
return Path().resolve()
1818

@@ -35,9 +35,10 @@ def load(
3535
"""Import nodes and their relationships into the database."""
3636
console = Console()
3737

38-
client = aiorun(
39-
initialize_client(branch=branch, timeout=timeout, max_concurrent_execution=concurrent, retry_on_failure=True)
38+
client = initialize_client(
39+
branch=branch, timeout=timeout, max_concurrent_execution=concurrent, retry_on_failure=True
4040
)
41+
4142
importer = LineDelimitedJSONImporter(
4243
client,
4344
InfrahubSchemaTopologicalSorter(),

pyproject.toml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,18 +159,10 @@ ignore_errors = true
159159
module = "infrahub_sdk.ctl.cli_commands"
160160
ignore_errors = true
161161

162-
[[tool.mypy.overrides]]
163-
module = "infrahub_sdk.ctl.exporter"
164-
ignore_errors = true
165-
166162
[[tool.mypy.overrides]]
167163
module = "infrahub_sdk.ctl.generator"
168164
ignore_errors = true
169165

170-
[[tool.mypy.overrides]]
171-
module = "infrahub_sdk.ctl.importer"
172-
ignore_errors = true
173-
174166
[[tool.mypy.overrides]]
175167
module = "infrahub_sdk.ctl.schema"
176168
ignore_errors = true

0 commit comments

Comments
 (0)