From 286d0dbec9e8ce2d7d363e0dec78a5be8ce1e867 Mon Sep 17 00:00:00 2001 From: MichaelBroughton Date: Mon, 28 Mar 2022 12:03:29 -0700 Subject: [PATCH] Fix raiser is not callable. (#5155) Appears to have broken other PRs. https://github.com/quantumlib/Cirq/runs/5724527312?check_suite_focus=true --- cirq-core/cirq/protocols/pow_protocol.py | 4 ++-- dev_tools/requirements/deps/format.txt | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cirq-core/cirq/protocols/pow_protocol.py b/cirq-core/cirq/protocols/pow_protocol.py index cc6673781c2f..411fd72be648 100644 --- a/cirq-core/cirq/protocols/pow_protocol.py +++ b/cirq-core/cirq/protocols/pow_protocol.py @@ -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 @@ -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 diff --git a/dev_tools/requirements/deps/format.txt b/dev_tools/requirements/deps/format.txt index 27782b46137a..b544c85dc39d 100644 --- a/dev_tools/requirements/deps/format.txt +++ b/dev_tools/requirements/deps/format.txt @@ -1,2 +1,3 @@ -r flynt.txt black==21.12b0 +click<=8.0.4