Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revisit the reserved terms in gapic/utils/reserved_names.py #2015

Open
Ark-kun opened this issue Apr 24, 2024 · 5 comments
Open

Revisit the reserved terms in gapic/utils/reserved_names.py #2015

Ark-kun opened this issue Apr 24, 2024 · 5 comments
Assignees
Labels
next major: breaking change this is a change that we should wait to bundle into the next major version type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@Ark-kun
Copy link

Ark-kun commented Apr 24, 2024

I've just noticed that the generated classes mangle the license field name:

class Citation(proto.Message):
    r"""Source attributions for content."""
    ...
    license_: str = proto.Field(
        proto.STRING,
        number=5,
    )

https://github.com/googleapis/python-aiplatform/blob/c56dd50310ecc42d6a3b0cd2f30db71e8cad0cf6/google/cloud/aiplatform_v1/types/content.py#L572

I think this is incorrect. license is not a Python reserved keyword and it can definitely be used as an attribute name.

@parthea
Copy link
Contributor

parthea commented Apr 24, 2024

It exists as a built-in constant: https://docs.python.org/3/library/constants.html#constants-added-by-the-site-module

>>> license
Type license() to see the full license text
>>> license()
A. HISTORY OF THE SOFTWARE
==========================

@parthea parthea added type: question Request for information or clarification. Not an issue. needs more info This issue needs more information from the customer to proceed. labels Apr 24, 2024
@parthea
Copy link
Contributor

parthea commented Apr 25, 2024

I'm going to close this issue but please feel free to open a new issue with more information.

@parthea parthea closed this as completed Apr 25, 2024
@Ark-kun
Copy link
Author

Ark-kun commented Apr 25, 2024

It exists as a built-in constant

This does not prevent it from being used as a field name.

@parthea
Copy link
Contributor

parthea commented Apr 25, 2024

A decision was made to add the trailing underscore in #514 (Fixes issue #504). Re-opening this issue to keep the discussion going.

@parthea parthea reopened this Apr 25, 2024
@parthea
Copy link
Contributor

parthea commented Apr 25, 2024

In the example from #2015 (comment)

class Citation(proto.Message):
    r"""Source attributions for content."""
    ...
    license: str = proto.Field(
        proto.STRING,
        number=5,
    )

We would be clobbering the built-in constant license. It can be done technically but It is generally bad practice.

Nonetheless, I'll keep this open as a feature request so we can evaluate when we are considering the next breaking change.

(Regardless of whether it can be done technically, it would be a breaking change to remove terms from the reserved words list. )

@parthea parthea added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. next major: breaking change this is a change that we should wait to bundle into the next major version and removed needs more info This issue needs more information from the customer to proceed. type: question Request for information or clarification. Not an issue. labels Apr 25, 2024
@parthea parthea changed the title license should not be a reserved field name Revisit the reserved terms in gapic/utils/reserved_names.py Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next major: breaking change this is a change that we should wait to bundle into the next major version type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

2 participants