From 58a556b58deb4e34421016c1c1d6f174b1676bd4 Mon Sep 17 00:00:00 2001
From: Nitsan Shai <shai.nitsan@gmail.com>
Date: Wed, 5 Oct 2022 11:35:13 -0400
Subject: [PATCH] fix: remove SpeechHelpers from STT V2 client library (#452)

* fix: remove SpeechHelpers from STT V2 client library

* chore: update post processing script

* chore: clean up post processing script

Co-authored-by: Nitsan Shai <nshai@google.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
---
 .../google/cloud/speech_v2/__init__.py            |  7 -------
 google-cloud-speech/owlbot.py                     | 15 ++++++++-------
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/google-cloud-speech/google/cloud/speech_v2/__init__.py b/google-cloud-speech/google/cloud/speech_v2/__init__.py
index 2e218826be6d..9cca12001e3c 100644
--- a/google-cloud-speech/google/cloud/speech_v2/__init__.py
+++ b/google-cloud-speech/google/cloud/speech_v2/__init__.py
@@ -69,13 +69,6 @@
 from .types.cloud_speech import UpdateRecognizerRequest
 from .types.cloud_speech import WordInfo
 
-from google.cloud.speech_v1.helpers import SpeechHelpers
-
-
-class SpeechClient(SpeechHelpers, SpeechClient):
-    __doc__ = SpeechClient.__doc__
-
-
 __all__ = (
     "SpeechAsyncClient",
     "AutoDetectDecodingConfig",
diff --git a/google-cloud-speech/owlbot.py b/google-cloud-speech/owlbot.py
index 4c19677961e4..cda41e362651 100644
--- a/google-cloud-speech/owlbot.py
+++ b/google-cloud-speech/owlbot.py
@@ -23,11 +23,12 @@
 default_version = "v1"
 
 for library in s.get_staging_dirs(default_version):
-    # Add the manually written SpeechHelpers to v1 and v1p1beta1
-    # See google/cloud/speech_v1/helpers.py for details
-    count = s.replace(library / f"google/cloud/speech_{library.name}/__init__.py",
-                        """__all__ = \(""",
-                        """from google.cloud.speech_v1.helpers import SpeechHelpers
+    if "v1" in library.name:
+        # Add the manually written SpeechHelpers to v1 and v1p1beta1
+        # See google/cloud/speech_v1/helpers.py for details
+        count = s.replace(library / f"google/cloud/speech_{library.name}/__init__.py",
+                            """__all__ = \(""",
+                            """from google.cloud.speech_v1.helpers import SpeechHelpers
 
 class SpeechClient(SpeechHelpers, SpeechClient):
     __doc__ = SpeechClient.__doc__
@@ -35,6 +36,7 @@ class SpeechClient(SpeechHelpers, SpeechClient):
 __all__ = (
                         """,
                     )
+        assert count == 1
 
     if library.name == "v1":
         # Import from speech_v1 to get the client with SpeechHelpers
@@ -42,9 +44,8 @@ class SpeechClient(SpeechHelpers, SpeechClient):
             """from google\.cloud\.speech_v1\.services\.speech\.client import SpeechClient""",
             """from google.cloud.speech_v1 import SpeechClient"""
             )
+        assert count == 1
 
-    # Don't move over __init__.py, as we modify it to make the generated client
-    # use helpers.py.
     s.move(library, excludes=["setup.py"])
 
 s.remove_staging_dirs()