Skip to content

Commit 3d24a50

Browse files
authored
fix: resolve issue where rest-numeric-enums=False is not supported (#2456)
1 parent 48c5f38 commit 3d24a50

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

gapic/utils/options.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,16 @@ def tweak_path(p):
167167
"TRUE",
168168
)
169169

170+
# `rest-numeric-enums` is False by default. Make sure users can also disable
171+
# it by passing `rest-numeric-enums=False`.
172+
rest_numeric_enums = opts.pop("rest-numeric-enums", ["False"])[0] in (
173+
"True",
174+
"true",
175+
"T",
176+
"t",
177+
"TRUE",
178+
)
179+
170180
# NOTE: Snippets are not currently correct for the alternative (Ads) templates
171181
# so always disable snippetgen in that case
172182
# https://github.com/googleapis/gapic-generator-python/issues/1052
@@ -197,7 +207,7 @@ def tweak_path(p):
197207
# transport should include desired transports delimited by '+', e.g. transport='grpc+rest'
198208
transport=opts.pop("transport", ["grpc"])[0].split("+"),
199209
service_yaml_config=service_yaml_config,
200-
rest_numeric_enums=bool(opts.pop("rest-numeric-enums", False)),
210+
rest_numeric_enums=rest_numeric_enums,
201211
proto_plus_deps=proto_plus_deps,
202212
gapic_version=opts.pop("gapic-version", ["0.0.0"]).pop(),
203213
)

tests/unit/generator/test_options.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@ def test_options_bool_flags():
212212
options = Options.build("autogen-snippets=False")
213213
assert not options.autogen_snippets
214214

215+
options = Options.build("rest-numeric-enums=False")
216+
assert not options.rest_numeric_enums
217+
215218

216219
def test_options_autogen_snippets_false_for_old_naming():
217220
# NOTE: Snippets are not currently correct for the alternative (Ads) templates

0 commit comments

Comments
 (0)