Skip to content

Fix typehints and remove type ignores for ctl.importer & ctl.exporter #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 17, 2024
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
7 changes: 4 additions & 3 deletions infrahub_sdk/ctl/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from .parameters import CONFIG_PARAM


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

client = aiorun(
initialize_client(branch=branch, timeout=timeout, max_concurrent_execution=concurrent, retry_on_failure=True)
client = initialize_client(

Check warning on line 42 in infrahub_sdk/ctl/exporter.py

View check run for this annotation

Codecov / codecov/patch

infrahub_sdk/ctl/exporter.py#L42

Added line #L42 was not covered by tests
branch=branch, timeout=timeout, max_concurrent_execution=concurrent, retry_on_failure=True
)

exporter = LineDelimitedJSONExporter(client, console=Console() if not quiet else None)
try:
aiorun(exporter.export(export_directory=directory, namespaces=namespace, branch=branch, exclude=exclude))
Expand Down
7 changes: 4 additions & 3 deletions infrahub_sdk/ctl/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from .parameters import CONFIG_PARAM


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

Expand All @@ -35,9 +35,10 @@
"""Import nodes and their relationships into the database."""
console = Console()

client = aiorun(
initialize_client(branch=branch, timeout=timeout, max_concurrent_execution=concurrent, retry_on_failure=True)
client = initialize_client(

Check warning on line 38 in infrahub_sdk/ctl/importer.py

View check run for this annotation

Codecov / codecov/patch

infrahub_sdk/ctl/importer.py#L38

Added line #L38 was not covered by tests
branch=branch, timeout=timeout, max_concurrent_execution=concurrent, retry_on_failure=True
)

importer = LineDelimitedJSONImporter(
client,
InfrahubSchemaTopologicalSorter(),
Expand Down
8 changes: 0 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -159,18 +159,10 @@ ignore_errors = true
module = "infrahub_sdk.ctl.cli_commands"
ignore_errors = true

[[tool.mypy.overrides]]
module = "infrahub_sdk.ctl.exporter"
ignore_errors = true

[[tool.mypy.overrides]]
module = "infrahub_sdk.ctl.generator"
ignore_errors = true

[[tool.mypy.overrides]]
module = "infrahub_sdk.ctl.importer"
ignore_errors = true

[[tool.mypy.overrides]]
module = "infrahub_sdk.ctl.schema"
ignore_errors = true
Expand Down