nixos-test-driver: adher to select's interface
TL;DR add `assert` to correct location for type-narrowing typeshed recently updated their definition of `select` in https://github.com/python/typeshed/commit/bcb6399e155cb6444150fe98dfd9c24eb0343016. The result is that the members of the lists passed to `select` now require an upper bound of `FileDescriptorLike`. The `self.shell` variable is typed as `socket | None`, but previously passed checking against typeshed due to the missing upper-bound. Despite the source code including a type-narrowing `assert`, `ty` does not make use of it within the inner function that `select` is used in, meaning `self.shell` wasn't narrowed at the appropriate place. Now that typeshed has added this upper-bound, type-checking starts to fail, as evidenced in https://github.com/NixOS/nixpkgs/pull/523288#issuecomment-4529738483. So the correct fix is just to add the `assert` into the inner function.
This commit is contained in:
@@ -1031,6 +1031,7 @@ class QemuMachine(BaseMachine):
|
||||
As soon as we read some data from the socket here, we assume that
|
||||
our root shell is operational.
|
||||
"""
|
||||
assert self.shell
|
||||
(ready, _, _) = select.select([self.shell], [], [], timeout_secs)
|
||||
return bool(ready)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user