Commit 71fab5b
committed
Merge remote-tracking branch 'origin/pr/438'
* origin/pr/438:
handle case where arg is None
add type hints for app.py
Pull request description:
Follows #437
* `_vm_list` is no a list - it's a dict. I renamed it accordingly.
* I added a new `_vm_dict_initialized` variable that explicitly tracks the initialisation rather than relying on `is None`. (which avoids putting `assert is not None` everywhere)
* (not done in this PR) I believe we should add a comment / docstring to state clearly what's supposed to be in both `_vm_list` and `_vm_objects`. Would be happy to add it to the PR if I get some suggestions.
```python3
def list_deviceclass(self) -> list[str]:
```
I would like to make `deviceclass` a `Literal` list of allowed strings, but I'm not sure what the exhaustive list of allowed classes are ?
* What guarantees below that `volume.name` is not `None` ?
```python3
default_pool = getattr(
self.app, "default_pool_" + volume.name, volume.pool
)
```
* Same for `dst_volume.name` a bit after:
```python3
src_volume = src_vm.volumes[dst_volume.name]
```
* in `qubesd_call` we have
```python3
def qubesd_call(
self, dest, method, arg=None, payload=None, payload_stream=None
):
if payload_stream:
method_path = os.path.join(
qubesadmin.config.QREXEC_SERVICES_DIR, method
)
if not os.path.exists(method_path):
raise qubesadmin.exc.QubesDaemonCommunicationError(
"{} not found".format(method_path)
)
command = [
"env",
"QREXEC_REMOTE_DOMAIN=dom0",
"QREXEC_REQUESTED_TARGET=" + dest,
method_path,
arg,
]
self._call_with_stream(
command, payload, payload_stream
)
```
* This will fail if `dest=None` but this is not mentioned in the docstring
* This should also fail if `arg` is `None` since _call_with_stream excepts a `list[str]`, not `list[str|None]`. Is that OK ?2 files changed
Lines changed: 144 additions & 103 deletions
0 commit comments