Buck: flatten_dicts()

flatten_dicts()

The flatten_dicts() function is used to merge a list of dicts together. It is useful for sharing a set of defaults across different build rules while allowing for customization. You will probably want to use it in conjunction with include_defs() in order to easily share configurations between your BUCK files.

Arguments

  • The function takes a varargs of dictionaries, with the lowest-priority dictionary first.

Examples

default_config = {
  'a': 'bar',
  'b': false,
}

flatten_dicts(
  default_config,
  dict(a='foo', c=[])
)
# Outputs
# {
#   'a': 'foo',
#   'b': false,
#   'c': [],
# }
Values in dictionaries which appear later in the list have priority over values which appear earlier.