chore(types): update mypy version (#768)
* use latest mypy for check
* use separate variable for error_info list vs dict
* make wrapped call generic
* fix typing for nullable retry functions
* include async_rest in mypy installation
* removed generic application
---------
Co-authored-by: Anthonios Partheniou <[email protected]>
diff --git a/google/api_core/exceptions.py b/google/api_core/exceptions.py
index 5b25d12..e3eb696 100644
--- a/google/api_core/exceptions.py
+++ b/google/api_core/exceptions.py
@@ -517,14 +517,14 @@
errors = payload.get("error", {}).get("errors", ())
# In JSON, details are already formatted in developer-friendly way.
details = payload.get("error", {}).get("details", ())
- error_info = list(
+ error_info_list = list(
filter(
lambda detail: detail.get("@type", "")
== "type.googleapis.com/google.rpc.ErrorInfo",
details,
)
)
- error_info = error_info[0] if error_info else None
+ error_info = error_info_list[0] if error_info_list else None
message = _format_rest_error_message(error_message, method, url)
exception = from_http_status(
diff --git a/google/api_core/grpc_helpers_async.py b/google/api_core/grpc_helpers_async.py
index 6feb222..2696045 100644
--- a/google/api_core/grpc_helpers_async.py
+++ b/google/api_core/grpc_helpers_async.py
@@ -152,9 +152,9 @@
# public type alias denoting the return type of async streaming gapic calls
-GrpcAsyncStream = _WrappedStreamResponseMixin[P]
+GrpcAsyncStream = _WrappedStreamResponseMixin
# public type alias denoting the return type of unary gapic calls
-AwaitableGrpcCall = _WrappedUnaryResponseMixin[P]
+AwaitableGrpcCall = _WrappedUnaryResponseMixin
def _wrap_unary_errors(callable_):
diff --git a/google/api_core/retry/retry_unary.py b/google/api_core/retry/retry_unary.py
index ab1b403..d5dff66 100644
--- a/google/api_core/retry/retry_unary.py
+++ b/google/api_core/retry/retry_unary.py
@@ -83,7 +83,7 @@
def retry_target(
- target: Callable[_P, _R],
+ target: Callable[[], _R],
predicate: Callable[[Exception], bool],
sleep_generator: Iterable[float],
timeout: float | None = None,
diff --git a/google/api_core/retry/retry_unary_async.py b/google/api_core/retry/retry_unary_async.py
index 3bdf6c7..e76a37b 100644
--- a/google/api_core/retry/retry_unary_async.py
+++ b/google/api_core/retry/retry_unary_async.py
@@ -94,7 +94,7 @@
async def retry_target(
- target: Callable[_P, Awaitable[_R]],
+ target: Callable[[], Awaitable[_R]],
predicate: Callable[[Exception], bool],
sleep_generator: Iterable[float],
timeout: float | None = None,
diff --git a/noxfile.py b/noxfile.py
index ada6f33..cffef97 100644
--- a/noxfile.py
+++ b/noxfile.py
@@ -275,9 +275,7 @@
@nox.session(python=DEFAULT_PYTHON_VERSION)
def mypy(session):
"""Run type-checking."""
- # TODO(https://github.com/googleapis/python-api-core/issues/682):
- # Use the latest version of mypy instead of mypy<1.11.0
- session.install(".[grpc,async_rest]", "mypy<1.11.0")
+ session.install(".[grpc,async_rest]", "mypy")
session.install(
"types-setuptools",
"types-requests",
diff --git a/tests/asyncio/test_grpc_helpers_async.py b/tests/asyncio/test_grpc_helpers_async.py
index d8f20ae..aa8d5d1 100644
--- a/tests/asyncio/test_grpc_helpers_async.py
+++ b/tests/asyncio/test_grpc_helpers_async.py
@@ -319,7 +319,7 @@
"""
AwaitableGrpcCall type should be an Awaitable and a grpc.aio.Call.
"""
- instance = grpc_helpers_async.AwaitableGrpcCall[int]()
+ instance = grpc_helpers_async.AwaitableGrpcCall()
assert isinstance(instance, grpc.aio.Call)
# should implement __await__
assert hasattr(instance, "__await__")