Skip to content

Commit 2d65221

Browse files
authored
Merge branch 'main' into fix-bigtable-tests
2 parents 1b54803 + c824b6d commit 2d65221

21 files changed

Lines changed: 273 additions & 96 deletions

File tree

.github/workflows/import-profiler.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ jobs:
2626
with:
2727
python-version: "3.15"
2828
allow-prereleases: true
29-
- name: Upgrade pip, setuptools, and wheel
30-
run: |
31-
python -m pip install --upgrade setuptools pip wheel
3229
- name: Run import profiler
3330
env:
3431
BUILD_TYPE: presubmit

librarian.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,7 +1685,6 @@ libraries:
16851685
version: 2.39.0
16861686
apis:
16871687
- path: google/pubsub/v1
1688-
skip_generate: true
16891688
python:
16901689
library_type: GAPIC_COMBO
16911690
opt_args_by_api:
@@ -1932,7 +1931,6 @@ libraries:
19321931
- docs/spanner_v1/table.rst
19331932
- docs/spanner_v1/transaction.rst
19341933
- tests/unit/gapic/conftest.py
1935-
skip_generate: true
19361934
python:
19371935
library_type: GAPIC_COMBO
19381936
opt_args_by_api:

packages/google-api-core/google/api_core/gapic_v1/__init__.py

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,44 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from google.api_core.gapic_v1 import client_info
16-
from google.api_core.gapic_v1 import config
17-
from google.api_core.gapic_v1 import config_async
18-
from google.api_core.gapic_v1 import method
19-
from google.api_core.gapic_v1 import method_async
20-
from google.api_core.gapic_v1 import routing_header
15+
import importlib.util
16+
from typing import Set
2117

22-
__all__ = [
23-
"client_info",
24-
"config",
25-
"config_async",
26-
"method",
27-
"method_async",
28-
"routing_header",
29-
]
18+
_has_grpc = importlib.util.find_spec("grpc") is not None
19+
20+
# PEP 0810: Explicit Lazy Imports
21+
# Python 3.15+ natively intercepts and defers these imports.
22+
# Developers can disable this behavior and force eager imports.
23+
# For more information, see:
24+
# https://docs.python.org/3.15/library/sys.html#sys.set_lazy_imports_filter
25+
# Older Python versions safely ignore this variable.
26+
__lazy_modules__: Set[str] = {
27+
"google.api_core.gapic_v1.client_info",
28+
"google.api_core.gapic_v1.routing_header",
29+
}
30+
__all__ = ["client_info", "routing_header"]
31+
32+
if _has_grpc:
33+
__lazy_modules__.update(
34+
{
35+
"google.api_core.gapic_v1.config",
36+
"google.api_core.gapic_v1.config_async",
37+
"google.api_core.gapic_v1.method",
38+
"google.api_core.gapic_v1.method_async",
39+
}
40+
)
41+
42+
from google.api_core.gapic_v1 import ( # noqa: E402
43+
client_info,
44+
routing_header,
45+
)
46+
47+
if _has_grpc:
48+
from google.api_core.gapic_v1 import ( # noqa: F401
49+
config,
50+
config_async,
51+
method,
52+
method_async,
53+
)
54+
55+
__all__.extend(["config", "config_async", "method", "method_async"])

packages/google-api-core/tests/asyncio/retry/test_retry_streaming_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ async def test___call___generator_send_retry(self, sleep):
293293
generator = await retry_(self._generator_mock)(error_on=3)
294294
with pytest.raises(TypeError) as exc_info:
295295
await generator.asend("cannot send to fresh generator")
296-
assert exc_info.match("can't send non-None value")
296+
assert exc_info.match("can't send non-None value")
297297
await generator.aclose()
298298

299299
# error thrown on 3

packages/google-api-core/tests/unit/retry/test_retry_streaming.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def test___call___with_generator_send_retry(self, sleep):
263263
with pytest.raises(TypeError) as exc_info:
264264
# calling first send with non-None input should raise a TypeError
265265
result.send("can not send to fresh generator")
266-
assert exc_info.match("can't send non-None value")
266+
assert exc_info.match("can't send non-None value")
267267
# initiate iteration with None
268268
result = retry_(self._generator_mock)(error_on=3)
269269
assert result.send(None) == 0

packages/google-cloud-pubsub/mypy.ini

Lines changed: 0 additions & 15 deletions
This file was deleted.

