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

Bump mypy from 0.790 to 0.800 #871

Merged
merged 1 commit into from
Mar 1, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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