Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

[Python] types.py should have separate local and shared modules loops #2058

Closed
crwilcox opened this issue Jun 11, 2018 · 0 comments
Closed
Assignees
Labels
lang: python Issues specific to Python. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. yoshi

Comments

@crwilcox
Copy link

crwilcox commented Jun 11, 2018

PR googleapis/google-cloud-python#5364 shows the change we want. The generator is currently undoing this fix. The transform we are using right now is as follows:

replace(
    "google/cloud/*/types.py",
    "for module in \(\n(.*\n)*?\):\n(    .*\n)+",
    """_shared_modules = [
    http_pb2,
    iam_policy_pb2,
    policy_pb2,
    any_pb2,
    descriptor_pb2,
    duration_pb2,
    empty_pb2,
    field_mask_pb2,
    timestamp_pb2,
    status_pb2,
]

_local_modules = [
    cloudtasks_pb2,
    queue_pb2,
    target_pb2,
    task_pb2,
]

for module in _shared_modules:
    for name, message in get_messages(module).items():
        setattr(sys.modules[__name__], name, message)
        names.append(name)

for module in _local_modules:
    for name, message in get_messages(module).items():
    message.__module__ = 'google.cloud.tasks_v2beta2.types'
    setattr(sys.modules[__name__], name, message)
""")
@theacodes theacodes added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. yoshi labels Jun 11, 2018
@andreamlin andreamlin self-assigned this Jun 12, 2018
@tseaver tseaver added the lang: python Issues specific to Python. label Jun 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lang: python Issues specific to Python. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. yoshi
Projects
None yet
Development

No branches or pull requests

4 participants