Skip to content

Commit 55b2c30

Browse files
authored
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
1 parent 95f6a3f commit 55b2c30

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

cirq-core/cirq/vis/heatmap.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
SupportsFloat,
2929
Tuple,
3030
Union,
31-
TYPE_CHECKING,
3231
)
3332

3433
import matplotlib as mpl
@@ -40,8 +39,6 @@
4039
from cirq.devices import grid_qubit
4140
from cirq.vis import vis_utils
4241

43-
if TYPE_CHECKING:
44-
from numpy.typing import ArrayLike
4542

4643
QubitTuple = Tuple[grid_qubit.GridQubit, ...]
4744

@@ -240,8 +237,8 @@ def _write_annotations(
240237
ax: plt.Axes,
241238
) -> None:
242239
"""Writes annotations to the center of cells. Internal."""
243-
facecolor: ArrayLike
244-
for (center, annotation), facecolor in zip(centers_and_annot, collection.get_facecolor()):
240+
face_colors = cast(np.ndarray, collection.get_facecolor())
241+
for (center, annotation), facecolor in zip(centers_and_annot, face_colors):
245242
# Calculate the center of the cell, assuming that it is a square
246243
# centered at (x=col, y=row).
247244
if not annotation:

0 commit comments

Comments
 (0)