mypy fixed
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
import os
|
import os
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
import structlog
|
import structlog
|
||||||
from python_utils import check_env
|
from python_utils import check_env
|
||||||
|
|
||||||
@@ -11,6 +12,10 @@ from python_repositories.interfaces import (
|
|||||||
ConnectionAwareInterface,
|
ConnectionAwareInterface,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Import for mypy type checking only
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from minio import Minio, S3Error
|
||||||
|
|
||||||
|
|
||||||
class MinioAdapter(
|
class MinioAdapter(
|
||||||
ContextAwareInterface,
|
ContextAwareInterface,
|
||||||
@@ -27,7 +32,7 @@ class MinioAdapter(
|
|||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
# Import here to avoid hard dependency if MinioAdapter is not used
|
# Import here to avoid hard dependency if MinioAdapter is not used
|
||||||
try:
|
try:
|
||||||
from minio import Minio, S3Error # type: ignore[import]
|
from minio import Minio, S3Error
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
raise RuntimeError("MinioAdapter dependencies missing") from e
|
raise RuntimeError("MinioAdapter dependencies missing") from e
|
||||||
# Setup logger
|
# Setup logger
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"""Definition of RedisAdapter class."""
|
"""Definition of RedisAdapter class."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
from typing import cast
|
from typing import cast, TYPE_CHECKING
|
||||||
import os
|
import os
|
||||||
import structlog
|
import structlog
|
||||||
|
|
||||||
@@ -12,6 +12,11 @@ from python_repositories.interfaces import (
|
|||||||
ConnectionAwareInterface,
|
ConnectionAwareInterface,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Import for mypy type checking only
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
import redis
|
||||||
|
from redis.commands.json.path import Path as RedisPath
|
||||||
|
|
||||||
|
|
||||||
class RedisAdapter(
|
class RedisAdapter(
|
||||||
ContextAwareInterface,
|
ContextAwareInterface,
|
||||||
@@ -26,8 +31,8 @@ class RedisAdapter(
|
|||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
# Import here to avoid hard dependency to optional package
|
# Import here to avoid hard dependency to optional package
|
||||||
try:
|
try:
|
||||||
import redis # type: ignore[import]
|
import redis
|
||||||
from redis.commands.json.path import Path as RedisPath # type: ignore[import]
|
from redis.commands.json.path import Path as RedisPath
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
raise RuntimeError("RedisAdapter dependencies missing") from e
|
raise RuntimeError("RedisAdapter dependencies missing") from e
|
||||||
# Setup logger
|
# Setup logger
|
||||||
|
|||||||
Reference in New Issue
Block a user