Skip to content

Commit fb1c3a9

Browse files
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]>
1 parent d8ca706 commit fb1c3a9

File tree

6 files changed

+8
-10
lines changed

6 files changed

+8
-10
lines changed

google/api_core/exceptions.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -517,14 +517,14 @@ def format_http_response_error(
517517
errors = payload.get("error", {}).get("errors", ())
518518
# In JSON, details are already formatted in developer-friendly way.
519519
details = payload.get("error", {}).get("details", ())
520-
error_info = list(
520+
error_info_list = list(
521521
filter(
522522
lambda detail: detail.get("@type", "")
523523
== "type.googleapis.com/google.rpc.ErrorInfo",
524524
details,
525525
)
526526
)
527-
error_info = error_info[0] if error_info else None
527+
error_info = error_info_list[0] if error_info_list else None
528528
message = _format_rest_error_message(error_message, method, url)
529529

530530
exception = from_http_status(

google/api_core/grpc_helpers_async.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ class _WrappedStreamStreamCall(
152152

153153

154154
# public type alias denoting the return type of async streaming gapic calls
155-
GrpcAsyncStream = _WrappedStreamResponseMixin[P]
155+
GrpcAsyncStream = _WrappedStreamResponseMixin
156156
# public type alias denoting the return type of unary gapic calls
157-
AwaitableGrpcCall = _WrappedUnaryResponseMixin[P]
157+
AwaitableGrpcCall = _WrappedUnaryResponseMixin
158158

159159

160160
def _wrap_unary_errors(callable_):

google/api_core/retry/retry_unary.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def check_if_exists():
8383

8484

8585
def retry_target(
86-
target: Callable[_P, _R],
86+
target: Callable[[], _R],
8787
predicate: Callable[[Exception], bool],
8888
sleep_generator: Iterable[float],
8989
timeout: float | None = None,

google/api_core/retry/retry_unary_async.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ async def check_if_exists():
9494

9595

9696
async def retry_target(
97-
target: Callable[_P, Awaitable[_R]],
97+
target: Callable[[], Awaitable[_R]],
9898
predicate: Callable[[Exception], bool],
9999
sleep_generator: Iterable[float],
100100
timeout: float | None = None,

noxfile.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,7 @@ def pytype(session):
275275
@nox.session(python=DEFAULT_PYTHON_VERSION)
276276
def mypy(session):
277277
"""Run type-checking."""
278-
# TODO(https://github.com/googleapis/python-api-core/issues/682):
279-
# Use the latest version of mypy instead of mypy<1.11.0
280-
session.install(".[grpc,async_rest]", "mypy<1.11.0")
278+
session.install(".[grpc,async_rest]", "mypy")
281279
session.install(
282280
"types-setuptools",
283281
"types-requests",

tests/asyncio/test_grpc_helpers_async.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def test_awaitable_grpc_call():
319319
"""
320320
AwaitableGrpcCall type should be an Awaitable and a grpc.aio.Call.
321321
"""
322-
instance = grpc_helpers_async.AwaitableGrpcCall[int]()
322+
instance = grpc_helpers_async.AwaitableGrpcCall()
323323
assert isinstance(instance, grpc.aio.Call)
324324
# should implement __await__
325325
assert hasattr(instance, "__await__")

0 commit comments

Comments
 (0)