Description
With --incompatible_string_join_requires_strings=false
, this code was previously accepted by Bazel:
>> ",".join(["a", 1, None, (2, 3)])
..
"a,1,None,(2, 3)"
However the argument of string.join
should an iterable of strings. Bazel used to implicitly convert each item to a string (https://github.com/bazelbuild/starlark/blob/master/spec.md#stringjoin).
Since Bazel 0.27, this is an error and the flag --incompatible_string_join_requires_strings
is set to true. If your code relies on the old behavior, do instead an explicit conversion to string with str
:
- ", ".join(my_list)
+ ", ".join([str(e) for e in my_list])
A temporary workaround is to use --incompatible_string_join_requires_strings=false
. This flag will be removed in the future.
Error message
If you see an error message similar to this (with a call to string.join in the stack trace), your code is likely affected by this change:
" ".join(([python_bin, ctx.path(ctx.attr....))
sequence element must be a string (got 'path'). See https://github.com/bazelbuild/bazel/issues/7802 for information about --incompatible_string_join_requires_strings.