Skip to content

Commit 0d454a6

Browse files
committed
efi: fix obviously-wrong type hints
* the VM.set_efi_var prototype was shown wrong by. lib/vm.py:400: error: "str" has no attribute "as_str" [attr-defined] lib/vm.py:401: error: "str" has no attribute "as_str" [attr-defined] * get_secure_boot_guid was never meant to return None (had to follow the code to convince myself, hope I did not miss anything), so avoid calling .get(): lib/efi.py:120: error: Incompatible return value type (got "GUID | None", expected "GUID") [return-value] * _get_efi_signature_list only ever returns bytes, not str as advertised (remants of py3 conversion?) lib/efi.py:385: error: Incompatible return value type (got "bytes", expected "str") [return-value] Signed-off-by: Yann Dirson <[email protected]>
1 parent 96e01d1 commit 0d454a6

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/efi.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def get_secure_boot_guid(variable: str) -> GUID:
122122
'KEK': global_variable_guid,
123123
'db': image_security_database_guid,
124124
'dbx': image_security_database_guid,
125-
}.get(variable)
125+
}[variable]
126126

127127

128128
def cert_to_efi_sig_list(cert):
@@ -149,7 +149,7 @@ def cert_to_efi_sig_list(cert):
149149
)
150150

151151

152-
def certs_to_sig_db(certs):
152+
def certs_to_sig_db(certs) -> bytes:
153153
"""Returns a signature database from a list cert file paths."""
154154
if isinstance(certs, str):
155155
certs = [certs]
@@ -380,7 +380,7 @@ def copy(cls, other, name=None):
380380

381381
return obj
382382

383-
def _get_efi_signature_list(self) -> str:
383+
def _get_efi_signature_list(self) -> bytes:
384384
if self.is_null:
385385
return b''
386386

lib/vm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ def sign_efi_bins(self, db: efi.EFIAuth):
387387
signed = db.sign_image(local_bin)
388388
self.scp(signed, remote_bin)
389389

390-
def set_efi_var(self, var: str, guid: str, attrs: bytes, data: bytes):
390+
def set_efi_var(self, var: str, guid: efi.GUID, attrs: bytes, data: bytes):
391391
"""Sets the data and attrs for an EFI variable and GUID."""
392392
assert len(attrs) == 4
393393

0 commit comments

Comments
 (0)