Skip to content

Commit

Permalink
pull in synth.py changes from #299
Browse files Browse the repository at this point in the history
  • Loading branch information
parthea committed Jul 17, 2021
1 parent 6339efd commit c842cf0
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions owlbot.py
Expand Up @@ -234,6 +234,63 @@
"\n\g<0>",
)

# Allow timeout to be an instance of google.api_core.timeout.*
s.replace(
library / f"google/pubsub_{library.name}/types/__init__.py",
r"from \.pubsub import \(",
"from typing import Union\n\n\g<0>"
)

s.replace(
library / f"google/pubsub_{library.name}/types/__init__.py",
r"__all__ = \(\n",
textwrap.dedent('''\
TimeoutType = Union[
int,
float,
"google.api_core.timeout.ConstantTimeout",
"google.api_core.timeout.ExponentialTimeout",
]
"""The type of the timeout parameter of publisher client methods."""
\g<0> "TimeoutType",''')
)

s.replace(
library / f"google/pubsub_{library.name}/services/publisher/*client.py",
r"from google.api_core import retry as retries.*\n",
"\g<0>from google.api_core import timeout as timeouts # type: ignore\n"
)

s.replace(
library / f"google/pubsub_{library.name}/services/publisher/*client.py",
f"from google\.pubsub_{library.name}\.types import pubsub",
f"\g<0>\nfrom google.pubsub_{library.name}.types import TimeoutType",
)

s.replace(
library / f"google/pubsub_{library.name}/services/publisher/*client.py",
r"(\s+)timeout: float = None.*\n",
f"\g<1>timeout: TimeoutType = gapic_{library.name}.method.DEFAULT,",
)

s.replace(
library / f"google/pubsub_{library.name}/services/publisher/*client.py",
r"([^\S\r\n]+)timeout \(float\): (.*)\n",
(
"\g<1>timeout (TimeoutType):\n"
"\g<1> \g<2>\n"
),
)

# The namespace package declaration in google/cloud/__init__.py should be excluded
# from coverage.
s.replace(
".coveragerc",
r"((?P<indent>[^\n\S]+)google/pubsub/__init__\.py)",
"\g<indent>google/cloud/__init__.py\n\g<0>",
)

s.move(
library,
excludes=[
Expand Down

0 comments on commit c842cf0

Please sign in to comment.