Skip to content

Commit

Permalink
Merge pull request #871 from camptocamp/dependabot/pip/mypy-0.800
Browse files Browse the repository at this point in the history
Bump mypy from 0.790 to 0.800
  • Loading branch information
sbrunner authored Mar 1, 2021
2 parents 5221630 + 48510d4 commit 74faca6
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ astroid = "==2.3.3"
bandit = "==1.7.0"
coverage = "==5.4"
junit2html = "==30.0.4"
mypy = "==0.790"
mypy = "==0.812"
prospector = "==1.2.0"
pycodestyle = "==2.4.0"
pyflakes = "==2.1.1"
Expand Down
38 changes: 23 additions & 15 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions c2cwsgiutils/broadcast/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import time
from typing import Any, Callable, List, Mapping, Optional

import redis
import redis # pylint: disable=unused-import

from c2cwsgiutils.broadcast import interface, local, utils

Expand All @@ -18,7 +18,12 @@ class RedisBroadcaster(interface.BaseBroadcaster):
Implement broadcasting messages using Redis
"""

def __init__(self, broadcast_prefix: str, master: redis.Redis, slave: redis.Redis) -> None:
def __init__(
self,
broadcast_prefix: str,
master: "redis.client.Redis[str]", # pylint: disable=unsubscriptable-object
slave: "redis.client.Redis[str]", # pylint: disable=unsubscriptable-object
) -> None:
from c2cwsgiutils import redis_utils

self._master = master
Expand Down
14 changes: 9 additions & 5 deletions c2cwsgiutils/redis_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,18 @@
REDIS_SERVICENAME_KEY_PROP = "c2c.redis_servicename"
REDIS_DB_KEY_PROP = "c2c.redis_db"

_master: Optional[redis.Redis] = None
_slave: Optional[redis.Redis] = None
_master: Optional["redis.client.Redis[str]"] = None # pylint: disable=unsubscriptable-object
_slave: Optional["redis.client.Redis[str]"] = None # pylint: disable=unsubscriptable-object
_sentinel: Optional[redis.sentinel.Sentinel] = None


def get(
settings: Optional[Mapping[str, Any]] = None,
) -> Tuple[Optional[redis.Redis], Optional[redis.Redis], Optional[redis.sentinel.Sentinel]]:
settings: Optional[Mapping[str, bytes]] = None,
) -> Tuple[
Optional["redis.client.Redis[str]"], # pylint: disable=unsubscriptable-object
Optional["redis.client.Redis[str]"], # pylint: disable=unsubscriptable-object
Optional[redis.sentinel.Sentinel],
]:
if _master is None:
_init(settings)
return _master, _slave, _sentinel
Expand Down Expand Up @@ -82,7 +86,7 @@ def _init(settings: Optional[Mapping[str, Any]]) -> None:
url = "redis://" + url

LOG.info("Redis setup using: %s, with options: %s", url, redis_options_)
_master = redis.Redis.from_url(url, decode_responses=True, **redis_options)
_master = redis.client.Redis.from_url(url, decode_responses=True, **redis_options)
_slave = _master
else:
LOG.info(
Expand Down

0 comments on commit 74faca6

Please sign in to comment.