Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit 212337f

Browse files
authored
chore: fix mypy issue for __func__ type (#2562)
1 parent d6098ca commit 212337f

File tree

21 files changed

+174
-30
lines changed

21 files changed

+174
-30
lines changed

.github/workflows/tests.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -405,13 +405,13 @@ jobs:
405405
- name: Install nox.
406406
run: |
407407
python -m pip install nox
408-
- name: Run blacken and lint on the generated output.
408+
- name: Run format, lint, and mypy on the generated output.
409409
run: |
410-
nox -f tests/integration/goldens/asset/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
411-
nox -f tests/integration/goldens/credentials/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
412-
nox -f tests/integration/goldens/eventarc/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
413-
nox -f tests/integration/goldens/logging/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
414-
nox -f tests/integration/goldens/redis/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
410+
nox -f tests/integration/goldens/asset/noxfile.py -s format lint mypy-${{ env.LATEST_STABLE_PYTHON }}
411+
nox -f tests/integration/goldens/credentials/noxfile.py -s format lint mypy-${{ env.LATEST_STABLE_PYTHON }}
412+
nox -f tests/integration/goldens/eventarc/noxfile.py -s format lint mypy-${{ env.LATEST_STABLE_PYTHON }}
413+
nox -f tests/integration/goldens/logging/noxfile.py -s format lint mypy-${{ env.LATEST_STABLE_PYTHON }}
414+
nox -f tests/integration/goldens/redis/noxfile.py -s format lint mypy-${{ env.LATEST_STABLE_PYTHON }}
415415
goldens-unit:
416416
runs-on: ubuntu-latest
417417
steps:

gapic/templates/%namespace/%name_%version/%sub/services/%service/async_client.py.j2

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ class {{ service.async_client_name }}:
9898
Returns:
9999
{{ service.async_client_name }}: The constructed client.
100100
"""
101-
sa_info_func = {{ service.client_name }}.from_service_account_info.__func__ # type: ignore
101+
sa_info_func = (
102+
{{ service.client_name }}.from_service_account_info.__func__ # type: ignore
103+
)
102104
return sa_info_func({{ service.async_client_name }}, info, *args, **kwargs)
103105

104106
@classmethod
@@ -115,7 +117,9 @@ class {{ service.async_client_name }}:
115117
Returns:
116118
{{ service.async_client_name }}: The constructed client.
117119
"""
118-
sa_file_func = {{ service.client_name }}.from_service_account_file.__func__ # type: ignore
120+
sa_file_func = (
121+
{{ service.client_name }}.from_service_account_file.__func__ # type: ignore
122+
)
119123
return sa_file_func({{ service.async_client_name }}, filename, *args, **kwargs)
120124

121125
from_service_account_json = from_service_account_file

gapic/templates/mypy.ini.j2

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
11
[mypy]
22
python_version = 3.14
33
namespace_packages = True
4+
ignore_missing_imports = False
5+
6+
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2563):
7+
# Dependencies that historically lacks py.typed markers
8+
[mypy-google.iam.*]
9+
ignore_missing_imports = True
10+
11+
# Helps mypy navigate the 'google' namespace more reliably in 3.10+
12+
explicit_package_bases = True
13+
14+
# Performance: reuse results from previous runs to speed up 'nox'
15+
incremental = True

tests/integration/goldens/asset/google/cloud/asset_v1/services/asset_service/async_client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ def from_service_account_info(cls, info: dict, *args, **kwargs):
106106
Returns:
107107
AssetServiceAsyncClient: The constructed client.
108108
"""
109-
sa_info_func = AssetServiceClient.from_service_account_info.__func__ # type: ignore
109+
sa_info_func = (
110+
AssetServiceClient.from_service_account_info.__func__ # type: ignore
111+
)
110112
return sa_info_func(AssetServiceAsyncClient, info, *args, **kwargs)
111113

112114
@classmethod
@@ -123,7 +125,9 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
123125
Returns:
124126
AssetServiceAsyncClient: The constructed client.
125127
"""
126-
sa_file_func = AssetServiceClient.from_service_account_file.__func__ # type: ignore
128+
sa_file_func = (
129+
AssetServiceClient.from_service_account_file.__func__ # type: ignore
130+
)
127131
return sa_file_func(AssetServiceAsyncClient, filename, *args, **kwargs)
128132

129133
from_service_account_json = from_service_account_file
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
11
[mypy]
22
python_version = 3.14
33
namespace_packages = True
4+
ignore_missing_imports = False
5+
6+
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2563):
7+
# Dependencies that historically lacks py.typed markers
8+
[mypy-google.iam.*]
9+
ignore_missing_imports = True
10+
11+
# Helps mypy navigate the 'google' namespace more reliably in 3.10+
12+
explicit_package_bases = True
13+
14+
# Performance: reuse results from previous runs to speed up 'nox'
15+
incremental = True

