Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -405,13 +405,13 @@ jobs:
- name: Install nox.
run: |
python -m pip install nox
- name: Run blacken and lint on the generated output.
- name: Run format, lint, and mypy on the generated output.
run: |
nox -f tests/integration/goldens/asset/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
nox -f tests/integration/goldens/credentials/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
nox -f tests/integration/goldens/eventarc/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
nox -f tests/integration/goldens/logging/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
nox -f tests/integration/goldens/redis/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
nox -f tests/integration/goldens/asset/noxfile.py -s format lint mypy-${{ env.LATEST_STABLE_PYTHON }}
nox -f tests/integration/goldens/credentials/noxfile.py -s format lint mypy-${{ env.LATEST_STABLE_PYTHON }}
nox -f tests/integration/goldens/eventarc/noxfile.py -s format lint mypy-${{ env.LATEST_STABLE_PYTHON }}
nox -f tests/integration/goldens/logging/noxfile.py -s format lint mypy-${{ env.LATEST_STABLE_PYTHON }}
nox -f tests/integration/goldens/redis/noxfile.py -s format lint mypy-${{ env.LATEST_STABLE_PYTHON }}
goldens-unit:
runs-on: ubuntu-latest
steps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ class {{ service.async_client_name }}:
Returns:
{{ service.async_client_name }}: The constructed client.
"""
sa_info_func = {{ service.client_name }}.from_service_account_info.__func__ # type: ignore
sa_info_func = (
{{ service.client_name }}.from_service_account_info.__func__ # type: ignore
)
return sa_info_func({{ service.async_client_name }}, info, *args, **kwargs)

@classmethod
Expand All @@ -115,7 +117,9 @@ class {{ service.async_client_name }}:
Returns:
{{ service.async_client_name }}: The constructed client.
"""
sa_file_func = {{ service.client_name }}.from_service_account_file.__func__ # type: ignore
sa_file_func = (
{{ service.client_name }}.from_service_account_file.__func__ # type: ignore
)
return sa_file_func({{ service.async_client_name }}, filename, *args, **kwargs)

from_service_account_json = from_service_account_file
Expand Down
13 changes: 13 additions & 0 deletions gapic/templates/mypy.ini.j2
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
[mypy]
python_version = 3.14
namespace_packages = True

# FIX: Prevents failure when dependencies (like google-iam) lack type hints
ignore_missing_imports = True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not totally against this change. But if we could silence specific imports, that would probably be cleaner.

Sometimes the errors can be solved by adding a types-xyz import to the noxfile, so it's probably better to do that instead of silence it where we can


# FIX: Silences the "note: By default the bodies of untyped functions are not checked"
# This keeps CI logs clean and focused on actual errors.
check_untyped_defs = False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I addressed this in this PR by configuring mypy to check the untyped defs. Maybe we should remove this silencing, and try to get that other PR iin instead?


# Helps mypy navigate the 'google' namespace more reliably in 3.10+
explicit_package_bases = True

# Performance: reuse results from previous runs to speed up 'nox'
incremental = True
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ def from_service_account_info(cls, info: dict, *args, **kwargs):
Returns:
AssetServiceAsyncClient: The constructed client.
"""
sa_info_func = AssetServiceClient.from_service_account_info.__func__ # type: ignore
sa_info_func = (
AssetServiceClient.from_service_account_info.__func__ # type: ignore
)
return sa_info_func(AssetServiceAsyncClient, info, *args, **kwargs)

@classmethod
Expand All @@ -123,7 +125,9 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
Returns:
AssetServiceAsyncClient: The constructed client.
"""
sa_file_func = AssetServiceClient.from_service_account_file.__func__ # type: ignore
sa_file_func = (
AssetServiceClient.from_service_account_file.__func__ # type: ignore
)
return sa_file_func(AssetServiceAsyncClient, filename, *args, **kwargs)

