From 1513d962fcb0cb2745c021a02de5b2d352bef679 Mon Sep 17 00:00:00 2001 From: DeepMind Date: Sat, 23 Sep 2023 22:42:44 -0700 Subject: [PATCH] "Resolve unsoundness caught by pytype --strict-none-binding. See go/pytype-releases#strict-none-binding and go/pytype-smarter-optional. In short, pytype was previously more permissive when variables were initialized to None but may have been re-assigned later. This change improves pytype's ability to catch unsoundness in the affected files. PiperOrigin-RevId: 567951095 --- android_env/components/coordinator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/android_env/components/coordinator.py b/android_env/components/coordinator.py index c309239..035cb12 100644 --- a/android_env/components/coordinator.py +++ b/android_env/components/coordinator.py @@ -92,7 +92,7 @@ def __init__( self._tmp_dir = tmp_dir or tempfile.gettempdir() self._orientation = np.zeros(4, dtype=np.uint8) self._interaction_rate_sec = interaction_rate_sec - self._interaction_thread = None + self._interaction_thread: InteractionThread | None = None # The size of the device screen in pixels (H x W). self._screen_size = np.array([0, 0], dtype=np.int32) @@ -362,6 +362,7 @@ def _gather_simulator_signals(self) -> dict[str, np.ndarray]: # Grab pixels. if self._interaction_rate_sec > 0: + assert self._interaction_thread is not None pixels = self._interaction_thread.screenshot() # Async mode. else: pixels = self._simulator.get_screenshot() # Sync mode.