Skip to content

Commit 1a29e93

Browse files
committed
Code formatting
Signed-off-by: Vlad Gheorghiu <[email protected]>
1 parent 4d39b92 commit 1a29e93

File tree

1 file changed

+10
-30
lines changed

1 file changed

+10
-30
lines changed

oqs/oqs.py

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,7 @@ def _load_liboqs() -> ct.CDLL:
202202
assert liboqs # noqa: S101
203203
except RuntimeError:
204204
# We don't have liboqs, so we try to install it automatically
205-
_install_liboqs(
206-
target_directory=oqs_install_dir, oqs_version_to_install=OQS_VERSION
207-
)
205+
_install_liboqs(target_directory=oqs_install_dir, oqs_version_to_install=OQS_VERSION)
208206
# Try loading it again
209207
try:
210208
liboqs = _load_shared_obj(
@@ -243,13 +241,9 @@ def oqs_version() -> str:
243241

244242
oqs_python_ver = oqs_python_version()
245243
if oqs_python_ver:
246-
oqs_python_ver_major, oqs_python_ver_minor, oqs_python_ver_patch = version(
247-
oqs_python_ver
248-
)
244+
oqs_python_ver_major, oqs_python_ver_minor, oqs_python_ver_patch = version(oqs_python_ver)
249245
# Warn the user if the liboqs version differs from liboqs-python version
250-
if not (
251-
oqs_ver_major == oqs_python_ver_major and oqs_ver_minor == oqs_python_ver_minor
252-
):
246+
if not (oqs_ver_major == oqs_python_ver_major and oqs_ver_minor == oqs_python_ver_minor):
253247
warnings.warn(
254248
f"liboqs version (major, minor) {oqs_version()} differs from liboqs-python version "
255249
f"{oqs_python_version()}",
@@ -303,9 +297,7 @@ class KeyEncapsulation(ct.Structure):
303297
("decaps_cb", ct.c_void_p),
304298
]
305299

306-
def __init__(
307-
self, alg_name: str, secret_key: Union[int, bytes, None] = None
308-
) -> None:
300+
def __init__(self, alg_name: str, secret_key: Union[int, bytes, None] = None) -> None:
309301
"""
310302
Create new KeyEncapsulation with the given algorithm.
311303
@@ -459,15 +451,9 @@ def is_kem_enabled(alg_name: str) -> bool:
459451
return native().OQS_KEM_alg_is_enabled(ct.create_string_buffer(alg_name.encode()))
460452

461453

462-
_KEM_alg_ids = [
463-
native().OQS_KEM_alg_identifier(i) for i in range(native().OQS_KEM_alg_count())
464-
]
465-
_supported_KEMs: tuple[str, ...] = tuple(
466-
[i.decode() for i in _KEM_alg_ids]
467-
) # noqa: N816
468-
_enabled_KEMs: tuple[str, ...] = tuple(
469-
[i for i in _supported_KEMs if is_kem_enabled(i)]
470-
) # noqa: N816
454+
_KEM_alg_ids = [native().OQS_KEM_alg_identifier(i) for i in range(native().OQS_KEM_alg_count())]
455+
_supported_KEMs: tuple[str, ...] = tuple([i.decode() for i in _KEM_alg_ids]) # noqa: N816
456+
_enabled_KEMs: tuple[str, ...] = tuple([i for i in _supported_KEMs if is_kem_enabled(i)]) # noqa: N816
471457

472458

473459
def get_enabled_kem_mechanisms() -> tuple[str, ...]:
@@ -508,9 +494,7 @@ class Signature(ct.Structure):
508494
("verify_cb", ct.c_void_p),
509495
]
510496

511-
def __init__(
512-
self, alg_name: str, secret_key: Union[int, bytes, None] = None
513-
) -> None:
497+
def __init__(self, alg_name: str, secret_key: Union[int, bytes, None] = None) -> None:
514498
"""
515499
Create new Signature with the given algorithm.
516500
@@ -755,13 +739,9 @@ def is_sig_enabled(alg_name: str) -> bool:
755739
return native().OQS_SIG_alg_is_enabled(ct.create_string_buffer(alg_name.encode()))
756740

757741

758-
_sig_alg_ids = [
759-
native().OQS_SIG_alg_identifier(i) for i in range(native().OQS_SIG_alg_count())
760-
]
742+
_sig_alg_ids = [native().OQS_SIG_alg_identifier(i) for i in range(native().OQS_SIG_alg_count())]
761743
_supported_sigs: tuple[str, ...] = tuple([i.decode() for i in _sig_alg_ids])
762-
_enabled_sigs: tuple[str, ...] = tuple(
763-
[i for i in _supported_sigs if is_sig_enabled(i)]
764-
)
744+
_enabled_sigs: tuple[str, ...] = tuple([i for i in _supported_sigs if is_sig_enabled(i)])
765745

766746

767747
def get_enabled_sig_mechanisms() -> tuple[str, ...]:

0 commit comments

Comments
 (0)