Skip to content

Commit

Permalink
fix: make 'gapic_v1.method.DEFAULT' a typed object (#292)
Browse files Browse the repository at this point in the history
FBO checkers which need to verify default values for 'retry' / 'timeout'
  • Loading branch information
tseaver committed Nov 2, 2021
1 parent d2a729e commit ffc51f0
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion google/api_core/gapic_v1/method.py
Expand Up @@ -18,14 +18,26 @@
pagination, and long-running operations to gRPC methods.
"""

import enum
import functools

from google.api_core import grpc_helpers
from google.api_core import timeout
from google.api_core.gapic_v1 import client_info

USE_DEFAULT_METADATA = object()
DEFAULT = object()


class _MethodDefault(enum.Enum):
# Uses enum so that pytype/mypy knows that this is the only possible value.
# https://stackoverflow.com/a/60605919/101923
#
# Literal[_DEFAULT_VALUE] is an alternative, but only added in Python 3.8.
# https://docs.python.org/3/library/typing.html#typing.Literal
_DEFAULT_VALUE = object()


DEFAULT = _MethodDefault._DEFAULT_VALUE
"""Sentinel value indicating that a retry or timeout argument was unspecified,
so the default should be used."""

Expand Down

0 comments on commit ffc51f0

Please sign in to comment.