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