Skip to content
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

Chore: Only import submodules at type checking level #553

Merged
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
41 changes: 24 additions & 17 deletions airbyte/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,23 +123,8 @@

from __future__ import annotations

from airbyte import (
caches,
callbacks,
# cli, # Causes circular import if included
cloud,
constants,
datasets,
destinations,
documents,
exceptions, # noqa: ICN001 # No 'exc' alias for top-level module
experimental,
logs,
records,
results,
secrets,
sources,
)
from typing import TYPE_CHECKING

from airbyte.caches.bigquery import BigQueryCache
from airbyte.caches.duckdb import DuckDBCache
from airbyte.caches.util import get_colab_cache, get_default_cache, new_local_cache
Expand All @@ -155,6 +140,28 @@
from airbyte.sources.util import get_source


# Submodules imported here for documentation reasons: https://github.com/mitmproxy/pdoc/issues/757
if TYPE_CHECKING:
# ruff: noqa: TCH004 # imports used for more than type checking
from airbyte import (
caches,
callbacks,
# cli, # Causes circular import if included
cloud,
constants,
datasets,
destinations,
documents,
exceptions, # noqa: ICN001 # No 'exc' alias for top-level module
experimental,
logs,
records,
results,
secrets,
sources,
)


__all__ = [
# Modules
"caches",
Expand Down
8 changes: 7 additions & 1 deletion airbyte/caches/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

from __future__ import annotations

from airbyte.caches import base, bigquery, duckdb, motherduck, postgres, snowflake, util
from typing import TYPE_CHECKING

from airbyte.caches.base import CacheBase
from airbyte.caches.bigquery import BigQueryCache
from airbyte.caches.duckdb import DuckDBCache
Expand All @@ -13,6 +14,11 @@
from airbyte.caches.util import get_default_cache, new_local_cache


# Submodules imported here for documentation reasons: https://github.com/mitmproxy/pdoc/issues/757
if TYPE_CHECKING:
# ruff: noqa: TCH004
from airbyte.caches import base, bigquery, duckdb, motherduck, postgres, snowflake, util

# We export these classes for easy access: `airbyte.caches...`
__all__ = [
# Factories
Expand Down
9 changes: 8 additions & 1 deletion airbyte/cloud/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,20 @@

from __future__ import annotations

from airbyte.cloud import connections, constants, sync_results, workspaces
from typing import TYPE_CHECKING

from airbyte.cloud.connections import CloudConnection
from airbyte.cloud.constants import JobStatusEnum
from airbyte.cloud.sync_results import SyncResult
from airbyte.cloud.workspaces import CloudWorkspace


# Submodules imported here for documentation reasons: https://github.com/mitmproxy/pdoc/issues/757
if TYPE_CHECKING:
# ruff: noqa: TCH004
from airbyte.cloud import connections, constants, sync_results, workspaces


__all__ = [
# Submodules
"workspaces",
Expand Down
9 changes: 8 additions & 1 deletion airbyte/destinations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,21 @@

from __future__ import annotations

from airbyte.destinations import util
from typing import TYPE_CHECKING

from airbyte.destinations.base import Destination
from airbyte.destinations.util import (
get_destination,
get_noop_destination,
)


# Submodules imported here for documentation reasons: https://github.com/mitmproxy/pdoc/issues/757
if TYPE_CHECKING:
# ruff: noqa: TCH004 # imports used for more than type checking
from airbyte.destinations import util


__all__ = [
# Modules
"util",
Expand Down
27 changes: 17 additions & 10 deletions airbyte/secrets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,8 @@

from __future__ import annotations

from airbyte.secrets import (
base,
config,
custom,
env_vars,
google_colab,
google_gsm,
prompt,
util,
)
from typing import TYPE_CHECKING

from airbyte.secrets.base import SecretHandle, SecretManager, SecretSourceEnum, SecretString
from airbyte.secrets.config import disable_secret_source, register_secret_manager
from airbyte.secrets.custom import CustomSecretManager
Expand All @@ -84,6 +76,21 @@
from airbyte.secrets.util import get_secret


# Submodules imported here for documentation reasons: https://github.com/mitmproxy/pdoc/issues/757
if TYPE_CHECKING:
# ruff: noqa: TCH004 # imports used for more than type checking
from airbyte.secrets import (
base,
config,
custom,
env_vars,
google_colab,
google_gsm,
prompt,
util,
)


__all__ = [
# Submodules
"base",
Expand Down
11 changes: 10 additions & 1 deletion airbyte/sources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

from __future__ import annotations

from airbyte.sources import base, util
from typing import TYPE_CHECKING

from airbyte.sources.base import Source
from airbyte.sources.registry import (
ConnectorMetadata,
Expand All @@ -16,6 +17,14 @@
)


# Submodules imported here for documentation reasons: https://github.com/mitmproxy/pdoc/issues/757
if TYPE_CHECKING:
# ruff: noqa: TCH004 # imports used for more than type checking
from airbyte.sources import (
base,
util,
)

__all__ = [
# Submodules
"base",
Expand Down
6 changes: 5 additions & 1 deletion tests/integration_tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@ def test_install_failure_log_pypi():
)

# Check that the stderr log contains the expected content from a failed pip install
assert "Could not install requirement" in str(exc_info.value.__cause__.log_text)
err_msg = str(exc_info.value.__cause__.log_text)
assert any([
"Cannot unpack file" in err_msg,
"Could not install requirement" in err_msg,
])
Loading