aboutsummaryrefslogtreecommitdiff
path: root/lib/structs.bzl
diff options
context:
space:
mode:
authorAlexandre Rostovtsev <arostovtsev@google.com>2021-05-03 12:27:40 -0400
committerGitHub <noreply@github.com>2021-05-03 12:27:40 -0400
commit7b859037a673db6f606661323e74c5d4751595e6 (patch)
treed6e6729705001521ee89a6fbeafc07fc36fe2c12 /lib/structs.bzl
parent398f3122891b9b711f5aab1adc7597d9fce09085 (diff)
downloadbazel-skylib-7b859037a673db6f606661323e74c5d4751595e6.tar.gz
to_json/to_proto methods on structs are deprecated and will be removed (#295)
Diffstat (limited to 'lib/structs.bzl')
-rw-r--r--lib/structs.bzl12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/structs.bzl b/lib/structs.bzl
index f291152..78066ad 100644
--- a/lib/structs.bzl
+++ b/lib/structs.bzl
@@ -25,10 +25,14 @@ def _to_dict(s):
transformation is only applied to the struct's fields and not to any
nested values.
"""
- attributes = dir(s)
- attributes.remove("to_json")
- attributes.remove("to_proto")
- return {key: getattr(s, key) for key in attributes}
+
+ # to_json()/to_proto() are disabled by --incompatible_struct_has_no_methods
+ # and will be removed entirely in a future Bazel release.
+ return {
+ key: getattr(s, key)
+ for key in dir(s)
+ if key != "to_json" and key != "to_proto"
+ }
structs = struct(
to_dict = _to_dict,