Skip to content

Commit

Permalink
Reused invalid_name_error variable when raising error. (#1792)
Browse files Browse the repository at this point in the history
Fixed #1791
  • Loading branch information
Incred committed Jul 6, 2022
1 parent 6f20a7b commit 03acbcd
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions channels/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,19 +153,13 @@ def valid_channel_name(self, name, receive=False):
"Specific channel names in receive() must end at the !"
)
return True
raise TypeError(
"Channel name must be a valid unicode string containing only ASCII "
+ "alphanumerics, hyphens, or periods, not '{}'.".format(name)
)
raise TypeError(self.invalid_name_error("Channel"))

def valid_group_name(self, name):
if self.match_type_and_length(name):
if bool(self.group_name_regex.match(name)):
return True
raise TypeError(
"Group name must be a valid unicode string containing only ASCII "
+ "alphanumerics, hyphens, or periods."
)
raise TypeError(self.invalid_name_error("Group"))

def valid_channel_names(self, names, receive=False):
_non_empty_list = True if names else False
Expand Down

0 comments on commit 03acbcd

Please sign in to comment.