Fix redundant-open-modes (UP015) warnings from Ruff (#2828)

This commit is contained in:
correctmost 2024-11-16 04:52:55 -05:00 committed by GitHub
parent 44f4bc8612
commit 2d6eef4672
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 6 deletions

View File

@ -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'):

View File

@ -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

View File

@ -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]