tests/integration/goldens/credentials/google/iam/credentials_v1/services/iam_credentials/async_client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ def from_service_account_info(cls, info: dict, *args, **kwargs):
9797
Returns:
9898
IAMCredentialsAsyncClient: The constructed client.
9999
"""
100-
sa_info_func = IAMCredentialsClient.from_service_account_info.__func__ # type: ignore
100+
sa_info_func = (
101+
IAMCredentialsClient.from_service_account_info.__func__ # type: ignore
102+
)
101103
return sa_info_func(IAMCredentialsAsyncClient, info, *args, **kwargs)
102104

103105
@classmethod
@@ -114,7 +116,9 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
114116
Returns:
115117
IAMCredentialsAsyncClient: The constructed client.
116118
"""
117-
sa_file_func = IAMCredentialsClient.from_service_account_file.__func__ # type: ignore
119+
sa_file_func = (
120+
IAMCredentialsClient.from_service_account_file.__func__ # type: ignore
121+
)
118122
return sa_file_func(IAMCredentialsAsyncClient, filename, *args, **kwargs)
119123

120124
from_service_account_json = from_service_account_file
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
11
[mypy]
22
python_version = 3.14
33
namespace_packages = True
4+
ignore_missing_imports = False
5+
6+
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2563):
7+
# Dependencies that historically lacks py.typed markers
8+
[mypy-google.iam.*]
9+
ignore_missing_imports = True
10+
11+
# Helps mypy navigate the 'google' namespace more reliably in 3.10+
12+
explicit_package_bases = True
13+
14+
# Performance: reuse results from previous runs to speed up 'nox'
15+
incremental = True

tests/integration/goldens/eventarc/google/cloud/eventarc_v1/services/eventarc/async_client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ def from_service_account_info(cls, info: dict, *args, **kwargs):
124124
Returns:
125125
EventarcAsyncClient: The constructed client.
126126
"""
127-
sa_info_func = EventarcClient.from_service_account_info.__func__ # type: ignore
127+
sa_info_func = (
128+
EventarcClient.from_service_account_info.__func__ # type: ignore
129+
)
128130
return sa_info_func(EventarcAsyncClient, info, *args, **kwargs)
129131

130132
@classmethod
@@ -141,7 +143,9 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
141143
Returns:
142144
EventarcAsyncClient: The constructed client.
143145
"""
144-
sa_file_func = EventarcClient.from_service_account_file.__func__ # type: ignore
146+
sa_file_func = (
147+
EventarcClient.from_service_account_file.__func__ # type: ignore
148+
)
145149
return sa_file_func(EventarcAsyncClient, filename, *args, **kwargs)
146150

147151
from_service_account_json = from_service_account_file
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
11
[mypy]
22
python_version = 3.14
33
namespace_packages = True
4+
ignore_missing_imports = False
5+
6+
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2563):
7+
# Dependencies that historically lacks py.typed markers
8+
[mypy-google.iam.*]
9+
ignore_missing_imports = True
10+
11+
# Helps mypy navigate the 'google' namespace more reliably in 3.10+
12+
explicit_package_bases = True
13+
14+
# Performance: reuse results from previous runs to speed up 'nox'
15+
incremental = True

tests/integration/goldens/logging/google/cloud/logging_v2/services/config_service_v2/async_client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ def from_service_account_info(cls, info: dict, *args, **kwargs):
104104
Returns:
105105
ConfigServiceV2AsyncClient: The constructed client.
106106
"""
107-
sa_info_func = ConfigServiceV2Client.from_service_account_info.__func__ # type: ignore
107+
sa_info_func = (
108+
ConfigServiceV2Client.from_service_account_info.__func__ # type: ignore
109+
)
108110
return sa_info_func(ConfigServiceV2AsyncClient, info, *args, **kwargs)
109111

110112
@classmethod
@@ -121,7 +123,9 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
121123
Returns:
122124
ConfigServiceV2AsyncClient: The constructed client.
123125
"""
124-
sa_file_func = ConfigServiceV2Client.from_service_account_file.__func__ # type: ignore
126+
sa_file_func = (
127+
ConfigServiceV2Client.from_service_account_file.__func__ # type: ignore
128+
)
125129
return sa_file_func(ConfigServiceV2AsyncClient, filename, *args, **kwargs)
126130

127131
from_service_account_json = from_service_account_file

0 commit comments

Comments
 (0)