Python code modernization, 8/n (#1179)

* Use to_text instead of to_native.

* Remove no longer needed pylint ignores.

* Remove another pylint ignore.

* Remove no longer needed ignore.

* Address redefined-outer-name.

* Address consider-using-with.
This commit is contained in:
Felix Fontein
2025-10-25 02:36:04 +02:00
committed by GitHub
parent 6ad4bfcd40
commit be000755fc
30 changed files with 156 additions and 150 deletions
+2 -2
View File
@@ -10,7 +10,7 @@ from __future__ import annotations
import base64
import random
from ansible.module_utils.common.text.converters import to_bytes, to_native, to_text
from ansible.module_utils.common.text.converters import to_bytes, to_text
def generate_insecure_key() -> bytes:
@@ -31,7 +31,7 @@ def scramble(value: str, key: bytes) -> str:
b_value = to_bytes(value)
k = key[0]
b_value = bytes([k ^ b for b in b_value])
return f"=S={to_native(base64.b64encode(b_value))}"
return f"=S={to_text(base64.b64encode(b_value))}"
def unscramble(value: str, key: bytes) -> str: