Skip to content

Commit 3b530e2

Browse files
chore: improve typing in api_core.exceptions (#16115)
GoogleApiCallError.grpc_status_code had no typing, so mypy will assume the value is always None This PR adds the proper type annotation --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 0e07218 commit 3b530e2

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

packages/google-api-core/google/api_core/exceptions.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
import http.client
2525
from typing import Optional, Dict
26-
from typing import Union
2726
import warnings
2827

2928
from google.rpc import error_details_pb2
@@ -121,7 +120,7 @@ class GoogleAPICallError(GoogleAPIError, metaclass=_GoogleAPICallErrorMeta):
121120
(google.rpc.error_details.ErrorInfo).
122121
"""
123122

124-
code: Union[int, None] = None
123+
code: Optional[int] = None
125124
"""Optional[int]: The HTTP status code associated with this error.
126125
127126
This may be ``None`` if the exception does not have a direct mapping
@@ -130,7 +129,7 @@ class GoogleAPICallError(GoogleAPIError, metaclass=_GoogleAPICallErrorMeta):
130129
See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
131130
"""
132131

133-
grpc_status_code = None
132+
grpc_status_code: Optional["grpc.StatusCode"] = None
134133
"""Optional[grpc.StatusCode]: The gRPC status code associated with this
135134
error.
136135

0 commit comments

Comments
 (0)