Refactored mutable default values.

Signed-off-by: yukihira1992 <ykhr0130@gmail.com>
This commit is contained in:
yukihira1992 2020-01-14 20:13:10 +09:00 committed by Ulysses Souza
parent a2cdffeeee
commit 53d00f7677
3 changed files with 8 additions and 5 deletions

View File

@ -40,7 +40,8 @@ SILENT_COMMANDS = {
}
def project_from_options(project_dir, options, additional_options={}):
def project_from_options(project_dir, options, additional_options=None):
additional_options = additional_options or {}
override_dir = options.get('--project-directory')
environment_file = options.get('--env-file')
environment = Environment.from_env_file(override_dir or project_dir, environment_file)
@ -81,7 +82,8 @@ def set_parallel_limit(environment):
parallel.GlobalLimit.set_global_limit(parallel_limit)
def get_config_from_options(base_dir, options, additional_options={}):
def get_config_from_options(base_dir, options, additional_options=None):
additional_options = additional_options or {}
override_dir = options.get('--project-directory')
environment_file = options.get('--env-file')
environment = Environment.from_env_file(override_dir or base_dir, environment_file)

View File

@ -87,10 +87,11 @@ class Project(object):
return labels
@classmethod
def from_config(cls, name, config_data, client, default_platform=None, extra_labels=[]):
def from_config(cls, name, config_data, client, default_platform=None, extra_labels=None):
"""
Construct a Project from a config.Config object.
"""
extra_labels = extra_labels or []
use_networking = (config_data.version and config_data.version != V1)
networks = build_networks(name, config_data, client)
project_networks = ProjectNetworks.from_services(

View File

@ -185,7 +185,7 @@ class Service(object):
scale=1,
pid_mode=None,
default_platform=None,
extra_labels=[],
extra_labels=None,
**options
):
self.name = name
@ -201,7 +201,7 @@ class Service(object):
self.scale_num = scale
self.default_platform = default_platform
self.options = options
self.extra_labels = extra_labels
self.extra_labels = extra_labels or []
def __repr__(self):
return '<Service: {}>'.format(self.name)