Skip to content

Commit 405c658

Browse files
author
Saurabh Kumar
committed
styling with black
1 parent 9482bf9 commit 405c658

File tree

4 files changed

+38
-38
lines changed

4 files changed

+38
-38
lines changed

tests/test_usernames.py

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,24 @@ def test_whitelist():
2020

2121
def test_usernames():
2222
unsafe_words = [
23-
'!',
24-
'#',
25-
'',
26-
'()',
27-
'-',
28-
'-hello',
29-
'.',
30-
'.hello',
31-
'_',
32-
'a@!/',
33-
'fuck',
34-
'hel--lo',
35-
'hel-.lo',
36-
'hel..lo',
37-
'hel__lo',
38-
'hello-',
39-
'hello.',
40-
'sex',
23+
"!",
24+
"#",
25+
"",
26+
"()",
27+
"-",
28+
"-hello",
29+
".",
30+
".hello",
31+
"_",
32+
"a@!/",
33+
"fuck",
34+
"hel--lo",
35+
"hel-.lo",
36+
"hel..lo",
37+
"hel__lo",
38+
"hello-",
39+
"hello.",
40+
"sex",
4141
"\\",
4242
"\\\\",
4343
"--1",
@@ -62,18 +62,17 @@ def test_usernames():
6262
" ",
6363
"𝐓𝐡𝐞",
6464
"⒯⒣⒠",
65-
"Powerلُلُصّبُلُلصّبُررًॣॣhॣॣ冗"
65+
"Powerلُلُصّبُلُلصّبُررًॣॣhॣॣ冗",
6666
]
6767

6868
safe_words = [
69-
'a'
70-
'10101',
71-
'1he-llo',
72-
'_hello',
73-
'he-llo',
74-
'he.llo_',
75-
'hello',
76-
'hello_',
69+
"a" "10101",
70+
"1he-llo",
71+
"_hello",
72+
"he-llo",
73+
"he.llo_",
74+
"hello",
75+
"hello_",
7776
"999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999",
7877
]
7978

usernames/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# -*- coding: utf-8 -*-
22
from .validators import is_safe_username
33

4-
__all__ = ['is_safe_username']
4+
__all__ = ["is_safe_username"]

usernames/reserved_words.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import unicode_literals
3-
'''
3+
4+
"""
45
List of reserved usernames (pre-defined list of special banned and reserved keywords in names,
56
such as "root", "www", "admin"). Useful when creating public systems, where users can choose
67
a login name or a sub-domain name.
78
__References:__
89
1. http://www.bannedwordlist.com/
910
2. http://blog.postbit.com/reserved-username-list.html
1011
3. https://ldpreload.com/blog/names-to-reserve
11-
'''
12+
"""
1213

1314
_d = """
1415
about
@@ -455,4 +456,5 @@
455456
def get_reserved_wordlist():
456457
return set(_d.splitlines())
457458

458-
__all__ = ['get_reserved_wordlist']
459+
460+
__all__ = ["get_reserved_wordlist"]

usernames/validators.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,22 @@
66
from .reserved_words import get_reserved_wordlist
77

88

9-
username_regex = re.compile(r"""
9+
username_regex = re.compile(
10+
r"""
1011
^ # beginning of string
1112
(?!_$) # no only _
1213
(?![-.]) # no - or . at the beginning
1314
(?!.*[_.-]{2}) # no __ or _. or ._ or .. or -- inside
1415
[a-zA-Z0-9_.-]+ # allowed characters, atleast one must be present
1516
(?<![.-]) # no - or . at the end
1617
$ # end of string
17-
""", re.X)
18+
""",
19+
re.X,
20+
)
1821

1922

2023
def is_safe_username(
21-
username,
22-
whitelist=[],
23-
blacklist=[],
24-
regex=username_regex,
25-
max_length=None
24+
username, whitelist=[], blacklist=[], regex=username_regex, max_length=None
2625
):
2726
if max_length and len(username) > max_length:
2827
return False

0 commit comments

Comments
 (0)