From f5e9f367ec6a72b4272f559a93f6fbb3d7e54b8b Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Tue, 23 Mar 2021 18:08:32 -0400 Subject: [PATCH 1/4] fix: Update module alias to resolve naming conflict (#820) In the current design, the first character of each package is used to create an alias. I'd like to append the first character before underscores in the package name to further reduce conflicts. Previously google.appengine_admin would have an alias prefix of ga. With this change, the alias prefix will be gaa. Fixes: #819 --- gapic/schema/metadata.py | 9 ++++++--- tests/unit/schema/test_metadata.py | 8 ++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/gapic/schema/metadata.py b/gapic/schema/metadata.py index 0276fe0989..0b1f6df2d5 100644 --- a/gapic/schema/metadata.py +++ b/gapic/schema/metadata.py @@ -115,9 +115,12 @@ def module_alias(self) -> str: return '_'.join( ( ''.join( - i[0] - for i in self.package - if i != self.api_naming.version + [ + partial_name[0] + for i in self.package + for partial_name in i.split("_") + if i != self.api_naming.version + ] ), self.module, ) diff --git a/tests/unit/schema/test_metadata.py b/tests/unit/schema/test_metadata.py index 4be166bc1b..693beffa9b 100644 --- a/tests/unit/schema/test_metadata.py +++ b/tests/unit/schema/test_metadata.py @@ -184,6 +184,14 @@ def test_address_name_builtin_keyword(): ) assert addr_kword.module_alias == "gp_class" + addr_kword = metadata.Address( + name="Class", + module="class", + package=("google", "appengine_admin"), + api_naming=naming.NewNaming(proto_package="foo.bar.baz.v1"), + ) + assert addr_kword.module_alias == "gaa_class" + def test_doc_nothing(): meta = metadata.Metadata() From 1de2e14061e77e9c77d32acd9fa597e4a1c82ad6 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 24 Mar 2021 00:08:06 +0100 Subject: [PATCH 2/4] chore(deps): update dependency google-api-core to v1.26.2 (#822) [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [google-api-core](https://togithub.com/googleapis/python-api-core) | `==1.26.1` -> `==1.26.2` | [![age](https://badges.renovateapi.com/packages/pypi/google-api-core/1.26.2/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/google-api-core/1.26.2/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/google-api-core/1.26.2/compatibility-slim/1.26.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/google-api-core/1.26.2/confidence-slim/1.26.1)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
googleapis/python-api-core ### [`v1.26.2`](https://togithub.com/googleapis/python-api-core/blob/master/CHANGELOG.md#​1262-httpswwwgithubcomgoogleapispython-api-corecomparev1261v1262-2021-03-23) [Compare Source](https://togithub.com/googleapis/python-api-core/compare/v1.26.1...v1.26.2)
--- ### Renovate configuration :date: **Schedule**: At any time (no schedule defined). :vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied. :recycle: **Rebasing**: Renovate will not automatically rebase this PR, because other commits have been found. :no_bell: **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/gapic-generator-python). --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 2770b54084..4c5eb59b97 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ click==7.1.2 -google-api-core==1.26.1 +google-api-core==1.26.2 googleapis-common-protos==1.53.0 jinja2==2.11.3 MarkupSafe==1.1.1 From 04bd8aaf0fc2c2c0615105cab39dc33266b66775 Mon Sep 17 00:00:00 2001 From: Dov Shlachter Date: Wed, 24 Mar 2021 10:20:02 -0700 Subject: [PATCH 3/4] fix: add certain raw imports to RESERVED_NAMES (#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. --- 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"} ) ) From f9f95a6ffe942d08426fbb54983f7c41f79af1a5 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Wed, 24 Mar 2021 17:30:03 +0000 Subject: [PATCH 4/4] chore: release 0.43.2 (#823) :robot: I have created a release \*beep\* \*boop\* --- ### [0.43.2](https://www.github.com/googleapis/gapic-generator-python/compare/v0.43.1...v0.43.2) (2021-03-24) ### Bug Fixes * add certain raw imports to RESERVED_NAMES ([#824](https://www.github.com/googleapis/gapic-generator-python/issues/824)) ([04bd8aa](https://www.github.com/googleapis/gapic-generator-python/commit/04bd8aaf0fc2c2c0615105cab39dc33266b66775)) * Update module alias to resolve naming conflict ([#820](https://www.github.com/googleapis/gapic-generator-python/issues/820)) ([f5e9f36](https://www.github.com/googleapis/gapic-generator-python/commit/f5e9f367ec6a72b4272f559a93f6fbb3d7e54b8b)), closes [#819](https://www.github.com/googleapis/gapic-generator-python/issues/819) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea06972a00..5f4b3c3fae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +### [0.43.2](https://www.github.com/googleapis/gapic-generator-python/compare/v0.43.1...v0.43.2) (2021-03-24) + + +### Bug Fixes + +* add certain raw imports to RESERVED_NAMES ([#824](https://www.github.com/googleapis/gapic-generator-python/issues/824)) ([04bd8aa](https://www.github.com/googleapis/gapic-generator-python/commit/04bd8aaf0fc2c2c0615105cab39dc33266b66775)) +* Update module alias to resolve naming conflict ([#820](https://www.github.com/googleapis/gapic-generator-python/issues/820)) ([f5e9f36](https://www.github.com/googleapis/gapic-generator-python/commit/f5e9f367ec6a72b4272f559a93f6fbb3d7e54b8b)), closes [#819](https://www.github.com/googleapis/gapic-generator-python/issues/819) + ### [0.43.1](https://www.github.com/googleapis/gapic-generator-python/compare/v0.43.0...v0.43.1) (2021-03-19)