diff --git a/plugins/code/colorize/colorize.py b/plugins/code/colorize/colorize.py index 6930a11..5747290 100644 --- a/plugins/code/colorize/colorize.py +++ b/plugins/code/colorize/colorize.py @@ -132,12 +132,10 @@ class Colorize(ColorConverterMixin): if not start_itr: start_itr = buffer.get_start_iter() - results = self.search(start_itr, end_itr, "#") - - return results + return self.search(start_itr, end_itr, "#") def search(self, start_itr = None, end_itr = None, query: str = None) -> list: - if not start_itr or not query: return None, None + if not start_itr or not query: return [] results: list = [] flags = Gtk.TextSearchFlags.VISIBLE_ONLY | Gtk.TextSearchFlags.TEXT_ONLY @@ -150,7 +148,7 @@ class Colorize(ColorConverterMixin): return results - def finalize_non_hex_matches(self, result_hits: [] = []) -> list: + def finalize_non_hex_matches(self, result_hits: list = []) -> list: results: list = [] for start_itr, end_itr in result_hits: @@ -165,7 +163,7 @@ class Colorize(ColorConverterMixin): end_itr.forward_chars(21) # Check if best case (255, 255, 255, 0.64) if end_itr.get_char() == ")": end_itr.forward_char() - results.append([start, end_itr]) + results.append([start_itr, end_itr]) continue # Break loop if we get back to rgb/rgba/hsl/hsv -> ( @@ -179,7 +177,7 @@ class Colorize(ColorConverterMixin): return results - def finalize_hex_matches(self, result_hits: [] = []) -> list: + def finalize_hex_matches(self, result_hits: list = []) -> list: results: list = [] for start_itr, end_itr in result_hits: diff --git a/plugins/code/search_replace/search_replace.py b/plugins/code/search_replace/search_replace.py index de1392d..61c875a 100644 --- a/plugins/code/search_replace/search_replace.py +++ b/plugins/code/search_replace/search_replace.py @@ -38,7 +38,6 @@ class SearchReplace(Gtk.Grid, SearchReplaceMixin): self.set_hexpand(True) self.set_column_spacing(15) self.set_row_spacing(15) - self.set_row_spacing(15) self.set_margin_start(15) self.set_margin_end(15) @@ -151,7 +150,7 @@ class SearchReplace(Gtk.Grid, SearchReplaceMixin): find_options += "Regex" find_options += ", " if self.mode_bttn_box.use_regex else "" - find_options += "Case Sensitive" if self.mode_bttn_box.match_case else "Case Inensitive" + find_options += "Case Sensitive" if self.mode_bttn_box.match_case else "Case Insensitive" if self.mode_bttn_box.in_selection: find_options += ", Within Current Selection" diff --git a/src/core/controllers/base_controller_mixin.py b/src/core/controllers/base_controller_mixin.py index 7edf38e..c0c9eee 100644 --- a/src/core/controllers/base_controller_mixin.py +++ b/src/core/controllers/base_controller_mixin.py @@ -29,7 +29,7 @@ class BaseControllerMixin: logger.info(f"Not a File: {arg}") - if len(files) == 0: return + if not files: return settings_manager.set_is_starting_with_file(True) settings_manager.set_starting_files(files) diff --git a/src/core/widgets/code/command_system/commands/load_start_files.py b/src/core/widgets/code/command_system/commands/load_start_files.py index 3af2186..f7d60dc 100644 --- a/src/core/widgets/code/command_system/commands/load_start_files.py +++ b/src/core/widgets/code/command_system/commands/load_start_files.py @@ -19,7 +19,7 @@ def execute( starting_files = settings_manager.get_starting_files() - if len(starting_files) == 0: return + if not starting_files: return file = starting_files.pop() file = file.replace("FILE|", "") @@ -31,7 +31,7 @@ def execute( (view, gfile, file) ) - if len(starting_files) == 0: return + if not starting_files: return for file in starting_files: file = file.replace("FILE|", "") diff --git a/src/core/widgets/code/controllers/files_controller.py b/src/core/widgets/code/controllers/files_controller.py index c0520f0..0184f66 100644 --- a/src/core/widgets/code/controllers/files_controller.py +++ b/src/core/widgets/code/controllers/files_controller.py @@ -101,7 +101,7 @@ class FilesController(ControllerBase, list): eve = Event_Factory.create_event( "popped_file", - view = view, + view = event.view, file = popped_file, next_file = next_file ) @@ -137,9 +137,9 @@ class FilesController(ControllerBase, list): def next_index(self, i): size = len(self) - if (i == 0) & (size >= 2): + if (i == 0) and (size >= 2): j = i + 1 - elif (i == (size - 1)) & (size >= 2): + elif (i == (size - 1)) and (size >= 2): j = i - 1 elif (size - 1) == 0: j = -1 diff --git a/src/core/widgets/code/key_mapper.py b/src/core/widgets/code/key_mapper.py index 862bea7..5d8be68 100644 --- a/src/core/widgets/code/key_mapper.py +++ b/src/core/widgets/code/key_mapper.py @@ -111,13 +111,13 @@ class KeyMapper: def _set_key_state(self, eve): modifiers = Gdk.ModifierType(eve.get_state() & ~Gdk.ModifierType.LOCK_MASK) - is_control = True if modifiers & Gdk.ModifierType.CONTROL_MASK else False - is_shift = True if modifiers & Gdk.ModifierType.SHIFT_MASK else False + is_control = modifiers & Gdk.ModifierType.CONTROL_MASK + is_shift = modifiers & Gdk.ModifierType.SHIFT_MASK try: - is_alt = True if modifiers & Gdk.ModifierType.ALT_MASK else False - except Exception: - is_alt = True if modifiers & Gdk.ModifierType.MOD1_MASK else False + is_alt = modifiers & Gdk.ModifierType.ALT_MASK + except: + is_alt = modifiers & Gdk.ModifierType.MOD1_MASK self.state = NoKeyState if is_control: @@ -129,11 +129,11 @@ class KeyMapper: def is_control(self, eve): modifiers = Gdk.ModifierType(eve.get_state() & ~Gdk.ModifierType.LOCK_MASK) - return True if modifiers & Gdk.ModifierType.CONTROL_MASK else False + return modifiers & Gdk.ModifierType.CONTROL_MASK def is_shift(self, eve): modifiers = Gdk.ModifierType(eve.get_state() & ~Gdk.ModifierType.LOCK_MASK) - return True if modifiers & Gdk.ModifierType.SHIFT_MASK else False + return modifiers & Gdk.ModifierType.SHIFT_MASK def get_raw_keyname(self, eve): return Gdk.keyval_name(eve.keyval) diff --git a/src/core/widgets/code/mixins/source_view_dnd_mixin.py b/src/core/widgets/code/mixins/source_view_dnd_mixin.py index 99b3fc2..bbe30be 100644 --- a/src/core/widgets/code/mixins/source_view_dnd_mixin.py +++ b/src/core/widgets/code/mixins/source_view_dnd_mixin.py @@ -26,8 +26,8 @@ class SourceViewDnDMixin: if info == 80: uris = data.get_uris() - if len(uris) == 0: - uris = data.get_text().split("\n") + if not uris: return + uris = data.get_text().split("\n") self._on_uri_data_received(uris) @@ -35,6 +35,6 @@ class SourceViewDnDMixin: uri = uris.pop(0) self.command.exec_with_args("dnd_load_file_to_buffer", (self, uri)) - if len(uris) == 0: return + if not uris: return self.command.exec_with_args("dnd_load_files", (self, uris)) diff --git a/src/core/widgets/code/source_buffer.py b/src/core/widgets/code/source_buffer.py index ff02d14..d89462c 100644 --- a/src/core/widgets/code/source_buffer.py +++ b/src/core/widgets/code/source_buffer.py @@ -71,6 +71,4 @@ class SourceBuffer(GtkSource.Buffer): self.disconnect(handle_id) def __del__(self): - for handle_id in self._handler_ids: - self.disconnect(handle_id) - + self.clear_signals() diff --git a/src/core/widgets/code/tab_widget.py b/src/core/widgets/code/tab_widget.py index 46e10fa..2f56c70 100644 --- a/src/core/widgets/code/tab_widget.py +++ b/src/core/widgets/code/tab_widget.py @@ -17,7 +17,6 @@ class TabWidget(Gtk.Box): self.file = None - self._close_tab = None self._handler_id = None self._eve_handler_id = None @@ -63,7 +62,6 @@ class TabWidget(Gtk.Box): def clear_signals_and_data(self): self.close_bttn.disconnect(self._handler_id) self.event_box.disconnect(self._eve_handler_id) - self._close_tab = None self._handler_id = None for child in self.get_children(): diff --git a/src/libs/mixins/dnd_mixin.py b/src/libs/mixins/dnd_mixin.py index 4e231d3..8b427f7 100644 --- a/src/libs/mixins/dnd_mixin.py +++ b/src/libs/mixins/dnd_mixin.py @@ -55,7 +55,7 @@ class DnDMixin: uris = data.get_uris() files = [] - if len(uris) == 0: + if not uris: uris = data.get_text().split("\n") for uri in uris: diff --git a/src/libs/settings/options/config.py b/src/libs/settings/options/config.py index 306470c..729d8ac 100644 --- a/src/libs/settings/options/config.py +++ b/src/libs/settings/options/config.py @@ -14,8 +14,8 @@ class Config: blender_thumbnailer_path: str = "" go_past_home: str = "true" lock_folder: str = "false" - locked_folders: list = field(default_factory=lambda: [ "venv", "flasks" ]) - mplayer_options: str = "-quiet -really-quiet -xy 1600 -geometry 50%:50%", + locked_folders: list = field(default_factory=lambda: [ "venv", "flasks" ]) + mplayer_options: str = "-quiet -really-quiet -xy 1600 -geometry 50%:50%" music_app: str = "/opt/deadbeef/bin/deadbeef" media_app: str = "mpv" image_app: str = "mirage" diff --git a/src/libs/settings/options/settings.py b/src/libs/settings/options/settings.py index 0e3597b..d107a42 100644 --- a/src/libs/settings/options/settings.py +++ b/src/libs/settings/options/settings.py @@ -2,7 +2,7 @@ from dataclasses import dataclass, field from dataclasses import asdict -# Gtk imports +# Lib imports # Application imports from .config import Config