Skip to content

Commit

Permalink
fixed typing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-sanche committed Oct 20, 2023
1 parent 1499563 commit 1406567
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
14 changes: 7 additions & 7 deletions google/cloud/bigtable/data/_async/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,9 @@ def get_table(
default_mutate_rows_attempt_timeout: float | None = None,
default_operation_timeout: float = 60,
default_attempt_timeout: float | None = None,
default_read_rows_retryable_error_codes: Sequence[grpc.StatusCode | int | type[Exception]] = DEFAULT_READ_ROWS_RETRYABLE_ERROR_CODES,
default_mutate_rows_retryable_error_codes: Sequence[grpc.StatusCode | int | type[Exception]] = DEFAULT_RETRYABLE_ERROR_CODES,
default_retryable_error_codes: Sequence[grpc.StatusCode | int | type[Exception]] = DEFAULT_RETRYABLE_ERROR_CODES,
default_read_rows_retryable_error_codes: Sequence[grpc.StatusCode | int | type[Exception]] = DEFAULT_READ_ROWS_RETRYABLE_ERRORS,
default_mutate_rows_retryable_error_codes: Sequence[grpc.StatusCode | int | type[Exception]] = DEFAULT_RETRYABLE_ERRORS,
default_retryable_error_codes: Sequence[grpc.StatusCode | int | type[Exception]] = DEFAULT_RETRYABLE_ERRORS,
) -> TableAsync:
"""
Returns a table instance for making data API requests
Expand Down Expand Up @@ -479,9 +479,9 @@ def __init__(
default_mutate_rows_attempt_timeout: float | None = 60,
default_operation_timeout: float = 60,
default_attempt_timeout: float | None = 20,
default_read_rows_retryable_error_codes: Sequence[grpc.StatusCode | int | type[Exception]] = DEFAULT_READ_ROWS_RETRYABLE_ERROR_CODES,
default_mutate_rows_retryable_error_codes: Sequence[grpc.StatusCode | int | type[Exception]] = DEFAULT_RETRYABLE_ERROR_CODES,
default_retryable_error_codes: Sequence[grpc.StatusCode | int | type[Exception]] = DEFAULT_RETRYABLE_ERROR_CODES,
default_read_rows_retryable_error_codes: Sequence[grpc.StatusCode | int | type[Exception]] = DEFAULT_READ_ROWS_RETRYABLE_ERRORS,
default_mutate_rows_retryable_error_codes: Sequence[grpc.StatusCode | int | type[Exception]] = DEFAULT_RETRYABLE_ERRORS,
default_retryable_error_codes: Sequence[grpc.StatusCode | int | type[Exception]] = DEFAULT_RETRYABLE_ERRORS,
):
"""
Initialize a Table instance
Expand Down Expand Up @@ -1157,7 +1157,7 @@ async def bulk_mutate_rows(
or operation_timeout
)
_validate_timeouts(operation_timeout, attempt_timeout)
retryable_excs = _errors_from_codes(retryable_error_codes, self.default_mutate_rows_retryable_error_codes),
retryable_excs = _errors_from_codes(retryable_error_codes, self.default_mutate_rows_retryable_error_codes)

operation = _MutateRowsOperationAsync(
self.client._gapic_client,
Expand Down
3 changes: 2 additions & 1 deletion google/cloud/bigtable/data/_async/mutations_batcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from google.cloud.bigtable.data.mutations import Mutation

if TYPE_CHECKING:
import grpc
from google.cloud.bigtable.data._async.client import TableAsync

# used to make more readable default values
Expand Down Expand Up @@ -192,7 +193,7 @@ def __init__(
flow_control_max_bytes: int = 100 * _MB_SIZE,
batch_operation_timeout: float | None = None,
batch_attempt_timeout: float | None = None,
batch_retryable_error_codes: Sequence[grpc.StatusCode | int | type[Exception]] | None = None
batch_retryable_error_codes: Sequence["grpc.StatusCode" | int | type[Exception]] | None = None
):
"""
Args:
Expand Down
13 changes: 7 additions & 6 deletions google/cloud/bigtable/data/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""
Helper functions used in various places in the library.
"""
from __future__ import annotations

from typing import Callable, Sequence, Any
from typing import Callable, Sequence, Any, TYPE_CHECKING
import time

from google.api_core import exceptions as core_exceptions
from google.cloud.bigtable.data.exceptions import RetryExceptionGroup

"""
Helper functions used in various places in the library.
"""

if TYPE_CHECKING:
import grpc

def _make_metadata(
table_name: str, app_profile_id: str | None
Expand Down Expand Up @@ -137,7 +138,7 @@ def _validate_timeouts(
raise ValueError("attempt_timeout must be greater than 0")

def _errors_from_codes(
call_codes: Sequence["grpc.StatusCode" | int | type[Exception]],
call_codes: Sequence["grpc.StatusCode" | int | type[Exception]] | None,
table_default_codes: Sequence["grpc.StatusCode" | int | type[Exception]]
) -> list[type[Exception]]:
retry_codes = call_codes if call_codes is not None else table_default_codes
Expand Down

0 comments on commit 1406567

Please sign in to comment.