Avoid modifying mutable default value

Rationale: http://effbot.org/zone/default-values.htm

Signed-off-by: Emil Hessman <emil@hessman.se>
This commit is contained in:
Emil Hessman 2018-09-29 18:30:52 +02:00
parent 48a6f2132b
commit 15089886c2
1 changed files with 3 additions and 1 deletions

View File

@ -197,7 +197,9 @@ class Service(object):
def __repr__(self):
return '<Service: {}>'.format(self.name)
def containers(self, stopped=False, one_off=False, filters={}, labels=None):
def containers(self, stopped=False, one_off=False, filters=None, labels=None):
if filters is None:
filters = {}
filters.update({'label': self.labels(one_off=one_off) + (labels or [])})
result = list(filter(None, [