From 149756b0118ade5d48efd2e10ba3df08bc1e480c Mon Sep 17 00:00:00 2001 From: Dov Shlachter Date: Tue, 23 Mar 2021 15:17:47 -0700 Subject: [PATCH] fix: add certain raw imports to RESERVED_NAMES 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. --- gapic/utils/reserved_names.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gapic/utils/reserved_names.py b/gapic/utils/reserved_names.py index 9bf1c9a914..9104015d5c 100644 --- a/gapic/utils/reserved_names.py +++ b/gapic/utils/reserved_names.py @@ -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"} ) )