from_service_account_json = from_service_account_file
Expand Down
13 changes: 13 additions & 0 deletions tests/integration/goldens/asset/mypy.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
[mypy]
python_version = 3.14
namespace_packages = True

# FIX: Prevents failure when dependencies (like google-iam) lack type hints
ignore_missing_imports = True

# FIX: Silences the "note: By default the bodies of untyped functions are not checked"
# This keeps CI logs clean and focused on actual errors.
check_untyped_defs = False

# Helps mypy navigate the 'google' namespace more reliably in 3.10+
explicit_package_bases = True

# Performance: reuse results from previous runs to speed up 'nox'
incremental = True
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ def from_service_account_info(cls, info: dict, *args, **kwargs):
Returns:
IAMCredentialsAsyncClient: The constructed client.
"""
sa_info_func = IAMCredentialsClient.from_service_account_info.__func__ # type: ignore
sa_info_func = (
IAMCredentialsClient.from_service_account_info.__func__ # type: ignore
)
return sa_info_func(IAMCredentialsAsyncClient, info, *args, **kwargs)

@classmethod
Expand All @@ -114,7 +116,9 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
Returns:
IAMCredentialsAsyncClient: The constructed client.
"""
sa_file_func = IAMCredentialsClient.from_service_account_file.__func__ # type: ignore
sa_file_func = (
IAMCredentialsClient.from_service_account_file.__func__ # type: ignore
)
return sa_file_func(IAMCredentialsAsyncClient, filename, *args, **kwargs)

from_service_account_json = from_service_account_file
Expand Down
13 changes: 13 additions & 0 deletions tests/integration/goldens/credentials/mypy.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
[mypy]
python_version = 3.14
namespace_packages = True

# FIX: Prevents failure when dependencies (like google-iam) lack type hints
ignore_missing_imports = True

# FIX: Silences the "note: By default the bodies of untyped functions are not checked"
# This keeps CI logs clean and focused on actual errors.
check_untyped_defs = False

# Helps mypy navigate the 'google' namespace more reliably in 3.10+
explicit_package_bases = True

# Performance: reuse results from previous runs to speed up 'nox'
incremental = True
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ def from_service_account_info(cls, info: dict, *args, **kwargs):
Returns:
EventarcAsyncClient: The constructed client.
"""
sa_info_func = EventarcClient.from_service_account_info.__func__ # type: ignore
sa_info_func = (
EventarcClient.from_service_account_info.__func__ # type: ignore
)
return sa_info_func(EventarcAsyncClient, info, *args, **kwargs)

@classmethod
Expand All @@ -141,7 +143,9 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
Returns:
EventarcAsyncClient: The constructed client.
"""
sa_file_func = EventarcClient.from_service_account_file.__func__ # type: ignore
sa_file_func = (
EventarcClient.from_service_account_file.__func__ # type: ignore
)
return sa_file_func(EventarcAsyncClient, filename, *args, **kwargs)

from_service_account_json = from_service_account_file
Expand Down
13 changes: 13 additions & 0 deletions tests/integration/goldens/eventarc/mypy.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
[mypy]
python_version = 3.14
namespace_packages = True

# FIX: Prevents failure when dependencies (like google-iam) lack type hints
ignore_missing_imports = True

# FIX: Silences the "note: By default the bodies of untyped functions are not checked"
# This keeps CI logs clean and focused on actual errors.
check_untyped_defs = False

# Helps mypy navigate the 'google' namespace more reliably in 3.10+
explicit_package_bases = True

# Performance: reuse results from previous runs to speed up 'nox'
incremental = True
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ def from_service_account_info(cls, info: dict, *args, **kwargs):
Returns:
ConfigServiceV2AsyncClient: The constructed client.
"""
sa_info_func = ConfigServiceV2Client.from_service_account_info.__func__ # type: ignore
sa_info_func = (
ConfigServiceV2Client.from_service_account_info.__func__ # type: ignore
)
return sa_info_func(ConfigServiceV2AsyncClient, info, *args, **kwargs)

@classmethod
Expand All @@ -121,7 +123,9 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
Returns:
ConfigServiceV2AsyncClient: The constructed client.
"""
sa_file_func = ConfigServiceV2Client.from_service_account_file.__func__ # type: ignore
sa_file_func = (
ConfigServiceV2Client.from_service_account_file.__func__ # type: ignore
)
return sa_file_func(ConfigServiceV2AsyncClient, filename, *args, **kwargs)

