Skip to content

Commit e772035

Browse files
committed
CHORE
1 parent 10b4a42 commit e772035

File tree

5 files changed

+26
-21
lines changed

5 files changed

+26
-21
lines changed

channels_redis/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,8 @@ async def group_add(self, group: str, channel: str):
494494
Adds the channel name to a group.
495495
"""
496496
# Check the inputs
497-
assert self.valid_group_name(group), True
498-
assert self.valid_channel_name(channel), True
497+
assert self.valid_group_name(group), "Group name not valid"
498+
assert self.valid_channel_name(channel), "Channel name not valid"
499499
# Get a connection to the right shard
500500
group_key = self._group_key(group)
501501
connection = self.connection(self.consistent_hash(group))

channels_redis/pubsub.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def __init__(
3737
] = None,
3838
serializer_format="msgpack",
3939
**kwargs,
40-
):
40+
) -> None:
4141
self._args = args
4242
self._kwargs = kwargs
4343
self._layers: typing.Dict[asyncio.AbstractEventLoop, RedisPubSubLoopLayer] = {}

channels_redis/py.typed

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-

channels_redis/serializers.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,22 @@ def _setup_encryption(
4343
],
4444
):
4545
# See if we can do encryption if they asked
46-
if not symmetric_encryption_keys:
47-
self.crypter = None
48-
return
49-
50-
if isinstance(symmetric_encryption_keys, (str, bytes)):
51-
raise ValueError(
52-
"symmetric_encryption_keys must be a list of possible keys"
53-
)
54-
keys = typing.cast(
55-
typing.Iterable[typing.Union[str, "Buffer"]], symmetric_encryption_keys
56-
)
57-
if _MultiFernet is None:
58-
raise ValueError(
59-
"Cannot run with encryption without 'cryptography' installed."
46+
if symmetric_encryption_keys:
47+
if isinstance(symmetric_encryption_keys, (str, bytes)):
48+
raise ValueError(
49+
"symmetric_encryption_keys must be a list of possible keys"
50+
)
51+
symmetric_encryption_keys = typing.cast(
52+
typing.Iterable[typing.Union[str, "Buffer"]], symmetric_encryption_keys
6053
)
61-
sub_fernets = [self.make_fernet(key) for key in keys]
62-
self.crypter = _MultiFernet(sub_fernets)
54+
if _MultiFernet is None:
55+
raise ValueError(
56+
"Cannot run with encryption without 'cryptography' installed."
57+
)
58+
sub_fernets = [self.make_fernet(key) for key in symmetric_encryption_keys]
59+
self.crypter = _MultiFernet(sub_fernets)
60+
else:
61+
self.crypter = None
6362

6463
def make_fernet(self, key: typing.Union[str, "Buffer"]) -> "Fernet":
6564
"""
@@ -116,7 +115,7 @@ def deserialize(self, message: bytes):
116115

117116

118117
class MissingSerializer(BaseMessageSerializer):
119-
exception: "Exception" = Exception(None)
118+
exception: typing.Optional[Exception] = None
120119

121120
def __init__(self, *args, **kwargs):
122121
raise self.exception

tests/test_core.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,12 @@ def test_repeated_group_send_with_async_to_sync(channel_layer):
419419
pytest.fail(f"repeated async_to_sync wrapped group_send calls raised {exc}")
420420

421421

422+
@pytest.mark.xfail(
423+
reason="""
424+
Fails with error in redis-py: int() argument must be a string, a bytes-like
425+
object or a real number, not 'NoneType'. Refs: #348
426+
"""
427+
)
422428
@pytest.mark.asyncio
423429
async def test_receive_cancel(channel_layer):
424430
"""
@@ -551,6 +557,7 @@ async def test_message_expiry__group_send(channel_layer):
551557
await channel_layer.receive(channel_name)
552558

553559

560+
@pytest.mark.xfail(reason="Fails with timeout. Refs: #348")
554561
@pytest.mark.asyncio
555562
async def test_message_expiry__group_send__one_channel_expires_message(channel_layer):
556563
expiry = 3

0 commit comments

Comments
 (0)