Skip to content

Commit

Permalink
feat: [Many APIs] Add support for Python 3.12 (#12072)
Browse files Browse the repository at this point in the history
- [ ] Regenerate this pull request now.

docs: updated doc for speech mode

PiperOrigin-RevId: 586469693

Source-Link:
googleapis/googleapis@e8148d6

Source-Link:
googleapis/googleapis-gen@85136bd
Copy-Tag:
eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWNvbW1lcmNlLWNvbnN1bWVyLXByb2N1cmVtZW50Ly5Pd2xCb3QueWFtbCIsImgiOiI4NTEzNmJkMDQzODNlZDcxNzJiYjE4YjdiOGQyMjBkZDdmZjZiM2EwIn0=
Copy-Tag:
eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWNvbXB1dGUvLk93bEJvdC55YW1sIiwiaCI6Ijg1MTM2YmQwNDM4M2VkNzE3MmJiMThiN2I4ZDIyMGRkN2ZmNmIzYTAifQ==
Copy-Tag:
eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWNvbmZpZGVudGlhbGNvbXB1dGluZy8uT3dsQm90LnlhbWwiLCJoIjoiODUxMzZiZDA0MzgzZWQ3MTcyYmIxOGI3YjhkMjIwZGQ3ZmY2YjNhMCJ9
Copy-Tag:
eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWNvbmZpZy8uT3dsQm90LnlhbWwiLCJoIjoiODUxMzZiZDA0MzgzZWQ3MTcyYmIxOGI3YjhkMjIwZGQ3ZmY2YjNhMCJ9
Copy-Tag:
eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWNvbnRhY3QtY2VudGVyLWluc2lnaHRzLy5Pd2xCb3QueWFtbCIsImgiOiI4NTEzNmJkMDQzODNlZDcxNzJiYjE4YjdiOGQyMjBkZDdmZjZiM2EwIn0=
Copy-Tag:
eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWNvbnRhaW5lci8uT3dsQm90LnlhbWwiLCJoIjoiODUxMzZiZDA0MzgzZWQ3MTcyYmIxO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3ZmY2YjNhMCJ9

BEGIN_COMMIT_OVERRIDE
feat: Add support for python 3.12
feat: Introduce compatibility with native namespace packages
fix: Use `retry_async` instead of `retry` in async client
fix: Require proto-plus >= 1.22.3
END_COMMIT_OVERRIDE

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
  • Loading branch information
3 people committed Dec 1, 2023
1 parent 0d1a592 commit b96013d
Show file tree
Hide file tree
Showing 196 changed files with 1,908 additions and 1,838 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ In order to add a feature:
documentation.

- The feature must work fully on the following CPython versions:
3.7, 3.8, 3.9, 3.10 and 3.11 on both UNIX and Windows.
3.7, 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
Expand Down Expand Up @@ -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::
Expand Down Expand Up @@ -143,12 +143,12 @@ Running System Tests
$ nox -s system

# Run a single system test
$ nox -s system-3.11 -- -k <name of test>
$ nox -s system-3.12 -- -k <name of test>


.. note::

System tests are only configured to run under Python 3.8, 3.9, 3.10 and 3.11.
System tests are only configured to run under Python 3.8, 3.9, 3.10, 3.11 and 3.12.
For expediency, we do not run them in older versions of Python 3.

This alone will not run the tests. You'll need to change some local
Expand Down Expand Up @@ -226,12 +226,14 @@ We support:
- `Python 3.9`_
- `Python 3.10`_
- `Python 3.11`_
- `Python 3.12`_

.. _Python 3.7: https://docs.python.org/3.7/
.. _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`_.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

from google.api_core import exceptions as core_exceptions
from google.api_core import gapic_v1
from google.api_core import retry as retries
from google.api_core import retry_async as retries
from google.api_core.client_options import ClientOptions
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore
Expand All @@ -40,9 +40,9 @@
)

try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault]
except AttributeError: # pragma: NO COVER
OptionalRetry = Union[retries.Retry, object] # type: ignore
OptionalRetry = Union[retries.AsyncRetry, object] # type: ignore

from google.api_core import operation # type: ignore
from google.api_core import operation_async # type: ignore
Expand Down Expand Up @@ -298,7 +298,7 @@ async def sample_place_order():
request (Optional[Union[google.cloud.commerce_consumer_procurement_v1.types.PlaceOrderRequest, dict]]):
The request object. Request message for
[ConsumerProcurementService.PlaceOrder][google.cloud.commerce.consumer.procurement.v1.ConsumerProcurementService.PlaceOrder].
retry (google.api_core.retry.Retry): Designation of what errors, if any,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
Expand Down Expand Up @@ -410,7 +410,7 @@ async def sample_get_order():
This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
Expand Down Expand Up @@ -459,7 +459,7 @@ async def sample_get_order():
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.get_order,
default_retry=retries.Retry(
default_retry=retries.AsyncRetry(
initial=1.0,
maximum=60.0,
multiplier=1.3,
Expand Down Expand Up @@ -542,7 +542,7 @@ async def sample_list_orders():
This corresponds to the ``parent`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
Expand Down Expand Up @@ -578,7 +578,7 @@ async def sample_list_orders():
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.list_orders,
default_retry=retries.Retry(
default_retry=retries.AsyncRetry(
initial=1.0,
maximum=60.0,
multiplier=1.3,
Expand Down Expand Up @@ -631,7 +631,7 @@ async def get_operation(
request (:class:`~.operations_pb2.GetOperationRequest`):
The request object. Request message for
`GetOperation` method.
retry (google.api_core.retry.Retry): Designation of what errors,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
if any, should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
Expand All @@ -648,7 +648,7 @@ async def get_operation(

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method.wrap_method(
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.get_operation,
default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

from google.api_core import exceptions as core_exceptions
from google.api_core import gapic_v1
from google.api_core import retry as retries
from google.api_core import retry_async as retries
from google.api_core.client_options import ClientOptions
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore
Expand All @@ -40,9 +40,9 @@
)

try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault]
except AttributeError: # pragma: NO COVER
OptionalRetry = Union[retries.Retry, object] # type: ignore
OptionalRetry = Union[retries.AsyncRetry, object] # type: ignore

from google.api_core import operation # type: ignore
from google.api_core import operation_async # type: ignore
Expand Down Expand Up @@ -298,7 +298,7 @@ async def sample_place_order():
request (Optional[Union[google.cloud.commerce_consumer_procurement_v1alpha1.types.PlaceOrderRequest, dict]]):
The request object. Request message for
[ConsumerProcurementService.PlaceOrder][google.cloud.commerce.consumer.procurement.v1alpha1.ConsumerProcurementService.PlaceOrder].
retry (google.api_core.retry.Retry): Designation of what errors, if any,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
Expand Down Expand Up @@ -410,7 +410,7 @@ async def sample_get_order():
This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
Expand Down Expand Up @@ -459,7 +459,7 @@ async def sample_get_order():
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.get_order,
default_retry=retries.Retry(
default_retry=retries.AsyncRetry(
initial=1.0,
maximum=60.0,
multiplier=1.3,
Expand Down Expand Up @@ -542,7 +542,7 @@ async def sample_list_orders():
This corresponds to the ``parent`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
Expand Down Expand Up @@ -578,7 +578,7 @@ async def sample_list_orders():
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.list_orders,
default_retry=retries.Retry(
default_retry=retries.AsyncRetry(
initial=1.0,
maximum=60.0,
multiplier=1.3,
Expand Down Expand Up @@ -631,7 +631,7 @@ async def get_operation(
request (:class:`~.operations_pb2.GetOperationRequest`):
The request object. Request message for
`GetOperation` method.
retry (google.api_core.retry.Retry): Designation of what errors,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
if any, should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
Expand All @@ -648,7 +648,7 @@ async def get_operation(

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method.wrap_method(
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.get_operation,
default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@

BLACK_VERSION = "black[jupyter]==23.7.0"
ISORT_VERSION = "isort==5.11.0"

LINT_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"]


DEFAULT_PYTHON_VERSION = "3.10"

UNIT_TEST_PYTHON_VERSIONS: List[str] = ["3.7", "3.8", "3.9", "3.10", "3.11"]
UNIT_TEST_PYTHON_VERSIONS: List[str] = ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
UNIT_TEST_STANDARD_DEPENDENCIES = [
"mock",
"asyncmock",
Expand All @@ -47,7 +49,7 @@
UNIT_TEST_EXTRAS: List[str] = []
UNIT_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {}

SYSTEM_TEST_PYTHON_VERSIONS: List[str] = ["3.8", "3.9", "3.10", "3.11"]
SYSTEM_TEST_PYTHON_VERSIONS: List[str] = ["3.8", "3.9", "3.10", "3.11", "3.12"]
SYSTEM_TEST_STANDARD_DEPENDENCIES = [
"mock",
"pytest",
Expand Down Expand Up @@ -89,6 +91,7 @@ def lint(session):
"--check",
*LINT_PATHS,
)

session.run("flake8", "google", "tests")


Expand Down Expand Up @@ -336,7 +339,7 @@ def docfx(session):
)


@nox.session(python="3.11")
@nox.session(python="3.12")
def prerelease_deps(session):
"""Run all tests with prerelease versions of dependencies installed."""

Expand Down
20 changes: 10 additions & 10 deletions packages/google-cloud-commerce-consumer-procurement/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#
import io
import os
import re

import setuptools # type: ignore

Expand All @@ -25,14 +26,16 @@

description = "Google Cloud Commerce Consumer Procurement API client library"

version = {}
version = None

with open(
os.path.join(
package_root, "google/cloud/commerce_consumer_procurement/gapic_version.py"
)
) as fp:
exec(fp.read(), version)
version = version["__version__"]
version_candidates = re.findall(r"(?<=\")\d+.\d+.\d+(?=\")", fp.read())
assert len(version_candidates) == 1
version = version_candidates[0]

if version[0] == "0":
release_status = "Development Status :: 4 - Beta"
Expand All @@ -41,11 +44,10 @@

dependencies = [
"google-api-core[grpc] >= 1.34.0, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,!=2.10.*",
"proto-plus >= 1.22.0, <2.0.0dev",
"proto-plus >= 1.22.2, <2.0.0dev; python_version>='3.11'",
"proto-plus >= 1.22.3, <2.0.0dev",
"protobuf>=3.19.5,<5.0.0dev,!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5",
]
url = "https://github.com/googleapis/google-cloud-python"
url = "https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-commerce-consumer-procurement"

package_root = os.path.abspath(os.path.dirname(__file__))

Expand All @@ -55,12 +57,10 @@

packages = [
package
for package in setuptools.PEP420PackageFinder.find()
for package in setuptools.find_namespace_packages()
if package.startswith("google")
]

namespaces = ["google", "google.cloud"]

setuptools.setup(
name=name,
version=version,
Expand All @@ -81,13 +81,13 @@
"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",
],
platforms="Posix; MacOS X; Windows",
packages=packages,
python_requires=">=3.7",
namespace_packages=namespaces,
install_requires=dependencies,
include_package_data=True,
zip_safe=False,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0dev",
# Then this file should have google-cloud-foo==1.14.0
google-api-core==1.34.0
proto-plus==1.22.0
proto-plus==1.22.3
protobuf==3.19.5
Original file line number Diff line number Diff line change
Expand Up @@ -3279,7 +3279,7 @@ def test_get_operation(transport: str = "grpc"):


@pytest.mark.asyncio
async def test_get_operation_async(transport: str = "grpc"):
async def test_get_operation_async(transport: str = "grpc_asyncio"):
client = ConsumerProcurementServiceAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3281,7 +3281,7 @@ def test_get_operation(transport: str = "grpc"):


@pytest.mark.asyncio
async def test_get_operation_async(transport: str = "grpc"):
async def test_get_operation_async(transport: str = "grpc_asyncio"):
client = ConsumerProcurementServiceAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
Expand Down
Loading

0 comments on commit b96013d

Please sign in to comment.