from_service_account_json = from_service_account_file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ def from_service_account_info(cls, info: dict, *args, **kwargs):
Returns:
LoggingServiceV2AsyncClient: The constructed client.
"""
sa_info_func = LoggingServiceV2Client.from_service_account_info.__func__ # type: ignore
sa_info_func = (
LoggingServiceV2Client.from_service_account_info.__func__ # type: ignore
)
return sa_info_func(LoggingServiceV2AsyncClient, info, *args, **kwargs)

@classmethod
Expand All @@ -106,7 +108,9 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
Returns:
LoggingServiceV2AsyncClient: The constructed client.
"""
sa_file_func = LoggingServiceV2Client.from_service_account_file.__func__ # type: ignore
sa_file_func = (
LoggingServiceV2Client.from_service_account_file.__func__ # type: ignore
)
return sa_file_func(LoggingServiceV2AsyncClient, filename, *args, **kwargs)

from_service_account_json = from_service_account_file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ def from_service_account_info(cls, info: dict, *args, **kwargs):
Returns:
MetricsServiceV2AsyncClient: The constructed client.
"""
sa_info_func = MetricsServiceV2Client.from_service_account_info.__func__ # type: ignore
sa_info_func = (
MetricsServiceV2Client.from_service_account_info.__func__ # type: ignore
)
return sa_info_func(MetricsServiceV2AsyncClient, info, *args, **kwargs)

@classmethod
Expand All @@ -107,7 +109,9 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
Returns:
MetricsServiceV2AsyncClient: The constructed client.
"""
sa_file_func = MetricsServiceV2Client.from_service_account_file.__func__ # type: ignore
sa_file_func = (
MetricsServiceV2Client.from_service_account_file.__func__ # type: ignore
)
return sa_file_func(MetricsServiceV2AsyncClient, filename, *args, **kwargs)

from_service_account_json = from_service_account_file
Expand Down
13 changes: 13 additions & 0 deletions tests/integration/goldens/logging/mypy.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
[mypy]
python_version = 3.14
namespace_packages = True

# FIX: Prevents failure when dependencies (like google-iam) lack type hints
ignore_missing_imports = True

# FIX: Silences the "note: By default the bodies of untyped functions are not checked"
# This keeps CI logs clean and focused on actual errors.
check_untyped_defs = False

# Helps mypy navigate the 'google' namespace more reliably in 3.10+
explicit_package_bases = True

# Performance: reuse results from previous runs to speed up 'nox'
incremental = True
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ def from_service_account_info(cls, info: dict, *args, **kwargs):
Returns:
BaseConfigServiceV2AsyncClient: The constructed client.
"""
sa_info_func = BaseConfigServiceV2Client.from_service_account_info.__func__ # type: ignore
sa_info_func = (
BaseConfigServiceV2Client.from_service_account_info.__func__ # type: ignore
)
return sa_info_func(BaseConfigServiceV2AsyncClient, info, *args, **kwargs)

@classmethod
Expand All @@ -121,7 +123,9 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
Returns:
BaseConfigServiceV2AsyncClient: The constructed client.
"""
sa_file_func = BaseConfigServiceV2Client.from_service_account_file.__func__ # type: ignore
sa_file_func = (
BaseConfigServiceV2Client.from_service_account_file.__func__ # type: ignore
)
return sa_file_func(BaseConfigServiceV2AsyncClient, filename, *args, **kwargs)

