From 2d6eef46726acd8d0d1a307509608534fc9c3ab9 Mon Sep 17 00:00:00 2001 From: correctmost <134317971+correctmost@users.noreply.github.com> Date: Sat, 16 Nov 2024 04:52:55 -0500 Subject: [PATCH] Fix redundant-open-modes (UP015) warnings from Ruff (#2828) --- archinstall/default_profiles/desktops/awesome.py | 4 ++-- archinstall/lib/profile/profiles_handler.py | 4 ++-- archinstall/lib/translationhandler.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/archinstall/default_profiles/desktops/awesome.py b/archinstall/default_profiles/desktops/awesome.py index e9a4daf0..5e328135 100644 --- a/archinstall/default_profiles/desktops/awesome.py +++ b/archinstall/default_profiles/desktops/awesome.py @@ -32,7 +32,7 @@ class AwesomeProfile(XorgProfile): super().install(install_session) # TODO: Copy a full configuration to ~/.config/awesome/rc.lua instead. - with open(f"{install_session.target}/etc/xdg/awesome/rc.lua", 'r') as fh: + with open(f"{install_session.target}/etc/xdg/awesome/rc.lua") as fh: awesome_lua = fh.read() # Replace xterm with alacritty for a smoother experience. @@ -45,7 +45,7 @@ class AwesomeProfile(XorgProfile): # TODO: check if we selected a greeter, # but for now, awesome is intended to run without one. - with open(f"{install_session.target}/etc/X11/xinit/xinitrc", 'r') as xinitrc: + with open(f"{install_session.target}/etc/X11/xinit/xinitrc") as xinitrc: xinitrc_data = xinitrc.read() for line in xinitrc_data.split('\n'): diff --git a/archinstall/lib/profile/profiles_handler.py b/archinstall/lib/profile/profiles_handler.py index ac2f4b72..195cf013 100644 --- a/archinstall/lib/profile/profiles_handler.py +++ b/archinstall/lib/profile/profiles_handler.py @@ -205,7 +205,7 @@ class ProfileHandler: # slick-greeter requires a config change if greeter == GreeterType.LightdmSlick: path = install_session.target.joinpath('etc/lightdm/lightdm.conf') - with open(path, 'r') as file: + with open(path) as file: filedata = file.read() filedata = filedata.replace('#greeter-session=example-gtk-gnome', 'greeter-session=lightdm-slick-greeter') @@ -302,7 +302,7 @@ class ProfileHandler: Check if the provided profile file contains a legacy profile definition """ - with open(file, 'r') as fp: + with open(file) as fp: for line in fp.readlines(): if '__packages__' in line: return True diff --git a/archinstall/lib/translationhandler.py b/archinstall/lib/translationhandler.py index 85a1f3e0..243417d5 100644 --- a/archinstall/lib/translationhandler.py +++ b/archinstall/lib/translationhandler.py @@ -103,7 +103,7 @@ class TranslationHandler: locales_dir = self._get_locales_dir() languages = Path.joinpath(locales_dir, self._languages) - with open(languages, 'r') as fp: + with open(languages) as fp: return json.load(fp) def _get_catalog_size(self, translation: gettext.NullTranslations) -> int: @@ -121,7 +121,7 @@ class TranslationHandler: Get total messages that could be translated """ locales = self._get_locales_dir() - with open(f'{locales}/{self._base_pot}', 'r') as fp: + with open(f'{locales}/{self._base_pot}') as fp: lines = fp.readlines() msgid_lines = [line for line in lines if 'msgid' in line]