Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7a1e1d0

Browse files
authored
Merge branch 'main' into any-error
2 parents 7bce39d + b91ed19 commit 7a1e1d0

File tree

8 files changed

+34
-17
lines changed

8 files changed

+34
-17
lines changed

.github/workflows/unittest.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
- "3.10"
2020
- "3.11"
2121
- "3.12"
22+
- "3.13"
2223
exclude:
2324
- option: "_wo_grpc"
2425
python: 3.7

CONTRIBUTING.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ In order to add a feature:
2121
documentation.
2222

2323
- The feature must work fully on the following CPython versions:
24-
3.7, 3.8, 3.9, 3.10, 3.11 and 3.12 on both UNIX and Windows.
24+
3.7, 3.8, 3.9, 3.10, 3.11, 3.12 and 3.13 on both UNIX and Windows.
2525

2626
- The feature must not add unnecessary dependencies (where
2727
"unnecessary" is of course subjective, but new dependencies should
@@ -71,7 +71,7 @@ We use `nox <https://nox.readthedocs.io/en/latest/>`__ to instrument our tests.
7171

7272
- To run a single unit test::
7373

74-
$ nox -s unit-3.12 -- -k <name of test>
74+
$ nox -s unit-3.13 -- -k <name of test>
7575

7676

7777
.. note::
@@ -203,13 +203,15 @@ We support:
203203
- `Python 3.10`_
204204
- `Python 3.11`_
205205
- `Python 3.12`_
206+
- `Python 3.13`_
206207

207208
.. _Python 3.7: https://docs.python.org/3.7/
208209
.. _Python 3.8: https://docs.python.org/3.8/
209210
.. _Python 3.9: https://docs.python.org/3.9/
210211
.. _Python 3.10: https://docs.python.org/3.10/
211212
.. _Python 3.11: https://docs.python.org/3.11/
212213
.. _Python 3.12: https://docs.python.org/3.12/
214+
.. _Python 3.13: https://docs.python.org/3.13/
213215

214216

215217
Supported versions can be found in our ``noxfile.py`` `config`_.

google/api_core/client_options.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,20 @@ def get_client_cert():
4848
4949
"""
5050

51+
from typing import Callable, Mapping, Optional, Sequence, Tuple
52+
5153

5254
class ClientOptions(object):
5355
"""Client Options used to set options on clients.
5456
5557
Args:
5658
api_endpoint (Optional[str]): The desired API endpoint, e.g.,
5759
compute.googleapis.com
58-
client_cert_source (Optional[Callable[[], (bytes, bytes)]]): A callback
60+
client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback
5961
which returns client certificate bytes and private key bytes both in
6062
PEM format. ``client_cert_source`` and ``client_encrypted_cert_source``
6163
are mutually exclusive.
62-
client_encrypted_cert_source (Optional[Callable[[], (str, str, bytes)]]):
64+
client_encrypted_cert_source (Optional[Callable[[], Tuple[str, str, bytes]]]):
6365
A callback which returns client certificate file path, encrypted
6466
private key file path, and the passphrase bytes.``client_cert_source``
6567
and ``client_encrypted_cert_source`` are mutually exclusive.
@@ -88,15 +90,17 @@ class ClientOptions(object):
8890

8991
def __init__(
9092
self,
91-
api_endpoint=None,
92-
client_cert_source=None,
93-
client_encrypted_cert_source=None,
94-
quota_project_id=None,
95-
credentials_file=None,
96-
scopes=None,
97-
api_key=None,
98-
api_audience=None,
99-
universe_domain=None,
93+
api_endpoint: Optional[str] = None,
94+
client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
95+
client_encrypted_cert_source: Optional[
96+
Callable[[], Tuple[str, str, bytes]]
97+
] = None,
98+
quota_project_id: Optional[str] = None,
99+
credentials_file: Optional[str] = None,
100+
scopes: Optional[Sequence[str]] = None,
101+
api_key: Optional[str] = None,
102+
api_audience: Optional[str] = None,
103+
universe_domain: Optional[str] = None,
100104
):
101105
if client_cert_source and client_encrypted_cert_source:
102106
raise ValueError(
@@ -114,11 +118,11 @@ def __init__(
114118
self.api_audience = api_audience
115119
self.universe_domain = universe_domain
116120

117-
def __repr__(self):
121+
def __repr__(self) -> str:
118122
return "ClientOptions: " + repr(self.__dict__)
119123

120124

121-
def from_dict(options):
125+
def from_dict(options: Mapping[str, object]) -> ClientOptions:
122126
"""Construct a client options object from a mapping object.
123127
124128
Args:

noxfile.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
# Black and flake8 clash on the syntax for ignoring flake8's F401 in this file.
2929
BLACK_EXCLUDES = ["--exclude", "^/google/api_core/operations_v1/__init__.py"]
3030

31-
PYTHON_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
31+
PYTHON_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
3232

3333
DEFAULT_PYTHON_VERSION = "3.10"
3434
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
@@ -95,7 +95,8 @@ def install_prerelease_dependencies(session, constraints_path):
9595
prerel_deps = [
9696
"google-auth",
9797
"googleapis-common-protos",
98-
"grpcio",
98+
# Exclude grpcio!=1.67.0rc1 which does not support python 3.13
99+
"grpcio!=1.67.0rc1",
99100
"grpcio-status",
100101
"proto-plus",
101102
"protobuf",
@@ -132,6 +133,7 @@ def default(session, install_grpc=True, prerelease=False, install_async_rest=Fal
132133

133134
install_extras = []
134135
if install_grpc:
136+
# Note: The extra is called `grpc` and not `grpcio`.
135137
install_extras.append("grpc")
136138

137139
constraints_dir = str(CURRENT_DIRECTORY / "testing")

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
"Programming Language :: Python :: 3.10",
9494
"Programming Language :: Python :: 3.11",
9595
"Programming Language :: Python :: 3.12",
96+
"Programming Language :: Python :: 3.13",
9697
"Operating System :: OS Independent",
9798
"Topic :: Internet",
9899
],

testing/constraints-3.13.txt

Whitespace-only changes.

tests/asyncio/retry/test_retry_streaming_async.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ async def test___call___generator_retry(self, sleep):
139139
unpacked = [await generator.__anext__() for i in range(10)]
140140
assert unpacked == [0, 1, 2, 0, 1, 2, 0, 1, 2, 0]
141141
assert on_error.call_count == 3
142+
await generator.aclose()
142143

143144
@mock.patch("random.uniform", autospec=True, side_effect=lambda m, n: n)
144145
@mock.patch("asyncio.sleep", autospec=True)
@@ -246,6 +247,7 @@ async def _mock_send_gen():
246247
recv = await generator.asend(msg)
247248
out_messages.append(recv)
248249
assert in_messages == out_messages
250+
await generator.aclose()
249251

250252
@mock.patch("asyncio.sleep", autospec=True)
251253
@pytest.mark.asyncio
@@ -263,6 +265,7 @@ async def test___call___generator_send_retry(self, sleep):
263265
with pytest.raises(TypeError) as exc_info:
264266
await generator.asend("cannot send to fresh generator")
265267
assert exc_info.match("can't send non-None value")
268+
await generator.aclose()
266269

267270
# error thrown on 3
268271
# generator should contain 0, 1, 2 looping
@@ -271,6 +274,7 @@ async def test___call___generator_send_retry(self, sleep):
271274
unpacked = [await generator.asend(i) for i in range(10)]
272275
assert unpacked == [1, 2, 0, 1, 2, 0, 1, 2, 0, 1]
273276
assert on_error.call_count == 3
277+
await generator.aclose()
274278

275279
@mock.patch("asyncio.sleep", autospec=True)
276280
@pytest.mark.asyncio
@@ -382,6 +386,7 @@ async def wrapper():
382386
assert await retryable.asend("test") == 1
383387
assert await retryable.asend("test2") == 2
384388
assert await retryable.asend("test3") == 3
389+
await retryable.aclose()
385390

386391
@pytest.mark.parametrize("awaitable_wrapped", [True, False])
387392
@mock.patch("asyncio.sleep", autospec=True)

tests/asyncio/test_page_iterator_async.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ async def test__page_aiter_increment(self):
110110
await page_aiter.__anext__()
111111

112112
assert iterator.num_results == 1
113+
await page_aiter.aclose()
113114

114115
@pytest.mark.asyncio
115116
async def test__page_aiter_no_increment(self):
@@ -122,6 +123,7 @@ async def test__page_aiter_no_increment(self):
122123

123124
# results should still be 0 after fetching a page.
124125
assert iterator.num_results == 0
126+
await page_aiter.aclose()
125127

126128
@pytest.mark.asyncio
127129
async def test__items_aiter(self):

0 commit comments

Comments
 (0)