Skip to content

Commit 04bd8aa

Browse files
authored
fix: add certain raw imports to RESERVED_NAMES (googleapis#824)
The current example is 'auth', which is imported directly by both transports and unit tests. This name conflicts with any calculated dependency import whose name happens to be 'auth'. Fix involves adding 'auth' and other direct, raw imports in templates to RESERVED_NAMES.
1 parent 1de2e14 commit 04bd8aa

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

gapic/utils/reserved_names.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,15 @@
2121
# They are explicitly allowed message, module, and field names.
2222
RESERVED_NAMES = frozenset(
2323
itertools.chain(
24+
# We CANNOT make exceptions for keywords.
2425
keyword.kwlist,
26+
# We make SOME exceptions for certain names that collide with builtins.
2527
set(dir(builtins)) - {"filter", "map", "id", "input", "property"},
28+
# This is a hand-maintained list of modules that are directly imported
29+
# in templates, i.e. they are not added as dependencies to any type,
30+
# the raw text is just there in the template.
31+
# More can be added as collisions are discovered.
32+
# See issue #819 for additional info.
33+
{"auth", "credentials", "exceptions", "future", "options", "policy", "math"}
2634
)
2735
)

0 commit comments

Comments
 (0)