*: pylint: Explicitly specify encoding when open a file

This is recommended by PEP-0597: https://peps.python.org/pep-0597/

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa authored and James Valleroy committed 2022-07-04 19:45:57 -04:00
1 parent 05815bc992
commit 3c7bc4a192
49 files changed
+165 -138

No files matched your search

+2 -1
View File
@@ -122,7 +122,8 @@ def is_setup():
def is_using_ecc():
"""Return whether the service is using ECC."""
if os.path.exists(SERVER_CONFIGURATION_FILE):
with open(SERVER_CONFIGURATION_FILE, 'r') as file_handle:
with open(SERVER_CONFIGURATION_FILE, 'r',
encoding='utf-8') as file_handle:
for line in file_handle:
if line.strip() == 'dh none':
return True
@@ -34,7 +34,7 @@ def fixture_conf_file(tmp_path):
def test_identify_rsa_configuration(conf_file):
"""Identify RSA configuration based on configuration file."""
with patch('plinth.modules.openvpn.SERVER_CONFIGURATION_FILE', conf_file):
with open(conf_file, 'w') as file_handle:
with open(conf_file, 'w', encoding='utf-8') as file_handle:
file_handle.write('dh /etc/openvpn/freedombox-keys/pki/dh.pem')
assert not openvpn.is_using_ecc()
@@ -42,7 +42,7 @@ def test_identify_rsa_configuration(conf_file):
def test_identify_ecc_configuration(conf_file):
"""Identify ECC configuration based on configuration file."""
with patch('plinth.modules.openvpn.SERVER_CONFIGURATION_FILE', conf_file):
with open(conf_file, 'w') as file_handle:
with open(conf_file, 'w', encoding='utf-8') as file_handle:
file_handle.write('dh none')
assert openvpn.is_using_ecc()