-
Notifications
You must be signed in to change notification settings - Fork 66
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
Table-setting for generating protos. #35
Conversation
This commit makes several schema edits and additions in order to facilitate generating pb2 replacements directly. In particular, it: * Adds support for a `$proto` rewrite for filenames (such files receive a `proto` variable), and adds loader support for such. * Refactors `Address` to include the `name` of the object it is attached to, enabling it to be used as the `ident` object. * Refactors the various `*_ident` properties into the address, and re-orders template use (e.g. `sphinx_ident` is now `ident.sphinx`). * Additionally, `python_ident` is now just `ident` in templates. * Adds a `rel` method for getting identifiers relative to the file being generated. This deals with a problem that will surface in replacing pb2s where a file would attempt to import or reference itself. LROs are slightly broken in a slightly different way than before (note that they were broken in the status quo ante due to a bug in `OperationType`), and `OperationType` turned out to be a mistake. Filed #34 to track this, and it will be fixed after pb2 replacements are introduced (since they will significantly alter what the fix is).
Codecov Report
@@ Coverage Diff @@
## master #35 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 15 15
Lines 522 552 +30
Branches 91 101 +10
=====================================
+ Hits 522 552 +30
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with nits.
gapic/schema/api.py
Outdated
"""Return the appropriate module name for this service. | ||
|
||
Returns: | ||
str: The service name, in snake case. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
gapic/schema/api.py
Outdated
|
||
@cached_property | ||
def top(self) -> 'Proto': | ||
"""Return a proto shim which is only aware of top-level objects.""" |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
gapic/schema/api.py
Outdated
@@ -282,11 +305,17 @@ def _load_children(self, children: Sequence, loader: Callable, *, | |||
path (Tuple[int]): The location path up to this point. This is | |||
used to correspond to documentation in | |||
``SourceCodeInfo.Location`` in ``descriptor.proto``. | |||
|
|||
Return: | |||
Mapping: A sequence of the objects that were loaded. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
) | ||
|
||
def rel(self, address: 'Address') -> str: |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This commit makes several schema edits and additions in order to facilitate generating pb2 replacements directly.
In particular, it:
$proto
rewrite for filenames (such files receive aproto
variable), and adds loader support for such.Address
to include thename
of the object it is attached to, enabling it to be used as theident
object.*_ident
properties into the address, and re-orders template use (e.g.sphinx_ident
is nowident.sphinx
).python_ident
is now justident
in templates.rel
method for getting identifiers relative to the file being generated. This deals with a problem that will surface in replacing pb2s where a file would attempt to import or reference itself.LROs are slightly broken in a slightly different way than before (note that they were broken in the status quo ante due to a bug in
OperationType
), andOperationType
turned out to be a mistake. Filed #34 to track this, and it will be fixed after pb2 replacements are introduced (since they will significantly alter what the fix is).