From 7f86d4a34bbd76295b8753ffc2740e43aa228fc2 Mon Sep 17 00:00:00 2001 From: laurentlb Date: Tue, 19 Dec 2017 04:35:01 -0800 Subject: 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 --- site/docs/skylark/skylint.md | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'site/docs/skylark') 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] 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] 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] + + +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 -- cgit v1.2.3