packages/google-cloud-pubsub/noxfile.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,24 @@
3636
"3.12",
3737
"3.13",
3838
"3.14",
39+
"3.15",
3940
]
4041

4142
DEFAULT_PYTHON_VERSION = "3.14"
4243

43-
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2450):
44-
# Switch this to Python 3.15 alpha1
45-
# https://peps.python.org/pep-0790/
46-
PREVIEW_PYTHON_VERSION = "3.14"
44+
PREVIEW_PYTHON_VERSION = "3.15"
4745

4846
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
47+
# Path to the centralized mypy configuration file at the repository root.
48+
# Search upwards to support running nox from both monorepo packages and integration test goldens.
49+
MYPY_CONFIG_FILE = next(
50+
(
51+
str(p / "mypy.ini")
52+
for p in CURRENT_DIRECTORY.parents
53+
if (p / "mypy.ini").exists()
54+
),
55+
str(CURRENT_DIRECTORY.parent.parent / "mypy.ini"),
56+
)
4957

5058
if (CURRENT_DIRECTORY / "testing").exists():
5159
LOWER_BOUND_CONSTRAINTS_FILE = (
@@ -615,7 +623,7 @@ def prerelease_deps(session, protobuf_implementation):
615623
)
616624

617625

618-
@nox.session(python=DEFAULT_PYTHON_VERSION)
626+
@nox.session(python=PREVIEW_PYTHON_VERSION)
619627
@nox.parametrize(
620628
"protobuf_implementation",
621629
["python", "upb"],
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# We use the constraints file for the latest Python version
2+
# (currently this file) to check that the latest
3+
# major versions of dependencies are supported in setup.py.
4+
# List all library dependencies and extras in this file.
5+
# Require the latest major version be installed for each dependency.
6+
# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0",
7+
# Then this file should have google-cloud-foo>=1
8+
google-api-core>=2
9+
google-auth>=2
10+
grpcio>=1
11+
proto-plus>=1
12+
protobuf>=7
13+
grpc-google-iam-v1>=0

packages/google-cloud-pubsub/tests/unit/gapic/pubsub_v1/test_publisher.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3000,6 +3000,9 @@ def test_list_topics_pager(transport_name: str = "grpc"):
30003000
assert pager._retry == retry
30013001
assert pager._timeout == timeout
30023002

3003+
assert pager.next_page_token == "abc"
3004+
assert str(pager).startswith(f"{pager.__class__.__name__}<")
3005+
30033006
results = list(pager)
30043007
assert len(results) == 6
30053008
assert all(isinstance(i, pubsub.Topic) for i in results)
@@ -3088,6 +3091,8 @@ async def test_list_topics_async_pager():
30883091
request={},
30893092
)
30903093
assert async_pager.next_page_token == "abc"
3094+
assert str(async_pager).startswith(f"{async_pager.__class__.__name__}<")
3095+
30913096
responses = []
30923097
async for response in async_pager: # pragma: no branch
30933098
responses.append(response)
@@ -3545,6 +3550,9 @@ def test_list_topic_subscriptions_pager(transport_name: str = "grpc"):
35453550
assert pager._retry == retry
35463551
assert pager._timeout == timeout
35473552

3553+
assert pager.next_page_token == "abc"
3554+
assert str(pager).startswith(f"{pager.__class__.__name__}<")
3555+
35483556
results = list(pager)
35493557
assert len(results) == 6
35503558
assert all(isinstance(i, str) for i in results)
@@ -3637,6 +3645,8 @@ async def test_list_topic_subscriptions_async_pager():
36373645
request={},
36383646
)
36393647
assert async_pager.next_page_token == "abc"
3648+
assert str(async_pager).startswith(f"{async_pager.__class__.__name__}<")
3649+
36403650
responses = []
36413651
async for response in async_pager: # pragma: no branch
36423652
responses.append(response)
@@ -4093,6 +4103,9 @@ def test_list_topic_snapshots_pager(transport_name: str = "grpc"):
40934103
assert pager._retry == retry
40944104
assert pager._timeout == timeout
40954105

4106+
assert pager.next_page_token == "abc"
4107+
assert str(pager).startswith(f"{pager.__class__.__name__}<")
4108+
40964109
results = list(pager)
40974110
assert len(results) == 6
40984111
assert all(isinstance(i, str) for i in results)
@@ -4185,6 +4198,8 @@ async def test_list_topic_snapshots_async_pager():
41854198
request={},
41864199
)
41874200
assert async_pager.next_page_token == "abc"
4201+
assert str(async_pager).startswith(f"{async_pager.__class__.__name__}<")
4202+
41884203
responses = []
41894204
async for response in async_pager: # pragma: no branch
41904205
responses.append(response)
@@ -5758,6 +5773,9 @@ def test_list_topics_rest_pager(transport: str = "rest"):
57585773

