fix: types for sessions

This commit is contained in:
Mose Mueller 2024-12-17 07:19:57 +01:00
parent 9b2c26dc42
commit bdeb62e595

View File

@ -1,12 +1,19 @@
class OptionalDependencyError(Exception):
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from .influxdb_session import InfluxDBSession # type: ignore
from .influxdbv1_session import InfluxDBv1Session # type: ignore
from .postgres_session import PostgresDatabaseSession # type: ignore
else:
class OptionalDependencyError(Exception):
"""Exception raised when an optional dependency is not installed."""
try:
try:
import influxdb_client # type: ignore # noqa
from .influxdb_session import InfluxDBSession # type: ignore
except ImportError:
except ImportError:
class InfluxDBSession: # type: ignore
def __init__(self) -> None:
@ -15,12 +22,11 @@ except ImportError:
"Please refer to https://gitlab.phys.ethz.ch/tiqi-projects/qchub/icon-services/pydase_service_base."
)
try:
import influxdb # noqa
try:
import influxdb # type: ignore # noqa
from .influxdbv1_session import InfluxDBv1Session # type: ignore
except ImportError:
except ImportError:
class InfluxDBv1Session: # type: ignore
def __init__(self) -> None:
@ -29,12 +35,11 @@ except ImportError:
"Please refer to https://gitlab.phys.ethz.ch/tiqi-projects/qchub/icon-services/pydase_service_base."
)
try:
try:
import sqlmodel # noqa
from .postgres_session import PostgresDatabaseSession # type: ignore
except ImportError:
except ImportError:
class PostgresDatabaseSession: # type: ignore
def __init__(self) -> None: