diff options
author | laurentlb <laurentlb@google.com> | 2017-12-19 04:35:01 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2017-12-19 04:37:06 -0800 |
commit | 7f86d4a34bbd76295b8753ffc2740e43aa228fc2 (patch) | |
tree | 4fe3b6e23b972733f981b7e592c471f50124fe0a /site/docs/skylark | |
parent | 173cae708cc667ef1353b5e65c3b7a62757e5f97 (diff) |
Skylint: Add a warning for the `+` operator on depsets.
In many cases, users do:
d = depset()
d += ...
To catch this issue, we use a heuristic to find which variable is a depset
(in theory, it could be reassigned - but it's unlikely and that would be
error-prone anyway)
RELNOTES: None.
PiperOrigin-RevId: 179536463
Diffstat (limited to 'site/docs/skylark')
-rw-r--r-- | site/docs/skylark/skylint.md | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/site/docs/skylark/skylint.md b/site/docs/skylark/skylint.md index 05ad4dec0f..338da4d1dd 100644 --- a/site/docs/skylark/skylint.md +++ b/site/docs/skylark/skylint.md @@ -5,7 +5,7 @@ title: Skylark Linter Documentation # Skylark Linter Documentation -Style guide: https://docs.bazel.build/versions/master/skylark/bzl-style.html +[Style guide](https://docs.bazel.build/versions/master/skylark/bzl-style.html) This document explains how to use the Skylark linter. @@ -42,9 +42,7 @@ where `/path/to/Skylint` is the path of the binary from the previous section. This section explains which checks the linter performs and how to deal with false positives. -### Deprecations - -#### Deprecating functions (docstring format) [deprecated-symbol] +### Deprecating functions (docstring format) [deprecated-symbol] <a name="deprecated-symbol"></a> To deprecate a function, add a `Deprecated:` section to the docstring, similarly @@ -66,7 +64,7 @@ def bar(): Note that the explanation starts on the next line after `Deprecated:` and may occupy multiple lines, with all lines indented by two spaces. -#### Using the operator + on dictionaries [deprecated-plus-dict] +### Using the operator + on dictionaries [deprecated-plus-dict] <a name="deprecated-plus-dict"></a> The `+` operator (and similarly `+=`) is deprecated for dictionaries. Instead, @@ -80,6 +78,21 @@ load("@bazel_skylib//lib:dicts.bzl", "dicts") dicts.add(d1, d2, d3) # instead of d1 + d2 + d3 ``` +### Using the operator + on depset [deprecated-plus-depset] + +<a name="deprecated-plus-depset"></a> +The `+` operator (and similarly `+=`) is deprecated for depsets. Instead, +use the depset constructor. + +See [documentation on depsets](depsets.md) for background and examples of use. + +``` + d1 = depset(items1) + d2 = depset(items2) + combined = depset(transitive=[d1, d2]) +``` + + ### Docstrings <a name="missing-docstring"></a> |