Skip to content

Commit

Permalink
Fix raiser is not callable. (quantumlib#5155)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelBroughton authored Mar 28, 2022
1 parent a75a7ae commit 2530747
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cirq/protocols/pow_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Any, overload, TYPE_CHECKING, TypeVar, Union
from typing import Any, cast, overload, TYPE_CHECKING, TypeVar, Union, Callable

if TYPE_CHECKING:
import cirq
Expand Down Expand Up @@ -81,7 +81,7 @@ def pow(val: Any, exponent: Any, default: Any = RaiseTypeErrorIfNotProvided) ->
TypeError: `val` doesn't have a __pow__ method (or that method returned
NotImplemented) and no `default` value was specified.
"""
raiser = getattr(val, '__pow__', None)
raiser = cast(Union[None, Callable], getattr(val, '__pow__', None))
result = NotImplemented if raiser is None else raiser(exponent)
if result is not NotImplemented:
return result
Expand Down

0 comments on commit 2530747

Please sign in to comment.