Repository: googleapis/python-pubsublite (language: python)

Issue:
Python 3.12 unit tests fail with `tuple index out of range`
See build log [here](https://github.com/googleapis/python-pubsublite/actions/runs/7049548836/job/19188264272?pr=455) from PR https://github.com/googleapis/python-pubsublite/pull/455
```
.nox/unit-3-12/lib/python3.12/site-packages/_pytest/assertion/rewrite.py:186: in exec_module
    exec(co, module.__dict__)
tests/unit/pubsublite/cloudpubsub/internal/subscriber_impl_test.py:32: in <module>
    from google.cloud.pubsublite.cloudpubsub.internal.subscriber_impl import SubscriberImpl
google/cloud/pubsublite/cloudpubsub/internal/subscriber_impl.py:33: in <module>
    from google.cloud.pubsublite.cloudpubsub.subscriber_client_interface import (
google/cloud/pubsublite/cloudpubsub/__init__.py:18: in <module>
    from .publisher_client import AsyncPublisherClient, PublisherClient
google/cloud/pubsublite/cloudpubsub/publisher_client.py:23: in <module>
    from google.cloud.pubsublite.cloudpubsub.internal.make_publisher import (
google/cloud/pubsublite/cloudpubsub/internal/make_publisher.py:32: in <module>
    from google.cloud.pubsublite.internal.wire.make_publisher import (
google/cloud/pubsublite/internal/wire/make_publisher.py:40: in <module>
    from google.cloud.pubsublite.internal.wire.single_partition_publisher import (
google/cloud/pubsublite/internal/wire/single_partition_publisher.py:65: in <module>
    class SinglePartitionPublisher(
google/cloud/pubsublite/internal/wire/single_partition_publisher.py:201: in SinglePartitionPublisher
    @overrides
.nox/unit-3-12/lib/python3.12/site-packages/overrides/overrides.py:88: in overrides
    return _overrides(method, check_signature, check_at_runtime)
.nox/unit-3-12/lib/python3.12/site-packages/overrides/overrides.py:104: in _overrides
    for super_class in _get_base_classes(sys._getframe(3), global_vars):
.nox/unit-3-12/lib/python3.12/site-packages/overrides/overrides.py:142: in _get_base_classes
    for class_name_components in _get_base_class_names(frame)
.nox/unit-3-12/lib/python3.12/site-packages/overrides/overrides.py:183: in _get_base_class_names
    extends.append(("attr", co.co_names[oparg]))
E   IndexError: tuple index out of range
```


Discussion / hints:

Fix patch:
diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml
index 453b540c..eb4d9f79 100644
--- a/.github/.OwlBot.lock.yaml
+++ b/.github/.OwlBot.lock.yaml
@@ -13,5 +13,5 @@
 # limitations under the License.
 docker:
   image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest
-  digest: sha256:caffe0a9277daeccc4d1de5c9b55ebba0901b57c2f713ec9c876b0d4ec064f61
-# created: 2023-11-08T19:46:45.022803742Z
+  digest: sha256:bacc3af03bff793a03add584537b36b5644342931ad989e3ba1171d3bd5399f5
+# created: 2023-11-23T18:17:28.105124211Z
diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml
index 271a1d4f..b826a86f 100644
--- a/.github/sync-repo-settings.yaml
+++ b/.github/sync-repo-settings.yaml
@@ -34,8 +34,19 @@ branchProtectionRules:
     - 'Samples - Python 3.9'
     - 'Samples - Python 3.10'
     - 'Samples - Python 3.11'
+    - 'Samples - Python 3.12'
     - 'Samples - Lint'
     - 'OwlBot Post Processor'
+    - 'docs'
+    - 'docfx'
+    - 'lint'
+    - 'unit (3.7)'
+    - 'unit (3.8)'
+    - 'unit (3.9)'
+    - 'unit (3.10)'
+    - 'unit (3.11)'
+    - 'unit (3.12)'
+    - 'cover'
 # List of explicit permissions to add (additive only)
 permissionRules:
     # Team slug to add to repository permissions
diff --git a/.kokoro/samples/python3.12/common.cfg b/.kokoro/samples/python3.12/common.cfg
new file mode 100644
index 00000000..fa056db7
--- /dev/null
+++ b/.kokoro/samples/python3.12/common.cfg
@@ -0,0 +1,40 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+# Build logs will be here
+action {
+  define_artifacts {
+    regex: "**/*sponge_log.xml"
+  }
+}
+
+# Specify which tests to run
+env_vars: {
+    key: "RUN_TESTS_SESSION"
+    value: "py-3.12"
+}
+
+# Declare build specific Cloud project.
+env_vars: {
+    key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
+    value: "python-docs-samples-tests-312"
+}
+
+env_vars: {
+    key: "TRAMPOLINE_BUILD_FILE"
+    value: "github/python-pubsublite/.kokoro/test-samples.sh"
+}
+
+# Configure the docker image for kokoro-trampoline.
+env_vars: {
+    key: "TRAMPOLINE_IMAGE"
+    value: "gcr.io/cloud-devrel-kokoro-resources/python-samples-testing-docker"
+}
+
+# Download secrets for samples
+gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"
+
+# Download trampoline resources.
+gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
+
+# Use the trampoline script to run in docker.
+build_file: "python-pubsublite/.kokoro/trampoline_v2.sh"
\ No newline at end of file
diff --git a/.kokoro/samples/python3.12/continuous.cfg b/.kokoro/samples/python3.12/continuous.cfg
new file mode 100644
index 00000000..a1c8d975
--- /dev/null
+++ b/.kokoro/samples/python3.12/continuous.cfg
@@ -0,0 +1,6 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+env_vars: {
+    key: "INSTALL_LIBRARY_FROM_SOURCE"
+    value: "True"
+}
\ No newline at end of file
diff --git a/.kokoro/samples/python3.12/periodic-head.cfg b/.kokoro/samples/python3.12/periodic-head.cfg
new file mode 100644
index 00000000..ddd32f34
--- /dev/null
+++ b/.kokoro/samples/python3.12/periodic-head.cfg
@@ -0,0 +1,11 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+env_vars: {
+    key: "INSTALL_LIBRARY_FROM_SOURCE"
+    value: "True"
+}
+
+env_vars: {
+    key: "TRAMPOLINE_BUILD_FILE"
+    value: "github/python-pubsublite/.kokoro/test-samples-against-head.sh"
+}
diff --git a/.kokoro/samples/python3.12/periodic.cfg b/.kokoro/samples/python3.12/periodic.cfg
new file mode 100644
index 00000000..71cd1e59
--- /dev/null
+++ b/.kokoro/samples/python3.12/periodic.cfg
@@ -0,0 +1,6 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+env_vars: {
+    key: "INSTALL_LIBRARY_FROM_SOURCE"
+    value: "False"
+}
diff --git a/.kokoro/samples/python3.12/presubmit.cfg b/.kokoro/samples/python3.12/presubmit.cfg
new file mode 100644
index 00000000..a1c8d975
--- /dev/null
+++ b/.kokoro/samples/python3.12/presubmit.cfg
@@ -0,0 +1,6 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+env_vars: {
+    key: "INSTALL_LIBRARY_FROM_SOURCE"
+    value: "True"
+}
\ No newline at end of file
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index 2bc07b6a..80859ced 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -22,7 +22,7 @@ In order to add a feature:
   documentation.
 
 - The feature must work fully on the following CPython versions:
-  3.8, 3.9, 3.10 and 3.11 on both UNIX and Windows.
+  3.8, 3.9, 3.10, 3.11 and 3.12 on both UNIX and Windows.
 
 - The feature must not add unnecessary dependencies (where
   "unnecessary" is of course subjective, but new dependencies should
@@ -72,7 +72,7 @@ We use `nox <https://nox.readthedocs.io/en/latest/>`__ to instrument our tests.
 
 - To run a single unit test::
 
-    $ nox -s unit-3.11 -- -k <name of test>
+    $ nox -s unit-3.12 -- -k <name of test>
 
 
   .. note::
@@ -225,11 +225,13 @@ We support:
 -  `Python 3.9`_
 -  `Python 3.10`_
 -  `Python 3.11`_
+-  `Python 3.12`_
 
 .. _Python 3.8: https://docs.python.org/3.8/
 .. _Python 3.9: https://docs.python.org/3.9/
 .. _Python 3.10: https://docs.python.org/3.10/
 .. _Python 3.11: https://docs.python.org/3.11/
+.. _Python 3.12: https://docs.python.org/3.12/
 
 
 Supported versions can be found in our ``noxfile.py`` `config`_.
diff --git a/noxfile.py b/noxfile.py
index 93813ce8..2c267ee3 100644
--- a/noxfile.py
+++ b/noxfile.py
@@ -35,7 +35,7 @@
 
 DEFAULT_PYTHON_VERSION = "3.8"
 
-UNIT_TEST_PYTHON_VERSIONS: List[str] = ["3.8", "3.9", "3.10", "3.11"]
+UNIT_TEST_PYTHON_VERSIONS: List[str] = ["3.8", "3.9", "3.10", "3.11", "3.12"]
 UNIT_TEST_STANDARD_DEPENDENCIES = [
     "mock",
     "asyncmock",
diff --git a/owlbot.py b/owlbot.py
index c332f0f2..95ae9667 100644
--- a/owlbot.py
+++ b/owlbot.py
@@ -63,7 +63,7 @@
 templated_files = gcp.CommonTemplates().py_library(
     cov_level=96,
     microgenerator=True,
-    unit_test_python_versions=["3.8", "3.9", "3.10", "3.11"],
+    unit_test_python_versions=["3.8", "3.9", "3.10", "3.11", "3.12"],
     versions=gcp.common.detect_versions(path="./google", default_first=True),
 )
 s.move(
diff --git a/samples/snippets/noxfile.py b/samples/snippets/noxfile.py
index 1224cbe2..3b713594 100644
--- a/samples/snippets/noxfile.py
+++ b/samples/snippets/noxfile.py
@@ -89,7 +89,7 @@ def get_pytest_env_vars() -> Dict[str, str]:
 
 # DO NOT EDIT - automatically generated.
 # All versions used to test samples.
-ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11"]
+ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
 
 # Any default versions that should be ignored.
 IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"]
diff --git a/setup.py b/setup.py
index 45e2a69c..dd90b87c 100644
--- a/setup.py
+++ b/setup.py
@@ -39,7 +39,8 @@
     "google-cloud-pubsub >= 2.10.0, <3.0.0dev",
     "grpcio >= 1.38.1, <2.0.0dev",
     "grpcio-status >= 1.38.1, <2.0.0dev",
-    "overrides>=6.0.1, <7.0.0",
+    "overrides>=6.0.1, <8.0.0",
+    "overrides>=7.0.1, <8.0.0; python_version>='3.12'",
     "google-api-core[grpc] >= 1.33.2, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*",
 ]
 url = "https://github.com/googleapis/python-pubsublite"
@@ -75,6 +76,7 @@
         "Programming Language :: Python :: 3.9",
         "Programming Language :: Python :: 3.10",
         "Programming Language :: Python :: 3.11",
+        "Programming Language :: Python :: 3.12",
         "Operating System :: OS Independent",
         "Topic :: Internet",
     ],


Test patch:
diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml
index 87a4fa3e..54c7c215 100644
--- a/.github/workflows/unittest.yml
+++ b/.github/workflows/unittest.yml
@@ -8,7 +8,7 @@ jobs:
     runs-on: ubuntu-latest
     strategy:
       matrix:
-        python: ['3.8', '3.9', '3.10', '3.11']
+        python: ['3.8', '3.9', '3.10', '3.11', '3.12']
     steps:
     - name: Checkout
       uses: actions/checkout@v3