57595774
pager = client.list_topics(request=sample_request)
57605775

5776+
assert pager.next_page_token == "abc"
5777+
assert str(pager).startswith(f"{pager.__class__.__name__}<")
5778+
57615779
results = list(pager)
57625780
assert len(results) == 6
57635781
assert all(isinstance(i, pubsub.Topic) for i in results)
@@ -6018,6 +6036,9 @@ def test_list_topic_subscriptions_rest_pager(transport: str = "rest"):
60186036

60196037
pager = client.list_topic_subscriptions(request=sample_request)
60206038

6039+
assert pager.next_page_token == "abc"
6040+
assert str(pager).startswith(f"{pager.__class__.__name__}<")
6041+
60216042
results = list(pager)
60226043
assert len(results) == 6
60236044
assert all(isinstance(i, str) for i in results)
@@ -6275,6 +6296,9 @@ def test_list_topic_snapshots_rest_pager(transport: str = "rest"):
62756296

62766297
pager = client.list_topic_snapshots(request=sample_request)
62776298

6299+
assert pager.next_page_token == "abc"
6300+
assert str(pager).startswith(f"{pager.__class__.__name__}<")
6301+
62786302
results = list(pager)
62796303
assert len(results) == 6
62806304
assert all(isinstance(i, str) for i in results)

packages/google-cloud-pubsub/tests/unit/gapic/pubsub_v1/test_schema_service.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2390,6 +2390,9 @@ def test_list_schemas_pager(transport_name: str = "grpc"):
23902390
assert pager._retry == retry
23912391
assert pager._timeout == timeout
23922392

2393+
assert pager.next_page_token == "abc"
2394+
assert str(pager).startswith(f"{pager.__class__.__name__}<")
2395+
23932396
results = list(pager)
23942397
assert len(results) == 6
23952398
assert all(isinstance(i, schema.Schema) for i in results)
@@ -2478,6 +2481,8 @@ async def test_list_schemas_async_pager():
24782481
request={},
24792482
)
24802483
assert async_pager.next_page_token == "abc"
2484+
assert str(async_pager).startswith(f"{async_pager.__class__.__name__}<")
2485+
24812486
responses = []
24822487
async for response in async_pager: # pragma: no branch
24832488
responses.append(response)
@@ -2929,6 +2934,9 @@ def test_list_schema_revisions_pager(transport_name: str = "grpc"):
29292934
assert pager._retry == retry
29302935
assert pager._timeout == timeout
29312936

2937+
assert pager.next_page_token == "abc"
2938+
assert str(pager).startswith(f"{pager.__class__.__name__}<")
2939+
29322940
results = list(pager)
29332941
assert len(results) == 6
29342942
assert all(isinstance(i, schema.Schema) for i in results)
@@ -3021,6 +3029,8 @@ async def test_list_schema_revisions_async_pager():
30213029
request={},
30223030
)
30233031
assert async_pager.next_page_token == "abc"
3032+
assert str(async_pager).startswith(f"{async_pager.__class__.__name__}<")
3033+
30243034
responses = []
30253035
async for response in async_pager: # pragma: no branch
30263036
responses.append(response)
@@ -5615,6 +5625,9 @@ def test_list_schemas_rest_pager(transport: str = "rest"):
56155625

56165626
pager = client.list_schemas(request=sample_request)
56175627

5628+
assert pager.next_page_token == "abc"
5629+
assert str(pager).startswith(f"{pager.__class__.__name__}<")
5630+
56185631
results = list(pager)
56195632
assert len(results) == 6
56205633
assert all(isinstance(i, schema.Schema) for i in results)
@@ -5877,6 +5890,9 @@ def test_list_schema_revisions_rest_pager(transport: str = "rest"):
58775890

58785891
pager = client.list_schema_revisions(request=sample_request)
58795892

5893+
assert pager.next_page_token == "abc"
5894+
assert str(pager).startswith(f"{pager.__class__.__name__}<")
5895+
58805896
results = list(pager)
58815897
assert len(results) == 6
58825898
assert all(isinstance(i, schema.Schema) for i in results)

0 commit comments

Comments
 (0)