From 498e92dc9546c5e01450eb722a53665bb7311c61 Mon Sep 17 00:00:00 2001 From: Teal Dulcet Date: Wed, 18 Jun 2025 04:28:09 -0700 Subject: [PATCH] Fixed PLW1514 (unspecified-encoding): `open` in text mode without explicit `encoding` argument --- management/mailconfig.py | 2 +- tools/readable_bash.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/management/mailconfig.py b/management/mailconfig.py index 7caee5f7..054b3b0f 100755 --- a/management/mailconfig.py +++ b/management/mailconfig.py @@ -148,7 +148,7 @@ def get_mail_users_ex(env, with_archived=False): percent = '' try: dirsize_file = os.path.join(env['STORAGE_ROOT'], 'mail/mailboxes/{}/{}/maildirsize'.format(domain, user)) - with open(dirsize_file, 'r') as f: + with open(dirsize_file, 'r', encoding="utf-8") as f: box_quota = int(f.readline().split('S')[0]) for line in f.readlines(): (size, count) = line.split(' ') diff --git a/tools/readable_bash.py b/tools/readable_bash.py index 78a4bc08..4c79665c 100644 --- a/tools/readable_bash.py +++ b/tools/readable_bash.py @@ -124,7 +124,7 @@ def generate_documentation(): """) parser = Source.parser() - with open("setup/start.sh", "r") as start_file: + with open("setup/start.sh", "r", encoding="utf-8") as start_file: for line in start_file: try: fn = parser.parse_string(line).filename() @@ -401,7 +401,7 @@ class BashScript(Grammar): @staticmethod def parse(fn): if fn in ("setup/functions.sh", "/etc/mailinabox.conf"): return "" - with open(fn, "r") as f: + with open(fn, "r", encoding="utf-8") as f: string = f.read() # tokenize