This repository was archived by the owner on Mar 26, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 78
fix: list oneofs in docstring #1030
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
14a88a6
fix: list oneofs in docstring
busunkim96 15c82b4
chore: copy to ads templates
busunkim96 403a0be
Merge branch 'master' into oneofs-in-docstrings
busunkim96 843c86b
docs: remove separate list in docstring
busunkim96 9a6ef5e
t push
busunkim96 5058a3f
Merge branch 'master' into oneofs-in-docstrings
busunkim96 8a80020
chore: also update ads
busunkim96 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,10 +2,32 @@ class {{ message.name }}({{ p }}.Message): | |
| r"""{{ message.meta.doc|rst(indent=4) }} | ||
| {% if message.fields|length %} | ||
|
|
||
| {# Only include note if a oneof has more than one member field. #} | ||
| {% if message.oneof_fields() %} | ||
| {% if message.oneof_fields().values() | map('length') | max > 1 %} | ||
| This message has the following `oneof`_ fields (mutually exclusive fields). | ||
| For each oneof, at most one member field can be set at the same time. | ||
| Setting any member of the oneof automatically clears all other | ||
| members. | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| {% for oneof, field_names in message.oneof_fields().items() %} | ||
| ``{{ oneof }}`` | ||
| {% for field_name in field_names %} | ||
| - :attr:`{{ field_name.name }}` | ||
| {% endfor %} | ||
| {% endfor %} | ||
|
|
||
| {% endif %} | ||
| .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields | ||
|
|
||
| {% endif %} | ||
| Attributes: | ||
| {% for field in message.fields.values() %} | ||
| {{ field.name }} ({{ field.ident.sphinx }}): | ||
| {{ field.meta.doc|rst(indent=12, nl=False) }} | ||
| {% if field.oneof %} | ||
| This field is a member of `oneof`_ ``{{ field.oneof }}``. | ||
| {% endif %} | ||
| {% endfor %} | ||
| {% endif %} | ||
| """ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -512,13 +512,26 @@ class DeleteFeedRequest(proto.Message): | |
| class OutputConfig(proto.Message): | ||
| r"""Output configuration for export assets destination. | ||
|
|
||
| This message has the following `oneof`_ fields (mutually exclusive fields). | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dandhlee This is a concrete example of the new docstring with the oneof information.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will take a look, intuition tells me it'll just show up as
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sadly it doesn't get parsed, but I'll be happy to include support for it C: |
||
| For each oneof, at most one member field can be set at the same time. | ||
| Setting any member of the oneof automatically clears all other | ||
| members. | ||
|
|
||
| ``destination`` | ||
| - :attr:`gcs_destination` | ||
| - :attr:`bigquery_destination` | ||
|
|
||
| .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields | ||
|
|
||
| Attributes: | ||
| gcs_destination (google.cloud.asset_v1.types.GcsDestination): | ||
| Destination on Cloud Storage. | ||
| This field is a member of `oneof`_ ``destination``. | ||
| bigquery_destination (google.cloud.asset_v1.types.BigQueryDestination): | ||
| Destination on BigQuery. The output table | ||
| stores the fields in asset proto as columns in | ||
| BigQuery. | ||
| This field is a member of `oneof`_ ``destination``. | ||
| """ | ||
|
|
||
| gcs_destination = proto.Field( | ||
|
|
@@ -538,9 +551,12 @@ class OutputConfig(proto.Message): | |
| class OutputResult(proto.Message): | ||
| r"""Output result of export assets. | ||
|
|
||
| .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields | ||
|
|
||
| Attributes: | ||
| gcs_result (google.cloud.asset_v1.types.GcsOutputResult): | ||
| Export result on Cloud Storage. | ||
| This field is a member of `oneof`_ ``result``. | ||
| """ | ||
|
|
||
| gcs_result = proto.Field( | ||
|
|
@@ -569,6 +585,17 @@ class GcsOutputResult(proto.Message): | |
| class GcsDestination(proto.Message): | ||
| r"""A Cloud Storage location. | ||
|
|
||
| This message has the following `oneof`_ fields (mutually exclusive fields). | ||
| For each oneof, at most one member field can be set at the same time. | ||
| Setting any member of the oneof automatically clears all other | ||
| members. | ||
|
|
||
| ``object_uri`` | ||
| - :attr:`uri` | ||
| - :attr:`uri_prefix` | ||
|
|
||
| .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields | ||
|
|
||
| Attributes: | ||
| uri (str): | ||
| The uri of the Cloud Storage object. It's the same uri that | ||
|
|
@@ -581,6 +608,7 @@ class GcsDestination(proto.Message): | |
| there is no | ||
| `hold <https://cloud.google.com/storage/docs/object-holds>`__, | ||
| it will be overwritten with the exported result. | ||
| This field is a member of `oneof`_ ``object_uri``. | ||
| uri_prefix (str): | ||
| The uri prefix of all generated Cloud Storage objects. | ||
| Example: "gs://bucket_name/object_name_prefix". Each object | ||
|
|
@@ -591,6 +619,7 @@ class GcsDestination(proto.Message): | |
| compute.googleapis.com/Disk assets. An INVALID_ARGUMENT | ||
| error will be returned if file with the same name | ||
| "gs://bucket_name/object_name_prefix" already exists. | ||
| This field is a member of `oneof`_ ``object_uri``. | ||
| """ | ||
|
|
||
| uri = proto.Field( | ||
|
|
@@ -751,9 +780,12 @@ class PubsubDestination(proto.Message): | |
| class FeedOutputConfig(proto.Message): | ||
| r"""Output configuration for asset feed destination. | ||
|
|
||
| .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields | ||
|
|
||
| Attributes: | ||
| pubsub_destination (google.cloud.asset_v1.types.PubsubDestination): | ||
| Destination on Pub/Sub. | ||
| This field is a member of `oneof`_ ``destination``. | ||
| """ | ||
|
|
||
| pubsub_destination = proto.Field( | ||
|
|
@@ -1420,12 +1452,15 @@ class Options(proto.Message): | |
| class ConditionContext(proto.Message): | ||
| r"""The IAM conditions context. | ||
|
|
||
| .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields | ||
|
|
||
| Attributes: | ||
| access_time (google.protobuf.timestamp_pb2.Timestamp): | ||
| The hypothetical access timestamp to evaluate IAM | ||
| conditions. Note that this value must not be earlier than | ||
| the current time; otherwise, an INVALID_ARGUMENT error will | ||
| be returned. | ||
| This field is a member of `oneof`_ ``TimeContext``. | ||
| """ | ||
|
|
||
| access_time = proto.Field( | ||
|
|
@@ -1580,11 +1615,24 @@ class IamPolicyAnalysisOutputConfig(proto.Message): | |
| r"""Output configuration for export IAM policy analysis | ||
| destination. | ||
|
|
||
| This message has the following `oneof`_ fields (mutually exclusive fields). | ||
| For each oneof, at most one member field can be set at the same time. | ||
| Setting any member of the oneof automatically clears all other | ||
| members. | ||
|
|
||
| ``destination`` | ||
| - :attr:`gcs_destination` | ||
| - :attr:`bigquery_destination` | ||
|
|
||
| .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields | ||
|
|
||
| Attributes: | ||
| gcs_destination (google.cloud.asset_v1.types.IamPolicyAnalysisOutputConfig.GcsDestination): | ||
| Destination on Cloud Storage. | ||
| This field is a member of `oneof`_ ``destination``. | ||
| bigquery_destination (google.cloud.asset_v1.types.IamPolicyAnalysisOutputConfig.BigQueryDestination): | ||
| Destination on BigQuery. | ||
| This field is a member of `oneof`_ ``destination``. | ||
| """ | ||
|
|
||
| class GcsDestination(proto.Message): | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.