Skip to main content
Version: 1.5.x

dicts

Skylib module containing functions that operate on dictionaries.

Macros and Functions

dicts.add

Returns a new dict that has all the entries of the given dictionaries.

If the same key is present in more than one of the input dictionaries, the last of them in the argument list overrides any earlier ones.

This function is designed to take zero or one arguments as well as multiple dictionaries, so that it follows arithmetic identities and callers can avoid special cases for their inputs: the sum of zero dictionaries is the empty dictionary, and the sum of a single dictionary is a copy of itself.

Example usage (generated):

load("@bazel_skylib//lib:dicts.bzl", "dicts")

dicts.add(
)

dictionaries

Optional.

Zero or more dictionaries to be added.

kwargs

Optional.

Additional dictionary passed as keyword args.

dicts.omit

Returns a new dict that has all the entries of dictionary with keys not in keys.

Example usage (generated):

load("@bazel_skylib//lib:dicts.bzl", "dicts")

dicts.omit(
# A `dict`.
dictionary = None,
# A sequence.
keys = None,
)

dictionary

Required.

A dict.

keys

Required.

A sequence.

dicts.pick

Returns a new dict that has all the entries of dictionary with keys in keys.

Example usage (generated):

load("@bazel_skylib//lib:dicts.bzl", "dicts")

dicts.pick(
# A `dict`.
dictionary = None,
# A sequence.
keys = None,
)

dictionary

Required.

A dict.

keys

Required.

A sequence.