Add type hints for device_protocol.py#437
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #437 +/- ##
==========================================
+ Coverage 76.29% 76.30% +0.01%
==========================================
Files 53 53
Lines 9359 9363 +4
==========================================
+ Hits 7140 7144 +4
Misses 2219 2219 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
It used to be used here, but not anymore (since 4102157). I agree, should be moved. |
|
Do you want me to move it in this PR ? If so what would be the appropriate destination ? |
|
b244545 to
61179e4
Compare
|
PipelineRetry |
|
I'd like to merge #442 first (when it will be ready), and then I'd ask you to rebase (which would be useful anyway, since some commits from other PRs here are outdated. |
61179e4 to
1efaa45
Compare
* 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 ?
Follows #436
Comment:
qboolhas nothing to do withdevice_protocolintrinsically, and is never used within - it's used inbackup/core3.pyasdevice_protocol.qbool. I believe it should be moved elsewhere (either insidecore3.pyor in someutil/lib/miscfile)