示例#1
0
 def _normalize_state_list(self, states) -> Set[TransferState]:
     states = {states} if isinstance(states,
                                     (str, TransferState, int)) else states
     result = set()
     for state in states:
         if isinstance(state, str):
             result.add(TransferState[state.upper()])
         elif isinstance(state, int):
             result.add(TransferState(state))
         elif isinstance(state, TransferState):
             result.add(state)
         else:
             raise TypeError(
                 f"Unsupported type. "
                 f"Expected: str, int, google.cloud.bigquery_datatransfer_v1.TransferState."
                 f"Current type: {type(state)}")
     return result
示例#2
0
 def _normalize_state_list(self, states) -> Set[TransferState]:
     states = {states} if isinstance(states,
                                     (str, TransferState, int)) else states
     result = set()
     for state in states:
         if isinstance(state, str):
             # The proto.Enum type is indexable (via MetaClass and aliased) but MyPy is not able to
             # infer this https://github.com/python/mypy/issues/8968
             result.add(TransferState[state.upper()])  # type: ignore[misc]
         elif isinstance(state, int):
             result.add(TransferState(state))
         elif isinstance(state, TransferState):
             result.add(state)
         else:
             raise TypeError(
                 f"Unsupported type. "
                 f"Expected: str, int, google.cloud.bigquery_datatransfer_v1.TransferState."
                 f"Current type: {type(state)}")
     return result