from_service_account_json = from_service_account_file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ def from_service_account_info(cls, info: dict, *args, **kwargs):
Returns:
LoggingServiceV2AsyncClient: The constructed client.
"""
sa_info_func = LoggingServiceV2Client.from_service_account_info.__func__ # type: ignore
sa_info_func = (
LoggingServiceV2Client.from_service_account_info.__func__ # type: ignore
)
return sa_info_func(LoggingServiceV2AsyncClient, info, *args, **kwargs)

@classmethod
Expand All @@ -106,7 +108,9 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
Returns:
LoggingServiceV2AsyncClient: The constructed client.
"""
sa_file_func = LoggingServiceV2Client.from_service_account_file.__func__ # type: ignore
sa_file_func = (
LoggingServiceV2Client.from_service_account_file.__func__ # type: ignore
)
return sa_file_func(LoggingServiceV2AsyncClient, filename, *args, **kwargs)

from_service_account_json = from_service_account_file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ def from_service_account_info(cls, info: dict, *args, **kwargs):
Returns:
BaseMetricsServiceV2AsyncClient: The constructed client.
"""
sa_info_func = BaseMetricsServiceV2Client.from_service_account_info.__func__ # type: ignore
sa_info_func = (
BaseMetricsServiceV2Client.from_service_account_info.__func__ # type: ignore
)
return sa_info_func(BaseMetricsServiceV2AsyncClient, info, *args, **kwargs)

@classmethod
Expand All @@ -107,7 +109,9 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
Returns:
BaseMetricsServiceV2AsyncClient: The constructed client.
"""
sa_file_func = BaseMetricsServiceV2Client.from_service_account_file.__func__ # type: ignore
sa_file_func = (
BaseMetricsServiceV2Client.from_service_account_file.__func__ # type: ignore
)
return sa_file_func(BaseMetricsServiceV2AsyncClient, filename, *args, **kwargs)

from_service_account_json = from_service_account_file
Expand Down
13 changes: 13 additions & 0 deletions tests/integration/goldens/logging_internal/mypy.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
[mypy]
python_version = 3.14
namespace_packages = True

# FIX: Prevents failure when dependencies (like google-iam) lack type hints
ignore_missing_imports = True

# FIX: Silences the "note: By default the bodies of untyped functions are not checked"
# This keeps CI logs clean and focused on actual errors.
check_untyped_defs = False

# Helps mypy navigate the 'google' namespace more reliably in 3.10+
explicit_package_bases = True

# Performance: reuse results from previous runs to speed up 'nox'
incremental = True
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ def from_service_account_info(cls, info: dict, *args, **kwargs):
Returns:
CloudRedisAsyncClient: The constructed client.
"""
sa_info_func = CloudRedisClient.from_service_account_info.__func__ # type: ignore
sa_info_func = (
CloudRedisClient.from_service_account_info.__func__ # type: ignore
)
return sa_info_func(CloudRedisAsyncClient, info, *args, **kwargs)

@classmethod
Expand All @@ -131,7 +133,9 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
Returns:
CloudRedisAsyncClient: The constructed client.
"""
sa_file_func = CloudRedisClient.from_service_account_file.__func__ # type: ignore
sa_file_func = (
CloudRedisClient.from_service_account_file.__func__ # type: ignore
)
return sa_file_func(CloudRedisAsyncClient, filename, *args, **kwargs)

from_service_account_json = from_service_account_file
Expand Down
13 changes: 13 additions & 0 deletions tests/integration/goldens/redis/mypy.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
[mypy]
python_version = 3.14
namespace_packages = True

# FIX: Prevents failure when dependencies (like google-iam) lack type hints
ignore_missing_imports = True

# FIX: Silences the "note: By default the bodies of untyped functions are not checked"
# This keeps CI logs clean and focused on actual errors.
check_untyped_defs = False

# Helps mypy navigate the 'google' namespace more reliably in 3.10+
explicit_package_bases = True

# Performance: reuse results from previous runs to speed up 'nox'
incremental = True
Loading
Loading