From 55b2c30887f61bc3121bf68908942a38a055b3ea Mon Sep 17 00:00:00 2001 From: Pavol Juhas Date: Thu, 3 Oct 2024 16:57:51 -0700 Subject: [PATCH] CI - fix flaky type check failure in `cirq.vis.heatmap` (#6750) Avoid `Incompatible types in assignment` error by providing explicit cast of the value returned from `get_facecolor()`. The failure is flaky and more likely to happen if run without mypy cache This fix was verified using: for i in {1..50}; do check/mypy --cache-dir=/dev/null || break; done --- cirq-core/cirq/vis/heatmap.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/cirq-core/cirq/vis/heatmap.py b/cirq-core/cirq/vis/heatmap.py index 0556663f0c0..ac561324fab 100644 --- a/cirq-core/cirq/vis/heatmap.py +++ b/cirq-core/cirq/vis/heatmap.py @@ -28,7 +28,6 @@ SupportsFloat, Tuple, Union, - TYPE_CHECKING, ) import matplotlib as mpl @@ -40,8 +39,6 @@ from cirq.devices import grid_qubit from cirq.vis import vis_utils -if TYPE_CHECKING: - from numpy.typing import ArrayLike QubitTuple = Tuple[grid_qubit.GridQubit, ...] @@ -240,8 +237,8 @@ def _write_annotations( ax: plt.Axes, ) -> None: """Writes annotations to the center of cells. Internal.""" - facecolor: ArrayLike - for (center, annotation), facecolor in zip(centers_and_annot, collection.get_facecolor()): + face_colors = cast(np.ndarray, collection.get_facecolor()) + for (center, annotation), facecolor in zip(centers_and_annot, face_colors): # Calculate the center of the cell, assuming that it is a square # centered at (x=col, y=row). if not annotation: