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

fix: add additional reserved names for disambiguation #1114

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions gapic/utils/reserved_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@
keyword.kwlist,
# We make SOME exceptions for certain names that collide with builtins.
set(dir(builtins)) - {"filter", "map", "id", "input", "property"},
# "mapping" and "ignore_unknown_fields" have special uses
# in the constructor of proto.Message
{"mapping", "ignore_unknown_fields"},
)
)
2 changes: 1 addition & 1 deletion tests/unit/samplegen/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from gapic.samplegen_utils import (types, utils as gapic_utils)
from gapic.schema import (naming, wrappers)

from tests.unit.samplegen.common_types import (DummyField, DummyMessage,
from common_types import (DummyField, DummyMessage,

DummyMessageTypePB, DummyMethod, DummyService, DummyIdent,
DummyApiSchema, DummyNaming, enum_factory, message_factory)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/samplegen/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from gapic.samplegen_utils.types import CallingForm
from textwrap import dedent
from tests.unit.samplegen import common_types
import common_types


def check_template(template_fragment, expected_output, **kwargs):
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/schema/wrappers/test_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,12 @@ def test_field_name_kword_disambiguation():
)
assert frum_field.name == "frum"

mapping_field = make_field(name="mapping")
software-dov marked this conversation as resolved.
Show resolved Hide resolved
assert mapping_field.name == "mapping_"

ignore_field = make_field(name="ignore_unknown_fields")
assert ignore_field.name == "ignore_unknown_fields_"


def test_field_resource_reference():
field = make_field(name='parent', type='TYPE_STRING')