From 74b33e351808ec61431e4577eb93bedabc880c05 Mon Sep 17 00:00:00 2001 From: Hari Rana Date: Wed, 8 Jan 2025 21:56:21 -0500 Subject: [PATCH] chore: Fix ruff issues and ignore more rules --- .pre-commit-config.yaml | 2 +- bottles/backend/managers/data.py | 2 +- bottles/frontend/cli/cli.py | 1 + bottles/frontend/operation.py | 5 +---- bottles/frontend/utils/filters.py | 2 ++ bottles/frontend/widgets/importer.py | 2 ++ bottles/frontend/widgets/state.py | 1 + bottles/frontend/windows/crash.py | 2 +- bottles/frontend/windows/display.py | 2 +- bottles/frontend/windows/dlloverrides.py | 2 ++ bottles/frontend/windows/drives.py | 2 ++ bottles/frontend/windows/envvars.py | 2 ++ bottles/frontend/windows/exclusionpatterns.py | 2 ++ bottles/frontend/windows/fsr.py | 2 ++ bottles/frontend/windows/generic.py | 2 +- bottles/frontend/windows/installer.py | 1 + bottles/frontend/windows/vkbasalt.py | 6 +++--- pyproject.toml | 6 ++++++ 18 files changed, 32 insertions(+), 12 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 45d0a6af0a..9d72aa9c19 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: rev: v0.8.2 hooks: - id: ruff - args: [ "--fix", "--ignore", "F401" ] + args: [ "--fix", "--ignore", "F401,F402,E722,E741" ] - id: ruff-format - repo: https://github.com/pre-commit/mirrors-mypy diff --git a/bottles/backend/managers/data.py b/bottles/backend/managers/data.py index 1c769d185a..d5224eb1c0 100644 --- a/bottles/backend/managers/data.py +++ b/bottles/backend/managers/data.py @@ -79,7 +79,7 @@ def set(self, key, value, of_type=None): else: self.__data[key] = value else: - if of_type == list: + if of_type is list: self.__data[key] = [value] else: self.__data[key] = value diff --git a/bottles/frontend/cli/cli.py b/bottles/frontend/cli/cli.py index 962857a599..d6211929f7 100644 --- a/bottles/frontend/cli/cli.py +++ b/bottles/frontend/cli/cli.py @@ -38,6 +38,7 @@ signal.signal(signal.SIGINT, signal.SIG_DFL) +# ruff: noqa: E402 from gi.repository import Gio from bottles.frontend.params import APP_ID diff --git a/bottles/frontend/operation.py b/bottles/frontend/operation.py index 83773ee8fc..e681277f06 100644 --- a/bottles/frontend/operation.py +++ b/bottles/frontend/operation.py @@ -17,14 +17,11 @@ from typing import Dict from uuid import UUID -import gi +from gi.repository import Gtk, Adw from bottles.backend.models.result import Result from bottles.backend.state import TaskManager -gi.require_version("Adw", "1") -from gi.repository import Gtk, Adw - @Gtk.Template(resource_path="/com/usebottles/bottles/task-entry.ui") class TaskEntry(Adw.ActionRow): diff --git a/bottles/frontend/utils/filters.py b/bottles/frontend/utils/filters.py index 081e1ad4a4..323dacc106 100644 --- a/bottles/frontend/utils/filters.py +++ b/bottles/frontend/utils/filters.py @@ -14,6 +14,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +from gettext import gettext as _ + from gi.repository import Gtk diff --git a/bottles/frontend/widgets/importer.py b/bottles/frontend/widgets/importer.py index 19c06694b6..f3e7004a9b 100644 --- a/bottles/frontend/widgets/importer.py +++ b/bottles/frontend/widgets/importer.py @@ -15,6 +15,8 @@ # along with this program. If not, see . # +from gettext import gettext as _ + from gi.repository import Gtk, Adw from bottles.backend.utils.manager import ManagerUtils diff --git a/bottles/frontend/widgets/state.py b/bottles/frontend/widgets/state.py index e0dfb347ce..ee016c3960 100644 --- a/bottles/frontend/widgets/state.py +++ b/bottles/frontend/widgets/state.py @@ -16,6 +16,7 @@ # from datetime import datetime +from gettext import gettext as _ from gi.repository import Gtk, Adw diff --git a/bottles/frontend/windows/crash.py b/bottles/frontend/windows/crash.py index 7b486a9d38..351f0f3d1b 100644 --- a/bottles/frontend/windows/crash.py +++ b/bottles/frontend/windows/crash.py @@ -63,7 +63,7 @@ def __init__(self, window, log, **kwargs): super().__init__(**kwargs) self.set_transient_for(window) - if type(log) == list: + if type(log) is list: log = "".join(log) # connect signals diff --git a/bottles/frontend/windows/display.py b/bottles/frontend/windows/display.py index 893811d612..2948d913b1 100644 --- a/bottles/frontend/windows/display.py +++ b/bottles/frontend/windows/display.py @@ -144,7 +144,7 @@ def update(result, error=False): ) if ( - self.expander_virtual_desktop.get_enable_expansion() == True + self.expander_virtual_desktop.get_enable_expansion() and resolution != self.parameters.virtual_desktop_res ): """Set virtual desktop resolution""" diff --git a/bottles/frontend/windows/dlloverrides.py b/bottles/frontend/windows/dlloverrides.py index 83eb55a436..5cf47082e7 100644 --- a/bottles/frontend/windows/dlloverrides.py +++ b/bottles/frontend/windows/dlloverrides.py @@ -15,6 +15,8 @@ # along with this program. If not, see . # +from gettext import gettext as _ + from gi.repository import Gtk, GLib, Adw from bottles.backend.dlls.dll import DLLComponent diff --git a/bottles/frontend/windows/drives.py b/bottles/frontend/windows/drives.py index a9c2c7fff6..1cbc929502 100644 --- a/bottles/frontend/windows/drives.py +++ b/bottles/frontend/windows/drives.py @@ -17,6 +17,8 @@ import string +from gettext import gettext as _ + from gi.repository import Gtk, GLib, Adw from bottles.backend.wine.drives import Drives diff --git a/bottles/frontend/windows/envvars.py b/bottles/frontend/windows/envvars.py index caca77d990..f78229d226 100644 --- a/bottles/frontend/windows/envvars.py +++ b/bottles/frontend/windows/envvars.py @@ -15,6 +15,8 @@ # along with this program. If not, see . # +from gettext import gettext as _ + from gi.repository import Gtk, GLib, Adw from bottles.frontend.utils.gtk import GtkUtils diff --git a/bottles/frontend/windows/exclusionpatterns.py b/bottles/frontend/windows/exclusionpatterns.py index 80bc5fc4f7..2c7bcdac79 100644 --- a/bottles/frontend/windows/exclusionpatterns.py +++ b/bottles/frontend/windows/exclusionpatterns.py @@ -15,6 +15,8 @@ # along with this program. If not, see . # +from gettext import gettext as _ + from gi.repository import Gtk, GLib, Adw diff --git a/bottles/frontend/windows/fsr.py b/bottles/frontend/windows/fsr.py index 02261e991a..1c7ce23c43 100644 --- a/bottles/frontend/windows/fsr.py +++ b/bottles/frontend/windows/fsr.py @@ -15,6 +15,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +from gettext import gettext as _ + from gi.repository import Gtk, GLib, Adw from bottles.backend.logger import Logger diff --git a/bottles/frontend/windows/generic.py b/bottles/frontend/windows/generic.py index 5796f23431..96070fb105 100644 --- a/bottles/frontend/windows/generic.py +++ b/bottles/frontend/windows/generic.py @@ -178,7 +178,7 @@ def __build_ui(self): btn_copy.connect("clicked", self.__copy_text) btn_copy.set_tooltip_text(_("Copy to clipboard")) - webview.load_html(self.message, "file://") + # webview.load_html(self.message, "file://") # scrolled.append(webview) box.append(headerbar) diff --git a/bottles/frontend/windows/installer.py b/bottles/frontend/windows/installer.py index 43fe78daa9..23343c9a2d 100644 --- a/bottles/frontend/windows/installer.py +++ b/bottles/frontend/windows/installer.py @@ -17,6 +17,7 @@ import urllib.request +from gettext import gettext as _ from gi.repository import Gtk, GLib, Gio, GdkPixbuf, Adw from bottles.backend.utils.threading import RunAsync diff --git a/bottles/frontend/windows/vkbasalt.py b/bottles/frontend/windows/vkbasalt.py index b201cb7615..8a3950f8c9 100644 --- a/bottles/frontend/windows/vkbasalt.py +++ b/bottles/frontend/windows/vkbasalt.py @@ -116,10 +116,10 @@ def __init__(self, window, config, **kwargs): # Check if subeffects are used for conf in subeffects: - if conf[0] != None: + if conf[0] is not None: conf[1].set_value(float(conf[0])) - if VkBasaltSettings.smaa_edge_detection != None: + if VkBasaltSettings.smaa_edge_detection is not None: if VkBasaltSettings.smaa_edge_detection == "color": self.toggle_color.set_active(True) self.smaa_edge_detection = "color" @@ -186,7 +186,7 @@ def __check_state(self, *args): # Enable and disable other buttons depending on default button when necessary def __default(self, widget, state): self.group_effects.set_sensitive(not state) - if self.check_effects_states() == False: + if not self.check_effects_states(): self.btn_save.set_sensitive(state) # Change edge detection type diff --git a/pyproject.toml b/pyproject.toml index a8e285e49a..cf6eccce65 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,3 +2,9 @@ log_cli = true log_cli_level = "INFO" log_cli_format = "%(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s)" + +[tool.ruff] +exclude = [ + "bottles/backend/utils/nvidia.py", + "bottles/backend/utils/vdf.py", +]