Skip to content

Commit 01cec5e

Browse files
authored
Removed datastructure from default variable
Based on feedback in comments and what I read in [this Python-guide article](http://docs.python-guide.org/en/latest/writing/gotchas/#mutable-default-arguments), I removed the datastructure from a default parameter
1 parent 3c68438 commit 01cec5e

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

sendgrid/helpers/mail/validators.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class ValidateAPIKey(object):
77

88
regexes = None
99

10-
def __init__(self, regex_strings=list(), use_default=True):
10+
def __init__(self, regex_strings=None, use_default=True):
1111
"""Constructor
1212
Args:
1313
regex_strings (list<str>): list of regex strings
@@ -18,8 +18,9 @@ def __init__(self, regex_strings=list(), use_default=True):
1818
self.regexes = set()
1919

2020
#Compile the regex strings into patterns, add them to our set
21-
for regex_string in regex_strings:
22-
self.regexes.add(re.compile(regex_string))
21+
if regex_strings is not None:
22+
for regex_string in regex_strings:
23+
self.regexes.add(re.compile(regex_string))
2324

2425
if use_default:
2526
default_regex_string = 'SG\.[0-9a-zA-Z]+\.[0-9a-zA-Z]+'

0 commit comments

Comments
 (0)