django / channels

Developer-friendly asynchrony for Django

Home Page:https://channels.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A little violations of DRY

Incred opened this issue · comments

invalid_name_error variable never used:

channels/channels/layers.py

Lines 142 to 145 in 6af1bc3

invalid_name_error = (
"{} name must be a valid unicode string containing only ASCII "
+ "alphanumerics, hyphens, underscores, or periods."
)

But it supposed to be used here?

channels/channels/layers.py

Lines 156 to 159 in 6af1bc3

raise TypeError(
"Channel name must be a valid unicode string containing only ASCII "
+ "alphanumerics, hyphens, or periods, not '{}'.".format(name)
)

So that TypeError shows that we can't use underscores, but we actually can (according regexps above).
Actually we can reuse that variable here (since both regexps almost identical) just using different prefixes in error message ("Channel" and "Group")

channels/channels/layers.py

Lines 165 to 168 in 6af1bc3

raise TypeError(
"Group name must be a valid unicode string containing only ASCII "
+ "alphanumerics, hyphens, or periods."
)