Skip to content

Commit 5b2faa9

Browse files
Merge pull request #11 from eshaan-test-org/deepsource-fix-f85a5791
Fix dangerous default argument
2 parents 2d1f995 + ff558ea commit 5b2faa9

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

demo_code.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ class RandomNumberGenerator:
3737
def limits(self):
3838
return self.limits
3939

40-
def get_number(self, min_max=[1, 10]):
40+
def get_number(self, min_max=None):
4141
"""Get a random number between min and max."""
42+
if min_max is None:
43+
min_max = [1, 10]
4244
assert all([isinstance(i, int) for i in min_max])
4345
return random.randint(*min_max)
4446

@@ -54,7 +56,9 @@ def __getattr__(self, key):
5456
return key
5557

5658

57-
def main(options: dict = {}) -> str:
59+
def main(options: dict = None) -> str:
60+
if options is None:
61+
options = {}
5862
pdb.set_trace()
5963
if "run" in options:
6064
value = options["run"]
@@ -73,7 +77,9 @@ def main(options: dict = {}) -> str:
7377
f.close()
7478

7579

76-
def moon_chooser(moon, moons=["europa", "callisto", "phobos"]):
80+
def moon_chooser(moon, moons=None):
81+
if moons is None:
82+
moons = ["europa", "callisto", "phobos"]
7783
if moon is not None:
7884
moons.append(moon)
7985

0 commit comments

Comments
 (0)