Skip to content

Commit

Permalink
fix: add certain raw imports to RESERVED_NAMES (#824)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
software-dov authored Mar 24, 2021
1 parent 1de2e14 commit 04bd8aa
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions gapic/utils/reserved_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@
# They are explicitly allowed message, module, and field names.
RESERVED_NAMES = frozenset(
itertools.chain(
# We CANNOT make exceptions for keywords.
keyword.kwlist,
# We make SOME exceptions for certain names that collide with builtins.
set(dir(builtins)) - {"filter", "map", "id", "input", "property"},
# This is a hand-maintained list of modules that are directly imported
# in templates, i.e. they are not added as dependencies to any type,
# the raw text is just there in the template.
# More can be added as collisions are discovered.
# See issue #819 for additional info.
{"auth", "credentials", "exceptions", "future", "options", "policy", "math"}
)
)

0 comments on commit 04bd8aa

Please sign in to comment.